public function getPossibleItems($a_ref_id) { if (!isset(self::$possible_items[$a_ref_id])) { $obj_id = ilObject::_lookupObjectId($a_ref_id); $items = array(); // only top-level chapters include_once "Services/MetaData/classes/class.ilMDEducational.php"; $tree = new ilTree($obj_id); $tree->setTableNames('lm_tree', 'lm_data'); $tree->setTreeTablePK("lm_id"); foreach ($tree->getChilds($tree->readRootId()) as $child) { if ($child["type"] == "st") { $child["tlt"] = ilMDEducational::_getTypicalLearningTimeSeconds($obj_id, $child["obj_id"]); $items[$child["obj_id"]] = $child; } } self::$possible_items[$a_ref_id] = $items; } return self::$possible_items[$a_ref_id]; }
/** * Get pages of chapter * * @param * @return */ static function getPagesOfChapter($a_lm_id, $a_chap_id) { // update structure entries: if at least one page of a chapter is public set chapter to public too $lm_tree = new ilTree($a_lm_id); $lm_tree->setTableNames('lm_tree', 'lm_data'); $lm_tree->setTreeTablePK("lm_id"); $lm_tree->readRootId(); $childs = $lm_tree->getChildsByType($a_chap_id, "pg"); return $childs; }
/** * Get scorm module editing tree * * @param int scorm module object id * * @return object tree object */ static function getTree($a_slm_obj_id) { $tree = new ilTree($a_slm_obj_id); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); $tree->readRootId(); return $tree; }
/** * output explorer tree */ function explorer() { global $ilUser, $ilias, $ilCtrl; switch ($this->object->getType()) { case "lm": $gui_class = "ilobjlearningmodulegui"; break; case "dlb": $gui_class = "ilobjdlbookgui"; break; } $ilCtrl->setParameterByClass($gui_class, "active_node", $_GET["active_node"]); $this->tpl = new ilTemplate("tpl.main.html", true, true); // get learning module object //$this->lm_obj =& new ilObjLearningModule($this->ref_id, true); $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); //$this->tpl = new ilTemplate("tpl.explorer.html", false, false); $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html"); $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false)); require_once "./Modules/LearningModule/classes/class.ilLMEditorExplorer.php"; $exp = new ilLMEditorExplorer($this->ctrl->getLinkTarget($this, "view"), $this->object, $gui_class); $exp->setTargetGet("obj_id"); $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "explorer")); if ($_GET["lmmovecopy"] == "1") { $this->proceedDragDrop(); } if ($_GET["lmexpand"] == "") { $mtree = new ilTree($this->object->getId()); $mtree->setTableNames('lm_tree', 'lm_data'); $mtree->setTreeTablePK("lm_id"); $expanded = $mtree->readRootId(); } else { $expanded = $_GET["lmexpand"]; } if ($_GET["active_node"] != "") { $path = $this->lm_tree->getPathId($_GET["active_node"]); $exp->setForceOpenPath($path); $exp->highlightNode($_GET["active_node"]); } $exp->setExpand($expanded); // build html-output $exp->setOutput(0); $output = $exp->getOutput(); // asynchronous output if ($ilCtrl->isAsynch()) { echo $output; exit; } include_once "./Services/COPage/classes/class.ilPageEditorGUI.php"; /*if (ilPageEditorGUI::_doJSEditing()) { //$this->tpl->touchBlock("includejavascript"); $IDS = ""; for ($i=0;$i<count($exp->iconList);$i++) { if ($i>0) $IDS .= ","; $IDS .= "'".$exp->iconList[$i]."'"; } $this->tpl->setVariable("ICONIDS",$IDS); //$this->ctrl->setParameter($this, "lmovecopy", 1); $this->tpl->setVariable("TESTPFAD",$this->ctrl->getLinkTarget($this, "explorer")."&lmmovecopy=1"); //$this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode"); $this->tpl->setVariable("POPUPLINK",$this->ctrl->getLinkTarget($this, "popup")."&ptype=movecopytreenode"); }*/ $this->tpl->setCurrentBlock("content"); $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_chap_and_pages")); $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh")); $this->tpl->setVariable("EXPLORER", $output); $this->ctrl->setParameter($this, "lmexpand", $_GET["lmexpand"]); $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "explorer")); $this->tpl->parseCurrentBlock(); $this->tpl->show(false); exit; }
/** * export (sub)structure objects of structure object (see ilias_co.dtd) * * @param object $a_xml_writer ilXmlWriter object that receives the * xml data */ static function getChapterList($a_lm_id) { $tree = new ilTree($a_lm_id); $tree->setTableNames('lm_tree', 'lm_data'); $tree->setTreeTablePK("lm_id"); $chapters = array(); $ndata = $tree->getNodeData($tree->readRootId()); $childs = $tree->getSubtree($ndata); foreach ($childs as $child) { if ($child["type"] == "st") { $chapters[] = $child; } } return $chapters; }
/** * Show Editing Tree */ function showTree() { global $ilUser, $ilias, $ilCtrl, $lng; $mtree = new ilTree($this->object->getId()); $mtree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $mtree->setTreeTablePK("slm_id"); if ($_POST["expandAll"] != "") { $_GET["scexpand"] = ""; $stree = $mtree->getSubTree($mtree->getNodeData($mtree->readRootId())); $n_arr = array(); foreach ($stree as $n) { $n_arr[] = $n["child"]; } $_SESSION["scexpand"] = $n_arr; } if ($_POST["collapseAll"] != "") { $_GET["scexpand"] = ""; $_SESSION["scexpand"] = array($mtree->readRootId()); } $this->tpl = new ilTemplate("tpl.main.html", true, true); $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); $ilCtrl->setParameter($this, "active_node", $_GET["active_node"]); $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html"); $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false)); $this->tpl->setCurrentBlock("exp2_button"); $this->tpl->setVariable("CMD_EXP2_BTN", "expandAll"); $this->tpl->setVariable("TXT_EXP2_BTN", $lng->txt("expand_all")); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("exp2_button"); $this->tpl->setVariable("CMD_EXP2_BTN", "collapseAll"); $this->tpl->setVariable("TXT_EXP2_BTN", $lng->txt("collapse_all")); $this->tpl->parseCurrentBlock(); require_once "./Modules/Scorm2004/classes/class.ilSCORM2004EditorExplorer.php"; $exp = new ilSCORM2004EditorExplorer($this->ctrl->getLinkTarget($this, "edit"), $this->object); $exp->setFrameUpdater("content", "ilHierarchyFormUpdater"); $exp->setTargetGet("obj_id"); $exp->setExpandTarget($this->ctrl->getLinkTarget($this, "showTree")); if ($_GET["scexpand"] == "") { $expanded = $mtree->readRootId(); } else { $expanded = $_GET["scexpand"]; } //echo "-".$_GET["active_node"]."-"; if ($_GET["active_node"] != "") { $path = $mtree->getPathId($_GET["active_node"]); $exp->setForceOpenPath($path); $exp->highlightNode($_GET["active_node"]); } $exp->setExpand($expanded); // build html-output $exp->setOutput(0); $output = $exp->getOutput(); // asynchronous output if ($ilCtrl->isAsynch()) { echo $output; exit; } $this->tpl->setCurrentBlock("content"); $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("sahs_organization")); $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh")); $this->tpl->setVariable("EXPLORER", $output); $this->ctrl->setParameter($this, "scexpand", $_GET["scexpand"]); $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, "showTree")); $this->tpl->parseCurrentBlock(); include_once "./Services/jQuery/classes/class.iljQueryUtil.php"; iljQueryUtil::initjQuery($this->tpl); $this->tpl->show(false); exit; }
/** * get top chapter of page for that any precondition is missing */ function _getMissingPreconditionsTopChapter($cont_obj_ref_id, $cont_obj_id, $page_id) { $lm_tree = new ilTree($cont_obj_id); $lm_tree->setTableNames('lm_tree', 'lm_data'); $lm_tree->setTreeTablePK("lm_id"); $conds = array(); if ($lm_tree->isInTree($page_id)) { // get full path of page $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId()); foreach ($path as $node) { if ($node["type"] == "st") { // get all preconditions of upper chapters $tconds = ilConditionHandler::_getConditionsOfTarget($cont_obj_ref_id, $node["child"], "st"); foreach ($tconds as $tcond) { // look for missing precondition if (!ilConditionHandler::_checkCondition($tcond["id"])) { return $node["child"]; } } } } } return ""; }
/** * Import record * * @param * @return */ function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version) { switch ($a_entity) { case "bookmarks": break; case "bookmark_tree": $usr_id = $a_mapping->getMapping("Services/User", "usr", $a_rec["UserId"]); if ($usr_id > 0 && ilObject::_lookupType($usr_id) == "usr") { //echo "<br><br>"; //var_dump($a_rec); switch ($a_rec["Type"]) { case "bmf": if ($a_rec["Parent"] > 0) { $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]); include_once "./Services/Bookmarks/classes/class.ilBookmarkFolder.php"; $bmf = new ilBookmarkFolder(0, $usr_id); $bmf->setTitle($a_rec["Title"]); $bmf->setParent($parent); $bmf->create(); $fold_id = $bmf->getId(); } else { $tree = new ilTree($usr_id); $tree->setTableNames('bookmark_tree', 'bookmark_data'); $fold_id = $tree->readRootId(); } $a_mapping->addMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Child"], $fold_id); break; case "bm": $parent = 0; if ((int) $a_rec["Parent"] > 0) { $parent = (int) $a_mapping->getMapping("Services/Bookmarks", "bookmark_tree", $a_rec["Parent"]); } else { return; } if ($parent == 0) { $tree = new ilTree($usr_id); $tree->setTableNames('bookmark_tree', 'bookmark_data'); $parent = $tree->readRootId(); } //echo "-$parent-"; include_once "./Services/Bookmarks/classes/class.ilBookmark.php"; $bm = new ilBookmark(0, $usr_id); $bm->setTitle($a_rec["Title"]); $bm->setDescription($a_rec["Description"]); $bm->setTarget($a_rec["Target"]); $bm->setParent($parent); $bm->create(); break; } } break; } }
/** * output explorer tree with bookmark folders */ function explorer() { global $tpl; $etpl = new ilTemplate("tpl.bookmark_explorer.html", true, true, "Services/Bookmarks"); $exp = new ilBookmarkExplorer($this->ctrl->getLinkTarget($this), $this->user_id); $exp->setAllowedTypes(array('dum', 'bmf')); $exp->setTargetGet("bmf_id"); $exp->setSessionExpandVariable('mexpand'); $exp->setExpand($this->id); $this->ctrl->setParameter($this, "bmf_id", $this->id); $exp->setExpandTarget($this->ctrl->getLinkTarget($this)); if ($_GET["mexpand"] == "") { $mtree = new ilTree($this->user_id); $mtree->setTableNames('bookmark_tree', 'bookmark_data'); $expanded = $mtree->readRootId(); } else { $expanded = $_GET["mexpand"]; } $exp->setExpand($expanded); $exp->highlightNode($_GET["bmf_id"]); // build html-output $exp->setOutput(0); $exp->highlightNode($this->id); $output = $exp->getOutput(); // $etpl->setCurrentBlock("adm_tree_content"); $etpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("bookmarks")); $this->ctrl->setParameter($this, "bmf_id", 1); if ($_REQUEST['bm_link']) { $link = $_SERVER['REQUEST_URI']; $link = ereg_replace('bmf_id=[0-9]*', 'bmf_id=1', $link); $etpl->setVariable("LINK_EXPLORER_HEADER", $link); } else { $etpl->setVariable("LINK_EXPLORER_HEADER", $this->ctrl->getLinkTarget($this)); } $etpl->setVariable("EXPLORER", $output); $tpl->setLeftNavContent($etpl->get()); }
/** * check access for an object * * @param ilTree $a_tree * @param integer $a_user_id * @param string $a_permission * @param string $a_cmd * @param int $a_node_id * @param string $a_type (optional) * @return bool */ public function checkAccessOfUser(ilTree $a_tree, $a_user_id, $a_permission, $a_cmd, $a_node_id, $a_type = "") { global $rbacreview, $ilUser; // :TODO: create permission for parent node with type ?! // tree root is read-only if ($a_permission == "write") { if ($a_tree->readRootId() == $a_node_id) { return false; } } // node owner has all rights if ($a_tree->lookupOwner($a_node_id) == $a_user_id) { return true; } // other users can only read if ($a_permission == "read" || $a_permission == "visible") { // get all objects with explicit permission $objects = $this->getPermissions($a_node_id); if ($objects) { // check if given user is member of object or has role foreach ($objects as $obj_id) { switch ($obj_id) { case ilWorkspaceAccessGUI::PERMISSION_ALL: return true; case ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD: // check against input kept in session if (self::getSharedNodePassword($a_node_id) == self::getSharedSessionPassword($a_node_id) || $a_permission == "visible") { return true; } break; case ilWorkspaceAccessGUI::PERMISSION_REGISTERED: if ($ilUser->getId() != ANONYMOUS_USER_ID) { return true; } break; default: switch (ilObject::_lookupType($obj_id)) { case "grp": // member of group? if (ilGroupParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) { return true; } break; case "crs": // member of course? if (ilCourseParticipants::_getInstanceByObjId($obj_id)->isAssigned($a_user_id)) { return true; } break; case "role": // has role? if ($rbacreview->isAssigned($a_user_id, $obj_id)) { return true; } break; case "usr": // direct assignment if ($a_user_id == $obj_id) { return true; } break; } break; } } } } return false; }