/**
  * Get's the repository object ID of a parent object, if possible
  * 
  * see ilWebAccessChecker 
  */
 function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
 {
     if (is_int(strpos($a_usage["type"], ":"))) {
         $us_arr = explode(":", $a_usage["type"]);
         $type = $us_arr[1];
         $cont_type = $us_arr[0];
     } else {
         $type = $a_usage["type"];
     }
     $id = $a_usage["id"];
     $obj_id = false;
     switch ($type) {
         // RTE / tiny mce
         case "html":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool *Question* Text (Test)
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "spl":
                     // Question Pool *Question* Text (Survey)
                     include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                     $quest = SurveyQuestion::_instanciateQuestion($id);
                     if ($quest) {
                         if ($quest->getOriginalId() > 0) {
                             $obj_id = $quest->getSurveyId();
                         } else {
                             $obj_id = $quest->getObjId();
                             // usage in pool
                         }
                         unset($quest);
                     }
                     break;
                 case "exca":
                     // Exercise assignment
                     $returned_pk = $a_usage['id'];
                     // we are just checking against exercise object
                     include_once 'Modules/Exercise/classes/class.ilObjExercise.php';
                     $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk);
                     break;
                 case "frm":
                     // Forum
                     $post_pk = $a_usage['id'];
                     include_once 'Modules/Forum/classes/class.ilForumPost.php';
                     include_once 'Modules/Forum/classes/class.ilForum.php';
                     $oPost = new ilForumPost($post_pk);
                     $frm_pk = $oPost->getForumId();
                     $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
                     break;
                     // temporary items (per user)
                 // temporary items (per user)
                 case "frm~":
                 case "exca~":
                     $obj_id = $a_usage['id'];
                     break;
                     // "old" category pages
                 // "old" category pages
                 case "cat":
                     // InfoScreen Text
                 // InfoScreen Text
                 case "tst":
                 case "svy":
                     // data collection
                 // data collection
                 case "dcl":
                     $obj_id = $id;
                     break;
             }
             break;
             // page editor
         // page editor
         case "pg":
             switch ($cont_type) {
                 case "qpl":
                     // Question Pool Question Pages
                     include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                     $qinfo = assQuestion::_getQuestionInfo($id);
                     if ($qinfo["original_id"] > 0) {
                         include_once "./Modules/Test/classes/class.ilObjTest.php";
                         $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                         // usage in test
                     } else {
                         $obj_id = $qinfo["obj_fi"];
                         // usage in pool
                     }
                     break;
                 case "lm":
                 case "dbk":
                     // learning modules
                     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $obj_id = ilLMObject::_lookupContObjID($id);
                     break;
                 case "gdf":
                     // glossary definition
                     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     $term_id = ilGlossaryDefinition::_lookupTermId($id);
                     $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
                     break;
                 case "wpg":
                     // wiki page
                     include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                     $obj_id = ilWikiPage::lookupObjIdByPage($id);
                     break;
                 case "sahs":
                     // sahs page
                     // can this implementation be used for other content types, too?
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'sahs');
                     break;
                 case "prtf":
                     // portfolio
                     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
                     $obj_id = ilPortfolioPage::findPortfolioForPage($id);
                     break;
                 case "prtt":
                     // portfolio template
                     include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php";
                     $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id);
                     break;
                 case "blp":
                     // blog
                     include_once './Services/COPage/classes/class.ilPageObject.php';
                     $obj_id = ilPageObject::lookupParentId($id, 'blp');
                     break;
                 case "crs":
                 case "grp":
                 case "cat":
                 case "fold":
                 case "root":
                     // repository pages
                     $obj_id = $id;
                     break;
             }
             break;
             // Media Pool
         // Media Pool
         case "mep":
             $obj_id = $id;
             break;
             // News Context Object (e.g. MediaCast)
         // News Context Object (e.g. MediaCast)
         case "news":
             include_once "./Services/News/classes/class.ilNewsItem.php";
             $obj_id = ilNewsItem::_lookupContextObjId($id);
             break;
     }
     return $obj_id;
 }
 /**
  * redirect script
  *
  * @param	string		$a_target
  */
 function _goto($a_target, $a_target_ref_id = "")
 {
     global $rbacsystem, $ilErr, $lng, $ilAccess;
     // determine learning object
     $lm_id = ilLMObject::_lookupContObjID($a_target);
     // get all references
     $ref_ids = ilObject::_getAllReferences($lm_id);
     // always try passed ref id first
     if (in_array($a_target_ref_id, $ref_ids)) {
         $ref_ids = array_merge(array($a_target_ref_id), $ref_ids);
     }
     // check read permissions
     foreach ($ref_ids as $ref_id) {
         // Permission check
         if ($ilAccess->checkAccess("read", "", $ref_id)) {
             // don't redirect anymore, just set parameters
             // (goto.php includes  "ilias.php")
             $_GET["baseClass"] = "ilLMPresentationGUI";
             $_GET["obj_id"] = $a_target;
             $_GET["ref_id"] = $ref_id;
             include_once "ilias.php";
             exit;
         }
     }
     if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
         ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"), ilObject::_lookupTitle($lm_id)), true);
         include_once "./Services/Object/classes/class.ilObjectGUI.php";
         ilObjectGUI::_gotoRepositoryRoot();
     }
     $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
 }
Ejemplo n.º 3
0
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 static function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false, $a_lm_id = 0, $a_lang = "-")
 {
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_pg_id);
     }
     if ($a_lm_id == 0) {
         return "";
     }
     // this is optimized when ilLMObject::preloadDataByLM is invoked (e.g. done in ilLMExplorerGUI)
     $title = ilLMObject::_lookupTitle($a_pg_id);
     // this is also optimized since ilObjectTranslation re-uses instances for one lm
     include_once "./Services/Object/classes/class.ilObjectTranslation.php";
     $ot = ilObjectTranslation::getInstance($a_lm_id);
     $languages = $ot->getLanguages();
     if ($a_lang != "-" && $ot->getContentActivated() && isset($languages[$a_lang])) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_pg_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $title = $lmobjtrans->getTitle();
         }
     }
     if ($a_mode == IL_PAGE_TITLE) {
         return $title;
     }
     include_once "./Modules/LearningModule/classes/class.ilLMTree.php";
     $tree = ilLMTree::getInstance($a_lm_id);
     if ($tree->isInTree($a_pg_id)) {
         $pred_node = $tree->fetchPredecessorNode($a_pg_id, "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_lookupActive($child["obj_id"], ilObject::_lookupType($a_lm_id), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilLMPage::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($a_lm_id));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $a_pg_id) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers, false, 0, $a_lang) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $title;
     }
 }
 /**
  * get presentation title
  *
  */
 function _getPresentationTitle($a_st_id, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_lm_id = 0, $a_lang = "-")
 {
     global $ilDB;
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_st_id);
     }
     // @todo: optimize
     include_once "./Services/COPage/classes/class.ilPageMultiLang.php";
     $ml = new ilPageMultiLang("lm", $a_lm_id);
     // get chapter data
     $query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_st_id, "integer");
     $st_set = $ilDB->query($query);
     $st_rec = $ilDB->fetchAssoc($st_set);
     if ($a_lang != "-" && $ml->getActivated() && in_array($a_lang, $ml->getLanguages())) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_st_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $st_rec["title"] = $lmobjtrans->getTitle();
         }
     }
     $tree = new ilTree($st_rec["lm_id"]);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($a_include_numbers) {
         if ($tree->isInTree($st_rec["obj_id"])) {
             // get chapter tree node
             $query = "SELECT * FROM lm_tree WHERE child = " . $ilDB->quote($a_st_id, "integer") . " AND lm_id = " . $ilDB->quote($st_rec["lm_id"], "integer");
             $tree_set = $ilDB->query($query);
             $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
             $depth = $tree_node["depth"];
             $nr = $tree->getChildSequenceNumber($tree_node, "st") . " ";
             for ($i = $depth - 1; $i > 1; $i--) {
                 // get next parent tree node
                 $query = "SELECT * FROM lm_tree WHERE child = " . $ilDB->quote($tree_node["parent"], "integer") . " AND lm_id = " . $ilDB->quote($st_rec["lm_id"], "integer");
                 $tree_set = $ilDB->query($query);
                 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
                 $seq = $tree->getChildSequenceNumber($tree_node, "st");
                 $nr = $seq . "." . $nr;
             }
         }
     }
     return $nr . $st_rec["title"];
 }
Ejemplo n.º 5
0
 /**
  * Standard Version of Fill Row. Most likely to
  * be overwritten by derived class.
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
     $ilCtrl->setParameterByClass("illmpageobjectgui", "obj_id", $a_set["obj_id"]);
     $this->tpl->setVariable("HREF_PAGE", $ilCtrl->getLinkTargetByClass("illmpageobjectgui", "edit"));
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     $page_object = new ilLMPage($a_set["obj_id"]);
     $page_object->buildDom();
     $int_links = $page_object->getInternalLinks();
     foreach ($int_links as $link) {
         $target = $link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $link["Type"];
             switch ($type) {
                 case "PageObject":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
                     if (ilLMObject::_exists($target_id)) {
                         $lm_id = ilLMObject::_lookupContObjID($target_id);
                         $add_str = $lm_id != $this->lm_id ? " (" . ilObject::_lookupTitle($lm_id) . ")" : "";
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilLMObject::_lookupTitle($target_id) . $add_str);
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "StructureObject":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
                     if (ilLMObject::_exists($target_id)) {
                         $lm_id = ilLMObject::_lookupContObjID($target_id);
                         $add_str = $lm_id != $this->lm_id ? " (" . ilObject::_lookupTitle($lm_id) . ")" : "";
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilLMObject::_lookupTitle($target_id) . $add_str);
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "GlossaryItem":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
                     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                     if (ilGlossaryTerm::_exists($target_id)) {
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilGlossaryTerm::_lookGlossaryTerm($target_id));
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "MediaObject":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
                     if (ilObject::_exists($target_id)) {
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilObject::_lookupTitle($target_id));
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
                 case "RepositoryItem":
                     $this->tpl->setCurrentBlock("link");
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     if (ilObject::_exists($obj_id)) {
                         $this->tpl->setVariable("TXT_LINK_TITLE", ilObject::_lookupTitle($obj_id) . " (" . $lng->txt("obj_" . $obj_type) . ")");
                     } else {
                         $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target_id . "]" . "</b>");
                     }
                     $this->tpl->parseCurrentBlock();
                     break;
             }
         } else {
             $type = $link["Type"];
             switch ($type) {
                 case "PageObject":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("pg"));
                     break;
                 case "StructureObject":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("st"));
                     break;
                 case "GlossaryItem":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_term"));
                     break;
                 case "MediaObject":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("mob"));
                     break;
                 case "RepositoryItem":
                     $this->tpl->setVariable("TXT_LINK_TYPE", $lng->txt("cont_repository_item"));
                     break;
             }
             $this->tpl->setCurrentBlock("link");
             $this->tpl->setVariable("TXT_MISSING", "<b>" . $lng->txt("cont_target_missing") . " [" . $target . "]" . "</b>");
             $this->tpl->parseCurrentBlock();
         }
     }
 }
 /**
  * split page to next page at hierarchical id
  *
  * the main reason for this method being static is that a lm page
  * object is not available within ilPageContentGUI where this method
  * is called
  */
 function _splitPageNext($a_page_id, $a_pg_parent_type, $a_hier_id)
 {
     // get content object (learning module / digilib book)
     $lm_id = ilLMObject::_lookupContObjID($a_page_id);
     $type = ilObject::_lookupType($lm_id, false);
     switch ($type) {
         case "lm":
             include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php";
             $cont_obj = new ilObjLearningModule($lm_id, false);
             break;
         case "dbk":
             include_once "./Modules/LearningModule/classes/class.ilObjDlBook.php";
             $cont_obj = new ilObjDlBook($lm_id, false);
             break;
     }
     $tree = new ilTree($cont_obj->getId());
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     $source_lm_page =& new ilLMPageObject($cont_obj, $a_page_id);
     $source_page =& $source_lm_page->getPageObject();
     // get next page
     $succ = $tree->fetchSuccessorNode($a_page_id, "pg");
     if ($succ["child"] > 0) {
         $target_lm_page =& new ilLMPageObject($cont_obj, $succ["child"]);
         $target_page =& $target_lm_page->getPageObject();
         $target_page->buildDom();
         $target_page->addHierIds();
         // move nodes to target page
         $source_page->buildDom();
         $source_page->addHierIds();
         ilPageObject::_moveContentAfterHierId($source_page, $target_page, $a_hier_id);
         //$source_page->deleteContentFromHierId($a_hier_id);
         return $succ["child"];
     }
 }
Ejemplo n.º 7
0
 /**
  * Set standard link xml
  */
 function setDefaultLinkXml()
 {
     global $ilCtrl;
     $int_links = $this->getPageObject()->getInternalLinks();
     //var_dump($int_links);
     $link_info = "<IntLinkInfos>";
     $targetframe = "None";
     foreach ($int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             $ltarget = "_top";
             if ($targetframe != "None") {
                 $ltarget = "_blank";
             }
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             $href = "";
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $href = "./goto.php?target=git_" . $target_id;
                     break;
                 case "MediaObject":
                     $ilCtrl->setParameter($this, "mob_id", $target_id);
                     //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
                     $href = $ilCtrl->getLinkTarget($this, "displayMedia");
                     $ilCtrl->setParameter($this, "mob_id", "");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . $anc_par . " " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" />";
         }
     }
     $link_info .= "</IntLinkInfos>";
     $this->setLinkXML($link_info);
 }
 /**
  * paste page
  */
 function pastePage()
 {
     if (ilEditClipboard::getContentObjectType() != "pg") {
         $this->ilias->raiseError($this->lng->txt("no_page_in_clipboard"), $this->ilias->error_obj->MESSAGE);
     }
     // paste selected object
     $id = ilEditClipboard::getContentObjectId();
     // copy page, if action is copy
     if (ilEditClipboard::getAction() == "copy") {
         // check wether page belongs to lm
         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()) == $this->object->getID()) {
             $lm_page = new ilLMPageObject($this->object, $id);
             $new_page =& $lm_page->copy();
             $id = $new_page->getId();
         } else {
             // get page from other content object into current content object
             $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
             $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
             $lm_page = new ilLMPageObject($lm_obj, $id);
             $copied_nodes = array();
             $new_page =& $lm_page->copyToOtherContObject($this->object, $copied_nodes);
             $id = $new_page->getId();
             ilLMObject::updateInternalLinks($copied_nodes);
         }
     }
     // cut is not be possible in "all pages" form yet
     if (ilEditClipboard::getAction() == "cut") {
         // check wether page belongs not to lm
         if (ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId()) != $this->object->getID()) {
             $lm_id = ilLMObject::_lookupContObjID(ilEditClipboard::getContentObjectId());
             $lm_obj =& $this->ilias->obj_factory->getInstanceByObjId($lm_id);
             $lm_page = new ilLMPageObject($lm_obj, $id);
             $lm_page->setLMId($this->object->getID());
             $lm_page->update();
             $page =& $lm_page->getPageObject();
             $page->buildDom();
             $page->setParentId($this->object->getID());
             $page->update();
         }
     }
     ilEditClipboard::clear();
     $this->ctrl->redirect($this, "pages");
 }
 /**
  * redirect script
  *
  * @param	string		$a_target
  */
 function _goto($a_target)
 {
     global $rbacsystem, $ilErr, $lng, $ilAccess;
     $first = strpos($a_target, "_");
     $second = strpos($a_target, "_", $first + 1);
     $page_id = substr($a_target, 0, $first);
     if ($first > 0) {
         $page_id = substr($a_target, 0, $first);
         if ($second > 0) {
             $ref_id = substr($a_target, $first + 1, $second - ($first + 1));
             $anchor = substr($a_target, $second + 1);
         } else {
             $ref_id = substr($a_target, $first + 1);
         }
     } else {
         $page_id = $a_target;
     }
     // determine learning object
     $lm_id = ilLMObject::_lookupContObjID($page_id);
     // get all references
     $ref_ids = ilObject::_getAllReferences($lm_id);
     // always try passed ref id first
     if (in_array($ref_id, $ref_ids)) {
         $ref_ids = array_merge(array($ref_id), $ref_ids);
     }
     // check read permissions
     foreach ($ref_ids as $ref_id) {
         // check read permissions
         if ($ilAccess->checkAccess("read", "", $ref_id)) {
             // don't redirect anymore, just set parameters
             // (goto.php includes  "ilias.php")
             $_GET["baseClass"] = "ilLMPresentationGUI";
             $_GET["obj_id"] = $page_id;
             $_GET["ref_id"] = $ref_id;
             $_GET["anchor"] = $anchor;
             include_once "ilias.php";
             exit;
         }
     }
     if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
         if ($lm_id > 0) {
             ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"), ilObject::_lookupTitle($lm_id)), true);
         } else {
             $lng->loadLanguageModule("content");
             ilUtil::sendFailure($lng->txt("page_does_not_exist"), true);
         }
         include_once "./Services/Object/classes/class.ilObjectGUI.php";
         ilObjectGUI::_gotoRepositoryRoot();
     }
     $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
 }
Ejemplo n.º 10
0
 function _checkGoto($a_target)
 {
     global $objDefinition, $ilPluginAdmin, $ilUser;
     if (is_object($ilPluginAdmin)) {
         // get user interface plugins
         $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
         // search
         foreach ($pl_names as $pl) {
             $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
             $gui_class = $ui_plugin->getUIClassInstance();
             $resp = $gui_class->checkGotoHook($a_target);
             if ($resp["target"] !== false) {
                 $a_target = $resp["target"];
                 break;
             }
         }
     }
     if ($a_target == "") {
         return false;
     }
     $t_arr = explode("_", $a_target);
     $type = $t_arr[0];
     if ($type == "git") {
         $type = "glo";
     }
     if ($type == "pg" | $type == "st") {
         $type = "lm";
     }
     $class = $objDefinition->getClassName($type);
     if ($class == "") {
         return false;
     }
     $location = $objDefinition->getLocation($type);
     $full_class = "ilObj" . $class . "Access";
     include_once $location . "/class." . $full_class . ".php";
     $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
     // if no access and repository object => check for parent course/group
     if (!$ret && !stristr($a_target, "_wsp") && $ilUser->getId() != ANONYMOUS_USER_ID && !$objDefinition->isAdministrationObject($type) && $objDefinition->isRBACObject($type) && $t_arr[1]) {
         global $tree, $rbacsystem, $ilAccess;
         // original type "pg" => pg_<page_id>[_<ref_id>]
         if ($t_arr[0] == "pg") {
             if (isset($t_arr[2])) {
                 $ref_id = $t_arr[2];
             } else {
                 $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
                 $ref_id = ilObject::_getAllReferences($lm_id);
                 if ($ref_id) {
                     $ref_id = array_shift($ref_id);
                 }
             }
         } else {
             $ref_id = $t_arr[1];
         }
         include_once "Services/Membership/classes/class.ilParticipants.php";
         $block_obj = array();
         // walk path to find parent container
         $path = $tree->getPathId($ref_id);
         array_pop($path);
         foreach ($path as $path_ref_id) {
             $redirect_infopage = false;
             $add_member_role = false;
             $ptype = ilObject::_lookupType($path_ref_id, true);
             $pobj_id = ilObject::_lookupObjId($path_ref_id);
             // core checks: timings/object-specific
             if (!$ilAccess->doActivationCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) || !$ilAccess->doStatusCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype)) {
                 // object in path is inaccessible - aborting
                 return false;
             } else {
                 if ($ptype == "crs") {
                     // check if already participant
                     include_once "Modules/Course/classes/class.ilCourseParticipant.php";
                     $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
                     if (!$participants->isAssigned()) {
                         // subscription currently possible?
                         include_once "Modules/Course/classes/class.ilObjCourse.php";
                         if (ilObjCourse::_isActivated($pobj_id) && ilObjCourse::_registrationEnabled($pobj_id)) {
                             $block_obj[] = $path_ref_id;
                             $add_member_role = true;
                         } else {
                             $redirect_infopage = true;
                         }
                     }
                 } else {
                     if ($ptype == "grp") {
                         // check if already participant
                         include_once "Modules/Group/classes/class.ilGroupParticipants.php";
                         if (!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId())) {
                             // subscription currently possible?
                             include_once "Modules/Group/classes/class.ilObjGroup.php";
                             $group_obj = new ilObjGroup($path_ref_id);
                             if ($group_obj->isRegistrationEnabled()) {
                                 $block_obj[] = $path_ref_id;
                                 $add_member_role = true;
                             } else {
                                 $redirect_infopage = true;
                             }
                         }
                     }
                 }
             }
             // add members roles for all "blocking" objects
             if ($add_member_role) {
                 // cannot join? goto will never work, so redirect to current object
                 $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
                 if (!$rbacsystem->checkAccess("join", $path_ref_id)) {
                     $redirect_infopage = true;
                 } else {
                     $rbacsystem->addTemporaryRole($ilUser->getId(), ilParticipants::getDefaultMemberRole($path_ref_id));
                 }
             }
             // redirect to infopage of 1st blocking object in path
             if ($redirect_infopage) {
                 if ($rbacsystem->checkAccess("visible", $path_ref_id)) {
                     ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" . "&ref_id=" . $path_ref_id . "&cmd=infoScreen");
                 } else {
                     return false;
                 }
             }
         }
         // check if access will be possible with all (possible) member roles added
         $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
         if ($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) {
             // this won't work with lm-pages (see above)
             // include_once "Services/Link/classes/class.ilLink.php";
             // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
             // keep original target
             $_SESSION["pending_goto"] = "goto.php?target=" . $a_target;
             // redirect to 1st non-member object in path
             ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI" . "&ref_id=" . array_shift($block_obj));
         }
     }
     return $ret;
 }
 /**
  * Get's the repository object ID of a parent object, if possible
  */
 function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false)
 {
     if (is_int(strpos($a_usage["type"], ":"))) {
         $us_arr = explode(":", $a_usage["type"]);
         $type = $us_arr[1];
         $cont_type = $us_arr[0];
     } else {
         $type = $a_usage["type"];
     }
     $id = $a_usage["id"];
     $obj_id = false;
     switch ($type) {
         case "html":
             // "old" category pages
             if ($cont_type == "cat") {
                 $obj_id = $id;
             }
             // Test InfoScreen Text
             if ($cont_type == "tst" || $cont_type == "svy") {
                 $obj_id = $id;
                 //var_dump($qinfo);
             }
             // Question Pool *Question* Text (Test)
             if ($cont_type == "qpl") {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $qinfo = assQuestion::_getQuestionInfo($id);
                 if ($qinfo["original_id"] > 0) {
                     include_once "./Modules/Test/classes/class.ilObjTest.php";
                     $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                     // usage in test
                 } else {
                     $obj_id = $qinfo["obj_fi"];
                     // usage in pool
                 }
             }
             // Question Pool *Question* Text (Survey)
             if ($cont_type == "spl") {
                 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
                 $quest = SurveyQuestion::_instanciateQuestion($id);
                 if ($quest) {
                     if ($quest->getOriginalId() > 0) {
                         $obj_id = $quest->getSurveyId();
                     } else {
                         $obj_id = $quest->getObjId();
                         // usage in pool
                     }
                     unset($quest);
                 }
             }
             // Forum
             if ($cont_type == "frm") {
                 $post_pk = $a_usage['id'];
                 include_once 'Modules/Forum/classes/class.ilForumPost.php';
                 include_once 'Modules/Forum/classes/class.ilForum.php';
                 $oPost = new ilForumPost($post_pk);
                 $frm_pk = $oPost->getForumId();
                 $obj_id = ilForum::_lookupObjIdForForumId($frm_pk);
             }
             if ($cont_type == 'frm~') {
                 $obj_id = $a_usage['id'];
             }
             if ($cont_type == "dcl") {
                 $obj_id = $id;
             }
             break;
         case "pg":
             // Question Pool Question Pages
             if ($cont_type == "qpl") {
                 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
                 $qinfo = assQuestion::_getQuestionInfo($id);
                 if ($qinfo["original_id"] > 0) {
                     include_once "./Modules/Test/classes/class.ilObjTest.php";
                     $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id);
                     // usage in test
                 } else {
                     $obj_id = $qinfo["obj_fi"];
                     // usage in pool
                 }
             }
             // learning modules
             if ($cont_type == "lm" || $cont_type == "dbk") {
                 include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                 $obj_id = ilLMObject::_lookupContObjID($id);
             }
             // glossary definition
             if ($cont_type == "gdf") {
                 include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
                 include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                 $term_id = ilGlossaryDefinition::_lookupTermId($id);
                 $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id);
             }
             // wiki page
             if ($cont_type == 'wpg') {
                 include_once 'Modules/Wiki/classes/class.ilWikiPage.php';
                 $obj_id = ilWikiPage::lookupObjIdByPage($id);
             }
             // sahs page
             if ($cont_type == 'sahs') {
                 // can this implementation be used for other content types, too?
                 include_once './Services/COPage/classes/class.ilPageObject.php';
                 $obj_id = ilPageObject::lookupParentId($id, 'sahs');
             }
             // repository pages
             if (in_array($cont_type, array("crs", "grp", "cat", "fold", "root"))) {
                 $obj_id = $id;
             }
             if ($cont_type == 'prtf') {
                 include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
                 $obj_id = ilPortfolioPage::findPortfolioForPage($id);
             }
             if ($cont_type == 'blp') {
                 include_once './Services/COPage/classes/class.ilPageObject.php';
                 $obj_id = ilPageObject::lookupParentId($id, 'blp');
             }
             break;
             // Media Pool
         // Media Pool
         case "mep":
             $obj_id = $id;
             break;
             // News Context Object (e.g. MediaCast)
         // News Context Object (e.g. MediaCast)
         case "news":
             include_once "./Services/News/classes/class.ilNewsItem.php";
             $obj_id = ilNewsItem::_lookupContextObjId($id);
             break;
     }
     return $obj_id;
 }
Ejemplo n.º 12
0
 /**
 * Sets a material link for the question
 *
 * @param string $material_id An internal link pointing to the material
 * @param boolean $is_import A boolean indication that the internal link was imported from another ILIAS installation
 * @access public
 */
 function setMaterial($material_id = "", $is_import = false, $material_title = "")
 {
     if (strcmp($material_id, "") != 0) {
         $import_id = "";
         if ($is_import) {
             $import_id = $material_id;
             $material_id = $this->_resolveInternalLink($import_id);
         }
         if (strcmp($material_title, "") == 0) {
             if (preg_match("/il__(\\w+)_(\\d+)/", $material_id, $matches)) {
                 $type = $matches[1];
                 $target_id = $matches[2];
                 $material_title = $this->lng->txt("obj_{$type}") . ": ";
                 switch ($type) {
                     case "lm":
                         include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
                         $cont_obj_gui =& new ilObjContentObjectGUI("", $target_id, true);
                         $cont_obj = $cont_obj_gui->object;
                         $material_title .= $cont_obj->getTitle();
                         break;
                     case "pg":
                         include_once "./Modules/LearningModule/classes/class.ilLMPageObject.php";
                         include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                         $lm_id = ilLMObject::_lookupContObjID($target_id);
                         include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
                         $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE);
                         $cont_obj = $cont_obj_gui->object;
                         $pg_obj =& new ilLMPageObject($cont_obj, $target_id);
                         $material_title .= $pg_obj->getTitle();
                         break;
                     case "st":
                         include_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
                         include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                         $lm_id = ilLMObject::_lookupContObjID($target_id);
                         include_once "./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php";
                         $cont_obj_gui =& new ilObjContentObjectGUI("", $lm_id, FALSE);
                         $cont_obj = $cont_obj_gui->object;
                         $st_obj =& new ilStructureObject($cont_obj, $target_id);
                         $material_title .= $st_obj->getTitle();
                         break;
                     case "git":
                         include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
                         $material_title = $this->lng->txt("glossary_term") . ": " . ilGlossaryTerm::_lookGlossaryTerm($target_id);
                         break;
                     case "mob":
                         break;
                 }
             }
         }
         $this->material = array("internal_link" => $material_id, "import_id" => $import_id, "title" => $material_title);
     }
     $this->saveMaterial();
 }
 /**
  * Check access rights for glossary terms
  * This checks also learning modules linking the term
  *
  * @param    int     	object id (glossary)
  * @param    int         page id (definition)
  * @return   boolean     access given (true/false)
  */
 private function checkAccessGlossaryTerm($obj_id, $page_id)
 {
     // give access if glossary is readable
     if ($this->checkAccessObject($obj_id)) {
         return true;
     }
     include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php";
     include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
     $term_id = ilGlossaryDefinition::_lookupTermId($page_id);
     include_once './Services/COPage/classes/class.ilInternalLink.php';
     $sources = ilInternalLink::_getSourcesOfTarget('git', $term_id, 0);
     if ($sources) {
         foreach ($sources as $src) {
             switch ($src['type']) {
                 // Give access if term is linked by a learning module with read access.
                 // The term including media is shown by the learning module presentation!
                 case 'lm:pg':
                     include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
                     $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
                     if ($this->checkAccessObject($src_obj_id, 'lm')) {
                         return true;
                     }
                     break;
                     // Don't yet give access if the term is linked by another glossary
                     // The link will lead to the origin glossary which is already checked
                     /*
                     case 'gdf:pg':
                     	$src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
                     	$src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
                      						if ($this->checkAccessObject($src_obj_id, 'glo'))
                     	{
                     		return true;
                     	}
                     	break;
                     */
             }
         }
     }
 }
 /**
  * get link targets
  */
 function getLinkXML($a_int_links)
 {
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         //echo "<br>+".$int_link["Type"]."+".$int_link["TargetFrame"]."+".$int_link["Target"]."+";
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             if ($targetframe == "New") {
                 $ltarget = "_blank";
             } else {
                 $ltarget = "";
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     $cont_obj =& $this->content_object;
                     if ($type == "PageObject") {
                         $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                     } else {
                         $href = "./goto.php?target=st_" . $target_id;
                     }
                     //$ltarget = "ilContObj".$lm_id;
                     break;
                 case "GlossaryItem":
                     if (ilGlossaryTerm::_lookGlossaryID($target_id) == $this->glossary->getId()) {
                         if ($this->offlineMode()) {
                             $href = "term_" . $target_id . ".html";
                         } else {
                             $this->ctrl->setParameter($this, "term_id", $target_id);
                             $href = $this->ctrl->getLinkTarget($this, "listDefinitions");
                             $href = str_replace("&", "&amp;", $href);
                         }
                     } else {
                         $href = "./goto.php?target=git_" . $target_id;
                     }
                     break;
                 case "MediaObject":
                     if ($this->offlineMode()) {
                         $href = "media_" . $target_id . ".html";
                     } else {
                         $this->ctrl->setParameter($this, "obj_type", $type);
                         $this->ctrl->setParameter($this, "mob_id", $target_id);
                         $href = $this->ctrl->getLinkTarget($this, "media");
                         $href = str_replace("&", "&amp;", $href);
                     }
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     $t_frame = ilFrameTargetInfo::_getFrame("MainContent", $obj_type);
                     $ltarget = $t_frame;
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             $this->ctrl->clearParameters($this);
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }
Ejemplo n.º 15
0
 /**
  * presentation title doesn't have to be page title, it may be
  * chapter title + page title or chapter title only, depending on settings
  *
  * @param	string	$a_mode		IL_CHAPTER_TITLE | IL_PAGE_TITLE | IL_NO_HEADER
  */
 function _getPresentationTitle($a_pg_id, $a_mode = IL_CHAPTER_TITLE, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_force_content = false, $a_lm_id = 0, $a_lang = "-")
 {
     global $ilDB, $ilUser;
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_pg_id);
     }
     // @todo: optimize
     include_once "./Services/COPage/classes/class.ilPageMultiLang.php";
     $ml = new ilPageMultiLang("lm", $a_lm_id);
     // select
     $query = "SELECT * FROM lm_data WHERE obj_id = " . $ilDB->quote($a_pg_id, "integer");
     $pg_set = $ilDB->query($query);
     $pg_rec = $ilDB->fetchAssoc($pg_set);
     if ($a_lang != "-" && $ml->getActivated() && in_array($a_lang, $ml->getLanguages())) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_pg_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $pg_rec["title"] = $lmobjtrans->getTitle();
         }
     }
     if ($a_mode == IL_NO_HEADER && !$a_force_content) {
         return "";
     }
     $tree = new ilTree($pg_rec["lm_id"]);
     $tree->setTableNames('lm_tree', 'lm_data');
     $tree->setTreeTablePK("lm_id");
     if ($a_mode == IL_PAGE_TITLE) {
         $nr = "";
         return $nr . $pg_rec["title"];
     }
     if ($tree->isInTree($pg_rec["obj_id"])) {
         $pred_node = $tree->fetchPredecessorNode($pg_rec["obj_id"], "st");
         $childs = $tree->getChildsByType($pred_node["obj_id"], "pg");
         $cnt_str = "";
         if (count($childs) > 1) {
             $cnt = 0;
             foreach ($childs as $child) {
                 include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
                 $active = ilLMPage::_lookupActive($child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]), $a_time_scheduled_activation);
                 if (!$active) {
                     $act_data = ilLMPage::_lookupActivationData((int) $child["obj_id"], ilObject::_lookupType($pg_rec["lm_id"]));
                     if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                         $active = true;
                     }
                 }
                 if ($child["type"] != "pg" || $active) {
                     $cnt++;
                 }
                 if ($child["obj_id"] == $pg_rec["obj_id"]) {
                     $cur_cnt = $cnt;
                 }
             }
             if ($cnt > 1) {
                 $cnt_str = " (" . $cur_cnt . "/" . $cnt . ")";
             }
         }
         require_once "./Modules/LearningModule/classes/class.ilStructureObject.php";
         //$struct_obj =& new ilStructureObject($pred_node["obj_id"]);
         //return $struct_obj->getTitle();
         return ilStructureObject::_getPresentationTitle($pred_node["obj_id"], $a_include_numbers) . $cnt_str;
         //return $pred_node["title"].$cnt_str;
     } else {
         return $pg_rec["title"];
     }
 }
 /**
  * check whether goto script will succeed
  */
 function _checkGoto($a_target)
 {
     global $ilAccess;
     $t_arr = explode("_", $a_target);
     if ($t_arr[0] != "lm" && $t_arr[0] != "dbk" && $t_arr[0] != "st" && $t_arr[0] != "pg" || (int) $t_arr[1] <= 0) {
         return false;
     }
     if ($t_arr[0] == "lm" || $t_arr[0] == "dbk") {
         if ($ilAccess->checkAccess("read", "", $t_arr[1]) || $ilAccess->checkAccess("visible", "", $t_arr[1])) {
             return true;
         }
     } else {
         if ($t_arr[2] > 0) {
             $ref_ids = array($t_arr[2]);
         } else {
             // determine learning object
             include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
             $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
             $ref_ids = ilObject::_getAllReferences($lm_id);
         }
         // check read permissions
         foreach ($ref_ids as $ref_id) {
             // Permission check
             if ($ilAccess->checkAccess("read", "", $ref_id)) {
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 17
0
 /**
  * get xml for links
  */
 function getLinkXML($a_int_links, $a_layoutframes)
 {
     global $ilCtrl;
     // Determine whether the view of a learning resource should
     // be shown in the frameset of ilias, or in a separate window.
     $showViewInFrameset = true;
     if ($a_layoutframes == "") {
         $a_layoutframes = array();
     }
     $link_info = "<IntLinkInfos>";
     foreach ($a_int_links as $int_link) {
         $target = $int_link["Target"];
         if (substr($target, 0, 4) == "il__") {
             $target_arr = explode("_", $target);
             $target_id = $target_arr[count($target_arr) - 1];
             $type = $int_link["Type"];
             $targetframe = $int_link["TargetFrame"] != "" ? $int_link["TargetFrame"] : "None";
             // anchor
             $anc = $anc_add = "";
             if ($int_link["Anchor"] != "") {
                 $anc = $int_link["Anchor"];
                 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
             }
             switch ($type) {
                 case "PageObject":
                 case "StructureObject":
                     $lm_id = ilLMObject::_lookupContObjID($target_id);
                     if ($lm_id == $this->lm->getId() || $targetframe != "None" && $targetframe != "New") {
                         $ltarget = $a_layoutframes[$targetframe]["Frame"];
                         //$nframe = ($ltarget == "")
                         //	? $_GET["frame"]
                         //	: $ltarget;
                         $nframe = $ltarget == "" ? "" : $ltarget;
                         if ($ltarget == "") {
                             if ($showViewInFrameset) {
                                 $ltarget = "_parent";
                             } else {
                                 $ltarget = "_top";
                             }
                         }
                         // scorm always in 1window view and link target
                         // is always same frame
                         if ($this->getExportFormat() == "scorm" && $this->offlineMode()) {
                             $ltarget = "";
                         }
                         $href = $this->getLink($_GET["ref_id"], "layout", $target_id, $nframe, $type, "append", $anc);
                     } else {
                         if (!$this->offlineMode()) {
                             if ($type == "PageObject") {
                                 $href = "./goto.php?target=pg_" . $target_id . $anc_add;
                             } else {
                                 $href = "./goto.php?target=st_" . $target_id;
                             }
                         } else {
                             if ($type == "PageObject") {
                                 $href = ILIAS_HTTP_PATH . "/goto.php?target=pg_" . $target_id . $anc_add . "&amp;client_id=" . CLIENT_ID;
                             } else {
                                 $href = ILIAS_HTTP_PATH . "/goto.php?target=st_" . $target_id . "&amp;client_id=" . CLIENT_ID;
                             }
                         }
                         if ($targetframe != "New") {
                             $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
                         } else {
                             $ltarget = "_blank";
                         }
                     }
                     break;
                 case "GlossaryItem":
                     if ($targetframe == "None") {
                         $targetframe = "Glossary";
                     }
                     $ltarget = $a_layoutframes[$targetframe]["Frame"];
                     $nframe = $ltarget == "" ? $_GET["frame"] : $ltarget;
                     $href = $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
                     break;
                 case "MediaObject":
                     $ltarget = $a_layoutframes[$targetframe]["Frame"];
                     $nframe = $ltarget == "" ? $_GET["frame"] : $ltarget;
                     $href = $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
                     break;
                 case "RepositoryItem":
                     $obj_type = ilObject::_lookupType($target_id, true);
                     $obj_id = ilObject::_lookupObjId($target_id);
                     if (!$this->offlineMode()) {
                         $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
                     } else {
                         $href = ILIAS_HTTP_PATH . "/goto.php?target=" . $obj_type . "_" . $target_id . "&amp;client_id=" . CLIENT_ID;
                     }
                     $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
                     break;
                 case "WikiPage":
                     include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
                     $href = ilWikiPage::getGotoForWikiPageTarget($target_id);
                     break;
                 case "File":
                     if (!$this->offlineMode()) {
                         $ilCtrl->setParameter($this, "file_id", "il__file_" . $target_id);
                         $href = $ilCtrl->getLinkTarget($this, "downloadFile");
                         $ilCtrl->setParameter($this, "file_id", "");
                     }
                     break;
             }
             $anc_par = 'Anchor="' . $anc . '"';
             $link_info .= "<IntLinkInfo Target=\"{$target}\" Type=\"{$type}\" " . "TargetFrame=\"{$targetframe}\" LinkHref=\"{$href}\" LinkTarget=\"{$ltarget}\" {$anc_par}/>";
             // set equal link info for glossary links of target "None" and "Glossary"
             /*
             				if ($targetframe=="None" && $type=="GlossaryItem")
             				{
             					$link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
             						"TargetFrame=\"Glossary\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
             				}*/
         }
     }
     $link_info .= "</IntLinkInfos>";
     return $link_info;
 }
Ejemplo n.º 18
0
 /**
  * Update internal links, after multiple pages have been copied
  */
 static function updateInternalLinks($a_copied_nodes, $a_parent_type = "lm")
 {
     $all_fixes = array();
     foreach ($a_copied_nodes as $original_id => $copied_id) {
         $copied_type = ilLMObject::_lookupType($copied_id);
         $copy_lm = ilLMObject::_lookupContObjID($copied_id);
         if ($copied_type == "pg") {
             //
             // 1. Outgoing links from the copied page.
             //
             //$targets = ilInternalLink::_getTargetsOfSource($a_parent_type.":pg", $copied_id);
             include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
             $tpg = new ilLMPage($copied_id);
             $tpg->buildDom();
             $il = $tpg->getInternalLinks();
             $targets = array();
             foreach ($il as $l) {
                 $targets[] = array("type" => ilInternalLink::_extractTypeOfTarget($l["Target"]), "id" => (int) ilInternalLink::_extractObjIdOfTarget($l["Target"]), "inst" => (int) ilInternalLink::_extractInstOfTarget($l["Target"]));
             }
             $fix = array();
             foreach ($targets as $target) {
                 if (($target["inst"] == 0 || ($target["inst"] = IL_INST_ID)) && ($target["type"] == "pg" || $target["type"] == "st")) {
                     // first check, whether target is also within the copied set
                     if ($a_copied_nodes[$target["id"]] > 0) {
                         $fix[$target["id"]] = $a_copied_nodes[$target["id"]];
                     } else {
                         // now check, if a copy if the target is already in the same lm
                         // only if target is not already in the same lm!
                         $trg_lm = ilLMObject::_lookupContObjID($target["id"]);
                         if ($trg_lm != $copy_lm) {
                             $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $target["type"] . "_" . $target["id"]);
                             $found = false;
                             foreach ($lm_data as $item) {
                                 if (!$found && $item["lm_id"] == $copy_lm) {
                                     $fix[$target["id"]] = $item["obj_id"];
                                     $found = true;
                                 }
                             }
                         }
                     }
                 }
             }
             // outgoing links to be fixed
             if (count($fix) > 0) {
                 //echo "<br>--".$copied_id;
                 //var_dump($fix);
                 $t = ilObject::_lookupType($copy_lm);
                 if (is_array($all_fixes[$t . ":" . $copied_id])) {
                     $all_fixes[$t . ":" . $copied_id] += $fix;
                 } else {
                     $all_fixes[$t . ":" . $copied_id] = $fix;
                 }
             }
         }
         if ($copied_type == "pg" || $copied_type == "st") {
             //
             // 2. Incoming links to the original pages
             //
             // A->B			A2			(A+B currently copied)
             // A->C			B2
             // B->A
             // C->A			C2->A		(C already copied)
             $original_lm = ilLMObject::_lookupContObjID($original_id);
             $original_type = ilObject::_lookupType($original_lm);
             if ($original_lm != $copy_lm) {
                 // This gets sources that link to A+B (so we have C here)
                 // (this also does already the trick when instance map areas are given in C)
                 // int_link, where target_type, target_id, target_inst -> ok
                 $sources = ilInternalLink::_getSourcesOfTarget($copied_type, $original_id, 0);
                 // mobs linking to $original_id
                 // map_area, where link_type, target -> ok
                 $mobs = ilMapArea::_getMobsForTarget("int", "il__" . $copied_type . "_" . $original_id);
                 // pages using these mobs
                 include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
                 foreach ($mobs as $mob) {
                     // mob_usage, where id -> ok
                     // mep_item, where foreign_id, type -> ok
                     // mep_tree, where child -> already existed
                     // il_news_item, where mob_id -> ok
                     // map_area, where link_type, target -> aready existed
                     // media_item, where id -> already existed
                     // personal_clipboard, where item_id, type -> ok
                     $usages = ilObjMediaObject::lookupUsages($mob);
                     foreach ($usages as $usage) {
                         if ($usage["type"] == "lm:pg" | $usage["type"] == "lm:st") {
                             $sources[] = $usage;
                         }
                     }
                 }
                 $fix = array();
                 foreach ($sources as $source) {
                     $stype = explode(":", $source["type"]);
                     $source_type = $stype[1];
                     if ($source_type == "pg" || $source_type == "st") {
                         // first of all: source must be in original lm
                         $src_lm = ilLMObject::_lookupContObjID($source["id"]);
                         if ($src_lm == $original_lm) {
                             // check, if a copy if the source is already in the same lm
                             // now we look for the latest copy of C in LM2
                             $lm_data = ilLMObject::_getAllObjectsForImportId("il__" . $source_type . "_" . $source["id"], $copy_lm);
                             $found = false;
                             foreach ($lm_data as $item) {
                                 if (!$found) {
                                     $fix[$item["obj_id"]][$original_id] = $copied_id;
                                     $found = true;
                                 }
                             }
                         }
                     }
                 }
                 // outgoing links to be fixed
                 if (count($fix) > 0) {
                     foreach ($fix as $page_id => $fix_array) {
                         $t = ilObject::_lookupType($copy_lm);
                         if (is_array($all_fixes[$t . ":" . $page_id])) {
                             $all_fixes[$t . ":" . $page_id] += $fix_array;
                         } else {
                             $all_fixes[$t . ":" . $page_id] = $fix_array;
                         }
                     }
                 }
             }
         }
     }
     foreach ($all_fixes as $pg => $fixes) {
         $pg = explode(":", $pg);
         include_once "./Services/COPage/classes/class.ilPageObjectFactory.php";
         $page = ilPageObjectFactory::getInstance($pg[0], $pg[1]);
         if ($page->moveIntLinks($fixes)) {
             $page->update(true, true);
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * get presentation title
  *
  */
 static function _getPresentationTitle($a_st_id, $a_include_numbers = false, $a_time_scheduled_activation = false, $a_lm_id = 0, $a_lang = "-")
 {
     global $ilDB;
     if ($a_lm_id == 0) {
         $a_lm_id = ilLMObject::_lookupContObjID($a_st_id);
     }
     if ($a_lm_id == 0) {
         return "";
     }
     // this is optimized when ilLMObject::preloadDataByLM is invoked (e.g. done in ilLMExplorerGUI)
     $title = ilLMObject::_lookupTitle($a_st_id);
     // this is also optimized since ilObjectTranslation re-uses instances for one lm
     include_once "./Services/Object/classes/class.ilObjectTranslation.php";
     $ot = ilObjectTranslation::getInstance($a_lm_id);
     $languages = $ot->getLanguages();
     if ($a_lang != "-" && $ot->getContentActivated() && isset($languages[$a_lang])) {
         include_once "./Modules/LearningModule/classes/class.ilLMObjTranslation.php";
         $lmobjtrans = new ilLMObjTranslation($a_st_id, $a_lang);
         if ($lmobjtrans->getTitle() != "") {
             $title = $lmobjtrans->getTitle();
         }
     }
     include_once "./Modules/LearningModule/classes/class.ilLMTree.php";
     $tree = ilLMTree::getInstance($a_lm_id);
     if ($a_include_numbers) {
         // this is optimized, since isInTree is cached
         if ($tree->isInTree($a_st_id)) {
             // optimization needed from here
             // get chapter tree node
             $query = "SELECT * FROM lm_tree WHERE child = " . $ilDB->quote($a_st_id, "integer") . " AND lm_id = " . $ilDB->quote($a_lm_id, "integer");
             $tree_set = $ilDB->query($query);
             $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
             $depth = $tree_node["depth"];
             $nr = $tree->getChildSequenceNumber($tree_node, "st") . " ";
             for ($i = $depth - 1; $i > 1; $i--) {
                 // get next parent tree node
                 $query = "SELECT * FROM lm_tree WHERE child = " . $ilDB->quote($tree_node["parent"], "integer") . " AND lm_id = " . $ilDB->quote($a_lm_id, "integer");
                 $tree_set = $ilDB->query($query);
                 $tree_node = $tree_set->fetchRow(DB_FETCHMODE_ASSOC);
                 $seq = $tree->getChildSequenceNumber($tree_node, "st");
                 $nr = $seq . "." . $nr;
             }
         }
     }
     return $nr . $title;
 }