ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilMStListUsersTableGUI.php
Go to the documentation of this file.
1<?php
2
9{
10
14 protected $filter = array();
18 protected $access;
19
20
26 {
27 global $DIC;
28
29 $this->access = ilMyStaffAccess::getInstance();
30
31 $this->setPrefix('myst_lu');
32 $this->setFormName('myst_lu');
33 $this->setId('myst_lu');
34
35 parent::__construct($parent_obj, $parent_cmd, '');
36
37 $this->setRowTemplate('tpl.list_users_row.html', "Services/MyStaff");
38 $this->setFormAction($DIC->ctrl()->getFormAction($parent_obj));
39 $this->setDefaultOrderDirection('desc');
40
41 $this->setShowRowsSelector(true);
42
43 $this->setEnableTitle(true);
44 $this->setDisableFilterHiding(true);
45 $this->setEnableNumInfo(true);
46
47 $this->setExportFormats(array( self::EXPORT_EXCEL, self::EXPORT_CSV ));
48
49 $this->setFilterCols(4);
50 $this->initFilter();
51 $this->addColumns();
52
53 $this->parseData();
54 }
55
56
60 protected function parseData()
61 {
62 global $DIC;
63
64 $this->setExternalSorting(true);
65 $this->setExternalSegmentation(true);
66 $this->setDefaultOrderField('lastname');
67
68 $this->determineLimit();
70
71 //Permission Filter
72 $arr_usr_id = $this->access->getUsersForUser($DIC->user()->getId());
73
74 $options = array(
75 'filters' => $this->filter,
76 'limit' => array(),
77 'count' => true,
78 'sort' => array(
79 'field' => $this->getOrderField(),
80 'direction' => $this->getOrderDirection(),
81 ),
82 );
83 $count = ilMStListUsers::getData($arr_usr_id, $options);
84 $options['limit'] = array(
85 'start' => intval($this->getOffset()),
86 'end' => intval($this->getLimit()),
87 );
88 $options['count'] = false;
90
91 $this->setMaxCount($count);
92 $this->setData($data);
93 }
94
95
99 public function initFilter()
100 {
101 global $DIC;
102
103 // User name, login, email filter
104 $item = new ilTextInputGUI($DIC->language()->txt("login") . "/" . $DIC->language()->txt("email") . "/" . $DIC->language()
105 ->txt("name"), "user");
106 //$item->setDataSource($DIC->ctrl()->getLinkTarget($this->getParentObject(),"addUserAutoComplete", "", true));
107 //$item->setSize(20);
108 //$item->setSubmitFormOnEnter(true);
109 $this->addFilterItem($item);
110 $item->readFromSession();
111 $this->filter['user'] = $item->getValue();
112
113 if (ilUserSearchOptions::_isEnabled('org_units')) {
116 $nodes = $tree->getAllChildren($root);
118 $options[0] = $DIC->language()->txt('mst_opt_all');
119 foreach ($paths as $org_ref_id => $path) {
120 $options[$org_ref_id] = $path;
121 }
122 $item = new ilSelectInputGUI($DIC->language()->txt('obj_orgu'), 'org_unit');
123 $item->setOptions($options);
124 $item->addCustomAttribute("style='width:100%'");
125 $this->addFilterItem($item);
126 $item->readFromSession();
127 $this->filter['org_unit'] = $item->getValue();
128 }
129 }
130
131
135 public function getSelectableColumns()
136 {
137 $arr_fields_without_table_sort = array(
138 'org_units',
139 'interests_general',
140 'interests_help_offered',
141 'interests_help_looking',
142 );
143 $cols = array();
145 $cols[$key] = $col;
146 if (!in_array($key, $arr_fields_without_table_sort)) {
147 $cols[$key]['sort_field'] = $key;
148 }
149 }
150
151 return $cols;
152 }
153
154
158 private function addColumns()
159 {
160 global $DIC;
161
162 //User Profile Picture
163 if (!$this->getExportMode()) {
164 $this->addColumn('');
165 }
166
167 foreach ($this->getSelectableColumns() as $k => $v) {
168 if ($this->isColumnSelected($k)) {
169 if (isset($v['sort_field'])) {
170 $sort = $v['sort_field'];
171 } else {
172 $sort = null;
173 }
174 $this->addColumn($v['txt'], $sort, $v['width']);
175 }
176 }
177 //Actions
178 if (!$this->getExportMode()) {
179 $this->addColumn($DIC->language()->txt('actions'));
180 }
181 }
182
183
187 public function fillRow($my_staff_user)
188 {
189 global $DIC;
190
191 $propGetter = Closure::bind(function ($prop) {
192 return $this->$prop;
193 }, $my_staff_user, $my_staff_user);
194
195 //Avatar
196 $this->tpl->setCurrentBlock('user_profile_picture');
197 $f = $DIC->ui()->factory();
198 $renderer = $DIC->ui()->renderer();
199 $il_obj_user = $my_staff_user->returnIlUserObj();
200 $avatar = $f->image()->standard($il_obj_user->getPersonalPicturePath('small'), $il_obj_user->getPublicName());
201 $this->tpl->setVariable('user_profile_picture', $renderer->render($avatar));
202 $this->tpl->parseCurrentBlock();
203
204 foreach ($this->getSelectableColumns() as $k => $v) {
205 if ($this->isColumnSelected($k)) {
206 switch ($k) {
207 case 'org_units':
208 $this->tpl->setCurrentBlock('td');
209 $this->tpl->setVariable('VALUE', strval(ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($my_staff_user->getUsrId())));
210 $this->tpl->parseCurrentBlock();
211 break;
212 case 'gender':
213 $this->tpl->setCurrentBlock('td');
214 $this->tpl->setVariable('VALUE', $DIC->language()->txt('gender_' . $my_staff_user->getGender()));
215 $this->tpl->parseCurrentBlock();
216 break;
217 case 'interests_general':
218 $this->tpl->setCurrentBlock('td');
219 $this->tpl->setVariable('VALUE', ($my_staff_user->returnIlUserObj()
220 ->getGeneralInterestsAsText() ? $my_staff_user->returnIlUserObj()->getGeneralInterestsAsText() : '&nbsp;'));
221 $this->tpl->parseCurrentBlock();
222 break;
223 case 'interests_help_offered':
224 $this->tpl->setCurrentBlock('td');
225 $this->tpl->setVariable('VALUE', ($my_staff_user->returnIlUserObj()
226 ->getOfferingHelpAsText() ? $my_staff_user->returnIlUserObj()->getOfferingHelpAsText() : '&nbsp;'));
227 $this->tpl->parseCurrentBlock();
228 break;
229 case 'interests_help_looking':
230 $this->tpl->setCurrentBlock('td');
231 $this->tpl->setVariable('VALUE', ($my_staff_user->returnIlUserObj()
232 ->getLookingForHelpAsText() ? $my_staff_user->returnIlUserObj()->getLookingForHelpAsText() : '&nbsp;'));
233 $this->tpl->parseCurrentBlock();
234 break;
235 default:
236 if ($propGetter($k) !== null) {
237 $this->tpl->setCurrentBlock('td');
238 $this->tpl->setVariable('VALUE', (is_array($propGetter($k)) ? implode(", ", $propGetter($k)) : $propGetter($k)));
239 $this->tpl->parseCurrentBlock();
240 } else {
241 $this->tpl->setCurrentBlock('td');
242 $this->tpl->setVariable('VALUE', '&nbsp;');
243 $this->tpl->parseCurrentBlock();
244 }
245 break;
246 }
247 }
248 }
249
250 $actions = new ilAdvancedSelectionListGUI();
251 $actions->setListTitle($DIC->language()->txt("actions"));
252 $actions->setAsynch(true);
253 $actions->setId($my_staff_user->getUsrId());
254
255 $DIC->ctrl()->setParameterByClass(ilMStListUsersGUI::class, 'mst_lus_usr_id', $my_staff_user->getUsrId());
256
257 $actions->setAsynchUrl(str_replace("\\", "\\\\", $DIC->ctrl()
258 ->getLinkTarget($this->parent_obj, ilMStListUsersGUI::CMD_GET_ACTIONS, "", true)));
259 $this->tpl->setVariable('ACTIONS', $actions->getHTML());
260 $this->tpl->parseCurrentBlock();
261 }
262
263
269 private function getProfileBackUrl()
270 {
271 global $DIC;
272
273 return rawurlencode($DIC->ctrl()->getLinkTargetByClass(strtolower(ilMyStaffGUI::class), ilMyStaffGUI::CMD_INDEX));
274 }
275
276
282 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $my_staff_user)
283 {
284 $col = 0;
285 foreach ($this->getFieldValuesForExport($my_staff_user) as $k => $v) {
286 $a_excel->setCell($a_row, $col, $v);
287 $col++;
288 }
289 }
290
291
296 protected function fillRowCSV($a_csv, $my_staff_user)
297 {
298 foreach ($this->getFieldValuesForExport($my_staff_user) as $k => $v) {
299 $a_csv->addColumn($v);
300 }
301 $a_csv->addRow();
302 }
303
304
310 protected function getFieldValuesForExport(ilMStListUser $my_staff_user)
311 {
312 global $DIC;
313
314 $propGetter = Closure::bind(function ($prop) {
315 return $this->$prop;
316 }, $my_staff_user, $my_staff_user);
317
318 $field_values = array();
319
320 foreach ($this->getSelectedColumns() as $k => $v) {
321 switch ($k) {
322 case 'org_units':
323 $field_values[$k] = ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($my_staff_user->getUsrId());
324 break;
325 case 'gender':
326 $field_values[$k] = $DIC->language()->txt('gender_' . $my_staff_user->getGender());
327 break;
328 case 'interests_general':
329 $field_values[$k] = $my_staff_user->returnIlUserObj()->getGeneralInterestsAsText();
330 break;
331 case 'interests_help_offered':
332 $field_values[$k] = $my_staff_user->returnIlUserObj()->getOfferingHelpAsText();
333 break;
334 case 'interests_help_looking':
335 $field_values[$k] = $my_staff_user->returnIlUserObj()->getLookingForHelpAsText();
336 break;
337 default:
338 $field_values[$k] = strip_tags($propGetter($k));
339 break;
340 }
341 }
342
343 return $field_values;
344 }
345}
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
Class ilMStListUser.
Class ilMStListUsersGUI.
Class ilMStListUsersTableGUI.
getFieldValuesForExport(ilMStListUser $my_staff_user)
getProfileBackUrl()
Get profile back url.
fillRowCSV($a_csv, $my_staff_user)
fillRowExcel(ilExcel $a_excel, &$a_row, $my_staff_user)
__construct(ilMStListUsersGUI $parent_obj, $parent_cmd=ilMStListUsersGUI::CMD_INDEX)
static getData(array $arr_usr_ids=array(), array $options=array())
static getRootOrgRefId()
static getTextRepresentationOfOrgUnits($sort_by_title=true)
Get ref id path array.
This class represents a selection list property in a property form.
Class ilTable2GUI.
getExportMode()
Was export activated?
getSelectedColumns()
Get selected columns.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
setExternalSorting($a_val)
Set external sorting.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setExportFormats(array $formats)
Set available export formats.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
getOffset()
Get offset.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFilterCols($a_val)
Set filter columns.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
determineLimit()
Determine the limit.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
isColumnSelected($a_col)
Is given column selected?
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
This class represents a text property in a property form.
static getSelectableColumnInfo($a_admin=false)
Get info of searchable fields for selectable columns in table gui.
$key
Definition: croninfo.php:18
if($argc< 2) $paths
Definition: migrateto20.php:44
$root
Definition: sabredav.php:45
global $DIC
Definition: saml.php:7
$cols
Definition: xhr_table.php:11