ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMailSearchCoursesMembersTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Table/classes/class.ilTable2GUI.php';
5require_once 'Services/Contact/BuddySystem/classes/class.ilBuddyList.php';
6require_once 'Services/Utilities/classes/class.ilStr.php';
7require_once 'Services/Contact/BuddySystem/classes/class.ilBuddySystem.php';
8
18{
22 protected $lng;
23
27 protected $ctrl;
28
32 protected $user;
33
34 protected $parentObject;
35 protected $mode;
46 public function __construct($a_parent_obj, $type = 'crs', $context = 'mail')
47 {
48 global $DIC;
49
50 $this->ctrl = $DIC['ilCtrl'];
51 $this->lng = $DIC['lng'];
52 $this->user = $DIC['ilUser'];
53
54 $this->setId($type. 'table_members');
55 parent::__construct($a_parent_obj, 'showMembers');
56
57 $this->context = $context;
58 if($this->context == 'mail')
59 {
60 // check if current user may send mails
61 include_once "Services/Mail/classes/class.ilMail.php";
62 $mail = new ilMail($GLOBALS['DIC']['ilUser']->getId());
63 $this->mailing_allowed = $DIC->rbac()->system()->checkAccess('internal_mail',$mail->getMailObjectReferenceId());
64 }
65
66 $this->lng->loadLanguageModule('crs');
67 $this->lng->loadLanguageModule('buddysystem');
68 $this->parentObject = $a_parent_obj;
69 $mode = array();
70 if ($type == 'crs')
71 {
72 $mode["checkbox"] = 'search_crs';
73 $mode["short"] = 'crs';
74 $mode["long"] = 'course';
75 $mode["lng_type"] = $this->lng->txt('course');
76 $mode["view"] = "crs_members";
77 }
78 else if ($type == 'grp')
79 {
80 $mode["checkbox"] = 'search_grp';
81 $mode["short"] = 'grp';
82 $mode["long"] = 'group';
83 $mode["lng_type"] = $this->lng->txt('group');
84 $mode["view"] = "grp_members";
85 }
86 $this->setTitle($this->lng->txt('members'));
87 $this->mode = $mode;
88 $this->ctrl->setParameter($a_parent_obj, 'view', $mode['view']);
89 if ($_GET['ref'] != '')
90 $this->ctrl->setParameter($a_parent_obj, 'ref', $_GET['ref']);
91 if (is_array($_POST[$mode["checkbox"]]))
92 $this->ctrl->setParameter($a_parent_obj, $mode["checkbox"], implode(',', $_POST[$mode["checkbox"]]));
93
94 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
95 $this->ctrl->clearParameters($a_parent_obj);
96
97 $this->setRowTemplate('tpl.mail_search_courses_members_row.html', 'Services/Contact');
98
99 // setup columns
100 $this->addColumn('', '', '1%', true);
101 $this->addColumn($this->lng->txt('login'), 'members_login', '22%');
102 $this->addColumn($this->lng->txt('name'), 'members_name', '22%');
103 $this->addColumn($this->lng->txt($mode['long']), 'members_crs_grp', '22%');
104 if(ilBuddySystem::getInstance()->isEnabled())
105 {
106 $this->addColumn($this->lng->txt('buddy_tbl_filter_state'), 'status', '23%');
107 }
108 $this->addColumn($this->lng->txt('actions'), '', '10%');
109
110 if($this->context == "mail")
111 {
112 if($this->mailing_allowed)
113 {
114 $this->setSelectAllCheckbox('search_members[]');
115 $this->addMultiCommand('mail', $this->lng->txt('mail_members'));
116 }
117 }
118 else
119 {
120 $this->setSelectAllCheckbox('search_members[]');
121 $this->lng->loadLanguageModule("wsp");
122 $this->addMultiCommand('share', $this->lng->txt("wsp_share_with_members"));
123 }
124 $this->lng->loadLanguageModule('buddysystem');
125
126 $this->addCommandButton('cancel', $this->lng->txt('cancel'));
127 }
128
136 public function fillRow($a_set)
137 {
138 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
139 $current_selection_list = new ilAdvancedSelectionListGUI();
140 $current_selection_list->setListTitle($this->lng->txt("actions"));
141 $current_selection_list->setId("act_".md5($a_set['members_id'].'::'.$a_set['search_' . $this->mode['short']]));
142
143 $this->ctrl->setParameter($this->parentObject, 'search_members', $a_set['members_id']);
144 $this->ctrl->setParameter($this->parentObject, 'search_' . $this->mode['short'],
145 is_array($_REQUEST['search_' . $this->mode['short']]) ?
146 implode(',', array_filter(array_map('intval', $_REQUEST['search_' . $this->mode['short']]))) :
147 (int)$_REQUEST['search_' . $this->mode['short']]
148 );
149 $this->ctrl->setParameter($this->parentObject, 'view', $this->mode['view']);
150
151 $action_html = '';
152 if($this->context == "mail")
153 {
154 if($this->mailing_allowed)
155 {
156 $current_selection_list->addItem($this->lng->txt("mail_member"), '', $this->ctrl->getLinkTarget($this->parentObject, "mail"));
157 }
158 }
159 else
160 {
161 $current_selection_list->addItem($this->lng->txt("wsp_share_with_members"), '', $this->ctrl->getLinkTarget($this->parentObject, "share"));
162 }
163
164 if($this->context == 'mail' && ilBuddySystem::getInstance()->isEnabled())
165 {
166 $relation = ilBuddyList::getInstanceByGlobalUser()->getRelationByUserId($a_set['members_id']);
167 if(
168 $a_set['members_id'] != $this->user->getId() &&
169 $relation->isUnlinked() &&
170 ilUtil::yn2tf(ilObjUser::_lookupPref($a_set['members_id'], 'bs_allow_to_contact_me'))
171 )
172 {
173 $this->ctrl->setParameterByClass('ilBuddySystemGUI', 'user_id', $a_set['members_id']);
174 $current_selection_list->addItem($this->lng->txt('buddy_bs_btn_txt_unlinked_a'), '', $this->ctrl->getLinkTargetByClass('ilBuddySystemGUI', 'request'));
175 }
176 }
177
178 if($current_selection_list->getItems())
179 {
180 $action_html = $current_selection_list->getHTML();
181 }
182 $this->tpl->setVariable(strtoupper('CURRENT_ACTION_LIST'), $action_html);
183
184 foreach($a_set as $key => $value)
185 {
186 $this->tpl->setVariable(strtoupper($key), $value);
187 }
188 }
189}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static getInstanceByGlobalUser()
__construct($a_parent_obj, $type='crs', $context='mail')
Constructor.
This class handles base functions for mail handling.
static _lookupPref($a_usr_id, $a_keyword)
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
getId()
Get element id.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static yn2tf($a_yn)
convert "y"/"n" to true/false
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $DIC