/**
  * Check if (current) user has access to the participant list
  * @param type $a_obj
  * @param type $a_usr_id
  */
 public static function hasParticipantListAccess($a_obj_id, $a_usr_id = null)
 {
     if (!$a_usr_id) {
         $a_usr_id = $GLOBALS['ilUser']->getId();
     }
     // if write access granted => return true
     $refs = ilObject::_getAllReferences($a_obj_id);
     $ref_id = end($refs);
     if ($GLOBALS['ilAccess']->checkAccess('write', '', $ref_id)) {
         return true;
     }
     $part = self::getInstanceByObjId($a_obj_id);
     if ($part->isAssigned($a_usr_id)) {
         if ($part->getType() == 'crs') {
             // Check for show_members
             include_once './Modules/Course/classes/class.ilObjCourse.php';
             if (!ilObjCourse::lookupShowMembersEnabled($a_obj_id)) {
                 return false;
             }
         }
         return true;
     }
     // User is not assigned to course/group => no read access
     return false;
 }
 function _getStatusInfo($a_obj_id)
 {
     $status_info = array();
     include_once "Services/Object/classes/class.ilObjectLP.php";
     $olp = ilObjectLP::getInstance($a_obj_id);
     $collection = $olp->getCollectionInstance();
     if ($collection) {
         $status_info["items"] = $collection->getItems($a_obj_id);
         foreach ($status_info["items"] as $item_id) {
             $status_info["completed"][$item_id] = array();
         }
         $ref_ids = ilObject::_getAllReferences($a_obj_id);
         $ref_id = end($ref_ids);
         $possible_items = $collection->getPossibleItems($ref_id);
         $chapter_ids = array_intersect(array_keys($possible_items), $status_info["items"]);
         // fix order (adapt from possible items)
         $status_info["items"] = $chapter_ids;
         if ($chapter_ids) {
             $status = self::_getObjectStatus($a_obj_id);
             foreach ($chapter_ids as $item_id) {
                 $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
                 if (isset($status[$item_id])) {
                     foreach ($status[$item_id] as $user_id => $user_status) {
                         if ($user_status) {
                             $status_info["completed"][$item_id][] = $user_id;
                         }
                     }
                 }
             }
         }
     }
     return $status_info;
 }
 protected function initItems($a_data)
 {
     global $ilAccess, $lng, $tree;
     $data = array();
     if (!$this->user_id) {
         $is_admin = $ilAccess->checkAccess("visible", "", SYSTEM_FOLDER_ID);
     }
     foreach ($a_data as $id => $item) {
         // workspace objects won't have references
         $refs = ilObject::_getAllReferences($id);
         if ($refs) {
             foreach ($refs as $idx => $ref_id) {
                 // objects in trash are hidden
                 if (!$tree->isDeleted($ref_id)) {
                     if ($this->user_id) {
                         $readable = $ilAccess->checkAccessOfUser($this->user_id, "read", "", $ref_id, $a_type);
                     } else {
                         $readable = $is_admin;
                     }
                     $data[$ref_id] = array("obj_id" => $id, "ref_id" => $ref_id, "type" => ilObject::_lookupType($id), "title" => $item, "path" => $this->buildPath($ref_id), "readable" => $readable);
                 }
             }
         }
     }
     $this->setData($data);
 }
 public function getSinglePool($CourseID, $PoolID)
 {
     global $ilUser, $ilObjDataCache;
     $retval = array();
     $items = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
     // $items = ilParticipants::_getMembershipByType(12855, 'crs');
     $itemId = array_search($CourseID, $items);
     if ($itemId !== FALSE && $itemId >= 0) {
         $obj_id = $items[$itemId];
         $item_references = ilObject::_getAllReferences($obj_id);
         reset($item_references);
         if (strcmp($this->iliasVersion, "4.2") === 0) {
             require_once 'Modules/Course/classes/class.ilCourseItems.php';
             foreach ($item_references as $ref_id) {
                 // Antique Ilias
                 $courseItems = new ilCourseItems($ref_id, 0, $ilUser->getId());
                 $courseItemList = $courseItems->getAllItems();
                 $retval = $this->mapItems($courseItemList, $PoolID);
                 $retval = $retval[0];
             }
         } else {
             // Modern Ilias
             $crs = new ilObjCourse($item_references, true);
             $courseItemList = $crs->getSubItems();
             $retval = $this->mapItems($courseItemList["_all"], $PoolID);
             $retval = $retval[0];
         }
     }
     return $retval;
 }
 /**
  * Get xml
  * @param object $a_entity
  * @param object $a_schema_version
  * @param object $a_id
  * @return 
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $GLOBALS['ilLog']->write(__METHOD__ . ': Received id = ' . $a_id);
     $writer = new ilContainerXmlWriter(end(ilObject::_getAllReferences($a_id)));
     $writer->write();
     return $writer->xmlDumpMem(false);
 }
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Course/classes/class.ilCourseXMLParser.php';
     include_once './Modules/Course/classes/class.ilObjCourse.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $refs = ilObject::_getAllReferences($new_id);
         $this->course = ilObjectFactory::getInstanceByRefId(end($refs), false);
         #$this->course = ilObjectFactory::getInstanceByObjId($new_id,false);
     } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
         $this->course = ilObjectFactory::getInstanceByRefId($new_id, false);
     } elseif (!$this->course instanceof ilObjCourse) {
         $this->course = new ilObjCourse();
         $this->course->create(true);
     }
     try {
         $parser = new ilCourseXMLParser($this->course);
         $parser->setXMLContent($a_xml);
         $parser->startParsing();
         $a_mapping->addMapping('Modules/Course', 'crs', $a_id, $this->course->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (Exception $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
 }
 /**
  * @param $id
  * @param $type
  *
  * @return bool|int
  */
 protected function buildRef($id, $type)
 {
     if ($type == 'reference_id') {
         if (!ilObjOrgUnit::_exists($id, true)) {
             return false;
         }
         return $id;
     } elseif ($type == 'external_id') {
         $obj_id = ilObject::_lookupObjIdByImportId($id);
         if (!ilObject::_hasUntrashedReference($obj_id)) {
             return false;
         }
         $ref_ids = ilObject::_getAllReferences($obj_id);
         if (!count($ref_ids)) {
             return false;
         }
         foreach ($ref_ids as $ref_id) {
             if (!ilObject::_isInTrash($ref_id)) {
                 return $ref_id;
             }
         }
         return false;
     } else {
         return false;
     }
 }
 /**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 public static function handleEvent($a_component, $a_event, $a_params)
 {
     $obj_id = $a_params['obj_id'];
     switch ($a_component) {
         case 'Services/Object':
             switch ($a_event) {
                 case 'toTrash':
                     include_once './Services/Object/classes/class.ilObjectLP.php';
                     $olp = ilObjectLP::getInstance($obj_id);
                     $olp->handleToTrash();
                     break;
                 case 'delete':
                     // ilRepUtil will raise "delete" even if only reference was deleted!
                     $all_ref = ilObject::_getAllReferences($obj_id);
                     if (!sizeof($all_ref)) {
                         include_once './Services/Object/classes/class.ilObjectLP.php';
                         $olp = ilObjectLP::getInstance($obj_id);
                         $olp->handleDelete();
                     }
                     break;
             }
             break;
         case 'Services/Tree':
             switch ($a_event) {
                 case 'moveTree':
                     if ($a_params['tree'] == 'tree') {
                         include_once './Services/Object/classes/class.ilObjectLP.php';
                         ilObjectLP::handleMove($a_params['source_id']);
                     }
                     break;
             }
             break;
     }
     return true;
 }
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Category/classes/class.ilObjCategory.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $refs = ilObject::_getAllReferences($new_id);
         $this->category = ilObjectFactory::getInstanceByRefId(end($refs), false);
     } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
         $this->category = ilObjectFactory::getInstanceByRefId($new_id, false);
     } elseif (!$this->category instanceof ilObjCategory) {
         $this->category = new ilObjCategory();
         $this->category->create(true);
     }
     include_once './Modules/Category/classes/class.ilCategoryXmlParser.php';
     try {
         $parser = new ilCategoryXmlParser($a_xml, 0);
         $parser->setCategory($this->category);
         $parser->setMode(ilCategoryXmlParser::MODE_UPDATE);
         $parser->startParsing();
         $a_mapping->addMapping('Modules/Category', 'cat', $a_id, $this->category->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (Excpetion $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
 }
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Category/classes/class.ilObjCategory.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $refs = ilObject::_getAllReferences($new_id);
         $this->category = ilObjectFactory::getInstanceByRefId(end($refs), false);
     } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
         $this->category = ilObjectFactory::getInstanceByRefId($new_id, false);
     } elseif (!$this->category instanceof ilObjCategory) {
         $this->category = new ilObjCategory();
         $this->category->create(true);
     }
     include_once './Modules/Category/classes/class.ilCategoryXmlParser.php';
     try {
         $parser = new ilCategoryXmlParser($a_xml, 0);
         $parser->setCategory($this->category);
         $parser->setMode(ilCategoryXmlParser::MODE_UPDATE);
         $parser->startParsing();
         $a_mapping->addMapping('Modules/Category', 'cat', $a_id, $this->category->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (Excpetion $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
     foreach ($a_mapping->getMappingsOfEntity('Services/Container', 'objs') as $old => $new) {
         $type = ilObject::_lookupType($new);
         // see ilGlossaryImporter::importXmlRepresentation()
         // see ilTaxonomyDataSet::importRecord()
         $a_mapping->addMapping("Services/Taxonomy", "tax_item", $type . ":obj:" . $old, $new);
         // this is since 4.3 does not export these ids but 4.4 tax node assignment needs it
         $a_mapping->addMapping("Services/Taxonomy", "tax_item_obj_id", $type . ":obj:" . $old, $new);
     }
 }
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Group/classes/class.ilObjGroup.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $refs = ilObject::_getAllReferences($new_id);
         $this->group = ilObjectFactory::getInstanceByRefId(end($refs), false);
         #$this->group = ilObjectFactory::getInstanceByObjId($new_id,false);
     } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
         $this->group = ilObjectFactory::getInstanceByRefId($new_id, false);
     } elseif (!$this->group instanceof ilObjGroup) {
         $this->group = new ilObjGroup();
         $this->group->create(true);
     }
     include_once './Modules/Group/classes/class.ilGroupXMLParser.php';
     #$GLOBALS['ilLog']->write($a_xml);
     try {
         $parser = new ilGroupXMLParser($a_xml, 0);
         $parser->setGroup($this->group);
         $parser->setMode(ilGroupXMLParser::$UPDATE);
         $parser->startParsing();
         $a_mapping->addMapping('Modules/Group', 'grp', $a_id, $this->group->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (ilWebLinkXMLParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
 }
 /**
  * Singleton Constructor
  *
  * @access protected
  * @param int obj_id of container
  */
 protected function __construct($a_obj_id, $a_usr_id)
 {
     global $ilDB, $lng;
     $this->obj_id = $a_obj_id;
     $this->usr_id = $a_usr_id;
     $this->type = ilObject::_lookupType($a_obj_id);
     $ref_ids = ilObject::_getAllReferences($this->obj_id);
     $this->ref_id = current($ref_ids);
     $this->readParticipant();
     $this->readParticipantStatus();
 }
 /**
  * Checks read permission on obj id
  */
 static function checkObjectPermission($a_obj_id)
 {
     global $ilAccess;
     $refs = ilObject::_getAllReferences($a_obj_id);
     foreach ($refs as $ref) {
         if ($ilAccess->checkAccess("read", "", $ref)) {
             return true;
         }
     }
     return false;
 }
 /**
  * Get xml representation
  *
  * @param	string		entity
  * @param	string		target release
  * @param	string		id
  * @return	string		xml string
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $refs = ilObject::_getAllReferences($a_id);
     $sql_ref_id = current($refs);
     include_once './Modules/SurveyQuestionPool/classes/class.ilObjSurveyQuestionPool.php';
     $spl = new ilObjSurveyQuestionPool($a_id, false);
     $spl->loadFromDb();
     include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyQuestionpoolExport.php";
     $spl_exp = new ilSurveyQuestionpoolExport($spl, 'xml');
     $zip = $spl_exp->buildExportFile();
     $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip);
 }
 /**
  * Check if target is accessible and not deleted 
  * @param int $a_ref_id ref_id
  * @return bool
  * @static
  */
 public static function _isAccessible($a_ref_id)
 {
     global $ilDB, $tree;
     $obj_id = ilObject::_lookupObjId($a_ref_id);
     $query = "SELECT target_obj_id FROM container_reference " . "WHERE obj_id = " . $ilDB->quote($obj_id, 'integer') . " ";
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $target_id = $row->target_obj_id;
     }
     $target_ref_ids = ilObject::_getAllReferences($target_id);
     $target_ref_id = current($target_ref_ids);
     return !$tree->isDeleted($target_ref_id);
 }
 /**
  * Get xml
  * @param object $a_entity
  * @param object $a_schema_version
  * @param object $a_id
  * @return
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $ref_ref_id = end(ilObject::_getAllReferences($a_id));
     $ref = ilObjectFactory::getInstanceByRefId($ref_ref_id, false);
     if (!$ref instanceof ilContainerReference) {
         $GLOBALS['ilLog']->write(__METHOD__ . $a_id . ' is not instance of type category!');
         return '';
     }
     $writer = $this->initWriter($ref);
     $writer->setMode(ilContainerReferenceXmlWriter::MODE_EXPORT);
     $writer->export(false);
     return $writer->getXml();
 }
 /**
  * Get xml
  * @param object $a_entity
  * @param object $a_schema_version
  * @param object $a_id
  * @return 
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $course_ref_id = end(ilObject::_getAllReferences($a_id));
     $course = ilObjectFactory::getInstanceByRefId($course_ref_id, false);
     if (!$course instanceof ilObjCourse) {
         $GLOBALS['ilLog']->write(__METHOD__ . $a_id . ' is not instance of type course');
         return '';
     }
     $this->writer = new ilCourseXMLWriter($course);
     $this->writer->setMode(ilCourseXMLWriter::MODE_EXPORT);
     $this->writer->start();
     return $this->writer->xmlDumpMem(false);
 }
 /**
  * Get xml
  * @param object $a_entity
  * @param object $a_schema_version
  * @param object $a_id
  * @return
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $cat_ref_id = end(ilObject::_getAllReferences($a_id));
     $category = ilObjectFactory::getInstanceByRefId($cat_ref_id, false);
     if (!$category instanceof ilObjCategory) {
         $GLOBALS['ilLog']->write(__METHOD__ . $a_id . ' is not instance of type category!');
         return '';
     }
     include_once './Modules/Category/classes/class.ilCategoryXmlWriter.php';
     $writer = new ilCategoryXmlWriter($category);
     $writer->setMode(ilCategoryXmlWriter::MODE_EXPORT);
     $writer->export(false);
     return $writer->getXml();
 }
 /**
  * Fill template row
  * @param <type> $a_set
  */
 public function fillRow($a_set)
 {
     $this->tpl->setVariable('TIME', $a_set['time']);
     $this->tpl->setVariable('DURATION', $a_set['duration']);
     $this->tpl->setVariable('REC', ilViteroUtils::recurrenceToString($a_set['rec']));
     if ($this->isAdminTable()) {
         include_once './Services/Tree/classes/class.ilPathGUI.php';
         $path = new ilPathGUI();
         $path->setUseImages(false);
         $path->enableTextOnly(false);
         $this->tpl->setVariable('OBJ_PATH', $path->getPath(ROOT_FOLDER_ID, end(ilObject::_getAllReferences($a_set['group']))));
     }
     if ($a_set['rec']) {
         $this->tpl->setVariable('ENDS', $a_set['ends']);
     } else {
         $this->tpl->setVariable('ENDS', '');
     }
     if (!$this->isEditable()) {
         return true;
     }
     include_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
     $list = new ilAdvancedSelectionListGUI();
     $list->setId('booka_' . $a_set['start']->get(IL_CAL_UNIX) . '_' . $a_set['id']);
     $list->setListTitle($this->lng->txt('actions'));
     // no recurrence
     if ($a_set['rec'] == 0) {
         $GLOBALS['ilCtrl']->setParameter($this->getParentObject(), 'bookid', $a_set['id']);
         $list->addItem(ilViteroPlugin::getInstance()->txt('edit_booking'), '', $GLOBALS['ilCtrl']->getLinkTarget($this->getParentObject(), 'editBooking'));
         // delete appointment
         $list->addItem(ilViteroPlugin::getInstance()->txt('delete_appointment'), '', $GLOBALS['ilCtrl']->getLinkTarget($this->getParentObject(), 'confirmDeleteAppointment'));
     }
     // A recurrence
     if ($a_set['rec'] > 0) {
         // Delete single appointment
         $GLOBALS['ilCtrl']->setParameter($this->getParentObject(), 'atime', $a_set['start']->get(IL_CAL_UNIX));
         $GLOBALS['ilCtrl']->setParameter($this->getParentObject(), 'bookid', $a_set['id']);
         $list->addItem(ilViteroPlugin::getInstance()->txt('edit_bookings'), '', $GLOBALS['ilCtrl']->getLinkTarget($this->getParentObject(), 'editBooking'));
         // not supported
         /*
         $list->addItem(
         	ilViteroPlugin::getInstance()->txt('delete_appointment'),
         	'',
         	$GLOBALS['ilCtrl']->getLinkTarget($this->getParentObject(),'confirmDeleteAppointmentInSeries')
         );
         */
         // Delete appointment series
         $list->addItem(ilViteroPlugin::getInstance()->txt('delete_reccurrence'), '', $GLOBALS['ilCtrl']->getLinkTarget($this->getParentObject(), 'confirmDeleteBooking'));
     }
     $this->tpl->setVariable('ACTION_PART', $list->getHTML());
 }
 /**
  * Get xml
  * @param object $a_entity
  * @param object $a_schema_version
  * @param object $a_id
  * @return 
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $group_ref_id = end(ilObject::_getAllReferences($a_id));
     $group = ilObjectFactory::getInstanceByRefId($group_ref_id, false);
     if (!$group instanceof ilObjGroup) {
         $GLOBALS['ilLog']->write(__METHOD__ . $a_id . ' is not instance of type group');
         return '';
     }
     include_once './Modules/Group/classes/class.ilGroupXMLWriter.php';
     $this->writer = new ilGroupXMLWriter($group);
     $this->writer->setMode(ilGroupXMLWriter::MODE_EXPORT);
     $this->writer->start();
     return $this->writer->getXML();
 }
 /**
  * Get xml representation
  *
  * @param	string		entity
  * @param	string		target release
  * @param	string		id
  * @return	string		xml string
  */
 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
 {
     $refs = ilObject::_getAllReferences($a_id);
     $svy_ref_id = current($refs);
     include_once './Modules/Survey/classes/class.ilObjSurvey.php';
     $svy = new ilObjSurvey($a_id, false);
     $svy->loadFromDb();
     include_once "./Modules/Survey/classes/class.ilSurveyExport.php";
     $svy_exp = new ilSurveyExport($svy, 'xml');
     $zip = $svy_exp->buildExportFile();
     // Unzip, since survey deletes this dir
     ilUtil::unzip($zip);
     $GLOBALS['ilLog']->write(__METHOD__ . ': Created zip file ' . $zip);
 }
 /**
  *  Constructor
  *
  * @access public
  * @param
  * 
  */
 public function __construct($a_obj_id)
 {
     global $lng, $tpl, $ilCtrl, $ilTabs;
     $this->lng = $lng;
     $this->lng->loadLanguageModule('ps');
     $this->lng->loadLanguageModule(ilObject::_lookupType($a_obj_id));
     $this->tpl = $tpl;
     $this->ctrl = $ilCtrl;
     $this->tabs_gui = $ilTabs;
     $this->obj_id = $a_obj_id;
     // Currently only supported for container objects
     $refs = ilObject::_getAllReferences($this->obj_id);
     $this->ref_id = end($refs);
 }
 protected function buildRef($id, $type)
 {
     if ($type == "reference_id") {
         if (!ilObjOrgUnit::_exists($id, true)) {
             return false;
         }
         return $id;
     } elseif ($type == "external_id") {
         $obj_id = ilObject::_lookupObjIdByImportId($id);
         $ref_ids = ilObject::_getAllReferences($obj_id);
         if (!count($ref_ids)) {
             return false;
         }
         return array_shift($ref_ids);
     } else {
         return false;
     }
 }
 function _getStatusInfo($a_obj_id, $a_include_tlt_data = false)
 {
     global $ilDB;
     $status_info = array();
     include_once "Services/Object/classes/class.ilObjectLP.php";
     $olp = ilObjectLP::getInstance($a_obj_id);
     $collection = $olp->getCollectionInstance();
     if ($collection) {
         $status_info["items"] = $collection->getItems($a_obj_id);
         include_once './Services/MetaData/classes/class.ilMDEducational.php';
         foreach ($status_info["items"] as $item_id) {
             $status_info["in_progress"][$item_id] = array();
             $status_info["completed"][$item_id] = array();
             $status_info["tlt"][$item_id] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id, $item_id);
         }
         $ref_ids = ilObject::_getAllReferences($a_obj_id);
         $ref_id = end($ref_ids);
         $possible_items = $collection->getPossibleItems($ref_id);
         $chapter_ids = array_intersect(array_keys($possible_items), $status_info["items"]);
         // fix order (adapt from possible items)
         $status_info["items"] = $chapter_ids;
         if ($chapter_ids) {
             foreach ($chapter_ids as $item_id) {
                 $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
             }
             $set = $ilDB->query("SELECT obj_id,usr_id,spent_seconds" . " FROM lm_read_event" . " WHERE " . $ilDB->in("obj_id", $chapter_ids, "", "integer"));
             while ($row = $ilDB->fetchAssoc($set)) {
                 if ($row["spent_seconds"] < $status_info["tlt"][$row["obj_id"]]) {
                     $status_info["in_progress"][$row["obj_id"]][] = $row["usr_id"];
                 } else {
                     $status_info["completed"][$row["obj_id"]][] = $row["usr_id"];
                 }
                 if ($a_include_tlt_data) {
                     $status_info["tlt_users"][$row["obj_id"]][$row["usr_id"]] = $row["spent_seconds"];
                 }
             }
         }
     }
     if (!$a_include_tlt_data) {
         unset($status_info["tlt"]);
     }
     return $status_info;
 }
 /**
  * get ims manifest xml
  *
  * @param string $sid
  * @param int $ref_id
  *
  * @return xml following scorm.dtd
  */
 function getIMSManifestXML($sid, $ref_id)
 {
     $this->initAuth($sid);
     $this->initIlias();
     if (!$this->__checkSession($sid)) {
         return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
     }
     if (!strlen($ref_id)) {
         return $this->__raiseError('No ref id given. Aborting!', 'Client');
     }
     global $rbacsystem, $tree, $ilLog;
     // get obj_id
     if (!($obj_id = ilObject::_lookupObjectId($ref_id))) {
         return $this->__raiseError('No exercise found for id: ' . $ref_id, 'Client');
     }
     if (ilObject::_isInTrash($ref_id)) {
         return $this->__raiseError("Parent with ID {$ref_id} has been deleted.", 'Client');
     }
     // Check access
     $permission_ok = false;
     foreach ($ref_ids = ilObject::_getAllReferences($obj_id) as $ref_id) {
         if ($rbacsystem->checkAccess('read', $ref_id)) {
             $permission_ok = true;
             break;
         }
     }
     if (!$permission_ok) {
         return $this->__raiseError('No permission to read the object with id: ' . $ref_id, 'Server');
     }
     $lm_obj = ilObjectFactory::getInstanceByObjId($obj_id, false);
     if (!is_object($lm_obj) || $lm_obj->getType() != "sahs") {
         return $this->__raiseError('Wrong obj id or type for scorm object with id ' . $ref_id, 'Server');
     }
     // get scorm xml
     require_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php";
     require_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php";
     $imsFilename = $lm_obj->getDataDirectory() . DIRECTORY_SEPARATOR . "imsmanifest.xml";
     if (!file_exists($imsFilename)) {
         return $this->__raiseError('Could not find manifest file for object with ref id ' . $ref_id, 'Server');
     }
     return file_get_contents($imsFilename);
 }
 /**
  * Import data from DB
  */
 protected function importData()
 {
     global $ilAccess, $lng;
     include_once "Modules/Survey/classes/class.ilObjSurvey.php";
     $table_data = array();
     foreach ($this->question->getCopyIds(true) as $survey_obj_id => $questions) {
         $survey_id = new ilObjSurvey($survey_obj_id, false);
         $survey_id->loadFromDB();
         $survey_id = $survey_id->getSurveyId();
         $ref_ids = ilObject::_getAllReferences($survey_obj_id);
         $message = "";
         // check permissions for "parent" survey
         $can_write = false;
         if (!ilObjSurvey::_hasDatasets($survey_id)) {
             foreach ($ref_ids as $ref_id) {
                 if ($ilAccess->checkAccess("edit", "", $ref_id)) {
                     $can_write = true;
                     break;
                 }
             }
             if (!$can_write) {
                 $message = $lng->txt("survey_sync_insufficient_permissions");
             }
         } else {
             $message = $lng->txt("survey_has_datasets_warning");
         }
         $survey_title = ilObject::_lookupTitle($survey_obj_id);
         $survey_path = $this->buildPath($ref_ids);
         foreach ($questions as $question_id) {
             $title = SurveyQuestion::_getTitle($question_id);
             if (!$can_write) {
                 $question_id = null;
             }
             $table_data[] = array("id" => $question_id, "title" => $title, "path" => $survey_path, "message" => $message);
         }
     }
     $this->setData($table_data);
 }
 /**
  * Delete references 
  *
  * @static
  */
 public static function deleteReferences($a_target_id)
 {
     global $ilLog;
     include_once './Services/ContainerReference/classes/class.ilContainerReference.php';
     if (!($source_id = ilContainerReference::_lookupSourceId($a_target_id))) {
         return true;
     }
     foreach (ilObject::_getAllReferences($source_id) as $ref_id) {
         if (!($instance = ilObjectFactory::getInstanceByRefId($ref_id, false))) {
             continue;
         }
         switch ($instance->getType()) {
             case 'crsr':
             case 'catr':
                 $instance->delete();
                 $ilLog->write(__METHOD__ . ': Deleted reference object of type ' . $instance->getType() . ' with Id ' . $instance->getId());
                 break;
             default:
                 $ilLog->write(__METHOD__ . ': Unexpected object type ' . $instance->getType() . ' with Id ' . $instance->getId());
                 break;
         }
     }
     return true;
 }
 /**
  * Import XML
  *
  * @param
  * @return
  */
 function importXmlRepresentation($a_entity, $a_id, $a_xml, $a_mapping)
 {
     include_once './Modules/Category/classes/class.ilObjCategory.php';
     if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
         $refs = ilObject::_getAllReferences($new_id);
         $this->initReference(end($refs));
     } elseif ($new_id = $a_mapping->getMapping('Services/Container', 'refs', 0)) {
         $this->initReference($new_id);
     } elseif (!$this->getReference() instanceof ilContainerReference) {
         $this->initReference();
         $this->getReference()->create(true);
     }
     try {
         $parser = $this->initParser($a_xml);
         $parser->setReference($this->getReference());
         $parser->setMode(ilContainerReferenceXmlParser::MODE_UPDATE);
         $parser->startParsing();
         $a_mapping->addMapping($GLOBALS['objDefinition']->getComponentForType($this->getType()), $this->getType(), $a_id, $this->getReference()->getId());
     } catch (ilSaxParserException $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     } catch (Excpetion $e) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Parsing failed with message, "' . $e->getMessage() . '".');
     }
 }
 /**
  * Handle an event in a listener.
  *
  * @param	string	$a_component	component, e.g. "Modules/Forum" or "Services/User"
  * @param	string	$a_event		event e.g. "createUser", "updateUser", "deleteUser", ...
  * @param	array	$a_parameter	parameter array (assoc), array("name" => ..., "phone_office" => ...)
  */
 static function handleEvent($a_component, $a_event, $a_parameter)
 {
     include_once "./Services/Tagging/classes/class.ilTagging.php";
     switch ($a_component) {
         case "Services/Object":
             switch ($a_event) {
                 case "toTrash":
                     if (!ilObject::_hasUntrashedReference($a_parameter["obj_id"])) {
                         ilTagging::setTagsOfObjectOffline($a_parameter["obj_id"], ilObject::_lookupType($a_parameter["obj_id"]), 0, "");
                     }
                     break;
                 case "undelete":
                     ilTagging::setTagsOfObjectOffline($a_parameter["obj_id"], ilObject::_lookupType($a_parameter["obj_id"]), 0, "", false);
                     break;
                 case "delete":
                     $ref_ids = ilObject::_getAllReferences($a_parameter["obj_id"]);
                     if (count($ref_ids) == 0) {
                         ilTagging::deleteTagsOfObject($a_parameter["obj_id"], $a_parameter["type"], 0, "");
                     }
                     break;
             }
             break;
     }
 }
 /**
  * Sync category
  * @param ilECSNodeMappingAssignment $ass
  */
 protected function syncCategory(ilECSNodeMappingAssignment $ass, $parent_id)
 {
     include_once './Services/WebServices/ECS/classes/Tree/class.ilECSCmsData.php';
     $data = new ilECSCmsData($ass->getCSId());
     // Check if node is imported => create
     // perform title update
     // perform position update
     include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
     $obj_id = ilECSImport::lookupObjIdByContentId($this->getServer()->getServerId(), $this->mid, $data->getCmsId());
     if ($obj_id) {
         $refs = ilObject::_getAllReferences($obj_id);
         $ref_id = end($refs);
         $cat = ilObjectFactory::getInstanceByRefId($ref_id, false);
         if ($cat instanceof ilObject and $this->default_settings['title_update']) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Updating cms category ');
             $GLOBALS['ilLog']->write(__METHOD__ . ': Title is ' . $data->getTitle());
             $cat->deleteTranslation($GLOBALS['lng']->getDefaultLanguage());
             $cat->addTranslation($data->getTitle(), $cat->getLongDescription(), $GLOBALS['lng']->getDefaultLanguage(), 1);
             $cat->setTitle($data->getTitle());
             $cat->update();
         } else {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Updating cms category -> nothing to do');
         }
         return $ref_id;
     } elseif ($this->getGlobalSettings()->isEmptyContainerCreationEnabled()) {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Creating new cms category');
         // Create category
         include_once './Modules/Category/classes/class.ilObjCategory.php';
         $cat = new ilObjCategory();
         $cat->setTitle($data->getTitle());
         $cat->create();
         // true for upload
         $cat->createReference();
         $cat->putInTree($parent_id);
         $cat->setPermissions($parent_id);
         $cat->deleteTranslation($GLOBALS['lng']->getDEfaultLanguage());
         $cat->addTranslation($data->getTitle(), $cat->getLongDescription(), $GLOBALS['lng']->getDefaultLanguage(), 1);
         // set imported
         $import = new ilECSImport($this->getServer()->getServerId(), $cat->getId());
         $import->setMID($this->mid);
         $import->setContentId($data->getCmsId());
         $import->setImported(true);
         $import->save();
         return $cat->getRefId();
     } else {
         $GLOBALS['ilLog']->write(__METHOD__ . ': Creation of empty containers is disabled.');
         return 0;
     }
 }