/** * 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(); } }
/** * Show user's courses */ public function showMyCourses() { global $lng, $ilUser, $ilObjDataCache, $tree, $tpl, $rbacsystem; include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $this->tpl->setTitle($this->lng->txt('mail_addressbook')); $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact'); $_GET['view'] = 'mycourses'; $lng->loadLanguageModule('crs'); include_once 'Services/Contact/classes/class.ilMailSearchCoursesTableGUI.php'; $table = new ilMailSearchCoursesTableGUI($this, "crs", $_GET["ref"]); $table->setId('search_crs_tbl'); include_once 'Modules/Course/classes/class.ilCourseParticipants.php'; $crs_ids = ilCourseParticipants::_getMembershipByType($ilUser->getId(), 'crs'); $counter = 0; $tableData = array(); if (is_array($crs_ids) && count($crs_ids) > 0) { $num_courses_hidden_members = 0; include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php"; foreach ($crs_ids as $crs_id) { /** * @var $oTmpCrs ilObjCourse */ $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id); $isOffline = !$oTmpCrs->isActivated(); $hasUntrashedReferences = ilObject::_hasUntrashedReference($crs_id); $showMemberListEnabled = (bool) $oTmpCrs->getShowMembers(); $ref_ids = array_keys(ilObject::_getAllReferences($crs_id)); $isPrivilegedUser = $rbacsystem->checkAccess('write', $ref_ids[0]); if ($hasUntrashedReferences && (!$isOffline && $showMemberListEnabled || $isPrivilegedUser)) { $oCrsParticipants = ilCourseParticipants::_getInstanceByObjId($crs_id); $crs_members = $oCrsParticipants->getParticipants(); foreach ($crs_members as $key => $member) { $tmp_usr = new ilObjUser($member); if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) { unset($crs_members[$key]); } } unset($tmp_usr); $hiddenMembers = false; if ((int) $oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) { ++$num_courses_hidden_members; $hiddenMembers = true; } unset($oTmpCrs); $ref_ids = ilObject::_getAllReferences($crs_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_crs', $crs_id); $this->ctrl->setParameter($this, 'view', 'mycourses'); 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" => $crs_id, "CRS_NAME" => $ilObjDataCache->lookupTitle($crs_id), "CRS_NO_MEMBERS" => count($crs_members), "CRS_PATH" => $path, 'COMMAND_SELECTION_LIST' => $current_selection_list->getHTML(), "hidden_members" => $hiddenMembers); $counter++; $tableData[] = $rowData; } } //if((int)$counter) //{ // $table->addCommandButton('mail',$lng->txt('mail_members')); // $table->addCommandButton('showMembers',$lng->txt('mail_list_members')); //} if ($num_courses_hidden_members > 0) { $searchTpl->setCurrentBlock('caption_block'); $searchTpl->setVariable('TXT_LIST_MEMBERS_NOT_AVAILABLE', $this->lng->txt('mail_crs_list_members_not_available')); $searchTpl->parseCurrentBlock(); } } $searchTpl->setVariable('TXT_MARKED_ENTRIES', $lng->txt('marked_entries')); $table->setData($tableData); if ($_GET['ref'] == 'mail') { $this->tpl->setVariable('BUTTON_CANCEL', $lng->txt('cancel')); } $searchTpl->setVariable('TABLE', $table->getHtml()); $tpl->setContent($searchTpl->get()); if ($_GET["ref"] != "wsp") { $tpl->show(); } }