Пример #1
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;
 }