public function getSinglePool($CourseID, $PoolID) { global $ilUser, $ilObjDataCache; $retval = array(); $items = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'); // $items = ilParticipants::_getMembershipByType(12855, 'crs'); $itemId = array_search($CourseID, $items); if ($itemId !== FALSE && $itemId >= 0) { $obj_id = $items[$itemId]; $item_references = ilObject::_getAllReferences($obj_id); reset($item_references); if (strcmp($this->iliasVersion, "4.2") === 0) { require_once 'Modules/Course/classes/class.ilCourseItems.php'; foreach ($item_references as $ref_id) { // Antique Ilias $courseItems = new ilCourseItems($ref_id, 0, $ilUser->getId()); $courseItemList = $courseItems->getAllItems(); $retval = $this->mapItems($courseItemList, $PoolID); $retval = $retval[0]; } } else { // Modern Ilias $crs = new ilObjCourse($item_references, true); $courseItemList = $crs->getSubItems(); $retval = $this->mapItems($courseItemList["_all"], $PoolID); $retval = $retval[0]; } } return $retval; }
public function getUserCourse($courseId) { global $ilUser, $ilObjDataCache; $this->log($courseId); $items = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'); foreach ($items as $obj_id) { $this->log($obj_id . " :: " . $courseId); if ($obj_id == $courseId) { $crs = new ilObjCourse($obj_id, false); $crs->read(); $title = $crs->getTitle(); $description = $crs->getDescription(); // $this->log($crs->getOfflineStatus()); if ($crs->getOfflineStatus() == 1) { // skip offline courses continue; } $course = array("id" => $obj_id, "title" => $title, "description" => $description); // 2 get course objects $item_references = ilObject::_getAllReferences($obj_id); reset($item_references); if (strcmp($this->iliasVersion, "4.2") === 0) { foreach ($item_references as $ref_id => $x) { // Antique Ilias // For some strange reason remains the $crs->getRefId() remains empty $crs = new ilObjCourse($ref_id); // TODO: Verify that the course is online // TODO: If the course is offline, check if the user is admin. // TODO: skip offline student courses require_once 'Modules/Course/classes/class.ilCourseItems.php'; $courseItems = new ilCourseItems($crs->getRefId(), 0, $ilUser->getId()); $courseItemList = $courseItems->getAllItems(); $course["content-type"] = $this->mapItemTypes($courseItemList, false); break; } } else { // Modern Ilias foreach ($item_references as $ref_id => $x) { $crs = new ilObjCourse($ref_id); // TODO: Verify that the course is online // TODO: If the course is offline, check if the user is admin. // TODO: skip offline student courses $courseItemList = $crs->getSubItems(); // TODO check with Ilias 4.4 and 4.3 // $this->log(">>> IL >>> " . json_encode($courseItemList["_all"])); $course["content-type"] = $this->mapItemTypes($courseItemList, true); } } return $course; } } return null; }
/** * Gets all objects the current user is member of * * @access protected * @return Array $items array of objects */ protected function getObjectsByMembership($types = array()) { global $tree, $ilUser, $ilObjDataCache; include_once 'Services/Membership/classes/class.ilParticipants.php'; $items = array(); if (is_array($types) && count($types)) { foreach ($types as $type) { switch ($type) { case 'grp': $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'grp'), $items); break; case 'crs': $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'), $items); break; default: break; } } } else { $crs_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'); $grp_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'grp'); $items = array_merge($crs_mbs, $grp_mbs); } $references = array(); foreach ($items as $key => $obj_id) { $item_references = ilObject::_getAllReferences($obj_id); if (is_array($item_references) && count($item_references)) { foreach ($item_references as $ref_id) { $title = $ilObjDataCache->lookupTitle($obj_id); $type = $ilObjDataCache->lookupType($obj_id); $references[$title . $ref_id] = array('ref_id' => $ref_id, 'obj_id' => $obj_id, 'type' => $type, 'title' => $title, 'description' => $ilObjDataCache->lookupDescription($obj_id), 'parent_ref' => $tree->getParentId($ref_id)); } } } ksort($references); return is_array($references) ? $references : array(); }
/** * Read categories of user * * @access protected * @param * @return void */ protected function readPDCalendars() { global $rbacsystem; $this->readPublicCalendars(); $this->readPrivateCalendars(); $this->readConsultationHoursCalendar(); $this->readBookingCalendar(); include_once './Services/Membership/classes/class.ilParticipants.php'; $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id, 'crs')); $this->readSelectedCategories(ilParticipants::_getMembershipByType($this->user_id, 'grp')); $this->addSubitemCalendars(); }
public function initFilter() { global $lng, $ilSetting, $ilUser; include_once "Services/Membership/classes/class.ilParticipants.php"; $this->crs_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "crs"); $this->grp_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "grp"); $lng->loadLanguageModule("search"); $item = $this->addFilterItemByMetaType("user", self::FILTER_TEXT, false, $lng->txt("wsp_shared_user_filter")); $this->filter["user"] = $item->getValue(); // incoming back link (shared) if ((int) $_REQUEST["shr_id"] && !$this->filter["user"]) { $this->filter["user"] = ilObjUser::_lookupName((int) $_REQUEST["shr_id"]); $this->filter["user"] = $this->filter["user"]["login"]; $item->setValue($this->filter["user"]); } $item = $this->addFilterItemByMetaType("title", self::FILTER_TEXT, false, $lng->txt("wsp_shared_title")); $this->filter["title"] = $item->getValue(); $item = $this->addFilterItemByMetaType("acl_date", self::FILTER_DATE, false, $lng->txt("wsp_shared_date_filter")); $this->filter["acl_date"] = $item->getDate(); if (!$this->portfolio_mode) { // see ilPersonalWorkspaceGUI::renderToolbar $options = array("" => $lng->txt("search_any")); $settings_map = array("blog" => "blogs", "file" => "files"); // see ilObjWorkspaceFolderTableGUI foreach (array("file", "blog") as $type) { if (isset($settings_map[$type]) && $ilSetting->get("disable_wsp_" . $settings_map[$type])) { continue; } $options[$type] = $lng->txt("wsp_type_" . $type); } } else { $options = array("prtf" => $lng->txt("obj_prtf")); } if (sizeof($options)) { asort($options); $item = $this->addFilterItemByMetaType("obj_type", self::FILTER_SELECT, false, $lng->txt("wsp_shared_object_type")); $item->setOptions($options); $this->filter["obj_type"] = $item->getValue(); } // see ilWorkspaceAccessGUI::share $options = array(); $options["user"] = $lng->txt("wsp_set_permission_single_user"); if (sizeof($this->grp_ids)) { $options["group"] = $lng->txt("wsp_set_permission_group"); } if (sizeof($this->crs_ids)) { $options["course"] = $lng->txt("wsp_set_permission_course"); } if (!$this->handler->hasRegisteredPermission($this->parent_node_id)) { $options["registered"] = $lng->txt("wsp_set_permission_registered"); } if ($ilSetting->get("enable_global_profiles")) { if (!$this->handler->hasGlobalPasswordPermission($this->parent_node_id)) { $options["password"] = $this->lng->txt("wsp_set_permission_all_password"); } if (!$this->handler->hasGlobalPermission($this->parent_node_id)) { $options["all"] = $this->lng->txt("wsp_set_permission_all"); } } if (sizeof($options)) { // asort($options); $item = $this->addFilterItemByMetaType("acl_type", self::FILTER_SELECT, false, $lng->txt("wsp_shared_type")); $item->setOptions(array("" => $lng->txt("search_any")) + $options); $this->filter["acl_type"] = $item->getValue(); } if (sizeof($this->crs_ids) || sizeof($this->grp_ids)) { $options = array(); foreach ($this->crs_ids as $crs_id) { $options[$crs_id] = $lng->txt("obj_crs") . " " . ilObject::_lookupTitle($crs_id); } foreach ($this->grp_ids as $grp_id) { $options[$grp_id] = $lng->txt("obj_grp") . " " . ilObject::_lookupTitle($grp_id); } asort($options); $item = $this->addFilterItemByMetaType("crsgrp", self::FILTER_SELECT, false, $lng->txt("wsp_shared_member_filter")); $item->setOptions(array("" => $lng->txt("search_any")) + $options); $this->filter["crsgrp"] = $item->getValue(); } }
/** * Get trigger completion * * @param * @return */ static function getCompletionDateForTriggerRefId($a_user_id, $a_ref_id = null, $a_self_eval = 0) { global $ilDB; die("ilBasicSkill::getCompletionDateForTriggerRefId is deprecated."); if ($a_ref_id == "") { $a_ref_id = null; } else { if (!is_array($a_ref_id)) { $a_ref_id = array($a_ref_id); } } if (!is_array($a_user_id)) { $a_user_id = array($a_user_id); } if ($a_ref_id != null) { if (!is_array($a_ref_id)) { $a_ref_id = array($a_ref_id); } $set = $ilDB->query($q = "SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE " . $ilDB->in("user_id", $a_user_id, false, "integer") . " AND " . $ilDB->in("trigger_ref_id", $a_ref_id, false, "integer")); $completion = array(); while ($rec = $ilDB->fetchAssoc($set)) { if (!isset($completion[$rec["user_id"]][$rec["trigger_ref_id"]])) { $completion[$rec["user_id"]][$rec["trigger_ref_id"]] = $rec["status_date"]; } else { if ($rec["status_date"] < $completion[$rec["user_id"]][$rec["trigger_ref_id"]]) { $completion[$rec["user_id"]][$rec["trigger_ref_id"]] = $rec["status_date"]; } } } foreach ($a_ref_id as $ref_id) { foreach ($a_user_id as $user_id) { if (!isset($completion[$user_id][$ref_id])) { $completion[$user_id][$ref_id] = false; } } } } else { $completion = array(); foreach ($a_user_id as $user_id) { include_once 'Services/Membership/classes/class.ilParticipants.php'; $a_ref_id = ilParticipants::_getMembershipByType($user_id, 'crs', true); $set = $ilDB->query($q = "SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE " . "user_id = " . $ilDB->quote($user_id, "integer") . " AND " . $ilDB->in("trigger_ref_id", $a_ref_id, false, "integer")); while ($rec = $ilDB->fetchAssoc($set)) { if (!isset($completion[$user_id][$rec["trigger_ref_id"]])) { $completion[$user_id][$rec["trigger_ref_id"]] = $rec["status_date"]; } else { if ($rec["status_date"] < $completion[$user_id][$rec["trigger_ref_id"]]) { $completion[$user_id][$rec["trigger_ref_id"]] = $rec["status_date"]; } } } foreach ($a_ref_id as $ref_id) { if (!isset($completion[$user_id][$ref_id])) { $completion[$user_id][$ref_id] = false; } } } } return $completion; }
/** * Get all news items for a user. */ static function _getNewsItemsOfUser($a_user_id, $a_only_public = false, $a_prevent_aggregation = false, $a_per = 0, &$a_cnt = NULL) { global $ilAccess; $news_item = new ilNewsItem(); $news_set = new ilSetting("news"); $per = $a_per; include_once "./Services/News/classes/class.ilNewsSubscription.php"; include_once "./Services/Block/classes/class.ilBlockSetting.php"; // this is currently not used $ref_ids = ilNewsSubscription::_getSubscriptionsOfUser($a_user_id); if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n") { // get all items of the personal desktop $pd_items = ilObjUser::_lookupDesktopItems($a_user_id); foreach ($pd_items as $item) { if (!in_array($item["ref_id"], $ref_ids)) { $ref_ids[] = $item["ref_id"]; } } // get all memberships include_once 'Services/Membership/classes/class.ilParticipants.php'; $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs'); $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp'); $items = array_merge($crs_mbs, $grp_mbs); foreach ($items as $i) { $item_references = ilObject::_getAllReferences($i); if (is_array($item_references) && count($item_references)) { foreach ($item_references as $ref_id) { if (!in_array($ref_id, $ref_ids)) { $ref_ids[] = $ref_id; } } } } } $data = array(); foreach ($ref_ids as $ref_id) { if (!$a_only_public) { // this loop should not cost too much performance $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id); if (!$acc) { continue; } } if (ilNewsItem::getPrivateFeedId() != false) { global $rbacsystem; $acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(), "read", $ref_id); if (!$acc) { continue; } } $obj_id = ilObject::_lookupObjId($ref_id); $obj_type = ilObject::_lookupType($obj_id); $news = $news_item->getNewsForRefId($ref_id, $a_only_public, false, $per, $a_prevent_aggregation, false, false, false, $a_user_id); // counter if (!is_null($a_cnt)) { $a_cnt[$ref_id] = count($news); } $data = ilNewsItem::mergeNews($data, $news); } $data = ilUtil::sortArray($data, "creation_date", "desc", false, true); return $data; }
function getItems() { $obj_ids = $this->obj_ids; if (!$obj_ids && !$this->details) { // restrict courses/groups to objects where current user is member $membership_ids = null; if ($this->filter["type"] == "crs" || $this->filter["type"] == "grp") { include_once "Services/Membership/classes/class.ilParticipants.php"; $membership_ids = ilParticipants::_getMembershipByType($this->tracked_user->getId(), $this->filter["type"]); } if ($membership_ids === null || sizeof($membership_ids)) { $obj_ids = $this->searchObjects($this->getCurrentFilter(true), "read", $membership_ids); } } if ($obj_ids) { include_once "./Services/Tracking/classes/class.ilTrQuery.php"; switch ($this->mode) { case LP_MODE_SCORM: $data = ilTrQuery::getSCOsStatusForUser($this->tracked_user->getId(), $this->parent_obj_id, $obj_ids); break; case LP_MODE_OBJECTIVES: $data = ilTrQuery::getObjectivesStatusForUser($this->tracked_user->getId(), $obj_ids); break; default: $data = ilTrQuery::getObjectsStatusForUser($this->tracked_user->getId(), $obj_ids); foreach ($data as $idx => $item) { if (!$item["status"] && !$this->filter["status"]) { unset($data[$idx]); } else { $data[$idx]["offline"] = ilLearningProgressBaseGUI::isObjectOffline($item["obj_id"], $item["type"]); } } break; } $this->setData($data); } }
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; }
public static function getPossibleSharedTargets() { global $ilUser, $ilSetting; include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessGUI.php"; include_once "Services/Membership/classes/class.ilParticipants.php"; $grp_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "grp"); $crs_ids = ilParticipants::_getMembershipByType($ilUser->getId(), "crs"); $obj_ids = array_merge($grp_ids, $crs_ids); $obj_ids[] = $ilUser->getId(); $obj_ids[] = ilWorkspaceAccessGUI::PERMISSION_REGISTERED; if ($ilSetting->get("enable_global_profiles")) { $obj_ids[] = ilWorkspaceAccessGUI::PERMISSION_ALL; $obj_ids[] = ilWorkspaceAccessGUI::PERMISSION_ALL_PASSWORD; } return $obj_ids; }
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; }
function getParticipants() { if (count($this->arrFilter)) { $filteredParticipants = array(); $courseids = array(); $groupids = array(); global $ilDB; if (array_key_exists('group', $this->arrFilter)) { $ids = ilObject::_getIdsForTitle($this->arrFilter['group'], 'grp', true); $groupids = array_merge($groupids, $ids); } if (array_key_exists('course', $this->arrFilter)) { $ids = ilObject::_getIdsForTitle($this->arrFilter['course'], 'crs', true); $courseids = array_merge($courseids, $ids); } foreach ($this->participants as $active_id => $participant) { $remove = FALSE; if (array_key_exists('name', $this->arrFilter)) { if (!(strpos(strtolower($participant->getName()), strtolower($this->arrFilter['name'])) !== FALSE)) { $remove = TRUE; } } if (!$remove) { if (array_key_exists('group', $this->arrFilter)) { include_once "./Services/Membership/classes/class.ilParticipants.php"; $groups = ilParticipants::_getMembershipByType($participant->getUserID(), "grp"); $foundfilter = FALSE; if (count(array_intersect($groupids, $groups))) { $foundfilter = TRUE; } if (!$foundfilter) { $remove = TRUE; } } } if (!$remove) { if (array_key_exists('course', $this->arrFilter)) { include_once "./Services/Membership/classes/class.ilParticipants.php"; $courses = ilParticipants::_getMembershipByType($participant->getUserID(), "crs"); $foundfilter = FALSE; if (count(array_intersect($courseids, $courses))) { $foundfilter = TRUE; } if (!$foundfilter) { $remove = TRUE; } } } if (!$remove) { if (array_key_exists('active_id', $this->arrFilter)) { if ($active_id != $this->arrFilter['active_id']) { $remove = TRUE; } } } if (!$remove) { $filteredParticipants[$active_id] = $participant; } } return $filteredParticipants; } else { return $this->participants; } }