/** * @see ilMembershipRegistrationCodes::register() * @param int user_id * @param int role * @param bool force registration and do not check registration constraints. */ public function register($a_user_id, $a_role = ilCourseConstants::CRS_MEMBER, $a_force_registration = false) { global $ilCtrl, $tree; include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php'; include_once "./Modules/Course/classes/class.ilCourseParticipants.php"; $part = ilCourseParticipants::_getInstanceByObjId($this->getId()); if ($part->isAssigned($a_user_id)) { return true; } if (!$a_force_registration) { // Availability if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_DEACTIVATED) { include_once './Modules/Group/classes/class.ilObjGroupAccess.php'; if (!ilObjCourseAccess::_usingRegistrationCode()) { throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course subscription is deactivated.', '456'); } } // Time Limitation if ($this->getSubscriptionLimitationType() == IL_CRS_SUBSCRIPTION_LIMITED) { if (!$this->inSubscriptionTime()) { throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', course is out of registration time.', '789'); } } // Max members if ($this->isSubscriptionMembershipLimited()) { $free = max(0, $this->getSubscriptionMaxMembers() - $part->getCountMembers()); include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; $waiting_list = new ilCourseWaitingList($this->getId()); if ($this->enabledWaitingList() and (!$free or $waiting_list->getCountUsers())) { $waiting_list->addToList($a_user_id); $this->lng->loadLanguageModule("crs"); $info = sprintf($this->lng->txt('crs_added_to_list'), $waiting_list->getPosition($a_user_id)); include_once './Modules/Course/classes/class.ilCourseParticipants.php'; $participants = ilCourseParticipants::_getInstanceByObjId($this->getId()); $participants->sendNotification($participants->NOTIFY_WAITING_LIST, $a_user_id); throw new ilMembershipRegistrationException($info, '124'); } if (!$this->enabledWaitingList() && !$free) { throw new ilMembershipRegistrationException('Cant registrate to course ' . $this->getId() . ', membership is limited.', '123'); } } } $part->add($a_user_id, $a_role); $part->sendNotification($part->NOTIFY_ACCEPT_USER, $a_user_id); $part->sendNotification($part->NOTIFY_ADMINS, $a_user_id); include_once './Modules/Forum/classes/class.ilForumNotification.php'; ilForumNotification::checkForumsExistsInsert($this->getRefId(), $a_user_id); return true; }
/** * Get container view mode */ function getViewMode() { global $tree; // default: by type $view = ilContainer::VIEW_BY_TYPE; // always inherit from $container_ref_id = $tree->checkForParentType($this->ref_id, 'grp'); if (!$container_ref_id) { $container_ref_id = $tree->checkForParentType($this->ref_id, 'crs'); } if ($container_ref_id) { include_once "./Modules/Course/classes/class.ilObjCourseAccess.php"; $view_mode = ilObjCourseAccess::_lookupViewMode(ilObject::_lookupObjId($container_ref_id)); if ($view_mode == ilContainer::VIEW_SESSIONS || $view_mode == ilContainer::VIEW_BY_TYPE || $view_mode == ilContainer::VIEW_SIMPLE) { $view = $view_mode; } } return $view; }
/** * Get item properties * * @return array array of property arrays: * "alert" (boolean) => display as an alert property (usually in red) * "property" (string) => property name * "value" (string) => property value */ function getProperties() { global $lng, $ilUser; $props = parent::getProperties(); // offline include_once 'Modules/Course/classes/class.ilObjCourseAccess.php'; if (ilObjCourseAccess::_isOffline($this->obj_id)) { $showRegistrationInfo = false; $props[] = array("alert" => true, "property" => $lng->txt("status"), "value" => $lng->txt("offline")); } // blocked include_once 'Modules/Course/classes/class.ilCourseParticipant.php'; $members = ilCourseParticipant::_getInstanceByObjId($this->obj_id, $ilUser->getId()); if ($members->isBlocked($ilUser->getId()) and $members->isAssigned($ilUser->getId())) { $props[] = array("alert" => true, "property" => $lng->txt("member_status"), "value" => $lng->txt("crs_status_blocked")); } // pending subscription include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; if (ilCourseParticipants::_isSubscriber($this->obj_id, $ilUser->getId())) { $props[] = array("alert" => true, "property" => $lng->txt("member_status"), "value" => $lng->txt("crs_status_pending")); } include_once './Modules/Course/classes/class.ilObjCourseAccess.php'; $info = ilObjCourseAccess::lookupRegistrationInfo($this->obj_id); if ($info['reg_info_list_prop']) { $props[] = array('alert' => false, 'newline' => true, 'property' => $info['reg_info_list_prop']['property'], 'value' => $info['reg_info_list_prop']['value']); } if ($info['reg_info_list_prop_limit']) { $props[] = array('alert' => false, 'newline' => false, 'property' => $info['reg_info_list_prop_limit']['property'], 'propertyNameVisible' => strlen($info['reg_info_list_prop_limit']['property']) ? true : false, 'value' => $info['reg_info_list_prop_limit']['value']); } // waiting list include_once './Modules/Course/classes/class.ilCourseWaitingList.php'; if (ilCourseWaitingList::_isOnList($ilUser->getId(), $this->obj_id)) { $props[] = array("alert" => true, "property" => $lng->txt('member_status'), "value" => $lng->txt('on_waiting_list')); } // check for certificates include_once "./Modules/Course/classes/class.ilCourseCertificateAdapter.php"; if (ilCourseCertificateAdapter::_hasUserCertificate($ilUser->getId(), $this->obj_id)) { $lng->loadLanguageModule('certificate'); $cmd_link = "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $this->ref_id . "&cmd=deliverCertificate"; $props[] = array("alert" => false, "property" => $lng->txt("passed"), "value" => '<a href="' . $cmd_link . '">' . $lng->txt("download_certificate") . '</a>'); } return $props; }
/** * get commands * * Depends on permissions * * @param int $a_ref_id Reference id of course link * * this method returns an array of all possible commands/permission combinations * * example: * $commands = array * ( * array("permission" => "read", "cmd" => "view", "lang_var" => "show"), * array("permission" => "write", "cmd" => "edit", "lang_var" => "edit"), * ); */ function _getCommands($a_ref_id) { global $ilAccess; if ($ilAccess->checkAccess('write', '', $a_ref_id)) { // Only local (reference specific commands) $commands = array(array("permission" => "visible", "cmd" => "", "lang_var" => "show", "default" => true), array("permission" => "write", "cmd" => "editReference", "lang_var" => "edit")); } else { include_once './Modules/Course/classes/class.ilObjCourseAccess.php'; $commands = ilObjCourseAccess::_getCommands(); } return $commands; }
/** * Registration enabled? Method is in Access class, since it is needed by Access/ListGUI. * * @param int id of user * @return boolean */ function _registrationEnabled($a_obj_id) { include_once "./Modules/Course/classes/class.ilObjCourseAccess.php"; return ilObjCourseAccess::_registrationEnabled($a_obj_id); }
protected function getCoursesOfUser($a_user_id) { global $tree; // see ilPDSelectedItemsBlockGUI include_once 'Modules/Course/classes/class.ilObjCourseAccess.php'; include_once 'Services/Membership/classes/class.ilParticipants.php'; $items = ilParticipants::_getMembershipByType($a_user_id, 'crs'); $references = $lp_obj_refs = array(); foreach ($items as $obj_id) { $ref_id = ilObject::_getAllReferences($obj_id); if (is_array($ref_id) && count($ref_id)) { $ref_id = array_pop($ref_id); if (!$tree->isDeleted($ref_id)) { $visible = false; $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false); if ($active && $visible) { $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id)); $lp_obj_refs[$obj_id] = $ref_id; } } } } // get lp data for valid courses if (sizeof($lp_obj_refs)) { // lp must be active, personal and not anonymized include_once "Services/Tracking/classes/class.ilObjUserTracking.php"; if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) { // see ilLPProgressTableGUI include_once "Services/Tracking/classes/class.ilTrQuery.php"; include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs); foreach ($lp_data as $item) { $ref_id = $item["ref_ids"]; $references[$ref_id]["lp_status"] = $item["status"]; // add objectives if ($item["u_mode"] == ilLPObjSettings::LP_MODE_OBJECTIVES) { // we need the collection for the correct order include_once "Services/Tracking/classes/collection/class.ilLPCollectionOfObjectives.php"; $coll_objtv = new ilLPCollectionOfObjectives($item["obj_id"], $item["u_mode"]); $coll_objtv = $coll_objtv->getItems(); if ($coll_objtv) { // #13373 $lo_results = $this->parseLOUserResults($item["obj_id"], $a_user_id); $tmp = array(); include_once "Modules/Course/classes/class.ilCourseObjective.php"; foreach ($coll_objtv as $objective_id) { $tmp[$objective_id] = array("id" => $objective_id, "title" => ilCourseObjective::lookupObjectiveTitle($objective_id)); if (array_key_exists($objective_id, $lo_results)) { $lo_result = $lo_results[$objective_id]; $tmp[$objective_id]["result_perc"] = $lo_result["result_perc"]; $tmp[$objective_id]["limit_perc"] = $lo_result["limit_perc"]; $tmp[$objective_id]["status"] = $lo_result["status"]; $tmp[$objective_id]["type"] = $lo_result["type"]; } } // order foreach ($coll_objtv as $objtv_id) { $references[$ref_id]["objectives"][] = $tmp[$objtv_id]; } } } } } } $references = ilUtil::sortArray($references, "title", "ASC"); return $references; }
/** * check whether goto script will succeed */ function _checkGoto($a_target) { global $ilAccess, $ilUser; $t_arr = explode("_", $a_target); // registration codes if (substr($t_arr[2], 0, 5) == 'rcode' and $ilUser->getId() != ANONYMOUS_USER_ID) { self::$using_code = true; return true; } if ($t_arr[0] != "crs" || (int) $t_arr[1] <= 0) { return false; } // checking for read results in endless loop, if read is given // but visible is not given (-> see bug 5323) if ($ilAccess->checkAccess("read", "", $t_arr[1]) || $ilAccess->checkAccess("visible", "", $t_arr[1])) { return true; } return false; }
protected function getCoursesOfUser($a_user_id, $a_add_path = false) { global $tree; // see ilPDSelectedItemsBlockGUI include_once 'Modules/Course/classes/class.ilObjCourseAccess.php'; include_once 'Services/Membership/classes/class.ilParticipants.php'; $items = ilParticipants::_getMembershipByType($a_user_id, 'crs'); $repo_title = $tree->getNodeData(ROOT_FOLDER_ID); $repo_title = $repo_title["title"]; if ($repo_title == "ILIAS") { $repo_title = $this->lng->txt("repository"); } $references = $lp_obj_refs = array(); foreach ($items as $obj_id) { $ref_id = ilObject::_getAllReferences($obj_id); if (is_array($ref_id) && count($ref_id)) { $ref_id = array_pop($ref_id); if (!$tree->isDeleted($ref_id)) { $visible = false; $active = ilObjCourseAccess::_isActivated($obj_id, $visible, false); if ($active && $visible) { $references[$ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'title' => ilObject::_lookupTitle($obj_id)); if ($a_add_path) { $path = array(); foreach ($tree->getPathFull($ref_id) as $item) { $path[] = $item["title"]; } // top level comes first if (sizeof($path) == 2) { $path[0] = 0; } else { $path[0] = 1; } $references[$ref_id]["path_sort"] = implode("__", $path); array_shift($path); array_pop($path); if (!sizeof($path)) { array_unshift($path, $repo_title); } $references[$ref_id]["path"] = implode(" › ", $path); } $lp_obj_refs[$obj_id] = $ref_id; } } } } // get lp data for valid courses if (sizeof($lp_obj_refs)) { // listing the objectives should NOT depend on any LP status / setting include_once 'Modules/Course/classes/class.ilObjCourse.php'; foreach ($lp_obj_refs as $obj_id => $ref_id) { // only if set in DB (default mode is not relevant if (ilObjCourse::_lookupViewMode($obj_id) == IL_CRS_VIEW_OBJECTIVE) { $references[$ref_id]["objectives"] = $this->parseObjectives($obj_id, $a_user_id); } } // LP must be active, personal and not anonymized include_once "Services/Tracking/classes/class.ilObjUserTracking.php"; if (ilObjUserTracking::_enabledLearningProgress() && ilObjUserTracking::_enabledUserRelatedData() && ilObjUserTracking::_hasLearningProgressLearner()) { // see ilLPProgressTableGUI include_once "Services/Tracking/classes/class.ilTrQuery.php"; include_once "Services/Tracking/classes/class.ilLPStatusFactory.php"; $lp_data = ilTrQuery::getObjectsStatusForUser($a_user_id, $lp_obj_refs); foreach ($lp_data as $item) { $ref_id = $item["ref_ids"]; $references[$ref_id]["lp_status"] = $item["status"]; } } } return $references; }