diff --git a/components/ILIAS/ItemGroup/Service/class.InternalRepoService.php b/components/ILIAS/ItemGroup/Service/class.InternalRepoService.php
index 1f80bc8fb031..c11f3737306a 100755
--- a/components/ILIAS/ItemGroup/Service/class.InternalRepoService.php
+++ b/components/ILIAS/ItemGroup/Service/class.InternalRepoService.php
@@ -1,7 +1,5 @@
- */
+use ilDBInterface;
+use ILIAS\ItemGroup\Repository\ItemGroupRepository;
+
class InternalRepoService
{
- protected InternalDataService $data;
- protected \ilDBInterface $db;
-
- public function __construct(InternalDataService $data, \ilDBInterface $db)
- {
- $this->data = $data;
- $this->db = $db;
+ public function __construct(
+ protected readonly InternalDataService $data,
+ protected readonly ilDBInterface $db,
+ ) {
}
- /*
- public function ...() : ...\RepoService
+ public function itemGroup(): ItemGroupRepository
{
- return new ...\RepoService(
- $this->data,
- $this->db
- );
- }*/
-
- /*public function accessSession() : AccessSessionRepository
- {
- return new AccessSessionRepository();
- }*/
+ return new ItemGroupRepository($this->db);
+ }
}
diff --git a/components/ILIAS/ItemGroup/classes/class.ilItemGroupAppEventListener.php b/components/ILIAS/ItemGroup/classes/class.ilItemGroupAppEventListener.php
new file mode 100644
index 000000000000..07be5ad48bac
--- /dev/null
+++ b/components/ILIAS/ItemGroup/classes/class.ilItemGroupAppEventListener.php
@@ -0,0 +1,40 @@
+ $DIC->itemGroup()->internal()->repo()->itemGroup()->removeItems([$ref_id]),
+ default => null,
+ };
+ }
+}
diff --git a/components/ILIAS/ItemGroup/classes/class.ilItemGroupItems.php b/components/ILIAS/ItemGroup/classes/class.ilItemGroupItems.php
index 7a671d048671..2a6c0b5c88c1 100755
--- a/components/ILIAS/ItemGroup/classes/class.ilItemGroupItems.php
+++ b/components/ILIAS/ItemGroup/classes/class.ilItemGroupItems.php
@@ -173,14 +173,28 @@ public function getAssignableItems(): array
public function getValidItems(): array
{
- $items = $this->getItems();
- $ass_items = $this->getAssignableItems();
- $valid_items = array();
- foreach ($ass_items as $aitem) {
- if (in_array($aitem["ref_id"], $items)) {
- $valid_items[] = $aitem["ref_id"];
+ if ($this->getItemGroupRefId() <= 0) {
+ return $this->items;
+ }
+
+ return $this->filterValidRefIds($this->items);
+ }
+
+ /**
+ * @param int[] $items
+ * @return int[]
+ */
+ protected function filterValidRefIds(array $items): array
+ {
+ $valid_items = [];
+ foreach ($this->getAssignableItems() as $assignable_item) {
+ if (!in_array($assignable_item['ref_id'], $items, true)) {
+ continue;
}
+
+ $valid_items[] = $assignable_item['ref_id'];
}
+
return $valid_items;
}
@@ -198,7 +212,7 @@ public function cloneItems(
$new_items = array();
// check: is this a ref id!?
$source_ig = new ilItemGroupItems($a_source_id);
- foreach ($source_ig->getItems() as $item_ref_id) {
+ foreach ($source_ig->getValidItems() as $item_ref_id) {
if (isset($mappings[$item_ref_id]) and $mappings[$item_ref_id]) {
$ilLog->write(__METHOD__ . ': Clone item group item nr. ' . $item_ref_id);
$new_items[] = $mappings[$item_ref_id];
@@ -232,6 +246,12 @@ public static function _getItemsOfContainer(int $a_ref_id): array
while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
$items[] = $row->item_ref_id;
}
- return $items;
+
+ $container_child_ref_ids = [];
+ foreach ($tree->getChilds($a_ref_id) as $node) {
+ $container_child_ref_ids[] = (int) ($node['ref_id'] ?? $node['child']);
+ }
+
+ return array_values(array_intersect($items, $container_child_ref_ids));
}
}
diff --git a/components/ILIAS/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php b/components/ILIAS/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php
index 8262065f0b5f..5302e3895f5f 100755
--- a/components/ILIAS/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php
+++ b/components/ILIAS/ItemGroup/classes/class.ilItemGroupItemsTableGUI.php
@@ -26,7 +26,7 @@
class ilItemGroupItemsTableGUI extends ilTable2GUI
{
protected InternalGUIService $gui;
- protected array $items;
+ protected array $valid_items;
protected ilItemGroupItems $item_group_items;
protected ilTree $tree;
protected ilObjectDefinition $obj_def;
@@ -50,7 +50,7 @@ public function __construct(
$this->obj_def = $objDefinition;
$this->item_group_items = new ilItemGroupItems($a_parent_obj->getObject()->getRefId());
- $this->items = $this->item_group_items->getItems();
+ $this->valid_items = $this->item_group_items->getValidItems();
parent::__construct($a_parent_obj, $a_parent_cmd);
$this->setLimit(9999);
@@ -75,7 +75,7 @@ public function getMaterials(): void
$items = $this->item_group_items->getAssignableItems();
foreach ($items as $item) {
- $item["sorthash"] = (int) (!in_array($item['ref_id'], $this->items)) . $item["title"];
+ $item["sorthash"] = (int) (!in_array($item['ref_id'], $this->valid_items)) . $item["title"];
$materials[] = $item;
}
@@ -101,7 +101,7 @@ protected function fillRow(array $a_set): void
"ilIcon"
));
- if (in_array($a_set["child"], $this->items)) {
+ if (in_array($a_set["child"], $this->valid_items)) {
$i = $f->symbol()->icon()->custom(
ilUtil::getImagePath("standard/icon_ok.svg"),
$this->lng->txt("yes")
diff --git a/components/ILIAS/ItemGroup/module.xml b/components/ILIAS/ItemGroup/module.xml
index ec9fe9b8641a..aac8b7ea80c8 100755
--- a/components/ILIAS/ItemGroup/module.xml
+++ b/components/ILIAS/ItemGroup/module.xml
@@ -14,4 +14,7 @@
root
+
+
+
diff --git a/components/ILIAS/ItemGroup/src/Repository/ItemGroupRepository.php b/components/ILIAS/ItemGroup/src/Repository/ItemGroupRepository.php
new file mode 100644
index 000000000000..223a34e4f0cd
--- /dev/null
+++ b/components/ILIAS/ItemGroup/src/Repository/ItemGroupRepository.php
@@ -0,0 +1,50 @@
+db->in('item_ref_id', $item_ref_ids, false, ilDBConstants::T_INTEGER)})";
+
+ if (is_int($item_group_id) && $item_group_id > 0) {
+ $query .= " AND item_group_id = {$this->db->quote($item_group_id, ilDBConstants::T_INTEGER)}";
+ }
+
+ $this->db->manipulate($query);
+ }
+}