/** * inititialize new item * * @param int $a_ref_id reference id * @param int $a_obj_id object id * @param string $a_title title * @param string $a_description description */ function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "") { global $ilBench; parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description); $this->conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $this->obj_id); }
function showStartObjects() { include_once './Modules/Course/classes/class.ilCourseLMHistory.php'; include_once './Services/Repository/classes/class.ilRepositoryExplorer.php'; include_once './Services/Link/classes/class.ilLink.php'; global $rbacsystem, $ilias, $ilUser, $ilAccess, $ilObjDataCache; $this->tabs_gui->setSubTabActive('crs_content'); $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_start_view.html", 'Modules/Course'); $this->tpl->setVariable("INFO_STRING", $this->lng->txt('crs_info_start')); $this->tpl->setVariable("TBL_TITLE_START", $this->lng->txt('crs_table_start_objects')); $this->tpl->setVariable("HEADER_NR", $this->lng->txt('crs_nr')); $this->tpl->setVariable("HEADER_DESC", $this->lng->txt('description')); $this->tpl->setVariable("HEADER_EDITED", $this->lng->txt('crs_objective_accomplished')); $lm_continue =& new ilCourseLMHistory($this->course_obj->getRefId(), $ilUser->getId()); $continue_data = $lm_continue->getLMHistory(); $counter = 0; foreach ($this->start_obj->getStartObjects() as $start) { $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']); $ref_id = $start['item_ref_id']; $type = $ilObjDataCache->lookupType($obj_id); $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($ref_id, $obj_id); $obj_link = ilLink::_getLink($ref_id, $type); $obj_frame = ilRepositoryExplorer::buildFrameTarget($type, $ref_id, $obj_id); $obj_frame = $obj_frame ? $obj_frame : ''; // Tmp fix for tests $obj_frame = $type == 'tst' ? '' : $obj_frame; $contentObj = false; if ($ilAccess->checkAccess('read', '', $ref_id)) { $this->tpl->setCurrentBlock("start_read"); $this->tpl->setVariable("READ_TITLE_START", $ilObjDataCache->lookupTitle($obj_id)); $this->tpl->setVariable("READ_TARGET_START", $obj_frame); $this->tpl->setVariable("READ_LINK_START", $obj_link . '&crs_show_result=' . $this->course_obj->getRefId()); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("start_visible"); $this->tpl->setVariable("VISIBLE_LINK_START", $ilObjDataCache->lookupTitle($obj_id)); $this->tpl->parseCurrentBlock(); } // CONTINUE LINK if (isset($continue_data[$ref_id])) { $this->tpl->setCurrentBlock("link"); $this->tpl->setVariable("LINK_HREF", ilLink::_getLink($ref_id, '', array('obj_id', $continue_data[$ref_id]['lm_page_id']))); #$this->tpl->setVariable("CONTINUE_LINK_TARGET",$target); $this->tpl->setVariable("LINK_NAME", $this->lng->txt('continue_work')); $this->tpl->parseCurrentBlock(); } // add to desktop link if (!$ilUser->isDesktopItem($ref_id, $type) and $this->course_obj->getAboStatus()) { if ($ilAccess->checkAccess('read', '', $ref_id)) { $this->tpl->setCurrentBlock("link"); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $ref_id); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $ref_id); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $type); $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTarget($this->container_gui, 'addToDesk')); $this->tpl->setVariable("LINK_NAME", $this->lng->txt("to_desktop")); $this->tpl->parseCurrentBlock(); } } elseif ($this->course_obj->getAboStatus()) { $this->tpl->setCurrentBlock("link"); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $ref_id); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $ref_id); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $type); $this->tpl->setVariable("LINK_HREF", $this->ctrl->getLinkTarget($this->container_gui, 'removeFromDesk')); $this->tpl->setVariable("LINK_NAME", $this->lng->txt("unsubscribe")); $this->tpl->parseCurrentBlock(); } // Description if (strlen($ilObjDataCache->lookupDescription($obj_id))) { $this->tpl->setCurrentBlock("start_description"); $this->tpl->setVariable("DESCRIPTION_START", $ilObjDataCache->lookupDescription($obj_id)); $this->tpl->parseCurrentBlock(); } if ($this->start_obj->isFullfilled($ilUser->getId(), $ref_id)) { $accomplished = 'accomplished'; } else { $accomplished = 'not_accomplished'; } $this->tpl->setCurrentBlock("start_row"); $this->tpl->setVariable("EDITED_IMG", ilUtil::getImagePath('crs_' . $accomplished . '.png')); $this->tpl->setVariable("EDITED_ALT", $this->lng->txt('crs_objective_' . $accomplished)); $this->tpl->setVariable("ROW_CLASS", 'option_value'); $this->tpl->setVariable("ROW_CLASS_CENTER", 'option_value_center'); $this->tpl->setVariable("OBJ_NR_START", ++$counter . '.'); $this->tpl->parseCurrentBlock(); } return true; }
protected function addItemDetails(ilObjectListGUI $a_item_list_gui, array $a_item) { global $lng, $ilCtrl; $item_ref_id = $a_item["ref_id"]; if (is_array($this->objective_map)) { $details = array(); if (isset($this->objective_map["material"][$item_ref_id])) { // #12965 foreach ($this->objective_map["material"][$item_ref_id] as $objective_id) { $ilCtrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $objective_id); $url = $ilCtrl->getLinkTargetByClass(array('illoeditorgui', 'ilcourseobjectivesgui'), 'edit'); $ilCtrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', ''); $details[] = array('desc' => $lng->txt('crs_loc_tab_materials') . ': ', 'target' => '_top', 'link' => $url, 'name' => $this->objective_map["names"][$objective_id]); } } if ($this->objective_map["test_i"] == $item_ref_id) { $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 1); $details[] = array('desc' => '', 'target' => '_top', 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testOverview'), 'name' => $lng->txt('crs_loc_tab_itest')); $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0); } if ($this->objective_map["test_q"] == $item_ref_id) { $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 2); $details[] = array('desc' => '', 'target' => '_top', 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testOverview'), 'name' => $lng->txt('crs_loc_tab_qtest')); $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0); } // #15367 - patch LOK if (is_array($this->objective_map["test_ass"][$item_ref_id])) { foreach ($this->objective_map["test_ass"][$item_ref_id] as $type => $items) { if ($type == ilLOSettings::TYPE_TEST_INITIAL) { $caption = $lng->txt('crs_loc_tab_itest'); $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 1); } else { $caption = $lng->txt('crs_loc_tab_qtest'); $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 2); } foreach ($items as $objtv_title) { $details[] = array('desc' => '', 'target' => '_top', 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testsOverview'), 'name' => $caption . " (" . $this->lng->txt("crs_loc_learning_objective") . ": " . $objtv_title . ")"); } $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0); } } if (sizeof($details)) { $a_item_list_gui->enableItemDetailLinks(true); $a_item_list_gui->setItemDetailLinks($details, $lng->txt('crs_loc_settings_tbl') . ': '); } else { $a_item_list_gui->enableItemDetailLinks(false); } } // order if ($this->getContainerGUI()->isActiveOrdering()) { $a_item_list_gui->enableCommands(true, true); $a_item_list_gui->enableProperties(false); } else { if (!$this->getContainerGUI()->isActiveAdministrationPanel()) { $a_item_list_gui->enableCommands(true, true); $a_item_list_gui->enableProperties(false); } } if ($a_item['objective_id']) { $a_item_list_gui->setDefaultCommandParameters(array('objective_id' => $a_item['objective_id'])); if ($this->loc_settings->getQualifiedTest() == $a_item['ref_id']) { $a_item_list_gui->setConditionTarget($this->getContainerObject()->getRefId(), $a_item['objective_id'], 'lobj'); // check conditions of target include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; $fullfilled = ilConditionHandler::_checkAllConditionsOfTarget($this->getContainerObject()->getRefId(), $a_item['objective_id'], 'lobj'); if (!$fullfilled || $a_item['objective_status']) { $a_item_list_gui->disableTitleLink(true); } } include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php'; $res = ilLOUserResults::lookupResult($this->getContainerObject()->getId(), $GLOBALS['ilUser']->getId(), $a_item['objective_id'], ilLOUserResults::TYPE_QUALIFIED); $res = $this->updateResult($res, $a_item['ref_id'], $a_item['objective_id'], $GLOBALS['ilUser']->getId()); if ($res['is_final']) { $a_item_list_gui->disableTitleLink(true); $a_item_list_gui->enableProperties(true); $a_item_list_gui->addCustomProperty($this->lng->txt('crs_loc_passes_reached'), '', true); } elseif ($this->loc_settings->getQualifiedTest() == $a_item['ref_id']) { include_once './Modules/Course/classes/class.ilCourseObjective.php'; $poss_pass = ilCourseObjective::lookupMaxPasses($a_item['objective_id']); if ($poss_pass) { $a_item_list_gui->enableProperties(true); $a_item_list_gui->addCustomProperty($this->lng->txt('crs_loc_passes_left'), $poss_pass - $res['tries'] > 0 ? $poss_pass - $res['tries'] : 1, false); } } } }
/** * inititialize new item * Course reference inits the course item * * @param int $a_ref_id reference id * @param int $a_obj_id object id * @param string $a_title title * @param string $a_description description */ function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "") { global $ilBench, $ilAccess, $tree; $this->reference_ref_id = $a_ref_id; $this->reference_obj_id = $a_obj_id; include_once './Services/ContainerReference/classes/class.ilContainerReference.php'; $target_obj_id = ilContainerReference::_lookupTargetId($a_obj_id); $target_ref_ids = ilObject::_getAllReferences($target_obj_id); $target_ref_id = current($target_ref_ids); $target_title = ilContainerReference::_lookupTitle($a_obj_id); $target_description = ilObject::_lookupDescription($target_obj_id); $this->deleted = $tree->isDeleted($target_ref_id); $ilBench->start("ilObjCourseListGUI", "1000_checkAllConditions"); $this->conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($target_ref_id, $target_obj_id); $ilBench->stop("ilObjCourseListGUI", "1000_checkAllConditions"); parent::initItem($target_ref_id, $target_obj_id, $target_title, $target_description); // general commands array include_once './Modules/CourseReference/classes/class.ilObjCourseReferenceAccess.php'; $this->commands = ilObjCourseReferenceAccess::_getCommands($this->reference_ref_id); if ($ilAccess->checkAccess('write', '', $this->reference_ref_id) or $this->deleted) { $this->info_screen_enabled = false; } else { $this->info_screen_enabled = true; } }
function __showOtherResources() { global $ilias, $rbacsystem, $ilObjDataCache, $objDefinition; if (!count($ors = $this->__getOtherResources())) { return false; } $this->tpl->addBlockfile('RESOURCES_BLOCK', 'resources_block', 'tpl.crs_objectives_view_or_table.html', 'Modules/Course'); $this->tpl->setVariable("TBL_TITLE_OR", $this->lng->txt('crs_other_resources')); $this->__showHideLinks('or'); if (isset($_SESSION['crs_hide_or'])) { return true; } $this->tpl->setCurrentBlock("tbl_header_columns_or"); $this->tpl->setVariable("TBL_HEADER_WIDTH_OR", "5%"); $this->tpl->setVariable("TBL_HEADER_NAME_OR", $this->lng->txt('type')); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("tbl_header_columns_or"); $this->tpl->setVariable("TBL_HEADER_WIDTH_OR", "75%"); $this->tpl->setVariable("TBL_HEADER_NAME_OR", $this->lng->txt('description')); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("tbl_header_columns_or"); $this->tpl->setVariable("TBL_HEADER_WIDTH_OR", "20%"); $this->tpl->setVariable("TBL_HEADER_NAME_OR", ''); $this->tpl->parseCurrentBlock(); $counter = 1; foreach ($ors as $or_id) { $obj_id = $ilObjDataCache->lookupObjId($or_id); $obj_type = $ilObjDataCache->lookupType($obj_id); // do not show side block items if ($objDefinition->isSideBlock($obj_type)) { continue; } $conditions_ok = ilConditionHandler::_checkAllConditionsOfTarget($or_id, $obj_id); $obj_link = ilRepositoryExplorer::buildLinkTarget($or_id, $obj_type); $obj_frame = ilRepositoryExplorer::buildFrameTarget($obj_type, $or_id, $obj_id); $obj_frame = $obj_frame ? $obj_frame : ''; if (ilRepositoryExplorer::isClickable($obj_type, $or_id, $obj_id)) { $this->tpl->setCurrentBlock("or_read"); $this->tpl->setVariable("READ_TITLE_OR", $ilObjDataCache->lookupTitle($obj_id)); $this->tpl->setVariable("READ_TARGET_OR", $obj_frame); $this->tpl->setVariable("READ_LINK_OR", $obj_link); $this->tpl->parseCurrentBlock(); } else { $this->tpl->setCurrentBlock("or_visible"); $this->tpl->setVariable("VISIBLE_LINK_OR", $ilObjDataCache->lookupTitle($obj_id)); $this->tpl->parseCurrentBlock(); } // add to desktop link if (!$ilias->account->isDesktopItem($or_id, $obj_type) and $this->course_obj->getAboStatus() == $this->course_obj->ABO_ENABLED) { if ($rbacsystem->checkAccess('read', $or_id)) { $this->tpl->setCurrentBlock("or_desklink"); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_ref_id', $or_id); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'item_id', $or_id); $this->ctrl->setParameterByClass(get_class($this->container_gui), 'type', $obj_type); $this->tpl->setVariable("DESK_LINK_OR", $this->ctrl->getLinkTarget($this->container_gui, 'addToDesk')); $this->tpl->setVariable("TXT_DESK_OR", $this->lng->txt("to_desktop")); $this->tpl->parseCurrentBlock(); } } $this->tpl->setCurrentBlock("or_row"); $this->tpl->setVariable("OBJ_TITLE_OR", $ilObjDataCache->lookupTitle($obj_id)); $this->tpl->setVariable('IMG_TYPE_OR', ilUtil::getTypeIconPath($obj_type, $obj_id, 'small')); $this->tpl->setVariable("TXT_IMG_OR", $this->lng->txt('obj_' . $obj_type)); $this->tpl->setVariable("OBJ_CLASS_CENTER_OR", 'option_value_center'); $this->tpl->setVariable("OBJ_CLASS_OR", 'option_value'); $this->tpl->parseCurrentBlock(); ++$counter; } }
/** * checks wether the preconditions of a page are fulfilled or not */ function _checkPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id) { global $ilUser, $ilErr; $lm_tree = new ilTree($cont_obj_id); $lm_tree->setTableNames('lm_tree', 'lm_data'); $lm_tree->setTreeTablePK("lm_id"); if ($lm_tree->isInTree($page_id)) { $path = $lm_tree->getPathFull($page_id, $lm_tree->readRootId()); foreach ($path as $node) { if ($node["type"] == "st") { if (!ilConditionHandler::_checkAllConditionsOfTarget($cont_ref_id, $node["child"], "st")) { return false; } } } } return true; }
function showChilds($a_ref_id, $a_obj_id = 0) { global $rbacsystem; if ($a_ref_id == 0) { return true; } if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id)) { return false; } if ($rbacsystem->checkAccess("read", $a_ref_id)) { return true; } else { return false; } }
/** * Is node clickable? * * @param mixed $a_node node object/array * @return boolean node clickable true/false */ function isNodeClickable($a_node) { global $rbacsystem, $tree, $ilDB, $ilUser, $ilAccess; $obj_id = ilObject::_lookupObjId($a_node["child"]); if (!ilConditionHandler::_checkAllConditionsOfTarget($a_node["child"], $obj_id)) { return false; } switch ($a_node["type"]) { case "crs": return $ilAccess->checkAccess("read", "", $a_node["child"]); // visible groups can allways be clicked; group processing decides // what happens next // visible groups can allways be clicked; group processing decides // what happens next case "grp": return true; case 'tst': if (!$rbacsystem->checkAccess("read", $a_node["child"])) { return false; } $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $obj_id); $res = $ilDB->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { return (bool) $row->complete; } return false; case 'svy': if (!$rbacsystem->checkAccess("read", $a_node["child"])) { return false; } $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $obj_id); $res = $ilDB->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { return (bool) $row->complete; } return false; // media pools can only be edited // media pools can only be edited case "mep": if ($rbacsystem->checkAccess("read", $a_node["child"])) { return true; } else { return false; } break; case 'crsr': case 'catr': include_once './Services/ContainerReference/classes/class.ilContainerReferenceAccess.php'; return ilContainerReferenceAccess::_isAccessible($a_node["child"]); // all other types are only clickable, if read permission is given // all other types are only clickable, if read permission is given default: if ($rbacsystem->checkAccess("read", $a_node["child"])) { // check if lm is online if ($a_node["type"] == "lm") { include_once "./Modules/LearningModule/classes/class.ilObjLearningModule.php"; $lm_obj =& new ilObjLearningModule($a_node["child"]); if (!$lm_obj->getOnline() && !$rbacsystem->checkAccess('write', $a_node["child"])) { return false; } } // check if fblm is online if ($a_node["type"] == "htlm") { include_once "./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php"; $lm_obj =& new ilObjFileBasedLM($a_node["child"]); if (!$lm_obj->getOnline() && !$rbacsystem->checkAccess('write', $a_node["child"])) { return false; } } // check if fblm is online if ($a_node["type"] == "sahs") { include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; $lm_obj =& new ilObjSAHSLearningModule($a_node["child"]); if (!$lm_obj->getOnline() && !$rbacsystem->checkAccess('write', $a_node["child"])) { return false; } } // check if glossary is online if ($a_node["type"] == "glo") { $obj_id = ilObject::_lookupObjectId($a_node["child"]); include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; if (!ilObjGlossary::_lookupOnline($obj_id) && !$rbacsystem->checkAccess('write', $a_node["child"])) { return false; } } return true; } else { return false; } break; } }
/** * condition check (currently only implemented for read permission) * */ function doConditionCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_obj_id, $a_type) { //echo "conditionCheck<br/>"; global $lng, $ilBench; if (($a_permission == "read" or $a_permission == 'join') && !$this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id, $a_type, $a_obj_id)) { $ilBench->start("AccessControl", "4000_checkAccess_condition_check"); if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id, $a_type, $a_user_id)) { $conditions = ilConditionHandler::_getConditionsOfTarget($a_ref_id, $a_obj_id, $a_type); foreach ($conditions as $condition) { $this->current_info->addInfoItem(IL_MISSING_PRECONDITION, $lng->txt("missing_precondition") . ": " . ilObject::_lookupTitle($condition["trigger_obj_id"]) . " " . $lng->txt("condition_" . $condition["operator"]) . " " . $condition["value"], $condition); } $ilBench->stop("AccessControl", "4000_checkAccess_condition_check"); return false; } $ilBench->stop("AccessControl", "4000_checkAccess_condition_check"); } return true; }