/** * checks wether a user may invoke a command or not * (this method is called by ilAccessHandler::checkAccess) * * @param string $a_cmd command (not permission!) * @param string $a_permission permission * @param int $a_ref_id reference id * @param int $a_obj_id object id * @param int $a_user_id user id (if not provided, current user is taken) * * @return boolean true, if everything is ok */ function _checkAccess($a_cmd, $a_permission, $a_ref_id, $a_obj_id, $a_user_id = "") { global $ilUser, $lng, $rbacsystem, $ilAccess; if ($a_user_id == "") { $a_user_id = $ilUser->getId(); } switch ($a_cmd) { case "info": include_once './Modules/Group/classes/class.ilGroupParticipants.php'; if (ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) { $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_member")); } else { $ilAccess->addInfoItem(IL_STATUS_MESSAGE, $lng->txt("info_is_not_member")); } break; case "join": if (!self::_registrationEnabled($a_obj_id)) { return false; } include_once './Modules/Group/classes/class.ilGroupWaitingList.php'; if (ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id)) { return false; } include_once './Modules/Group/classes/class.ilGroupParticipants.php'; if (ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) { return false; } break; case 'leave': // Regular member if ($a_permission == 'leave') { include_once './Modules/Group/classes/class.ilGroupParticipants.php'; if (!ilGroupParticipants::_isParticipant($a_ref_id, $a_user_id)) { return false; } } // Waiting list if ($a_permission == 'join') { include_once './Modules/Group/classes/class.ilGroupWaitingList.php'; if (!ilGroupWaitingList::_isOnList($ilUser->getId(), $a_obj_id)) { return false; } } break; } switch ($a_permission) { } return true; }
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; }
protected function initHeaderAction($a_sub_type = null, $a_sub_id = null) { global $ilSetting, $ilUser; $lg = parent::initHeaderAction($a_sub_type, $a_sub_id); include_once './Modules/Group/classes/class.ilGroupParticipants.php'; if ($ilSetting->get("crsgrp_ntf") && ilGroupParticipants::_isParticipant($this->ref_id, $ilUser->getId())) { if (!$ilUser->getPref("grpcrs_ntf_" . $this->ref_id)) { $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_off.png"), $this->lng->txt("grp_notification_deactivated")); $this->ctrl->setParameter($this, "grp_ntf", 1); $caption = "grp_activate_notification"; } else { $lg->addHeaderIcon("not_icon", ilUtil::getImagePath("notification_on.png"), $this->lng->txt("grp_notification_activated")); $this->ctrl->setParameter($this, "grp_ntf", 0); $caption = "grp_deactivate_notification"; } $lg->addCustomCommand($this->ctrl->getLinkTarget($this, "saveNotification"), $caption); $this->ctrl->setParameter($this, "grp_ntf", ""); } return $lg; }