public function __construct($a_parent_obj, $a_parent_cmd, array &$a_data, $a_view, $a_by_location = false) { global $ilCtrl, $tree, $ilUser; $this->setId("pdmng"); parent::__construct($a_parent_obj, $a_parent_cmd); $this->addColumn('', '', '5%'); $this->addColumn($this->lng->txt("type"), 'type_caption', '1%'); $this->addColumn($this->lng->txt("title"), 'title', '44%'); $this->addColumn($this->lng->txt("container"), 'container', '50%'); $this->setDefaultOrderField("title"); $this->setRowTemplate("tpl.pd_manage_row.html", "Services/PersonalDesktop"); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd)); if ($a_view == ilPDSelectedItemsBlockGUI::VIEW_MY_OFFERS) { $this->setTitle($this->lng->txt("pd_my_offers")); $this->addMultiCommand('confirmRemove', $this->lng->txt('unsubscribe')); } else { $this->setTitle($this->lng->txt("pd_my_memberships")); $this->addMultiCommand('confirmRemove', $this->lng->txt('crs_unsubscribe')); } $this->addCommandButton("getHTML", $this->lng->txt("cancel")); // root node caption $root = $tree->getNodeData(ROOT_FOLDER_ID); $root = $root["title"]; if ($root == "ILIAS") { $root = $this->lng->txt("repository"); } foreach ($a_data as $idx => $item) { if (!$item["parent_ref"]) { unset($a_data[$idx]); continue; } if ($a_view == ilPDSelectedItemsBlockGUI::VIEW_MY_MEMBERSHIPS) { $a_data[$idx]["last_admin"] = false; switch ($item["type"]) { case "crs": // see ilObjCourseGUI:performUnsubscribeObject() include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $members = new ilCourseParticipants($item["obj_id"]); break; case "grp": include_once "Modules/Group/classes/class.ilGroupParticipants.php"; $members = new ilGroupParticipants($item["obj_id"]); break; default: // do nothing? continue; } $a_data[$idx]["last_admin"] = $members->isLastAdmin($ilUser->getId()); } $a_data[$idx]["type_caption"] = $this->lng->txt("obj_" . $item["type"]); // parent if ($tree->getRootId() != $item["parent_ref"]) { $a_data[$idx]["container"] = ilObject::_lookupTitle(ilObject::_lookupObjId($item["parent_ref"])); } else { $a_data[$idx]["container"] = $root; } } $this->setData($a_data); }
/** * Constructor * * @access public * @param object parent gui object * @return void */ public function __construct($a_parent_obj) { global $lng, $ilCtrl; $this->lng = $lng; $this->lng->loadLanguageModule('grp'); $this->ctrl = $ilCtrl; $this->container = $a_parent_obj; include_once './Services/PrivacySecurity/classes/class.ilPrivacySettings.php'; $this->privacy = ilPrivacySettings::_getInstance(); $this->participants = ilGroupParticipants::_getInstanceByObjId($a_parent_obj->object->getId()); parent::__construct($a_parent_obj, 'editMembers'); $this->setFormName('participants'); $this->setFormAction($this->ctrl->getFormAction($a_parent_obj)); $this->addColumn($this->lng->txt('name'), 'name', '20%'); $this->addColumn($this->lng->txt('login'), 'login', '25%'); if ($this->privacy->enabledGroupAccessTimes()) { $this->addColumn($this->lng->txt('last_access'), 'access_time'); } $this->addColumn($this->lng->txt('grp_notification'), 'notification'); $this->addColumn($this->lng->txt('objs_role'), 'roles'); $this->addCommandButton('updateMembers', $this->lng->txt('save')); $this->addCommandButton('members', $this->lng->txt('cancel')); $this->setRowTemplate("tpl.edit_participants_row.html", "Modules/Group"); $this->disable('sort'); $this->enable('header'); $this->enable('numinfo'); $this->disable('select_all'); }
/** * Get participants and responsible users */ function getParticipantsAndResponsibles() { $participants = array(); if ($this->app_id > 0) { include_once "./Services/Calendar/classes/class.ilCalendarEntry.php"; $app = new ilCalendarEntry($this->app_id); $resp_users = $app->readResponsibleUsers(); foreach ($resp_users as $v) { $n = ilObjUser::_lookupName($v["user_id"]); $participants[$v["user_id"]] = array_merge($n, array("type" => "non-member")); $this->resp_users[] = $v["user_id"]; } } include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $part = ilGroupParticipants::_getInstanceByObjId($this->grp_id); $admins = $part->getAdmins(); $members = $part->getMembers(); foreach ($members as $v) { $n = ilObjUser::_lookupName($v); $participants[$v] = array_merge($n, array("type" => "member")); } foreach ($admins as $v) { $n = ilObjUser::_lookupName($v); $participants[$v] = array_merge($n, array("type" => "admin")); } $this->setData($participants); }
/** * constructor * @param string xml version * @param string output encoding * @param string input encoding * @access public */ function ilGroupXMLWriter($group_obj) { global $ilias; parent::ilXmlWriter(); $this->EXPORT_VERSION = "3"; $this->ilias =& $ilias; $this->group_obj =& $group_obj; $this->participants = ilGroupParticipants::_getInstanceByObjId($this->group_obj->getId()); }
/** * Get instance by obj type * * @param int $a_obj_id * @return ilParticipants */ public static function getInstanceByObjId($a_obj_id) { $type = ilObject::_lookupType($a_obj_id); switch ($type) { case 'crs': include_once './Modules/Course/classes/class.ilCourseParticipants.php'; return ilCourseParticipants::_getInstanceByObjId($a_obj_id); case 'grp': include_once './Modules/Group/classes/class.ilGroupParticipants.php'; return ilGroupParticipants::_getInstanceByObjId($a_obj_id); } // @todo proper error handling return null; }
/** * @param int $a_obj_id * @return ilParticipants|mixed|null|object */ public static function getInstanceByObjId($a_obj_id) { $type = ilObject::_lookupType($a_obj_id); switch ($type) { case 'crs': include_once './Modules/Course/classes/class.ilCourseParticipants.php'; return ilCourseParticipants::_getInstanceByObjId($a_obj_id); case 'grp': include_once './Modules/Group/classes/class.ilGroupParticipants.php'; return ilGroupParticipants::_getInstanceByObjId($a_obj_id); case 'sess': include_once './Modules/Session/classes/class.ilSessionParticipants.php'; return ilSessionParticipants::_getInstanceByObjId($a_obj_id); default: include_once 'class.ilAdobeConnectParticipantsNullObject.php'; return new ilAdobeConnectParticipantsNullObject(); } }
/** * Get instance by obj type * * @param int $a_obj_id * @return ilParticipants * @throws InvalidArgumentException */ public static function getInstanceByObjId($a_obj_id) { $type = ilObject::_lookupType($a_obj_id); switch ($type) { case 'crs': include_once './Modules/Course/classes/class.ilCourseParticipants.php'; return ilCourseParticipants::_getInstanceByObjId($a_obj_id); case 'grp': include_once './Modules/Group/classes/class.ilGroupParticipants.php'; return ilGroupParticipants::_getInstanceByObjId($a_obj_id); case 'sess': include_once './Modules/Session/classes/class.ilSessionParticipants.php'; return ilSessionParticipants::_getInstanceByObjId($a_obj_id); default: $GLOBALS['ilLog']->logStack(); $GLOBALS['ilLog']->write(__METHOD__ . ': Invalid obj_id given: ' . $a_obj_id); throw new InvalidArgumentException('Invalid obj id given'); } }
/** * find groups in course, exclude groups in groups */ function initGroups() { global $tree, $ilAccess; $parent_node = $tree->getNodeData($this->ref_id); $groups = $tree->getSubTree($parent_node, true, "grp"); if (is_array($groups) && sizeof($groups)) { include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $this->participants = $this->groups = $this->groups_rights = array(); foreach ($groups as $idx => $group_data) { // check for group in group if ($group_data["parent"] != $this->ref_id && $tree->checkForParentType($group_data["ref_id"], "grp", true)) { unset($groups[$idx]); } else { $this->groups[$group_data["ref_id"]] = $group_data["title"]; $this->groups_rights[$group_data["ref_id"]]["write"] = (bool) $ilAccess->checkAccess("write", "", $group_data["ref_id"]); $this->groups_rights[$group_data["ref_id"]]["edit_permission"] = (bool) $ilAccess->checkAccess("edit_permission", "", $group_data["ref_id"]); $gobj = ilGroupParticipants::_getInstanceByObjId($group_data["obj_id"]); $this->participants[$group_data["ref_id"]]["members"] = $gobj->getMembers(); $this->participants[$group_data["ref_id"]]["admins"] = $gobj->getAdmins(); } } } }
protected function assignGroups() { if (count($this->getAssignedGroupes()) == 0) { return false; } foreach ($this->getAssignedGroupes() as $grp_obj_id) { if (ilObject2::_lookupType($grp_obj_id) != 'grp') { continue; } $part = ilGroupParticipants::_getInstanceByObjId($grp_obj_id); $usr_id = $this->getUsrObject()->getId(); $part->add($usr_id, IL_GRP_MEMBER); $all_refs = ilObject2::_getAllReferences($grp_obj_id); $first = array_shift(array_values($all_refs)); ilObjUser::_dropDesktopItem($usr_id, $first, 'grp'); } }
/** * Get participant ids for given object * * @param int $a_ref_id * @return array */ public static function getParticipantsForObject($a_ref_id) { global $tree; $obj_id = ilObject::_lookupObjectId($a_ref_id); $obj_type = ilObject::_lookupType($obj_id); // try to get participants from (parent) course/group switch ($obj_type) { case "crs": include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $member_obj = ilCourseParticipants::_getInstanceByObjId($obj_id); return $member_obj->getMembers(); case "grp": include_once "Modules/Group/classes/class.ilGroupParticipants.php"; $member_obj = ilGroupParticipants::_getInstanceByObjId($obj_id); return $member_obj->getMembers(); default: // walk path to find course or group object and use members of that object $path = $tree->getPathId($a_ref_id); array_pop($path); foreach (array_reverse($path) as $path_ref_id) { $type = ilObject::_lookupType($path_ref_id, true); if ($type == "crs" || $type == "grp") { return self::getParticipantsForObject($path_ref_id); } } break; } $a_users = null; // no participants possible: use tracking/object data where possible switch ($obj_type) { case "sahs": include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php"; $subtype = ilObjSAHSLearningModule::_lookupSubType($obj_id); if ($subtype == "scorm2004") { // based on cmi_node/cp_node, used for scorm tracking data views include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php"; $mod = new ilObjSCORM2004LearningModule($obj_id, false); $all = $mod->getTrackedUsers(""); if ($all) { $a_users = array(); foreach ($all as $item) { $a_users[] = $item["user_id"]; } } } else { include_once "./Modules/ScormAicc/classes/SCORM/class.ilObjSCORMTracking.php"; $a_users = ilObjSCORMTracking::_getTrackedUsers($obj_id); } break; case "exc": include_once "./Modules/Exercise/classes/class.ilExerciseMembers.php"; include_once "./Modules/Exercise/classes/class.ilObjExercise.php"; $exc = new ilObjExercise($obj_id, false); $members = new ilExerciseMembers($exc); $a_users = $members->getMembers(); break; case "tst": include_once "./Services/Tracking/classes/class.ilLPStatusTestFinished.php"; $a_users = ilLPStatusTestFinished::getParticipants($obj_id); break; default: // no sensible data: return null break; } return $a_users; }
protected function getNotificationTargetUserIds() { global $tree; if ($this->getTutorNotificationTarget() == self::NOTIFICATION_INVITED_USERS) { $user_ids = $this->getInvitedUsers(); } else { $parent_grp_ref_id = $tree->checkForParentType($this->getRefId(), "grp"); if ($parent_grp_ref_id) { include_once "Modules/Group/classes/class.ilGroupParticipants.php"; $part = new ilGroupParticipants(ilObject::_lookupObjId($parent_grp_ref_id)); $user_ids = $part->getMembers(); } else { $parent_crs_ref_id = $tree->checkForParentType($this->getRefId(), "crs"); if ($parent_crs_ref_id) { include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $part = new ilCourseParticipants(ilObject::_lookupObjId($parent_crs_ref_id)); $user_ids = $part->getMembers(); } } } return $user_ids; }
/** * Get course status body * @param int $a_usr_id * @return string */ protected function createGroupStatus($a_usr_id) { $part = ilGroupParticipants::_getInstanceByObjId($this->getObjId()); $body = $this->getLanguageText('grp_new_status') . "\n"; $body .= $this->getLanguageText('role') . ': '; if ($part->isAdmin($a_usr_id)) { $body .= $this->getLanguageText('il_grp_admin') . "\n"; } else { $body .= $this->getLanguageText('il_grp_member') . "\n"; } if ($part->isAdmin($a_usr_id)) { $body .= $this->getLanguageText('grp_notification') . ': '; if ($part->isNotificationEnabled($a_usr_id)) { $body .= $this->getLanguageText('grp_notify_on') . "\n"; } else { $body .= $this->getLanguageText('grp_notify_off') . "\n"; } } return $body; }
/** * Get members for object * @param int $a_obj_id * @return array */ protected static function getMembers($a_obj_id) { global $ilObjDataCache, $tree; switch ($ilObjDataCache->lookupType($a_obj_id)) { case 'crs': include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id); return $member_obj->getMembers(); case 'grp': include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $member_obj = ilGroupParticipants::_getInstanceByObjId($a_obj_id); return $member_obj->getMembers(); case 'fold': $folder_ref_ids = ilObject::_getAllReferences($a_obj_id); $folder_ref_id = current($folder_ref_ids); if ($crs_id = $tree->checkForParentType($folder_ref_id, 'crs')) { include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $member_obj = ilCourseParticipants::_getInstanceByObjId(ilObject::_lookupObjId($crs_id)); return $member_obj->getMembers(); } break; } return array(); }
function add() { global $ilErr, $ilObjDataCache, $lng, $ilAccess; if (sizeof($_POST["usrs"])) { if (!$ilAccess->checkAccess("write", "", $_POST["grp_id"])) { ilUtil::sendFailure($lng->txt("permission_denied"), true); $this->show(); return; } include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $members_obj = ilGroupParticipants::_getInstanceByObjId($ilObjDataCache->lookupObjId($_POST["grp_id"])); foreach ($_POST["usrs"] as $new_member) { if (!$members_obj->add($new_member, IL_GRP_MEMBER)) { $ilErr->raiseError("An Error occured while assigning user to group !", $ilErr->MESSAGE); } include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php'; $members_obj->sendNotification(ilGroupMembershipMailNotification::TYPE_ADMISSION_MEMBER, $new_member); } ilUtil::sendSuccess($lng->txt("grp_msg_member_assigned")); } $this->show(); }
/** * Show user's courses */ public function showMyGroups() { global $lng, $ilUser, $ilObjDataCache, $tree; include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $this->tpl->setTitle($this->lng->txt('mail_addressbook')); $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact'); $_GET['view'] = 'mygroups'; $lng->loadLanguageModule('crs'); $this->ctrl->setParameter($this, 'view', 'mygroups'); include_once 'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php'; $table = new ilMailSearchCoursesTableGUI($this, 'grp', $_GET["ref"]); $table->setId('search_grps_tbl'); $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp'); $counter = 0; $tableData = array(); if (is_array($grp_ids) && count($grp_ids) > 0) { include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; foreach ($grp_ids as $grp_id) { if (ilObject::_hasUntrashedReference($grp_id)) { $oGroupParticipants = ilGroupParticipants::_getInstanceByObjId($grp_id); $grp_members = $oGroupParticipants->getParticipants(); foreach ($grp_members as $key => $member) { $tmp_usr = new ilObjUser($member); if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) { unset($grp_members[$key]); } } unset($tmp_usr); $ref_ids = ilObject::_getAllReferences($grp_id); $ref_id = current($ref_ids); $path_arr = $tree->getPathFull($ref_id, $tree->getRootId()); $path_counter = 0; $path = ''; foreach ($path_arr as $data) { if ($path_counter++) { $path .= " -> "; } $path .= $data['title']; } $path = $this->lng->txt('path') . ': ' . $path; $current_selection_list = new ilAdvancedSelectionListGUI(); $current_selection_list->setListTitle($this->lng->txt("actions")); $current_selection_list->setId("act_" . $counter); $this->ctrl->setParameter($this, 'search_grp', $grp_id); $this->ctrl->setParameter($this, 'view', 'mygroups'); if ($_GET["ref"] == "mail") { if ($this->mailing_allowed) { $current_selection_list->addItem($this->lng->txt("mail_members"), '', $this->ctrl->getLinkTarget($this, "mail")); } } else { if ($_GET["ref"] == "wsp") { $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $this->ctrl->getLinkTarget($this, "share")); } } $current_selection_list->addItem($this->lng->txt("mail_list_members"), '', $this->ctrl->getLinkTarget($this, "showMembers")); $this->ctrl->clearParameters($this); $rowData = array('CRS_ID' => $grp_id, 'CRS_NAME' => $ilObjDataCache->lookupTitle($grp_id), 'CRS_NO_MEMBERS' => count($grp_members), 'CRS_PATH' => $path, 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML()); $counter++; $tableData[] = $rowData; } } } $table->setData($tableData); if ($counter > 0) { $this->tpl->setVariable('TXT_MARKED_ENTRIES', $lng->txt('marked_entries')); } $searchTpl->setVariable('TABLE', $table->getHtml()); $this->tpl->setContent($searchTpl->get()); if ($_GET["ref"] != "wsp") { $this->tpl->show(); } }
protected function share() { global $ilToolbar, $tpl, $ilUser, $ilSetting; $options = array(); $options["user"] = $this->lng->txt("wsp_set_permission_single_user"); include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $grp_ids = ilGroupParticipants::_getMembershipByType($ilUser->getId(), 'grp'); if (sizeof($grp_ids)) { $options["group"] = $this->lng->txt("wsp_set_permission_group"); } include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs'); if (sizeof($crs_ids)) { $options["course"] = $this->lng->txt("wsp_set_permission_course"); } if (!$this->getAccessHandler()->hasRegisteredPermission($this->node_id)) { $options["registered"] = $this->lng->txt("wsp_set_permission_registered"); } if ($ilSetting->get("enable_global_profiles")) { if (!$this->getAccessHandler()->hasGlobalPasswordPermission($this->node_id)) { $options["password"] = $this->lng->txt("wsp_set_permission_all_password"); } if (!$this->getAccessHandler()->hasGlobalPermission($this->node_id)) { $options["all"] = $this->lng->txt("wsp_set_permission_all"); } } include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $actions = new ilSelectInputGUI("", "action"); $actions->setOptions($options); $ilToolbar->addInputItem($actions); $ilToolbar->setFormAction($this->ctrl->getFormAction($this)); $ilToolbar->addFormButton($this->lng->txt("add"), "addpermissionhandler"); include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessTableGUI.php"; $table = new ilWorkspaceAccessTableGUI($this, "share", $this->node_id, $this->getAccessHandler()); $tpl->setContent($table->getHTML() . $this->footer); }
public static function checkParentNodeTree($ref_id) { global $tree; $parent_ref_id = $tree->getParentId($ref_id); $parent_obj = ilObjectFactory::getInstanceByRefId($parent_ref_id); if ($parent_obj->getType() == 'crs') { include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId()); } else { if ($parent_obj->getType() == 'grp') { include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId()); } } $result = array(); if ($parent_obj->getType() == 'crs' || $parent_obj->getType() == 'grp') { $moderator_ids = self::_getModerators($ref_id); $admin_ids = $oParticipants->getAdmins(); $tutor_ids = $oParticipants->getTutors(); $result = array_unique(array_merge($moderator_ids, $admin_ids, $tutor_ids)); } return $result; }
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; }
/** * @param integer $ref_id ref_id of ilias ac-object * @param integer $sco_id * @param array $member_ids */ public function addCrsGrpMembers($ref_id, $sco_id, $member_ids = null) { global $tree; $parent_crs_ref = $tree->checkForParentType($ref_id, 'crs'); $parent_grp_ref = $tree->checkForParentType($ref_id, 'grp'); $type = null; $obj_id = 0; if ($parent_crs_ref && empty($parent_grp_ref)) { $obj_id = ilObject::_lookupObjectId($parent_crs_ref); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $oParticipants = ilCourseParticipants::_getInstanceByObjId($obj_id); $type = 'crs'; } else { if ($parent_grp_ref) { $obj_id = ilObject::_lookupObjectId($parent_grp_ref); include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $oParticipants = ilGroupParticipants::_getInstanceByObjId($obj_id); $type = 'grp'; } } if ($type == 'crs' || $type == 'grp') { $role_map = ilAdobeConnectServer::getRoleMap(); $owner_id = ilObject::_lookupOwner(ilObject::_lookupObjectId($ref_id)); /** @var $oParticipants ilGroupParticipants | ilCourseParticipants */ $admins = $oParticipants->getAdmins(); $tutors = $oParticipants->getTutors(); $members = $oParticipants->getMembers(); if (is_array($member_ids) && count($member_ids) > 0) { $all_participants = $member_ids; $admins = array_uintersect($member_ids, $admins, 'strcmp'); $tutors = array_uintersect($member_ids, $tutors, 'strcmp'); $members = array_uintersect($member_ids, $members, 'strcmp'); } else { $all_participants = array_unique(array_merge($admins, $tutors, $members)); } $this->pluginObj->includeClass('class.ilAdobeConnectRoles.php'); $xavcRoles = new ilAdobeConnectRoles($ref_id); if (ilAdobeConnectServer::getSetting('user_assignment_mode') != ilAdobeConnectServer::ASSIGN_USER_SWITCH) { foreach ($all_participants as $user_id) { $this->pluginObj->includeClass('class.ilAdobeConnectUserUtil.php'); //check if there is an adobe connect account at the ac-server $ilAdobeConnectUser = new ilAdobeConnectUserUtil($user_id); $ilAdobeConnectUser->ensureAccountExistance(); // add to desktop if (ilAdobeConnectServer::getSetting('add_to_desktop') == 1) { ilObjUser::_addDesktopItem($user_id, $ref_id, 'xavc'); } } } // receive breeze session $session = self::getSession(); $this->pluginObj->includeClass('class.ilXAVCMembers.php'); if ($session != NULL && $this->xmlApi->login($this->adminLogin, $this->adminPass, $session)) { foreach ($admins as $user_id) { $xavcRoles->addAdministratorRole($user_id); $is_member = ilXAVCMembers::_isMember($user_id, $ref_id); // local member table $xavcMemberObj = new ilXAVCMembers($ref_id, $user_id); $status = $role_map[$type . '_admin']; $xavcMemberObj->setStatus($status); $xavcMemberObj->setScoId($sco_id); if ($is_member) { $xavcMemberObj->updateXAVCMember(); } else { $xavcMemberObj->insertXAVCMember(); } $xavc_login = ilXAVCMembers::_lookupXAVCLogin($user_id); if (!empty($xavc_login)) { $this->xmlApi->updateMeetingParticipant($sco_id, $xavc_login, $session, $status); } } foreach ($tutors as $user_id) { if (($xavc_login = ilXAVCMembers::_lookupXAVCLogin($user_id)) != $this->adminLogin && $user_id != $owner_id) { $xavcRoles->addAdministratorRole($user_id); $is_member = ilXAVCMembers::_isMember($user_id, $ref_id); // local member table $xavcMemberObj = new ilXAVCMembers($ref_id, $user_id); $status = $role_map[$type . '_tutor']; $xavcMemberObj->setStatus($status); $xavcMemberObj->setScoId($sco_id); if ($is_member) { $xavcMemberObj->updateXAVCMember(); } else { $xavcMemberObj->insertXAVCMember(); } if (!empty($xavc_login)) { $this->xmlApi->updateMeetingParticipant($sco_id, $xavc_login, $session, $status); } } } foreach ($members as $user_id) { if (($xavc_login = ilXAVCMembers::_lookupXAVCLogin($user_id)) != $this->adminLogin && $user_id != $owner_id) { $xavcRoles->addMemberRole($user_id); $is_member = ilXAVCMembers::_isMember($user_id, $ref_id); // local member table $xavcMemberObj = new ilXAVCMembers($ref_id, $user_id); $status = $role_map[$type . '_member']; $xavcMemberObj->setStatus($status); $xavcMemberObj->setScoId($sco_id); if ($is_member) { $xavcMemberObj->updateXAVCMember(); } else { $xavcMemberObj->insertXAVCMember(); } if (!empty($xavc_login)) { $this->xmlApi->updateMeetingParticipant($sco_id, $xavc_login, $session, $status); } } } $xavcRoles->addAdministratorRole($owner_id); // local member table $xavcMemberObj = new ilXAVCMembers($ref_id, $owner_id); $status = $role_map[$type . '_owner']; $xavcMemberObj->setStatus($status); $xavcMemberObj->setScoId($sco_id); $is_member = ilXAVCMembers::_isMember($owner_id, $ref_id); if ($is_member) { $xavcMemberObj->updateXAVCMember(); } else { $xavcMemberObj->insertXAVCMember(); } $this->xmlApi->updateMeetingParticipant($sco_id, ilXAVCMembers::_lookupXAVCLogin($owner_id), $session, $status); } } }
function isAssignedToGroup($sid, $group_id, $user_id) { $this->initAuth($sid); $this->initIlias(); if (!$this->__checkSession($sid)) { return $this->__raiseError($this->__getMessage(), $this->__getMessageCode()); } if (!is_numeric($group_id)) { return $this->__raiseError('No valid group id given. Please choose an existing id of an ILIAS group', 'Client'); } global $rbacsystem; if (($type = ilObject::_lookupType(ilObject::_lookupObjId($group_id))) != 'grp') { $group_id = end($ref_ids = ilObject::_getAllReferences($group_id)); if (ilObject::_lookupType(ilObject::_lookupObjId($group_id)) != 'grp') { return $this->__raiseError('Invalid group id. Object with id "' . $group_id . '" is not of type "group"', 'Client'); } } if (ilObject::_lookupType($user_id) != 'usr') { return $this->__raiseError('Invalid user id. User with id "' . $user_id . ' does not exist', 'Client'); } if (!($tmp_group = ilObjectFactory::getInstanceByRefId($group_id, false))) { return $this->__raiseError('Cannot create group instance!', 'Server'); } if (!$rbacsystem->checkAccess('read', $group_id)) { return $this->__raiseError('Check access failed. No permission to read group data', 'Server'); } include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $participants = ilGroupParticipants::_getInstanceByObjId(ilObject::_lookupObjId($group_id)); if ($participants->isAdmin($user_id)) { return 1; } if ($participants->isMember($user_id)) { return 2; } return 0; }
/** * Init member object * @return */ protected function initMembers() { if ($this->getType() == 'crs') { $this->members = ilCourseParticipants::_getInstanceByObjId($this->getObjId()); } if ($this->getType() == 'grp') { $this->members = ilGroupParticipants::_getInstanceByObjId($this->getObjId()); } return true; }
/** * Parse user data * @param array $a_user_data * @return */ public function parse($a_user_data) { include_once './Services/User/classes/class.ilUserQuery.php'; $additional_fields = $this->getSelectedColumns(); unset($additional_fields["firstname"]); unset($additional_fields["lastname"]); unset($additional_fields["last_login"]); unset($additional_fields["access_until"]); switch ($this->type) { case 'admin': $part = ilGroupParticipants::_getInstanceByObjId($this->getParentObject()->object->getId())->getAdmins(); break; case 'member': $part = ilGroupParticipants::_getInstanceByObjId($this->getParentObject()->object->getId())->getMembers(); break; } $udf_ids = $usr_data_fields = $odf_ids = array(); foreach ($additional_fields as $field) { if (substr($field, 0, 3) == 'udf') { $udf_ids[] = substr($field, 4); continue; } if (substr($field, 0, 3) == 'odf') { $odf_ids[] = substr($field, 4); continue; } $usr_data_fields[] = $field; } $usr_data = ilUserQuery::getUserListData('login', 'ASC', 0, 9999, '', '', null, false, false, 0, 0, null, $usr_data_fields, $part); // Custom user data fields if ($udf_ids) { include_once './Services/User/classes/class.ilUserDefinedData.php'; $data = ilUserDefinedData::lookupData($part, $udf_ids); foreach ($data as $usr_id => $fields) { if (!$this->checkAcceptance($usr_id)) { continue; } foreach ($fields as $field_id => $value) { $a_user_data[$usr_id]['udf_' . $field_id] = $value; } } } // Object specific user data fields if ($odf_ids) { include_once './Modules/Course/classes/Export/class.ilCourseUserData.php'; $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId()); foreach ($data as $usr_id => $fields) { if (!$this->checkAcceptance($usr_id)) { continue; } foreach ($fields as $field_id => $value) { if ($a_user_data[$usr_id]) { $a_user_data[$usr_id]['odf_' . $field_id] = $value; } } } } foreach ($usr_data['set'] as $user) { // Check acceptance if (!$this->checkAcceptance($user['usr_id'])) { continue; } // DONE: accepted foreach ($usr_data_fields as $field) { $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : ''; } } return $this->setData($a_user_data); }
/** * Refresh status of course member assignments * @param object $course_member * @param int $obj_id */ protected function refreshAssignmentStatus($course_member, $obj_id, $sub_id, $assigned) { include_once './Services/WebServices/ECS/classes/Course/class.ilECSCourseMemberAssignment.php'; $type = ilObject::_lookupType($obj_id); if ($type == 'crs') { include_once './Modules/Course/classes/class.ilCourseParticipants.php'; $part = ilCourseParticipants::_getInstanceByObjId($obj_id); } else { include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $part = ilGroupParticipants::_getInstanceByObjId($obj_id); } $course_id = (int) $course_member->lectureID; $usr_ids = ilECSCourseMemberAssignment::lookupUserIds($course_id, $sub_id, $obj_id); // Delete remote deleted foreach ((array) $usr_ids as $usr_id) { if (!isset($assigned[$usr_id])) { $ass = ilECSCourseMemberAssignment::lookupAssignment($course_id, $sub_id, $obj_id, $usr_id); if ($ass instanceof ilECSCourseMemberAssignment) { $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $usr_id); if ($il_usr_id = ilObjUser::_lookupId($acc)) { // this removes also admin, tutor roles $part->delete($il_usr_id); $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id)); } else { $GLOBALS['ilLog']->write(__METHOD__ . ': Deassigning unknown ILIAS user ' . $usr_id . ' ' . 'from course ' . ilObject::_lookupTitle($obj_id)); } $ass->delete(); } } } // Assign new participants foreach ((array) $assigned as $person_id => $person) { $role = $this->lookupRole($person['role']); $role_info = ilECSMappingUtils::getRoleMappingInfo($role); $acc = ilObjUser::_checkExternalAuthAccount(ilECSSetting::lookupAuthMode(), (string) $person_id); $GLOBALS['ilLog']->write(__METHOD__ . ': Handling user ' . (string) $person_id); if (in_array($person_id, $usr_ids)) { if ($il_usr_id = ilObjUser::_lookupId($acc)) { $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($role, true)); $part->updateRoleAssignments($il_usr_id, array($role)); // Nothing to do, user is member or is locally deleted } } else { if ($il_usr_id = ilObjUser::_lookupId($acc)) { if ($role) { // Add user $GLOBALS['ilLog']->write(__METHOD__ . ': Assigning new user ' . $person_id . ' ' . 'to ' . ilObject::_lookupTitle($obj_id)); $part->add($il_usr_id, $role); } } else { if ($role_info['create']) { $this->createMember($person_id); $GLOBALS['ilLog']->write(__METHOD__ . ': Added new user ' . $person_id); } } $assignment = new ilECSCourseMemberAssignment(); $assignment->setServer($this->getServer()->getServerId()); $assignment->setMid($this->mid); $assignment->setCmsId($course_id); $assignment->setCmsSubId($sub_id); $assignment->setObjId($obj_id); $assignment->setUid($person_id); $assignment->save(); } } return true; }
protected function initContainer($a_init_participants = false) { global $tree; $is_course = $is_group = false; $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs'); if ($this->container_ref_id) { $is_course = true; } if (!$this->container_ref_id) { $this->container_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp'); if ($this->container_ref_id) { $is_group = true; } } if (!$this->container_ref_id) { ilUtil::sendFailure('No container object found. Aborting'); return true; } $this->container_obj_id = ilObject::_lookupObjId($this->container_ref_id); if ($a_init_participants && $this->container_obj_id) { if ($is_course) { include_once './Modules/Course/classes/class.ilCourseParticipants.php'; return ilCourseParticipants::_getInstanceByObjId($this->container_obj_id); } else { if ($is_group) { include_once './Modules/Group/classes/class.ilGroupParticipants.php'; return ilGroupParticipants::_getInstanceByObjId($this->container_obj_id); } } } }
public function showMembersObject() { /** * @var $tree ilTree * @var $tpl ilTemplate * @var $ilTabs ilTabsGUI * @var $ilAccess ilAccessHandler * @var $ilErr ilErr */ global $tree, $tpl, $ilTabs, $ilAccess, $ilErr; if (!$ilAccess->checkAccess('write', '', $this->ref_id)) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } $tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.forums_members_list.html', 'Modules/Forum'); $ilTabs->setTabActive('settings'); $this->settingsTabs(); // instantiate the property form if (!$this->initNotificationSettingsForm()) { // if the form was just created set the values fetched from database $this->notificationSettingsForm->setValuesByArray(array('notification_type' => $this->objProperties->getNotificationType(), 'adm_force' => (bool) $this->objProperties->isAdminForceNoti(), 'usr_toggle' => (bool) $this->objProperties->isUserToggleNoti())); } // set form html into template $tpl->setVariable('NOTIFICATIONS_SETTINGS_FORM', $this->notificationSettingsForm->getHTML()); include_once 'Modules/Forum/classes/class.ilForumNotification.php'; include_once 'Modules/Forum/classes/class.ilObjForum.php'; $frm_noti = new ilForumNotification($this->object->getRefId()); // check if there a parent-node is a grp or crs $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp'); $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs'); if ($grp_ref_id == 0 && $crs_ref_id == 0) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } /** * @var $oParticipants ilParticipants */ $oParticipants = null; if ($grp_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($grp_ref_id); include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId()); } else { if ($crs_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId()); } } $moderator_ids = $frm_noti->_getModerators($this->object->getRefId()); $admin_ids = $oParticipants->getAdmins(); $member_ids = $oParticipants->getMembers(); $tutor_ids = $oParticipants->getTutors(); $moderators = array(); $admins = array(); $members = array(); $tutors = array(); $all_forum_users = array_merge($moderator_ids, $admin_ids, $member_ids, $tutor_ids); $all_forum_users = array_unique($all_forum_users); if ($this->objProperties->getNotificationType() == 'default') { // update forum_notification table include_once 'Modules/Forum/classes/class.ilForumNotification.php'; $forum_noti = new ilForumNotification($this->object->getRefId()); $forum_noti->setAdminForce($this->objProperties->isAdminForceNoti()); $forum_noti->setUserToggle($this->objProperties->isUserToggleNoti()); $forum_noti->setForumId($this->objProperties->getObjId()); if (isset($_POST['notification_type']) && $_POST['notification_type'] == 'default') { // delete all notifications set by admin $forum_noti->deleteNotificationAllUsers(); } } else { if ($this->objProperties->getNotificationType() == 'per_user') { $counter = 0; foreach ($moderator_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $moderators[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $moderators[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $moderators[$counter]['firstname'] = $name['firstname']; $moderators[$counter]['lastname'] = $name['lastname']; $moderators[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $counter = 0; foreach ($admin_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $admins[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $admins[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $admins[$counter]['firstname'] = $name['firstname']; $admins[$counter]['lastname'] = $name['lastname']; $admins[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $counter = 0; foreach ($member_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $members[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $members[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $members[$counter]['firstname'] = $name['firstname']; $members[$counter]['lastname'] = $name['lastname']; $members[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $counter = 0; foreach ($tutor_ids as $user_id) { $frm_noti->setUserId($user_id); #$admin_force_noti = $frm_noti->isAdminForceNotification(); $user_toggle_noti = $frm_noti->isUserToggleNotification(); $icon_ok = $this->getIcon(!$user_toggle_noti); $tutors[$counter]['user_id'] = ilUtil::formCheckbox(0, 'user_id[]', $user_id); $tutors[$counter]['login'] = ilObjUser::_lookupLogin($user_id); $name = ilObjUser::_lookupName($user_id); $tutors[$counter]['firstname'] = $name['firstname']; $tutors[$counter]['lastname'] = $name['lastname']; $tutors[$counter]['user_toggle_noti'] = $icon_ok; $counter++; } $this->__showMembersTable($moderators, $admins, $members, $tutors); } else { $frm_noti = new ilForumNotification($this->object->getRefId()); $all_notis = $frm_noti->read(); foreach ($all_forum_users as $user_id) { $frm_noti->setUserId($user_id); $frm_noti->setAdminForce(1); $frm_noti->setUserToggle($this->objProperties->isUserToggleNoti()); if (array_key_exists($user_id, $all_notis)) { $frm_noti->update(); } else { if ($frm_noti->existsNotification() == false && !in_array($user_id, $moderator_ids)) { $frm_noti->insertAdminForce(); } } } } } }
/** * Lookup registration info * @global ilDB $ilDB * @global ilObjUser $ilUser * @global ilLanguage $lng * @param int $a_obj_id * @return array */ public static function lookupRegistrationInfo($a_obj_id) { global $ilDB, $ilUser, $lng; $query = 'SELECT registration_type, registration_enabled, registration_unlimited, registration_start, ' . 'registration_end, registration_mem_limit, registration_max_members FROM grp_settings ' . 'WHERE obj_id = ' . $ilDB->quote($a_obj_id); $res = $ilDB->query($query); $info = array(); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $info['reg_info_start'] = new ilDateTime($row->registration_start, IL_CAL_DATETIME); $info['reg_info_end'] = new ilDateTime($row->registration_end, IL_CAL_DATETIME); $info['reg_info_type'] = $row->registration_type; $info['reg_info_max_members'] = $row->registration_max_members; $info['reg_info_mem_limit'] = $row->registration_mem_limit; $info['reg_info_unlimited'] = $row->registration_unlimited; $info['reg_info_max_members'] = 0; if ($info['reg_info_mem_limit']) { $info['reg_info_max_members'] = $row->registration_max_members; } $info['reg_info_enabled'] = $row->registration_enabled; } $registration_possible = $info['reg_info_enabled']; // Limited registration (added $registration_possible, see bug 0010157) if (!$info['reg_info_unlimited'] && $registration_possible) { $dt = new ilDateTime(time(), IL_CAL_UNIX); if (ilDateTime::_before($dt, $info['reg_info_start'])) { $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_start'); $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_start']); } elseif (ilDateTime::_before($dt, $info['reg_info_end'])) { $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_end'); $info['reg_info_list_prop']['value'] = ilDatePresentation::formatDate($info['reg_info_end']); } else { $registration_possible = false; $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period'); $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg'); } } else { // added !$registration_possible, see bug 0010157 if (!$registration_possible) { $registration_possible = false; $info['reg_info_list_prop']['property'] = $lng->txt('grp_list_reg_period'); $info['reg_info_list_prop']['value'] = $lng->txt('grp_list_reg_noreg'); } } if ($info['reg_info_mem_limit'] && $registration_possible) { // Check if users are on waiting list // @todo // Check for free places include_once './Modules/Group/classes/class.ilGroupParticipants.php'; $part = ilGroupParticipants::_getInstanceByObjId($a_obj_id); if ($part->getCountMembers() <= $info['reg_info_max_members']) { $info['reg_info_list_prop_limit']['property'] = $lng->txt('grp_list_reg_limit_places'); $info['reg_info_list_prop_limit']['value'] = max(0, $info['reg_info_max_members'] - $part->getCountMembers()); } else { $info['reg_info_list_prop_limit']['property'] = ''; $info['reg_info_list_prop_limit']['value'] = $lng->txt('grp_list_reg_limit_full'); } } return $info; }
public function confirmedUnsubscribe() { global $ilCtrl, $ilAccess, $ilUser; if (!sizeof($_POST["ref_id"])) { $ilCtrl->redirect($this, "manage"); } foreach ($_POST["ref_id"] as $ref_id) { if ($ilAccess->checkAccess("leave", "", $ref_id)) { switch (ilObject::_lookupType($ref_id, true)) { case "crs": // see ilObjCourseGUI:performUnsubscribeObject() include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $members = new ilCourseParticipants(ilObject::_lookupObjId($ref_id)); $members->delete($ilUser->getId()); $members->sendUnsubscribeNotificationToAdmins($ilUser->getId()); $members->sendNotification($members->NOTIFY_UNSUBSCRIBE, $ilUser->getId()); break; case "grp": // see ilObjGroupGUI:performUnsubscribeObject() include_once "Modules/Group/classes/class.ilGroupParticipants.php"; $members = new ilGroupParticipants(ilObject::_lookupObjId($ref_id)); $members->delete($ilUser->getId()); include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php'; $members->sendNotification(ilGroupMembershipMailNotification::TYPE_UNSUBSCRIBE_MEMBER, $ilUser->getId()); $members->sendNotification(ilGroupMembershipMailNotification::TYPE_NOTIFICATION_UNSUBSCRIBE, $ilUser->getId()); break; default: // do nothing continue; } include_once './Modules/Forum/classes/class.ilForumNotification.php'; ilForumNotification::checkForumsExistsDelete($ref_id, $ilUser->getId()); } } ilUtil::sendSuccess($this->lng->txt("settings_saved"), true); $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show"); }
/** * Get parent members object * * @param int $a_node_id * @return array */ function getParentMemberIds($a_node_id) { $container_id = $this->getParentContainerId($a_node_id); if ($container_id) { $members = null; if (ilObject::_lookupType($container_id) == "crs") { include_once "Modules/Course/classes/class.ilCourseParticipants.php"; $members = new ilCourseParticipants(ilObject::_lookupObjId($container_id)); } else { include_once "Modules/Group/classes/class.ilGroupParticipants.php"; $members = new ilGroupParticipants(ilObject::_lookupObjId($container_id)); } // :TODO: review limit, members vs. participants if ($members && $members->getCountParticipants() < 100) { return $members->getParticipants(); } } }
/** * @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 = IL_GRP_MEMBER, $a_force_registration = false) { include_once './Services/Membership/exceptions/class.ilMembershipRegistrationException.php'; include_once "./Modules/Group/classes/class.ilGroupParticipants.php"; $part = ilGroupParticipants::_getInstanceByObjId($this->getId()); if ($part->isAssigned($a_user_id)) { return true; } if (!$a_force_registration) { // Availability include_once './Modules/Group/classes/class.ilObjGroupAccess.php'; if (!ilObjGroupAccess::_registrationEnabled($this->getId())) { $this->lng->loadLanguageModule('crs'); throw new ilMembershipRegistrationException('456', $this->getRefId()); } // Max members if (!$this->isRegistrationUnlimited()) { $free = max(0, $this->getMaxMembers() - $part->getCountMembers()); include_once './Modules/Group/classes/class.ilGroupWaitingList.php'; $waiting_list = new ilGroupWaitingList($this->getId()); if ($this->isWaitingListEnabled() and (!$free or $waiting_list->getCountUsers())) { throw new ilMembershipRegistrationException('123', $this->getRefId()); } } } $part->add($a_user_id, $a_role); $part->sendNotification($part->TYPE_NOTIFICATION_REGISTRATION, $a_user_id); return true; }
/** * @return ilParticipants for course or group */ public function getParticipantsObject() { global $tree, $ilErr; $grp_ref_id = $tree->checkForParentType($this->object->getRefId(), 'grp'); $crs_ref_id = $tree->checkForParentType($this->object->getRefId(), 'crs'); if ($this->isParentObjectCrsOrGrp() == false) { $ilErr->raiseError($this->lng->txt('msg_no_perm_read'), $ilErr->MESSAGE); } /** * @var $oParticipants ilParticipants */ $oParticipants = null; if ($grp_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($grp_ref_id); include_once 'Modules/Group/classes/class.ilGroupParticipants.php'; $oParticipants = ilGroupParticipants::_getInstanceByObjId($parent_obj->getId()); return $oParticipants; } else { if ($crs_ref_id > 0) { $parent_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $oParticipants = ilCourseParticipants::_getInstanceByObjId($parent_obj->getId()); return $oParticipants; } } return $oParticipants; }