ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilWaitingListTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 
26 
36 {
37  protected $waiting_list = null;
38  protected $wait = array();
39  protected $wait_user_ids = array();
40 
41  protected static $all_columns = null;
42 
50  public function __construct($a_parent_obj,$waiting_list,$show_content = true)
51  {
52  global $lng,$ilCtrl;
53 
54  $this->lng = $lng;
55  $this->lng->loadLanguageModule('grp');
56  $this->lng->loadLanguageModule('crs');
57  $this->ctrl = $ilCtrl;
58 
59  $this->setId('crs_wait_'. $a_parent_obj->object->getId());
60  parent::__construct($a_parent_obj,'members');
61 
62  $this->setFormName('waiting');
63  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj,'members'));
64 
65  $this->addColumn('','f',"1");
66  $this->addColumn($this->lng->txt('name'),'lastname','20%');
67 
68  $all_cols = $this->getSelectableColumns();
69  foreach($this->getSelectedColumns() as $col)
70  {
71  $this->addColumn($all_cols[$col]['txt'], $col);
72  }
73 
74  $this->addColumn($this->lng->txt('application_date'),'sub_time',"10%");
75  $this->addColumn('','mail','10%');
76 
77  $this->addMultiCommand('assignFromWaitingList',$this->lng->txt('assign'));
78  $this->addMultiCommand('refuseFromList',$this->lng->txt('refuse'));
79  $this->addMultiCommand('sendMailToSelectedUsers',$this->lng->txt('crs_mem_send_mail'));
80 
81  $this->setPrefix('waiting');
82  $this->setSelectAllCheckbox('waiting');
83  $this->setRowTemplate("tpl.show_waiting_list_row.html","Services/Membership");
84 
85  if($show_content)
86  {
87  $this->enable('sort');
88  $this->enable('header');
89  $this->enable('numinfo');
90  $this->enable('select_all');
91  }
92  else
93  {
94  $this->disable('content');
95  $this->disable('header');
96  $this->disable('footer');
97  $this->disable('numinfo');
98  $this->disable('select_all');
99  }
100 
101  $this->waiting_list = $waiting_list;
102  }
103 
111  public function setUsers($a_sub)
112  {
113  $this->wait = $a_sub;
114  foreach($this->wait as $usr_id => $usr_data)
115  {
116  $this->wait_user_ids[] = $usr_id;
117  }
118 
119  $this->readUserData();
120  }
121 
126  public function getSelectableColumns()
127  {
128  if(self::$all_columns)
129  {
130  return self::$all_columns;
131  }
132 
133  include_once './Services/PrivacySecurity/classes/class.ilExportFieldsInfo.php';
134  $ef = ilExportFieldsInfo::_getInstanceByType($this->getParentObject()->object->getType());
135  self::$all_columns = $ef->getSelectableFieldsInfo($this->getParentObject()->object->getId());
136  return self::$all_columns;
137  }
138 
139 
147  public function fillRow($a_set)
148  {
149  global $ilUser;
150 
151  include_once('./Services/Calendar/classes/class.ilDateTime.php');
152  include_once './Modules/Course/classes/class.ilObjCourseGrouping.php';
153 
154  if(!ilObjCourseGrouping::_checkGroupingDependencies($this->getParentObject()->object,$a_set['usr_id']) and
156  {
157  $prefix = $this->getParentObject()->object->getType();
158  $this->tpl->setVariable('ALERT_MSG',
159  sprintf($this->lng->txt($prefix.'_lim_assigned'),
160  ilObject::_lookupTitle(current($ids))
161  ));
162 
163  }
164 
165  $this->tpl->setVariable('VAL_ID',$a_set['usr_id']);
166  $this->tpl->setVariable('VAL_NAME',$a_set['lastname'].', '.$a_set['firstname']);
167 
168  foreach($this->getSelectedColumns() as $field)
169  {
170  switch($field)
171  {
172  case 'gender':
173  $a_set['gender'] = $a_set['gender'] ? $this->lng->txt('gender_' . $a_set['gender']) : '';
174  $this->tpl->setCurrentBlock('custom_fields');
175  $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
176  $this->tpl->parseCurrentBlock();
177  break;
178 
179  case 'birthday':
180  $a_set['birthday'] = $a_set['birthday'] ? ilDatePresentation::formatDate(new ilDate($a_set['birthday'], IL_CAL_DATE)) : $this->lng->txt('no_date');
181  $this->tpl->setCurrentBlock('custom_fields');
182  $this->tpl->setVariable('VAL_CUST', $a_set[$field]);
183  $this->tpl->parseCurrentBlock();
184  break;
185 
186  default:
187  $this->tpl->setCurrentBlock('custom_fields');
188  $this->tpl->setVariable('VAL_CUST', isset($a_set[$field]) ? (string) $a_set[$field] : '');
189  $this->tpl->parseCurrentBlock();
190  break;
191  }
192  }
193 
194  $this->tpl->setVariable('VAL_SUBTIME',ilDatePresentation::formatDate(new ilDateTime($a_set['sub_time'],IL_CAL_UNIX)));
195 
196  #$this->tpl->setVariable('VAL_LOGIN',$a_set['login']);
197 
198  $this->ctrl->setParameterByClass(get_class($this->getParentObject()),'member_id',$a_set['id']);
199  $link = $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()),'sendMailToSelectedUsers');
200  $this->tpl->setVariable('MAIL_LINK',$link);
201  $this->tpl->setVariable('MAIL_TITLE',$this->lng->txt('crs_mem_send_mail'));
202  }
203 
211  public function readUserData()
212  {
213  global $rbacreview;
214 
215  $this->determineOffsetAndOrder();
216 
217  include_once './Services/User/classes/class.ilUserQuery.php';
218 
219  $additional_fields = $this->getSelectedColumns();
220  unset($additional_fields["firstname"]);
221  unset($additional_fields["lastname"]);
222  unset($additional_fields["last_login"]);
223  unset($additional_fields["access_until"]);
224 
225  $udf_ids = $usr_data_fields = $odf_ids = array();
226  foreach($additional_fields as $field)
227  {
228  if(substr($field, 0, 3) == 'udf')
229  {
230  $udf_ids[] = substr($field, 4);
231  continue;
232  }
233  if(substr($field, 0, 3) == 'odf')
234  {
235  $odf_ids[] = substr($field, 4);
236  continue;
237  }
238 
239  $usr_data_fields[] = $field;
240  }
241 
242  $usr_data = ilUserQuery::getUserListData(
243  $this->getOrderField(),
244  $this->getOrderDirection(),
245  $this->getOffset(),
246  $this->getLimit(),
247  '',
248  '',
249  null,
250  false,
251  false,
252  0,
253  0,
254  null,
255  $usr_data_fields,
256  $this->wait_user_ids
257  );
258 
259  foreach((array) $usr_data['set'] as $user)
260  {
261  $usr_ids[] = $user['usr_id'];
262  }
263 
264  // merge course data
265  $course_user_data = $this->getParentObject()->readMemberData($usr_ids,$this->type == 'admin');
266  $a_user_data = array();
267  foreach((array) $usr_data['set'] as $ud)
268  {
269  $a_user_data[$ud['usr_id']] = array_merge($ud,$course_user_data[$ud['usr_id']]);
270  }
271 
272  // Custom user data fields
273  if($udf_ids)
274  {
275  include_once './Services/User/classes/class.ilUserDefinedData.php';
276  $data = ilUserDefinedData::lookupData($usr_ids, $udf_ids);
277  foreach($data as $usr_id => $fields)
278  {
279  if(!$this->checkAcceptance($usr_id))
280  {
281  continue;
282  }
283 
284  foreach($fields as $field_id => $value)
285  {
286  $a_user_data[$usr_id]['udf_' . $field_id] = $value;
287  }
288  }
289  }
290  // Object specific user data fields
291  if($odf_ids)
292  {
293  include_once './Modules/Course/classes/Export/class.ilCourseUserData.php';
294  $data = ilCourseUserData::_getValuesByObjId($this->getParentObject()->object->getId());
295  foreach($data as $usr_id => $fields)
296  {
297  // #7264: as we get data for all course members filter against user data
298  if(!$this->checkAcceptance($usr_id) || !in_array($usr_id, $usr_ids))
299  {
300  continue;
301  }
302 
303  foreach($fields as $field_id => $value)
304  {
305  $a_user_data[$usr_id]['odf_' . $field_id] = $value;
306  }
307  }
308  }
309 
310  foreach($usr_data['set'] as $user)
311  {
312  // Check acceptance
313  if(!$this->checkAcceptance($user['usr_id']))
314  {
315  continue;
316  }
317  // DONE: accepted
318  foreach($usr_data_fields as $field)
319  {
320  $a_user_data[$user['usr_id']][$field] = $user[$field] ? $user[$field] : '';
321  }
322  }
323 
324  // Waiting list subscription
325  foreach($this->wait as $usr_id => $usr_data)
326  {
327  $a_user_data[$usr_id]['sub_time'] = $usr_data['time'];
328  }
329 
330  $this->setMaxCount($usr_data['cnt'] ? $usr_data['cnt'] : 0);
331  return $this->setData($a_user_data);
332  }
333 
334 
335  protected function checkAcceptance()
336  {
337  return true;
338  }
339 
340 
341 
342 }
343 ?>