/**
  * Show course members
  */
 public function showMembers()
 {
     global $lng;
     if ($_GET["search_grp"] != "") {
         $_POST["search_grp"] = explode(",", $_GET["search_grp"]);
     }
     if (!is_array($_POST["search_grp"]) || count($_POST["search_grp"]) == 0) {
         ilUtil::sendInfo($lng->txt("mail_select_group"));
         $this->showMyGroups();
     } else {
         $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
         include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
         $context = $_GET["ref"] ? $_GET["ref"] : "mail";
         $table = new ilMailSearchCoursesMembersTableGUI($this, 'grp', $context);
         $table->setId('show_grps_mmbrs_tbl');
         $lng->loadLanguageModule('crs');
         $tableData = array();
         $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
         foreach ($_POST["search_grp"] as $grp_id) {
             $ref_ids = ilObject::_getAllReferences($grp_id);
             $ref_id = current($ref_ids);
             if (is_object($group_obj = ilObjectFactory::getInstanceByRefId($ref_id, false))) {
                 $grp_members = $group_obj->getGroupMemberData($group_obj->getGroupMemberIds());
                 foreach ($grp_members as $member) {
                     $tmp_usr = new ilObjUser($member['id']);
                     if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) {
                         unset($tmp_usr);
                         continue;
                     }
                     unset($tmp_usr);
                     $fullname = "";
                     if (in_array(ilObjUser::_lookupPref($member['id'], 'public_profile'), array("g", 'y'))) {
                         $fullname = $member['lastname'] . ', ' . $member['firstname'];
                     }
                     $rowData = array('members_id' => $member["id"], 'members_login' => $member["login"], 'members_name' => $fullname, 'members_crs_grp' => $group_obj->getTitle(), 'members_in_addressbook' => $this->abook->checkEntryByLogin($member["login"]) ? $lng->txt("yes") : $lng->txt("no"), 'search_grp' => $grp_id);
                     $tableData[] = $rowData;
                 }
             }
         }
         $table->setData($tableData);
         if (count($tableData)) {
             $searchTpl->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 course members
  */
 public function showMembers()
 {
     global $lng, $ilUser, $ilObjDataCache;
     include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
     if ($_GET["search_crs"] != "") {
         $_POST["search_crs"] = explode(",", $_GET["search_crs"]);
         $_GET["search_crs"] = "";
     } else {
         if ($_SESSION["search_crs"] != "") {
             $_POST["search_crs"] = explode(",", $_SESSION["search_crs"]);
             $_SESSION["search_crs"] = "";
         }
     }
     if (!is_array($_POST["search_crs"]) || count($_POST["search_crs"]) == 0) {
         ilUtil::sendInfo($lng->txt("mail_select_course"));
         $this->showMyCourses();
     } else {
         foreach ($_POST['search_crs'] as $crs_id) {
             $oTmpCrs = ilObjectFactory::getInstanceByObjId($crs_id);
             if ($oTmpCrs->getShowMembers() == $oTmpCrs->SHOW_MEMBERS_DISABLED) {
                 unset($_POST['search_crs']);
                 ilUtil::sendInfo($lng->txt('mail_crs_list_members_not_available_for_at_least_one_crs'));
                 return $this->showMyCourses();
             }
             unset($oTmpCrs);
         }
         $this->tpl->setTitle($this->lng->txt("mail_addressbook"));
         $this->ctrl->setParameter($this, "view", "crs_members");
         if ($_GET["ref"] != "") {
             $this->ctrl->setParameter($this, "ref", $_GET["ref"]);
         }
         if (is_array($_POST["search_crs"])) {
             $this->ctrl->setParameter($this, "search_crs", implode(",", $_POST["search_crs"]));
         }
         $this->tpl->setVariable("ACTION", $this->ctrl->getFormAction($this));
         $this->ctrl->clearParameters($this);
         $lng->loadLanguageModule('crs');
         include_once 'Services/Contact/classes/class.ilMailSearchCoursesMembersTableGUI.php';
         $context = $_GET["ref"] ? $_GET["ref"] : "mail";
         $table = new ilMailSearchCoursesMembersTableGUI($this, 'crs', $context);
         $table->setId('show_crs_mmbrs_tbl');
         $tableData = array();
         $searchTpl = new ilTemplate('tpl.mail_search_template.html', true, true, 'Services/Contact');
         foreach ($_POST["search_crs"] as $crs_id) {
             $members_obj = ilCourseParticipants::_getinstanceByObjId($crs_id);
             $tmp_members = $members_obj->getParticipants();
             $course_members = ilUtil::_sortIds($tmp_members, 'usr_data', 'lastname', 'usr_id');
             foreach ($course_members as $member) {
                 $tmp_usr = new ilObjUser($member);
                 if ($tmp_usr->checkTimeLimit() == false || $tmp_usr->getActive() == false) {
                     unset($tmp_usr);
                     continue;
                 }
                 unset($tmp_usr);
                 $name = ilObjUser::_lookupName($member);
                 $login = ilObjUser::_lookupLogin($member);
                 $fullname = "";
                 if (in_array(ilObjUser::_lookupPref($member, 'public_profile'), array("g", 'y'))) {
                     $fullname = $name['lastname'] . ', ' . $name['firstname'];
                 }
                 $rowData = array('members_id' => $member, 'members_login' => $login, 'members_name' => $fullname, 'members_crs_grp' => $ilObjDataCache->lookupTitle($crs_id), 'members_in_addressbook' => $this->abook->checkEntryByLogin($login) ? $lng->txt("yes") : $lng->txt("no"), 'search_crs' => $crs_id);
                 $tableData[] = $rowData;
             }
         }
         $table->setData($tableData);
         if (count($tableData)) {
             $searchTpl->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();
         }
     }
 }