ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilMStListCoursesTableGUI.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_lc');
32 $this->setFormName('myst_lc');
33 $this->setId('myst_lc');
34
35 parent::__construct($parent_obj, $parent_cmd, '');
36
37 $this->setRowTemplate('tpl.list_courses_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(5);
50 $this->initFilter();
51
52 $this->addColumns();
53
54 $this->parseData();
55 }
56
57
61 protected function parseData()
62 {
63 global $DIC;
64
65 $this->setExternalSorting(true);
66 $this->setExternalSegmentation(true);
67 $this->setDefaultOrderField('crs_title');
68
69 $this->determineLimit();
71
72 $options = array(
73 'filters' => $this->filter,
74 'limit' => array(),
75 'count' => true,
76 'sort' => array(
77 'field' => $this->getOrderField(),
78 'direction' => $this->getOrderDirection(),
79 ),
80 );
81
82 $all_users_for_user = $this->access->getUsersForUser($DIC->user()->getId());
83
84 $count = ilMStListCourses::getData($all_users_for_user, $options);
85 $options['limit'] = array(
86 'start' => intval($this->getOffset()),
87 'end' => intval($this->getLimit()),
88 );
89 $options['count'] = false;
90 $data = ilMStListCourses::getData($all_users_for_user, $options);
91 $this->setMaxCount($count);
92 $this->setData($data);
93 }
94
95
99 public function initFilter()
100 {
101 global $DIC;
102
103 $item = new ilTextInputGUI($DIC->language()->txt("crs_title"), "crs_title");
104 $this->addFilterItem($item);
105 $item->readFromSession();
106 $this->filter['crs_title'] = $item->getValue();
107
108 // course members
109 $item = new ilRepositorySelectorInputGUI($DIC->language()->txt("usr_filter_coursemember"), "course");
110 $item->setParent($this->getParentObject());
111 $item->setSelectText($DIC->language()->txt("mst_select_course"));
112 $item->setHeaderMessage($DIC->language()->txt("mst_please_select_course"));
113 $item->setClickableTypes(array( ilMyStaffAccess::DEFAULT_CONTEXT ));
114 $this->addFilterItem($item);
115 $item->readFromSession();
116 $item->setParent($this->getParentObject());
117 $this->filter["course"] = $item->getValue();
118
119 //membership status
120 $item = new ilSelectInputGUI($DIC->language()->txt('member_status'), 'memb_status');
121 $item->setOptions(array(
122 "" => $DIC->language()->txt("mst_opt_all"),
123 ilMStListCourse::MEMBERSHIP_STATUS_REQUESTED => $DIC->language()->txt('mst_memb_status_requested'),
124 ilMStListCourse::MEMBERSHIP_STATUS_WAITINGLIST => $DIC->language()->txt('mst_memb_status_waitinglist'),
125 ilMStListCourse::MEMBERSHIP_STATUS_REGISTERED => $DIC->language()->txt('mst_memb_status_registered'),
126 ));
127 $this->addFilterItem($item);
128 $item->readFromSession();
129 $this->filter["memb_status"] = $item->getValue();
130
131 if (ilObjUserTracking::_enabledLearningProgress() && $this->access->hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser()) {
132 //learning progress status
133 $item = new ilSelectInputGUI($DIC->language()->txt('learning_progress'), 'lp_status');
134 //+1 because LP_STATUS_NOT_ATTEMPTED_NUM is 0.
135 $item->setOptions(array(
136 "" => $DIC->language()->txt("mst_opt_all"),
141 ));
142 $this->addFilterItem($item);
143 $item->readFromSession();
144 $this->filter["lp_status"] = $item->getValue();
145 if ($this->filter["lp_status"]) {
146 $this->filter["lp_status"] = $this->filter["lp_status"] - 1;
147 }
148 }
149
150 //user
151 $item = new ilTextInputGUI($DIC->language()->txt("login") . "/" . $DIC->language()->txt("email") . "/" . $DIC->language()
152 ->txt("name"), "user");
153
154 $this->addFilterItem($item);
155 $item->readFromSession();
156 $this->filter['user'] = $item->getValue();
157
158 if (ilUserSearchOptions::_isEnabled('org_units')) {
160 $options[0] = $DIC->language()->txt('mst_opt_all');
161 foreach ($paths as $org_ref_id => $path) {
162 $options[$org_ref_id] = $path;
163 }
164 $item = new ilSelectInputGUI($DIC->language()->txt('obj_orgu'), 'org_unit');
165 $item->setOptions($options);
166 $this->addFilterItem($item);
167 $item->readFromSession();
168 $this->filter['org_unit'] = $item->getValue();
169 }
170 }
171
172
176 public function getSelectableColumns()
177 {
178 global $DIC;
179
180 $cols = array();
181
182 $arr_searchable_user_columns = ilUserSearchOptions::getSelectableColumnInfo();
183
184 $cols['crs_title'] = array(
185 'txt' => $DIC->language()->txt('crs_title'),
186 'default' => true,
187 'width' => 'auto',
188 'sort_field' => 'crs_title',
189 );
190 $cols['usr_reg_status'] = array(
191 'txt' => $DIC->language()->txt('member_status'),
192 'default' => true,
193 'width' => 'auto',
194 'sort_field' => 'reg_status',
195 );
196 if (ilObjUserTracking::_enabledLearningProgress() && $this->access->hasCurrentUserAccessToCourseLearningProgressForAtLeastOneUser()) {
197 $cols['usr_lp_status'] = array(
198 'txt' => $DIC->language()->txt('learning_progress'),
199 'default' => true,
200 'width' => 'auto',
201 'sort_field' => 'lp_status',
202 );
203 }
204
205 if ($arr_searchable_user_columns['login']) {
206 $cols['usr_login'] = array(
207 'txt' => $DIC->language()->txt('login'),
208 'default' => true,
209 'width' => 'auto',
210 'sort_field' => 'usr_login',
211 );
212 }
213 if ($arr_searchable_user_columns['firstname']) {
214 $cols['usr_firstname'] = array(
215 'txt' => $DIC->language()->txt('firstname'),
216 'default' => true,
217 'width' => 'auto',
218 'sort_field' => 'usr_firstname',
219 );
220 }
221 if ($arr_searchable_user_columns['lastname']) {
222 $cols['usr_lastname'] = array(
223 'txt' => $DIC->language()->txt('lastname'),
224 'default' => true,
225 'width' => 'auto',
226 'sort_field' => 'usr_lastname',
227 );
228 }
229
230 if ($arr_searchable_user_columns['email']) {
231 $cols['usr_email'] = array(
232 'txt' => $DIC->language()->txt('email'),
233 'default' => true,
234 'width' => 'auto',
235 'sort_field' => 'usr_email',
236 );
237 }
238
239 if ($arr_searchable_user_columns['org_units']) {
240 $cols['usr_assinged_orgus'] = array(
241 'txt' => $DIC->language()->txt('objs_orgu'),
242 'default' => true,
243 'width' => 'auto',
244 );
245 }
246
247 return $cols;
248 }
249
250
254 private function addColumns()
255 {
256 global $DIC;
257
258 foreach ($this->getSelectableColumns() as $k => $v) {
259 if ($this->isColumnSelected($k)) {
260 if (isset($v['sort_field'])) {
261 $sort = $v['sort_field'];
262 } else {
263 $sort = null;
264 }
265 $this->addColumn($v['txt'], $sort, $v['width']);
266 }
267 }
268
269 //Actions
270 if (!$this->getExportMode()) {
271 $this->addColumn($DIC->language()->txt('actions'));
272 }
273 }
274
275
279 public function fillRow($my_staff_course)
280 {
281 global $DIC;
282
283 $propGetter = Closure::bind(function ($prop) {
284 return $this->$prop;
285 }, $my_staff_course, $my_staff_course);
286
287 foreach ($this->getSelectableColumns() as $k => $v) {
288 if ($this->isColumnSelected($k)) {
289 switch ($k) {
290 case 'usr_assinged_orgus':
291 $this->tpl->setCurrentBlock('td');
292 $this->tpl->setVariable('VALUE', strval(ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($my_staff_course->getUsrId())));
293 $this->tpl->parseCurrentBlock();
294 break;
295 case 'usr_reg_status':
296 $this->tpl->setCurrentBlock('td');
297 $this->tpl->setVariable('VALUE', ilMStListCourse::getMembershipStatusText($my_staff_course->getUsrRegStatus()));
298 $this->tpl->parseCurrentBlock();
299 break;
300 case 'usr_lp_status':
301 $this->tpl->setCurrentBlock('td');
302 $this->tpl->setVariable('VALUE', ilMyStaffGUI::getUserLpStatusAsHtml($my_staff_course));
303 $this->tpl->parseCurrentBlock();
304 break;
305 default:
306 if ($propGetter($k) !== null) {
307 $this->tpl->setCurrentBlock('td');
308 $this->tpl->setVariable('VALUE', (is_array($propGetter($k)) ? implode(", ", $propGetter($k)) : $propGetter($k)));
309 $this->tpl->parseCurrentBlock();
310 } else {
311 $this->tpl->setCurrentBlock('td');
312 $this->tpl->setVariable('VALUE', '&nbsp;');
313 $this->tpl->parseCurrentBlock();
314 }
315 break;
316 }
317 }
318 }
319
320 $actions = new ilAdvancedSelectionListGUI();
321 $actions->setListTitle($DIC->language()->txt("actions"));
322 $actions->setAsynch(true);
323 $actions->setId($my_staff_course->getUsrId() . "-" . $my_staff_course->getCrsRefId());
324
325 $DIC->ctrl()->setParameterByClass(ilMStListCoursesGUI::class, 'mst_lco_usr_id', $my_staff_course->getUsrId());
326 $DIC->ctrl()->setParameterByClass(ilMStListCoursesGUI::class, 'mst_lco_crs_ref_id', $my_staff_course->getCrsRefId());
327
328 $actions->setAsynchUrl(str_replace("\\", "\\\\", $DIC->ctrl()
329 ->getLinkTarget($this->parent_obj, ilMStListCoursesGUI::CMD_GET_ACTIONS, "", true)));
330 $this->tpl->setVariable('ACTIONS', $actions->getHTML());
331 $this->tpl->parseCurrentBlock();
332 }
333
334
340 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $my_staff_course)
341 {
342 $col = 0;
343 foreach ($this->getFieldValuesForExport($my_staff_course) as $k => $v) {
344 $a_excel->setCell($a_row, $col, $v);
345 $col++;
346 }
347 }
348
349
354 protected function fillRowCSV($a_csv, $my_staff_course)
355 {
356 foreach ($this->getFieldValuesForExport($my_staff_course) as $k => $v) {
357 $a_csv->addColumn($v);
358 }
359 $a_csv->addRow();
360 }
361
362
368 protected function getFieldValuesForExport(ilMStListCourse $my_staff_course)
369 {
370 $propGetter = Closure::bind(function ($prop) {
371 return $this->$prop;
372 }, $my_staff_course, $my_staff_course);
373
374 $field_values = array();
375 foreach ($this->getSelectedColumns() as $k => $v) {
376 switch ($k) {
377 case 'usr_assinged_orgus':
378 $field_values[$k] = ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits($my_staff_course->getUsrId());
379 break;
380 case 'usr_reg_status':
381 $field_values[$k] = ilMStListCourse::getMembershipStatusText($my_staff_course->getUsrRegStatus());
382 break;
383 case 'usr_lp_status':
384 $field_values[$k] = ilMyStaffGUI::getUserLpStatusAsText($my_staff_course);
385 break;
386 default:
387 $field_values[$k] = strip_tags($propGetter($k));
388 break;
389 }
390 }
391
392 return $field_values;
393 }
394}
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
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.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
Class ilMStListCourse.
static getMembershipStatusText($status)
Class ilMStListCoursesGUI.
Class ilMStListCoursesTableGUI.
getFieldValuesForExport(ilMStListCourse $my_staff_course)
fillRowExcel(ilExcel $a_excel, &$a_row, $my_staff_course)
__construct(ilMStListCoursesGUI $parent_obj, $parent_cmd=ilMStListCoursesGUI::CMD_INDEX)
static getData(array $arr_usr_ids=array(), array $options=array())
static getUserLpStatusAsText(ilMStListCourse $my_staff_course)
static getUserLpStatusAsHtml(ilMStListCourse $my_staff_course)
static _enabledLearningProgress()
check wether learing progress is enabled or not
static getTextRepresentationOfOrgUnits($sort_by_title=true)
Get ref id path array.
This class represents a repository selector in a property form.
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.
getParentObject()
Get parent object.
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.
global $DIC
Definition: saml.php:7
$cols
Definition: xhr_table.php:11