/** * Get instance * @return object ilMemberViewSettings */ public static function getInstance() { if (self::$instance != null) { return self::$instance; } return self::$instance = new ilMemberViewSettings(); }
/** * add repository item * * @param int $a_ref_id current ref id (optional); * if empty $_GET["ref_id"] is used */ function addRepositoryItems($a_ref_id = 0) { global $tree, $ilCtrl; if ($a_ref_id == 0) { $a_ref_id = $_GET["ref_id"]; } include_once './Services/Container/classes/class.ilMemberViewSettings.php'; if (ilMemberViewSettings::getInstance()->isActive() and $a_ref_id != ROOT_FOLDER_ID) { $a_start = ilMemberViewSettings::getInstance()->getContainer(); } else { $a_start = ROOT_FOLDER_ID; } if ($a_ref_id > 0) { $path = $tree->getPathFull($a_ref_id, $a_start); // add item for each node on path foreach ((array) $path as $key => $row) { if (!in_array($row["type"], array("root", "cat", "crs", "fold", "grp", "icrs"))) { continue; } if ($row["title"] == "ILIAS" && $row["type"] == "root") { $row["title"] = $this->lng->txt("repository"); } $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $row["child"]); $this->addItem($row["title"], $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"), ilFrameTargetInfo::_getFrame("MainContent"), $row["child"]); $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]); } } }
/** * Show member view switch * @return * @param int $a_ref_id */ public static function showMemberViewSwitch($a_ref_id) { global $ilAccess, $ilCtrl; $settings = ilMemberViewSettings::getInstance(); if (!$settings->isEnabled()) { return false; } global $tpl, $tree, $lng, $ilTabs; // No course or group in path => aborting if (!$tree->checkForParentType($a_ref_id, 'crs') and !$tree->checkForParentType($a_ref_id, 'grp')) { return false; } // TODO: check edit_permission $active = $settings->isActive(); $type = ilObject::_lookupType(ilObject::_lookupObjId($a_ref_id)); if (($type == 'crs' or $type == 'grp') and $ilAccess->checkAccess('write', '', $a_ref_id)) { $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_ref_id); $ilCtrl->setParameterByClass("ilrepositorygui", "mv", "1"); $ilCtrl->setParameterByClass("ilrepositorygui", "set_mode", "flat"); $ilTabs->addNonTabbedLink("members_view", $lng->txt('mem_view_activate'), $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset")); $ilCtrl->clearParametersByClass("ilrepositorygui"); return true; } return true; }
/** * @param string $a_target target frame * @param boolean $a_use_start_template true means: target scripts should * be called through start template */ function ilMainMenuGUI($a_target = "_top", $a_use_start_template = false) { global $ilias, $rbacsystem, $ilUser; $this->tpl = new ilTemplate("tpl.main_menu.html", true, true, "Services/MainMenu"); $this->ilias =& $ilias; $this->target = $a_target; $this->start_template = $a_use_start_template; $this->mail = false; if ($ilUser->getId() != ANONYMOUS_USER_ID) { if ($rbacsystem->checkAccess('internal_mail', ilMailGlobalServices::getMailObjectRefId())) { $this->mail = true; } } $this->setMode(self::MODE_FULL); // member view include_once './Services/Container/classes/class.ilMemberViewSettings.php'; $set = ilMemberViewSettings::getInstance(); if ($set->isActive()) { $this->initMemberView(); } }
/** * Init member view * @return */ public function initMemberView() { include_once './Services/Container/classes/class.ilMemberViewSettings.php'; $settings = ilMemberViewSettings::getInstance(); if ($settings->isEnabled() and isset($_GET['mv'])) { $settings->toggleActivation((int) $_GET['ref_id'], (int) $_GET['mv']); } if (!$settings->isActive()) { $this->mem_view['active'] = false; $this->mem_view['items'] = array(); $this->mem_view['role'] = 0; } else { global $tree; $this->mem_view['active'] = true; $this->mem_view['items'] = $tree->getSubTreeIds($settings->getContainer()); $this->mem_view['items'] = array_merge($this->mem_view['items'], array($settings->getContainer())); include_once './Services/Membership/classes/class.ilParticipants.php'; $this->mem_view['role'] = ilParticipants::getDefaultMemberRole($settings->getContainer()); } return true; }
function getHTML() { include_once './Services/Container/classes/class.ilMemberViewSettings.php'; $set = ilMemberViewSettings::getInstance(); if ($set->isActive()) { return $this->getMemberViewHTML(); } $this->setTemplateVars(); return $this->tpl->get(); }
/** * Init member view * @global type $lng */ protected function initMemberView() { global $lng; include_once './Services/Container/classes/class.ilMemberViewSettings.php'; $ref_id = ilMemberViewSettings::getInstance()->getCurrentRefId(); if (!$ref_id) { return FALSE; } include_once './Services/Link/classes/class.ilLink.php'; $url = ilLink::_getLink($ref_id, ilObject::_lookupType(ilObject::_lookupObjId($ref_id)), array('mv' => 0)); $this->setMode(self::MODE_TOPBAR_MEMBERVIEW); $this->setTopBarBack($url, $lng->txt('mem_view_close')); }
/** * Is activated? * * @see ilStartupGUI * @param int $a_obj_id * @param bool &$a_visible_flag * @param bool $a_mind_member_view * @return boolean */ public static function _isActivated($a_obj_id, &$a_visible_flag = null, $a_mind_member_view = true) { // #7669 if ($a_mind_member_view) { include_once './Services/Container/classes/class.ilMemberViewSettings.php'; if (ilMemberViewSettings::getInstance()->isActive()) { $a_visible_flag = true; return true; } } // offline? if (!self::_isOnline($a_obj_id)) { $a_visible_flag = false; return false; } $ref_id = ilObject::_getAllReferences($a_obj_id); $ref_id = array_pop($ref_id); $a_visible_flag = true; include_once './Services/Object/classes/class.ilObjectActivation.php'; $item = ilObjectActivation::getItem($ref_id); switch ($item['timing_type']) { case ilObjectActivation::TIMINGS_ACTIVATION: if (time() < $item['timing_start'] or time() > $item['timing_end']) { $a_visible_flag = $item['visible']; return false; } // fallthrough // fallthrough default: return true; } }
/** * Check if cache is disabled * Forced if member view is active * @return bool */ public function isDisabled() { include_once './Services/Container/classes/class.ilMemberViewSettings.php'; return ilMemberViewSettings::getInstance()->isActive(); }
function showTreeFlatIcon() { global $tpl; // dont show icon, if role (permission gui->rolegui) is edited if ($_GET["obj_id"] != "") { return; } // hide for member view include_once './Services/Container/classes/class.ilMemberViewSettings.php'; if (ilMemberViewSettings::getInstance()->isActive()) { return; } $mode = $_SESSION["il_rep_mode"] == "flat" ? "tree" : "flat"; $link = "ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&set_mode=" . $mode . "&ref_id=" . $this->object->getRefId(); $tpl->setTreeFlatIcon($link, $mode); }
/** * Handle member view * @return */ public function prepareOutput() { global $rbacsystem; if (!$this->getCreationMode()) { include_once './Services/Container/classes/class.ilMemberViewSettings.php'; $settings = ilMemberViewSettings::getInstance(); if ($settings->isActive() and $settings->getContainer() != $this->object->getRefId()) { $settings->setContainer($this->object->getRefId()); $rbacsystem->initMemberView(); } } parent::prepareOutput(); }
/** * Check agreement and redirect if it is not accepted * * @access private * */ private function checkAgreement() { global $ilUser, $ilAccess; if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) { return true; } // Disable aggrement if is not member of group if (!$this->object->members_obj->isAssigned($ilUser->getId())) { return true; } include_once './Services/Container/classes/class.ilMemberViewSettings.php'; if (ilMemberViewSettings::getInstance()->isActive()) { return true; } include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; include_once 'Services/Membership/classes/class.ilMemberAgreement.php'; $privacy = ilPrivacySettings::_getInstance(); // Check agreement if (($privacy->groupConfirmationRequired() or ilCourseDefinedFieldDefinition::_hasFields($this->object->getId())) and !ilMemberAgreement::_hasAccepted($ilUser->getId(), $this->object->getId())) { return false; } // Check required fields include_once 'Modules/Course/classes/Export/class.ilCourseUserData.php'; if (!ilCourseUserData::_checkRequired($ilUser->getId(), $this->object->getId())) { return false; } return true; }
protected function parseConditions($toggle_id, $conditions, $obligatory = true) { global $ilAccess, $lng, $objDefinition, $tree; $num_required = ilConditionHandler::calculateRequiredTriggers($this->ref_id, $this->obj_id); $num_optional_required = $num_required - count($conditions) + count(ilConditionHandler::getOptionalConditionsOfTarget($this->ref_id, $this->obj_id)); // Check if all conditions are fullfilled $visible_conditions = array(); $passed_optional = 0; foreach ($conditions as $condition) { if ($obligatory and !$condition['obligatory']) { continue; } if (!$obligatory and $condition['obligatory']) { continue; } if ($tree->isDeleted($condition['trigger_ref_id'])) { continue; } include_once 'Services/Container/classes/class.ilMemberViewSettings.php'; $ok = ilConditionHandler::_checkCondition($condition['id']) and !ilMemberViewSettings::getInstance()->isActive(); if (!$ok) { $visible_conditions[] = $condition['id']; } if (!$obligatory and $ok) { ++$passed_optional; // optional passed if ($passed_optional >= $num_optional_required) { return true; } } } foreach ($conditions as $condition) { if (!in_array($condition['id'], $visible_conditions)) { continue; } include_once './Services/AccessControl/classes/class.ilConditionHandlerGUI.php'; $cond_txt = ilConditionHandlerGUI::translateOperator($condition['trigger_obj_id'], $condition['operator']) . ' ' . $condition['value']; // display trigger item $class = $objDefinition->getClassName($condition["trigger_type"]); $location = $objDefinition->getLocation($condition["trigger_type"]); if ($class == "" && $location == "") { continue; } $missing_cond_exist = true; $full_class = "ilObj" . $class . "ListGUI"; include_once $location . "/class." . $full_class . ".php"; $item_list_gui = new $full_class($this); $item_list_gui->setMode(IL_LIST_AS_TRIGGER); $item_list_gui->enablePath(false); $item_list_gui->enableIcon(true); $item_list_gui->setConditionDepth($this->condition_depth + 1); $item_list_gui->setParentRefId($this->getUniqueItemId()); // yes we can $item_list_gui->addCustomProperty($this->lng->txt("precondition_required_itemlist"), $cond_txt, false, true); $item_list_gui->enableCommands($this->commands_enabled, $this->std_cmd_only); $item_list_gui->enableProperties($this->properties_enabled); $trigger_html = $item_list_gui->getListItemHTML($condition['trigger_ref_id'], $condition['trigger_obj_id'], ilObject::_lookupTitle($condition["trigger_obj_id"]), ""); $this->tpl->setCurrentBlock("precondition"); if ($trigger_html == "") { $trigger_html = $this->lng->txt("precondition_not_accessible"); } $this->tpl->setVariable("TXT_CONDITION", trim($cond_txt)); $this->tpl->setVariable("TRIGGER_ITEM", $trigger_html); $this->tpl->parseCurrentBlock(); } if ($missing_cond_exist and $obligatory) { $this->tpl->setCurrentBlock("preconditions"); $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_obl_" . $toggle_id); $this->tpl->setVariable("TXT_PRECONDITIONS", $lng->txt("preconditions_obligatory_hint")); $this->tpl->parseCurrentBlock(); } elseif ($missing_cond_exist and !$obligatory) { $this->tpl->setCurrentBlock("preconditions"); $this->tpl->setVariable("CONDITION_TOGGLE_ID", "_opt_" . $toggle_id); $this->tpl->setVariable("TXT_PRECONDITIONS", sprintf($lng->txt("preconditions_optional_hint"), $num_optional_required)); $this->tpl->parseCurrentBlock(); } return !$missing_cond_exist; }
/** * check for course activation * */ function doActivationCheck($a_permission, $a_cmd, $a_ref_id, $a_user_id, $a_all = false) { global $ilBench, $ilUser; $ilBench->start("AccessControl", "3150_checkAccess_check_course_activation"); $cache_perm = $a_permission == "visible" ? "visible" : "other"; //echo "<br>doActivationCheck-$cache_perm-$a_ref_id-$a_user_id-".$ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id)); if (isset($this->ac_cache[$cache_perm][$a_ref_id][$a_user_id])) { $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id]; } // nothings needs to be done if current permission is write permission if ($a_permission == 'write') { $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return true; } // #10852 - member view check if ($a_user_id == $ilUser->getId()) { // #10905 - activate parent container ONLY include_once './Services/Container/classes/class.ilMemberViewSettings.php'; $memview = ilMemberViewSettings::getInstance(); if ($memview->isActiveForRefId($a_ref_id) && $memview->getContainer() == $a_ref_id) { return true; } } include_once 'Services/Object/classes/class.ilObjectActivation.php'; $item_data = ilObjectActivation::getItem($a_ref_id); // if activation isn't enabled if ($item_data === NULL || $item_data['timing_type'] != ilObjectActivation::TIMINGS_ACTIVATION) { $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true; $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return true; } // if within activation time if (time() >= $item_data['timing_start'] and time() <= $item_data['timing_end']) { $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true; $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return true; } // if user has write permission if ($this->checkAccessOfUser($a_user_id, "write", "", $a_ref_id)) { $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true; $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return true; } // if current permission is visible and visible is set in activation if ($a_permission == 'visible' and $item_data['visible']) { $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = true; $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return true; } // no access $this->ac_cache[$cache_perm][$a_ref_id][$a_user_id] = false; $ilBench->stop("AccessControl", "3150_checkAccess_check_course_activation"); return false; }
/** * checks wether all conditions of a target object are fulfilled */ function _checkAllConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type = "", $a_usr_id = 0) { global $ilBench, $ilUser, $tree; $a_usr_id = $a_usr_id ? $a_usr_id : $ilUser->getId(); $conditions = ilConditionHandler::_getConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type); if (!count($conditions)) { return true; } // @todo check this include_once './Services/Container/classes/class.ilMemberViewSettings.php'; if (ilMemberViewSettings::getInstance()->isActive()) { return true; } // First check obligatory conditions $optional = self::getOptionalConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type); $num_required = self::calculateRequiredTriggers($a_target_ref_id, $a_target_id, $a_target_type); $passed = 0; foreach ($conditions as $condition) { if ($tree->isDeleted($condition['trigger_ref_id'])) { continue; } $check = ilConditionHandler::_checkCondition($condition['id'], $a_usr_id); if ($check) { ++$passed; if ($passed >= $num_required) { return true; } } else { if (!count($optional)) { return false; } } } // not all optional conditions passed return false; }