/** * get current term id for import id (static) * * @param int $a_import_id import id * * @return int id */ function _getIdForImportId($a_import_id) { global $ilDB; if ($a_import_id == "") { return 0; } $q = "SELECT * FROM glossary_term WHERE import_id = " . $ilDB->quote($a_import_id, "text") . " ORDER BY create_date DESC"; $term_set = $ilDB->query($q); while ($term_rec = $ilDB->fetchAssoc($term_set)) { $glo_id = ilGlossaryTerm::_lookGlossaryID($term_rec["id"]); if (ilObject::_hasUntrashedReference($glo_id)) { return $term_rec["id"]; } } return 0; }
/** * Meta data update listener * * Important note: Do never call create() or update() * method of ilObject here. It would result in an * endless loop: update object -> update meta -> update * object -> ... * Use static _writeTitle() ... methods instead. * * Even if this is not stored to db, it should be stored to the object * e.g. for during import parsing * * @param string $a_element */ function MDUpdateListener($a_element) { include_once 'Services/MetaData/classes/class.ilMD.php'; switch ($a_element) { case 'General': // Update Title and description $glo_id = ilGlossaryTerm::_lookGlossaryID($this->getTermId()); $md =& new ilMD($glo_id, $this->getId(), $this->getType()); $md_gen = $md->getGeneral(); //ilObject::_writeTitle($this->getId(),$md_gen->getTitle()); $this->setTitle($md_gen->getTitle()); foreach ($md_gen->getDescriptionIds() as $id) { $md_des = $md_gen->getDescription($id); //ilObject::_writeDescription($this->getId(),$md_des->getDescription()); $this->setDescription($md_des->getDescription()); break; } break; default: } return true; }
/** * 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("&", "&", $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("&", "&", $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; }
/** * 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_ref_id = "") { global $rbacsystem, $ilErr, $lng, $ilAccess; $glo_id = ilGlossaryTerm::_lookGlossaryID($a_target); //::_lookupContObjID($a_target); // get all references if ($a_ref_id > 0) { $ref_ids = array($a_ref_id); } else { $ref_ids = ilObject::_getAllReferences($glo_id); } // check read permissions foreach ($ref_ids as $ref_id) { // Permission check if ($ilAccess->checkAccess("read", "", $ref_id)) { $_GET["baseClass"] = "ilGlossaryPresentationGUI"; $_GET["term_id"] = $a_target; $_GET["ref_id"] = $ref_id; $_GET["cmd"] = "listDefinitions"; include_once "ilias.php"; exit; } } if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) { ilUtil::sendFailure(sprintf($lng->txt("msg_no_perm_read_item"), ilObject::_lookupTitle($glo_id)), true); ilObjectGUI::_gotoRepositoryRoot(); } $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL); }
/** * 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; }
/** * add definition */ function addDefinition() { global $ilCtrl; $term_id = (int) $_GET["term_id"]; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_glo_id = ilGlossaryTerm::_lookGlossaryID((int) $term_id); if ($term_glo_id != $this->object->getId()) { ilUtil::sendFailure($this->lng->txt("glo_term_must_belong_to_glo"), true); $ilCtrl->redirect($this, "listTerms"); } // add term include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term = new ilGlossaryTerm($term_id); // add first definition $def = new ilGlossaryDefinition(); $def->setTermId($term->getId()); $def->setTitle(ilUtil::stripSlashes($term->getTerm())); $def->create(); $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId()); $this->ctrl->setParameterByClass("ilglossarydefpagegui", "def", $def->getId()); $this->ctrl->redirectByClass(array("ilglossarytermgui", "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit"); }
/** * Perform automatic modifications (may be overwritten by sub classes) */ function performAutomaticModifications() { if ($this->getGlossaryId() > 0) { // we fix glossary links here $this->buildDom(); $xpc = xpath_new_context($this->dom); $path = "//IntLink[@Type='GlossaryItem']"; $res =& xpath_eval($xpc, $path); for ($i = 0; $i < count($res->nodeset); $i++) { $target = $res->nodeset[$i]->get_attribute("Target"); //echo "<br>".$target; $tarr = explode("_", $target); $term_id = $tarr[count($tarr) - 1]; if (is_int(strpos($target, "__")) && $term_id > 0) { include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; //echo "<br>-".ilGlossaryTerm::_lookGlossaryID($term_id)."-".$this->getGlossaryId()."-"; if (ilGlossaryTerm::_lookGlossaryID($term_id) != $this->getGlossaryId()) { // copy the glossary term from glossary a to b $new_id = ilGlossaryTerm::_copyTerm($term_id, $this->getGlossaryId()); $res->nodeset[$i]->set_attribute("Target", "il__git_" . $new_id); } } } } //exit; }
/** * check whether goto script will succeed */ function _checkGoto($a_target) { global $ilAccess; $t_arr = explode("_", $a_target); if ($t_arr[0] != "glo" && $t_arr[0] != "git" || (int) $t_arr[1] <= 0) { return false; } if ($t_arr[0] == "glo") { if ($ilAccess->checkAccess("read", "", $t_arr[1]) || $ilAccess->checkAccess("visible", "", $t_arr[1])) { return true; } } if ($t_arr[0] == "git") { if ($t_arr[2] > 0) { $ref_ids = array($t_arr[2]); } else { // determine learning object require_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $glo_id = ilGlossaryTerm::_lookGlossaryID($t_arr[1]); $ref_ids = ilObject::_getAllReferences($glo_id); } // check read permissions foreach ($ref_ids as $ref_id) { // Permission check if ($ilAccess->checkAccess("read", "", $ref_id)) { return true; } } } return false; }