/**
  * Get settings handler for repository object
  * 
  * @param ilObject $a_content_obj
  * @return ilECSObjectSettings
  */
 public static function getInstanceByObject(ilObject $a_content_obj)
 {
     switch ($a_content_obj->getType()) {
         case 'crs':
             include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
             return new ilECSCourseSettings($a_content_obj);
         case 'cat':
             include_once 'Modules/Category/classes/class.ilECSCategorySettings.php';
             return new ilECSCategorySettings($a_content_obj);
         case 'file':
             include_once 'Modules/File/classes/class.ilECSFileSettings.php';
             return new ilECSFileSettings($a_content_obj);
         case 'glo':
             include_once 'Modules/Glossary/classes/class.ilECSGlossarySettings.php';
             return new ilECSGlossarySettings($a_content_obj);
         case 'grp':
             include_once 'Modules/Group/classes/class.ilECSGroupSettings.php';
             return new ilECSGroupSettings($a_content_obj);
         case 'lm':
             include_once 'Modules/LearningModule/classes/class.ilECSLearningModuleSettings.php';
             return new ilECSLearningModuleSettings($a_content_obj);
         case 'wiki':
             include_once 'Modules/Wiki/classes/class.ilECSWikiSettings.php';
             return new ilECSWikiSettings($a_content_obj);
     }
 }
 /**
  * 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() . '".');
     }
 }
 /**
  * Constructor
  *
  * @access public
  * @param
  * @return
  */
 public function __construct($a_parent_obj, $a_parent_cmd, $a_pool_ref_id)
 {
     global $lng, $ilCtrl;
     $this->setId("cont_qpl");
     $this->pool_ref_id = $a_pool_ref_id;
     $this->pool_obj_id = ilObject::_lookupObjId($a_pool_ref_id);
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->setTitle(ilObject::_lookupTitle($this->pool_obj_id));
     //		$qplSetting = new ilSetting("qpl");
     $this->setFormName('sa_quest_browser');
     //		$this->addColumn('','f','1%');
     $this->addColumn($this->lng->txt("title"), 'title', '');
     $this->addColumn($this->lng->txt("cont_question_type"), 'ttype', '');
     $this->addColumn($this->lng->txt("actions"), '', '');
     //		$this->setPrefix('q_id');
     //		$this->setSelectAllCheckbox('q_id');
     $this->setRowTemplate("tpl.copy_sa_quest_row.html", "Services/COPage");
     $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
     $this->setDefaultOrderField("title");
     $this->setDefaultOrderDirection("asc");
     //			$this->setFilterCommand('filterQuestionBrowser');
     //			$this->setResetCommand('resetQuestionBrowser');
     $this->initFilter();
     $this->getQuestions();
 }
 /**
  * Parse object data
  * @return 
  * @param object $a_ids
  */
 public function parseObjectIds($a_ids)
 {
     foreach ($a_ids as $object_id) {
         $row = array();
         $type = ilObject::_lookupType($object_id);
         $row['title'] = ilObject::_lookupTitle($object_id);
         $row['desc'] = ilObject::_lookupDescription($object_id);
         $row['id'] = $object_id;
         switch ($type) {
             case 'crs':
             case 'grp':
                 include_once './Services/Membership/classes/class.ilParticipants.php';
                 if (ilParticipants::hasParticipantListAccess($object_id)) {
                     $row['member'] = count(ilParticipants::getInstanceByObjId($object_id)->getParticipants());
                 } else {
                     $row['member'] = 0;
                 }
                 break;
             case 'role':
                 global $rbacreview;
                 include_once './Services/User/classes/class.ilUserFilter.php';
                 $row['member'] = count(ilUserFilter::getInstance()->filter($rbacreview->assignedUsers($object_id)));
                 break;
         }
         $data[] = $row;
     }
     $this->setData($data ? $data : array());
 }
    function putparam($ref_id, $obj_id, $version, $aicc_data)
    {
        //aiccdata is a non standard ini format
        //$data=parse_ini_file($tmpFilename, TRUE);
        $data = $this->parseAICCData($aicc_data);
        $hacp_id = ilObject::_lookupObjId($ref_id);
        //choose either insert or update to be able to inherit superclass
        global $ilDB, $ilUser, $ilLog;
        $this->update = array();
        $this->insert = array();
        if (is_object($ilUser)) {
            $user_id = $ilUser->getId();
            foreach ($data as $key => $value) {
                $set = $ilDB->queryF('
				SELECT * FROM scorm_tracking WHERE user_id = %s
				AND sco_id = %s
				AND lvalue = %s
				AND obj_id = %s', array('integer', 'integer', 'text', 'integer'), array($user_id, $obj_id, $key, $hacp_id));
                if ($rec = $ilDB->fetchAssoc($set)) {
                    $this->update[] = array("left" => $key, "right" => $value);
                } else {
                    $this->insert[] = array("left" => $key, "right" => $value);
                }
            }
        }
        //store
        $this->store($hacp_id, $obj_id, 0);
        $response = new ilHACPResponse($ref_id, $obj_id);
        $response->sendOk();
    }
 /**
  * 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() . '".');
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng;
     $this->tpl->setVariable("TXT_DEP_OBJ", $lng->txt("obj_" . ilObject::_lookupType($a_set["dep_obj"])) . ": " . ilObject::_lookupTitle($a_set["dep_obj"]));
     $this->tpl->setVariable("TXT_DEL_OBJ", $lng->txt("obj_" . ilObject::_lookupType($a_set["del_obj"])) . ": " . ilObject::_lookupTitle($a_set["del_obj"]));
     $this->tpl->setVariable("TXT_MESS", $a_set["message"]);
 }
 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;
 }
 function gatherCourseLPData()
 {
     global $tree, $ilDB;
     // process all courses
     $all_courses = array_keys(ilObject::_getObjectsByType("crs"));
     if ($all_courses) {
         // gather objects in trash
         $trashed_objects = $tree->getSavedNodeObjIds($all_courses);
         include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
         include_once "Modules/Course/classes/class.ilCourseParticipants.php";
         include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
         foreach ($all_courses as $crs_id) {
             // trashed objects will not change
             if (!in_array($crs_id, $trashed_objects)) {
                 // only if LP is active
                 $mode = ilLPObjSettings::_lookupMode($crs_id);
                 if ($mode == LP_MODE_DEACTIVATED || $mode == LP_MODE_UNDEFINED) {
                     continue;
                 }
                 // only save once per day
                 $ilDB->manipulate("DELETE FROM obj_lp_stat WHERE" . " obj_id = " . $ilDB->quote($crs_id, "integer") . " AND fulldate = " . $ilDB->quote(date("Ymd", $this->date), "integer"));
                 $members = new ilCourseParticipants($crs_id);
                 $members = $members->getMembers();
                 $in_progress = count(ilLPStatusWrapper::_lookupInProgressForObject($crs_id, $members));
                 $completed = count(ilLPStatusWrapper::_lookupCompletedForObject($crs_id, $members));
                 $failed = count(ilLPStatusWrapper::_lookupFailedForObject($crs_id, $members));
                 // calculate with other values - there is not direct method
                 $not_attempted = count($members) - $in_progress - $completed - $failed;
                 $set = array("type" => array("text", "crs"), "obj_id" => array("integer", $crs_id), "yyyy" => array("integer", date("Y", $this->date)), "mm" => array("integer", date("m", $this->date)), "dd" => array("integer", date("d", $this->date)), "fulldate" => array("integer", date("Ymd", $this->date)), "mem_cnt" => array("integer", count($members)), "in_progress" => array("integer", $in_progress), "completed" => array("integer", $completed), "failed" => array("integer", $failed), "not_attempted" => array("integer", $not_attempted));
                 $ilDB->insert("obj_lp_stat", $set);
             }
         }
     }
 }
 /**
  * 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() . '".');
     }
 }
 /**
  * Get HTML for navigation history
  */
 function getHTML()
 {
     global $ilNavigationHistory, $lng;
     include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $selection = new ilAdvancedSelectionListGUI();
     $selection->setFormSelectMode("url_ref_id", "ilNavHistorySelect", true, "goto.php?target=navi_request", "ilNavHistory", "ilNavHistoryForm", "_top", $lng->txt("go"), "ilNavHistorySubmit");
     $selection->setListTitle($lng->txt("last_visited"));
     $selection->setId("lastvisited");
     $selection->setSelectionHeaderClass("MMInactive");
     $selection->setHeaderIcon(ilAdvancedSelectionListGUI::NO_ICON);
     $selection->setItemLinkClass("small");
     $selection->setUseImages(true);
     include_once "./Services/Accessibility/classes/class.ilAccessKey.php";
     $selection->setAccessKey(ilAccessKey::LAST_VISITED);
     $items = $ilNavigationHistory->getItems();
     //$sel_arr = array(0 => "-- ".$lng->txt("last_visited")." --");
     reset($items);
     $cnt = 0;
     foreach ($items as $k => $item) {
         if ($cnt++ > 20) {
             break;
         }
         if (!isset($item["ref_id"]) || !isset($_GET["ref_id"]) || $item["ref_id"] != $_GET["ref_id"] || $k > 0) {
             $obj_id = ilObject::_lookupObjId($item["ref_id"]);
             $selection->addItem($item["title"], $item["ref_id"], $item["link"], ilObject::_getIcon($obj_id, "tiny", $item["type"]), $lng->txt("obj_" . $item["type"]), "_top");
         }
     }
     $html = $selection->getHTML();
     if ($html == "") {
         $selection->addItem($lng->txt("no_items"), "", "#", "", "", "_top");
         $selection->setUseImages(false);
         $html = $selection->getHTML();
     }
     return $html;
 }
 /**
  * Get list of roles assigned to an object
  * @return 
  * @param object $result
  */
 public static function getListByObject($a_str)
 {
     global $rbacreview, $ilDB;
     include_once './Services/JSON/classes/class.ilJsonUtil.php';
     $result = array();
     if (strpos($a_str, '@') !== 0) {
         return ilJsonUtil::encode($result);
     }
     $a_str = substr($a_str, 1);
     $ilDB->setLimit(100);
     $query = "SELECT ref_id, title FROM object_data ode " . "JOIN object_reference ore ON ode.obj_id = ore.obj_id " . "WHERE " . $ilDB->like('title', 'text', $a_str . '%') . ' ' . 'ORDER BY title';
     $res = $ilDB->query($query);
     $counter = 0;
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $rolf = $rbacreview->getRoleFolderIdOfObject($row->ref_id);
         if ($rolf) {
             foreach ($rbacreview->getRolesOfRoleFolder($rolf, false) as $rol_id) {
                 $role = ilObject::_lookupTitle($rol_id);
                 $result[$counter] = new stdClass();
                 $result[$counter]->value = $role;
                 $result[$counter]->label = $role . " (" . $row->title . ")";
                 ++$counter;
             }
         }
     }
     return ilJsonUtil::encode($result);
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng;
     $this->tpl->setVariable("REF_ID", $a_set["ref_id"]);
     $this->tpl->setVariable("SUBSTYLE", $a_set["substyle"]);
     $this->tpl->setVariable("CATEGORY", ilObject::_lookupTitle(ilObject::_lookupObjId($a_set["ref_id"])));
 }
 /**
  * Get head dependencies
  *
  * @param		string		entity
  * @param		string		target release
  * @param		array		ids
  * @return		array		array of array with keys "component", entity", "ids"
  */
 function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
 {
     if ($a_entity == "pg") {
         // get all media objects and files of the page
         include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
         include_once "./Modules/File/classes/class.ilObjFile.php";
         $mob_ids = array();
         $file_ids = array();
         foreach ($a_ids as $pg_id) {
             $pg_id = explode(":", $pg_id);
             // get media objects
             $mids = ilObjMediaObject::_getMobsOfObject($pg_id[0] . ":pg", $pg_id[1]);
             foreach ($mids as $mid) {
                 if (ilObject::_lookupType($mid) == "mob") {
                     $mob_ids[] = $mid;
                 }
             }
             // get files
             $files = ilObjFile::_getFilesOfObject($pg_id[0] . ":pg", $pg_id[1]);
             foreach ($files as $file) {
                 if (ilObject::_lookupType($file) == "file") {
                     $file_ids[] = $file;
                 }
             }
         }
         return array(array("component" => "Services/MediaObjects", "entity" => "mob", "ids" => $mob_ids), array("component" => "Modules/File", "entity" => "file", "ids" => $file_ids));
     }
     return array();
 }
 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;
 }
 /**
  * check access to learning progress
  * 
  * @param int $a_ref_id reference ifd of object
  * @param bool $a_allow_only_read read access is sufficient (see courses/groups)
  * @return
  * @static
  */
 public static function checkAccess($a_ref_id, $a_allow_only_read = true)
 {
     global $ilUser, $ilAccess;
     if ($ilUser->getId() == ANONYMOUS_USER_ID) {
         return false;
     }
     include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
     if (!ilObjUserTracking::_enabledLearningProgress()) {
         return false;
     }
     if ($ilAccess->checkAccess('edit_learning_progress', '', $a_ref_id)) {
         return true;
     }
     if (!ilObjUserTracking::_hasLearningProgressLearner()) {
         return false;
     }
     include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
     if (ilLPObjSettings::_lookupMode(ilObject::_lookupObjId($a_ref_id)) == LP_MODE_DEACTIVATED) {
         return false;
     }
     if (!$ilAccess->checkAccess('read', '', $a_ref_id)) {
         return false;
     }
     if ($a_allow_only_read) {
         return true;
     }
     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;
 }
 protected function getItems($a_content_obj, $a_group_obj)
 {
     global $ilUser, $tree;
     $counter = 0;
     $items = ilUtil::_getObjectsByOperations($this->type, 'write', $ilUser->getId(), -1);
     $items_obj_id = array();
     $items_ids = array();
     foreach ($items as $ref_id) {
         $obj_id = ilObject::_lookupObjId($ref_id);
         $items_ids[$obj_id] = $ref_id;
         $items_obj_id[] = $obj_id;
     }
     $items_obj_id = ilUtil::_sortIds($items_obj_id, 'object_data', 'title', 'obj_id');
     $assigned_ids = array();
     $assigned = $a_group_obj->getAssignedItems();
     if ($assigned) {
         foreach ($assigned as $item) {
             $assigned_ids[] = $item['target_ref_id'];
         }
     }
     $data = array();
     foreach ($items_obj_id as $obj_id) {
         $item_id = $items_ids[$obj_id];
         if ($tree->checkForParentType($item_id, 'adm')) {
             continue;
         }
         $obj_id = ilObject::_lookupObjId($item_id);
         $data[] = array('id' => $item_id, 'title' => ilObject::_lookupTitle($obj_id), 'description' => ilObject::_lookupDescription($obj_id), 'path' => $this->__formatPath($tree->getPathFull($item_id)), 'assigned' => in_array($item_id, $assigned_ids));
     }
     $this->setData($data);
 }
 function listObjects()
 {
     global $tpl, $ilToolbar, $lng, $ilCtrl, $objDefinition;
     $objects = ilObject::getAllOwnedRepositoryObjects($this->user_id);
     if (sizeof($objects)) {
         include_once "Services/Form/classes/class.ilSelectInputGUI.php";
         $sel = new ilSelectInputGUI($lng->txt("type"), "type");
         $ilToolbar->addInputItem($sel, true);
         $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "listObjects"));
         $ilToolbar->addFormButton($lng->txt("ok"), "listObjects");
         $options = array();
         foreach (array_keys($objects) as $type) {
             // #11050
             if (!$objDefinition->isPlugin($type)) {
                 $options[$type] = $lng->txt("obj_" . $type);
             } else {
                 include_once "./Services/Component/classes/class.ilPlugin.php";
                 $options[$type] = ilPlugin::lookupTxt("rep_robj", $type, "obj_" . $type);
             }
         }
         asort($options);
         $sel->setOptions($options);
         $sel_type = (string) $_REQUEST["type"];
         if ($sel_type) {
             $sel->setValue($sel_type);
         } else {
             $sel_type = array_keys($options);
             $sel_type = array_shift($sel_type);
         }
         $ilCtrl->setParameter($this, "type", $sel_type);
     }
     include_once "Services/Object/classes/class.ilObjectOwnershipManagementTableGUI.php";
     $tbl = new ilObjectOwnershipManagementTableGUI($this, "listObjects", $this->user_id, $objects[$sel_type]);
     $tpl->setContent($tbl->getHTML());
 }
 /**
  * Show member view switch
  * @return 
  * @param int $a_ref_id
  */
 public static function showMemberViewSwitch($a_ref_id)
 {
     global $ilAccess, $ilCtrl;
     $settings = ilMemberViewSettings::getInstance();
     if (!$settings->isEnabled()) {
         return false;
     }
     global $tpl, $tree, $lng, $ilTabs;
     // No course or group in path => aborting
     if (!$tree->checkForParentType($a_ref_id, 'crs') and !$tree->checkForParentType($a_ref_id, 'grp')) {
         return false;
     }
     // TODO: check edit_permission
     $active = $settings->isActive();
     $type = ilObject::_lookupType(ilObject::_lookupObjId($a_ref_id));
     if (($type == 'crs' or $type == 'grp') and $ilAccess->checkAccess('write', '', $a_ref_id)) {
         $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id);
         $ilCtrl->setParameterByClass("ilrepositorygui", "mv", "1");
         $ilCtrl->setParameterByClass("ilrepositorygui", "set_mode", "flat");
         $ilTabs->addNonTabbedLink("members_view", $lng->txt('mem_view_activate'), $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"));
         $ilCtrl->clearParametersByClass("ilrepositorygui");
         return true;
     }
     return true;
 }
 /**
  * check access to learning progress
  * 
  * @param int $a_ref_id reference ifd of object
  * @param bool $a_allow_only_read read access is sufficient (see courses/groups)
  * @return
  * @static
  */
 public static function checkAccess($a_ref_id, $a_allow_only_read = true)
 {
     global $ilUser, $ilAccess;
     if ($ilUser->getId() == ANONYMOUS_USER_ID) {
         return false;
     }
     include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
     if (!ilObjUserTracking::_enabledLearningProgress()) {
         return false;
     }
     if ($ilAccess->checkAccess('edit_learning_progress', '', $a_ref_id)) {
         return true;
     }
     if (!ilObjUserTracking::_hasLearningProgressLearner()) {
         return false;
     }
     include_once './Services/Object/classes/class.ilObjectLP.php';
     $olp = ilObjectLP::getInstance(ilObject::_lookupObjId($a_ref_id));
     if (!$olp->isActive()) {
         return false;
     }
     if (!$ilAccess->checkAccess('read', '', $a_ref_id)) {
         return false;
     }
     if ($a_allow_only_read) {
         return true;
     }
     return false;
 }
 /**
  * Get characteristics
  */
 static function _getCharacteristics($a_style_id)
 {
     $st_chars = ilPCParagraphGUI::_getStandardCharacteristics();
     $chars = ilPCParagraphGUI::_getStandardCharacteristics();
     if ($a_style_id > 0 && ilObject::_lookupType($a_style_id) == "sty") {
         include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $style = new ilObjStyleSheet($a_style_id);
         $types = array("text_block", "heading1", "heading2", "heading3");
         $chars = array();
         foreach ($types as $t) {
             $chars = array_merge($chars, $style->getCharacteristics($t));
         }
         $new_chars = array();
         foreach ($chars as $char) {
             if ($st_chars[$char] != "") {
                 $new_chars[$char] = $st_chars[$char];
             } else {
                 $new_chars[$char] = $char;
             }
             asort($new_chars);
         }
         $chars = $new_chars;
     }
     return $chars;
 }
Exemple #24
0
 function __construct()
 {
     global $ilias, $tpl, $ilCtrl, $ilUser, $lng;
     //erase next?
     if ($_REQUEST['learnerId']) {
         $this->userId = $_REQUEST['learnerId'];
     } else {
         $this->userId = $GLOBALS['USER']['usr_id'];
     }
     $this->packageId = (int) $_REQUEST['packageId'];
     $this->jsMode = strpos($_SERVER['HTTP_ACCEPT'], 'text/javascript') !== false;
     $this->page = $_REQUEST['page'];
     $this->slm =& new ilObjSCORM2004LearningModule($_GET["ref_id"], true);
     $this->ilias =& $ilias;
     $this->tpl =& $tpl;
     $this->ctrl =& $ilCtrl;
     $this->packageId = ilObject::_lookupObjectId($_GET['ref_id']);
     $this->ref_id = $_GET['ref_id'];
     $this->userId = $ilUser->getID();
     if ($_GET['envEditor'] != null) {
         $this->envEditor = $_GET['envEditor'];
     } else {
         $this->envEditor = 0;
     }
 }
 protected function prepareOutput()
 {
     $this->tpl->getStandardTemplate();
     $this->tpl->setTitleIcon(ilObject::_getIcon('', '', 'pays'), $this->lng->txt("shop"));
     $this->tpl->setTitle($this->lng->txt("shop"));
     ilUtil::infoPanel();
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilUser;
     include_once "./Services/Skill/classes/class.ilPersonalSkill.php";
     $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]);
     $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
     foreach ($mat as $m) {
         $this->tpl->setCurrentBlock("mat");
         $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
         $this->tpl->setVariable("MAT_TITLE", ilObject::_lookupTitle($obj_id));
         $this->tpl->setVariable("MAT_IMG", ilUtil::img(ilUtil::getImagePath("icon_" . ilObject::_lookupType($obj_id) . ".svg")));
         $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
         $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]);
         $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial"));
         $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
         $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id);
         $this->tpl->setVariable("HREF_MAT", $url);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setCurrentBlock("cmd");
     $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget($this->parent_obj, "assignMaterial"));
     $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials"));
     $this->tpl->parseCurrentBlock();
     $ilCtrl->setParameter($this->parent_obj, "level_id", "");
     $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
     $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
     $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
     $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
 }
 /**
  * @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;
     }
 }
 /**
  * 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);
 }
 public function __construct($a_parent_obj, $a_parent_cmd, array &$a_data, $a_view, $a_by_location = false)
 {
     global $ilCtrl, $tree, $ilUser;
     $this->setId("pdmng");
     parent::__construct($a_parent_obj, $a_parent_cmd);
     $this->addColumn('', '', '5%');
     $this->addColumn($this->lng->txt("type"), 'type_caption', '1%');
     $this->addColumn($this->lng->txt("title"), 'title', '44%');
     $this->addColumn($this->lng->txt("container"), 'container', '50%');
     $this->setDefaultOrderField("title");
     $this->setRowTemplate("tpl.pd_manage_row.html", "Services/PersonalDesktop");
     $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
     if ($a_view == ilPDSelectedItemsBlockGUI::VIEW_MY_OFFERS) {
         $this->setTitle($this->lng->txt("pd_my_offers"));
         $this->addMultiCommand('confirmRemove', $this->lng->txt('unsubscribe'));
     } else {
         $this->setTitle($this->lng->txt("pd_my_memberships"));
         $this->addMultiCommand('confirmRemove', $this->lng->txt('crs_unsubscribe'));
     }
     $this->addCommandButton("getHTML", $this->lng->txt("cancel"));
     // root node caption
     $root = $tree->getNodeData(ROOT_FOLDER_ID);
     $root = $root["title"];
     if ($root == "ILIAS") {
         $root = $this->lng->txt("repository");
     }
     foreach ($a_data as $idx => $item) {
         if (!$item["parent_ref"]) {
             unset($a_data[$idx]);
             continue;
         }
         if ($a_view == ilPDSelectedItemsBlockGUI::VIEW_MY_MEMBERSHIPS) {
             $a_data[$idx]["last_admin"] = false;
             switch ($item["type"]) {
                 case "crs":
                     // see ilObjCourseGUI:performUnsubscribeObject()
                     include_once "Modules/Course/classes/class.ilCourseParticipants.php";
                     $members = new ilCourseParticipants($item["obj_id"]);
                     break;
                 case "grp":
                     include_once "Modules/Group/classes/class.ilGroupParticipants.php";
                     $members = new ilGroupParticipants($item["obj_id"]);
                     break;
                 default:
                     // do nothing?
                     continue;
             }
             $a_data[$idx]["last_admin"] = $members->isLastAdmin($ilUser->getId());
         }
         $a_data[$idx]["type_caption"] = $this->lng->txt("obj_" . $item["type"]);
         // parent
         if ($tree->getRootId() != $item["parent_ref"]) {
             $a_data[$idx]["container"] = ilObject::_lookupTitle(ilObject::_lookupObjId($item["parent_ref"]));
         } else {
             $a_data[$idx]["container"] = $root;
         }
     }
     $this->setData($a_data);
 }
 function getSelectableColumns()
 {
     global $ilObjDataCache;
     $columns = array();
     if ($this->obj_ids === NULL) {
         $this->obj_ids = $this->getItems();
     }
     if ($this->obj_ids) {
         $tmp_cols = array();
         foreach ($this->obj_ids as $obj_id) {
             if ($obj_id == $this->obj_id) {
                 $parent = array("txt" => $this->lng->txt("status"), "default" => true);
             } else {
                 $title = $ilObjDataCache->lookupTitle($obj_id);
                 $type = $ilObjDataCache->lookupType($obj_id);
                 $icon = ilObject::_getIcon("", "tiny", $type);
                 if ($type == "sess") {
                     include_once "Modules/Session/classes/class.ilObjSession.php";
                     $sess = new ilObjSession($obj_id, false);
                     $title = $sess->getPresentationTitle();
                 }
                 $tmp_cols[strtolower($title) . "#~#obj_" . $obj_id] = array("txt" => $title, "icon" => $icon, "type" => $type, "default" => true);
             }
         }
         if (sizeof($this->objective_ids)) {
             foreach ($this->objective_ids as $obj_id => $title) {
                 $tmp_cols[strtolower($title) . "#~#objtv_" . $obj_id] = array("txt" => $title, "default" => true);
             }
         }
         if (sizeof($this->sco_ids)) {
             foreach ($this->sco_ids as $obj_id => $title) {
                 $icon = ilUtil::getTypeIconPath("sco", $obj_id, "tiny");
                 $tmp_cols[strtolower($title) . "#~#objsco_" . $obj_id] = array("txt" => $title, "icon" => $icon, "default" => true);
             }
         }
         // alex, 5 Nov 2011: Do not sort SCORM items
         if (!sizeof($this->sco_ids)) {
             ksort($tmp_cols);
         }
         foreach ($tmp_cols as $id => $def) {
             $id = explode('#~#', $id);
             $columns[$id[1]] = $def;
         }
         unset($tmp_cols);
         if ($parent) {
             $columns["obj_" . $this->obj_id] = $parent;
         }
     }
     $columns["status_changed"] = array("txt" => $this->lng->txt("trac_status_changed"), "id" => "status_changed", "default" => false);
     include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
     $tracking = new ilObjUserTracking();
     if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_LAST_ACCESS)) {
         $columns["last_access"] = array("txt" => $this->lng->txt("last_access"), "id" => "last_access", "default" => false);
     }
     if ($tracking->hasExtendedData(ilObjUserTracking::EXTENDED_DATA_SPENT_SECONDS)) {
         $columns["spent_seconds"] = array("txt" => $this->lng->txt("trac_spent_seconds"), "id" => "spent_seconds", "default" => false);
     }
     return $columns;
 }