function __read() { global $ilObjDataCache, $ilDB; $this->items = array(); if ($ilObjDataCache->lookupType($this->getObjId()) != 'sahs') { $course_ref_ids = ilObject::_getAllReferences($this->getObjId()); $course_ref_id = end($course_ref_ids); $query = "SELECT * FROM ut_lp_collections utc " . "JOIN object_reference obr ON item_id = ref_id " . "JOIN object_data obd ON obr.obj_id = obd.obj_id " . "WHERE utc.obj_id = " . $this->db->quote($this->obj_id, 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer') . " " . "ORDER BY title"; } else { $query = "SELECT * FROM ut_lp_collections WHERE obj_id = " . $ilDB->quote($this->getObjId(), 'integer') . " " . "AND active = " . $ilDB->quote(1, 'integer'); } $res = $this->db->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { if ($ilObjDataCache->lookupType($this->getObjId()) != 'sahs') { if (!in_array($row->item_id, ilLPCollections::_getPossibleItems($course_ref_id))) { $this->__deleteEntry($this->getObjId(), $row->item_id); continue; } } // Check anonymized if ($ilObjDataCache->lookupType($item_obj_id = $ilObjDataCache->lookupObjId($row->item_id)) == 'tst') { include_once './Modules/Test/classes/class.ilObjTest.php'; if (ilObjTest::_lookupAnonymity($item_obj_id)) { $this->__deleteEntry($this->getObjId(), $row->item_id); continue; } } $this->items[] = $row->item_id; } }
/** * Read and parse collection items * @return void */ protected function parseCollection() { $hasGroupedItems = false; $this->collections = new ilLPCollections(ilObject::_lookupObjId($this->getNode())); $items = ilLPCollections::_getPossibleItems($this->getNode(), $this->getCollection()); $data = array(); $done = array(); foreach ($items as $item) { if (in_array($item, $done)) { continue; } $tmp = $this->parseCollectionItem($item); $tmp['grouped'] = array(); if ($this->getMode() == LP_MODE_COLLECTION) { $grouped_items = ilLPCollections::lookupGroupedItems(ilObject::_lookupObjId($this->getNode()), $item); if (count((array) $grouped_items['items']) > 1) { foreach ($grouped_items['items'] as $gr) { if ($gr == $item) { continue; } $tmp['grouped'][] = $this->parseCollectionItem($gr); $tmp['num_obligatory'] = $grouped_items['num_obligatory']; $tmp['grouping_id'] = $grouped_items['grouping_id']; $hasGroupedItems = true; $done[] = $gr; } } } $data[] = $tmp; } if ($hasGroupedItems) { $this->addCommandButton('saveObligatoryMaterials', $this->lng->txt('trac_group_materials_save')); } $this->setData((array) $data); }