ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilRegistrationSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 require_once './Services/Registration/classes/class.ilRegistrationSettings.php';
25 
37 {
38  var $ctrl;
39  var $tpl;
40  var $ref_id;
41 
43  {
44  global $ilCtrl,$tpl,$lng;
45 
46  $this->tpl =& $tpl;
47  $this->ctrl =& $ilCtrl;
48 
49  $this->lng =& $lng;
50  $this->lng->loadLanguageModule('administration');
51  $this->lng->loadLanguageModule('registration');
52 
53  $this->ref_id = (int) $_GET['ref_id'];
54 
55  $this->registration_settings = new ilRegistrationSettings();
56  }
57 
58  function executeCommand()
59  {
60  $next_class = $this->ctrl->getNextClass($this);
61  $cmd = $this->ctrl->getCmd();
62  switch($next_class)
63  {
64  default:
65  if(!$cmd)
66  {
67  $cmd = 'diplayForm';
68  }
69  $this->$cmd();
70  break;
71  }
72  return true;
73  }
74 
75  function view()
76  {
77  global $ilAccess,$ilErr;
78 
79  if(!$ilAccess->checkAccess('read','',$this->ref_id))
80  {
81  $ilErr->raiseError($this->lng->txt("msg_no_perm_read"),$ilErr->MESSAGE);
82  }
83 
84  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.registration_settings.html','Services/Registration');
85 
86  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
87  $this->tpl->setVariable("TXT_REGISTRATION_SETTINGS",$this->lng->txt('reg_settings_header'));
88  $this->tpl->setVariable("TXT_REG_TYPE",$this->lng->txt('reg_type'));
89  $this->tpl->setVariable("TXT_REG_DEACTIVATED",$this->lng->txt('reg_disabled'));
90  $this->tpl->setVariable("REG_DEACTIVATED_DESC",$this->lng->txt('reg_disabled_info'));
91  $this->tpl->setVariable("TXT_DIRECT",$this->lng->txt('reg_direct'));
92  $this->tpl->setVariable("REG_DIRECT_DESC",$this->lng->txt('reg_direct_info'));
93  $this->tpl->setVariable("TXT_APPROVE",$this->lng->txt('reg_approve'));
94  $this->tpl->setVariable("REG_APPROVE_DESC",$this->lng->txt('reg_approve_info'));
95  $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT",$this->lng->txt('reg_role_assignment'));
96  $this->tpl->setVariable("TXT_REG_FIXED",$this->lng->txt('reg_fixed'));
97  $this->tpl->setVariable("TXT_AVAILABLE",$this->lng->txt('reg_available_roles'));
98  $this->tpl->setVariable("TXT_APPROVE_REC",$this->lng->txt('approve_recipient'));
99  $this->tpl->setVariable("TXT_REG_NOTIFICATION",$this->lng->txt('reg_notification'));
100  $this->tpl->setVariable("REG_NOTIFICATION_DESC",$this->lng->txt('reg_notification_info'));
101  $this->tpl->setVariable("TXT_REG_EMAIL",$this->lng->txt('reg_email'));
102 
103  $this->tpl->setVariable("TXT_REG_ACCESS_LIMITATIONS",$this->lng->txt('reg_access_limitations'));
104  $this->tpl->setVariable("TXT_ENABLE_ACCESS_LIMITATIONS",$this->lng->txt('reg_enable_access_limitations'));
105 
106  $this->tpl->setVariable("EDIT",$this->lng->txt('edit'));
107  $this->tpl->setVariable("LINK_EDIT_FIXED",$this->ctrl->getLinkTarget($this,'editRoles'));
108  $this->tpl->setVariable("LINK_EDIT_EMAIL",$this->ctrl->getLinkTarget($this,'editEmailAssignments'));
109  $this->tpl->setVariable("LINK_EDIT_ACCESS_LIMITATIONS",$this->ctrl->getLinkTarget($this,'editRoleAccessLimitations'));
110 
111  $this->__prepareRoleList();
114 
115  // pwd forwarding
116  $this->tpl->setVariable("TXT_REG_PWD_FORWARD",$this->lng->txt('passwd_generation'));
117  $this->tpl->setVariable("REG_INFO_PWD",$this->lng->txt('reg_info_pwd'));
118 
119  $this->tpl->setVariable("RADIO_DEACTIVATE",ilUtil::formRadioButton(!$this->registration_settings->enabled(),
120  'reg_type',
121  IL_REG_DISABLED));
122 
123  $this->tpl->setVariable("RADIO_DIRECT",ilUtil::formRadioButton($this->registration_settings->directEnabled(),
124  'reg_type',
125  IL_REG_DIRECT));
126 
127  $this->tpl->setVariable("RADIO_APPROVE",ilUtil::formRadioButton($this->registration_settings->approveEnabled(),
128  'reg_type',
129  IL_REG_APPROVE));
130 
131  $this->tpl->setVariable("APPROVER",ilUtil::prepareFormOutput($this->registration_settings->getApproveRecipientLogins()));
132 
133 
134  $this->tpl->setVariable("CHECK_PWD",ilUtil::formCheckbox($this->registration_settings->passwordGenerationEnabled(),
135  'reg_pwd',
136  1));
137 
138  $this->tpl->setVariable("RADIO_FIXED",ilUtil::formRadioButton($this->registration_settings->roleSelectionEnabled(),
139  'reg_role_type',
141 
142  $this->tpl->setVariable("RADIO_EMAIL",ilUtil::formRadioButton($this->registration_settings->automaticRoleAssignmentEnabled(),
143  'reg_role_type',
145  // access limitation
146  if ($this->registration_settings->getAccessLimitation())
147  {
148  $this->tpl->setVariable("REG_ACCESS_LIMITATION_CHECK","checked=\"checked\"");
149  $this->tpl->setVariable("CSS_DISPLAY_ACCESS_LIMITATION","block");
150  }
151  else
152  {
153  $this->tpl->setVariable("CSS_DISPLAY_ACCESS_LIMITATION","none");
154  }
155 
156  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
157  }
158 
159  function save()
160  {
161  global $ilAccess,$ilErr;
162 
163  if(!$ilAccess->checkAccess('write','',$this->ref_id))
164  {
165  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
166  }
167 
168  $this->registration_settings->setRegistrationType((int) $_POST['reg_type']);
169  $this->registration_settings->setPasswordGenerationStatus((int) $_POST['reg_pwd']);
170  $this->registration_settings->setApproveRecipientLogins(ilUtil::stripSlashes($_POST['reg_approver']));
171  $this->registration_settings->setRoleType((int) $_POST['reg_role_type']);
172  $this->registration_settings->setAccessLimitation((int) $_POST['reg_access_limitation']);
173 
174  if($error_code = $this->registration_settings->validate())
175  {
176  ilUtil::sendInfo($this->lng->txt('reg_unknown_recipients').' '.$this->registration_settings->getUnknown());
177  $this->view();
178  return false;
179  }
180 
181  $this->registration_settings->save();
182  ilUtil::sendInfo($this->lng->txt('saved_successfully'));
183  $this->view();
184 
185  return true;
186  }
187 
188  function editRoles()
189  {
190  include_once './Services/AccessControl/classes/class.ilObjRole.php';
191 
192  global $ilAccess,$ilErr,$rbacreview;
193 
194  if(!$ilAccess->checkAccess('write','',$this->ref_id))
195  {
196  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
197  }
198 
199  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.edit_roles.html','Services/Registration');
200 
201  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
202  $this->tpl->setVariable("TXT_SELECTABLE_ROLES",$this->lng->txt('reg_selectable_roles'));
203  $this->tpl->setVariable("ARR_DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
204  $this->tpl->setVariable("ACTIONS",$this->lng->txt('actions'));
205  $this->tpl->setVariable("UPDATE",$this->lng->txt('save'));
206  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
207 
208  $counter = 0;
209  foreach($rbacreview->getGlobalRoles() as $role)
210  {
211  if($role == SYSTEM_ROLE_ID or
212  $role == ANONYMOUS_ROLE_ID)
213  {
214  continue;
215  }
216  $this->tpl->setCurrentBlock("roles");
217  $this->tpl->setVariable("CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
218  $this->tpl->setVariable("CHECK_ROLE",ilUtil::formCheckbox(ilObjRole::_lookupAllowRegister($role),
219  "roles[$role]",
220  1));
221  $this->tpl->setVariable("ROLE",ilObjRole::_lookupTitle($role));
222  $this->tpl->parseCurrentBlock();
223 
224  }
225  }
226 
227  function updateRoles()
228  {
229  global $ilAccess,$ilErr,$rbacreview;
230 
231  if(!$ilAccess->checkAccess('write','',$this->ref_id))
232  {
233  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
234  }
235  // Minimum one role
236  if(count($_POST['roles']) < 1)
237  {
238  ilUtil::sendInfo($this->lng->txt('msg_last_role_for_registration'));
239  $this->editRoles();
240  return false;
241  }
242  // update allow register
243  foreach($rbacreview->getGlobalRoles() as $role)
244  {
245  if($role_obj = ilObjectFactory::getInstanceByObjId($role,false))
246  {
247  $role_obj->setAllowRegister($_POST['roles'][$role] ? 1 : 0);
248  $role_obj->update();
249  }
250  }
251 
252  ilUtil::sendInfo($this->lng->txt('saved_successfully'));
253  $this->view();
254 
255  return true;
256  }
257 
259  {
260  global $ilAccess,$ilErr,$rbacreview;
261 
262  if(!$ilAccess->checkAccess('write','',$this->ref_id))
263  {
264  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
265  }
266 
267  $this->__initRoleAssignments();
268 
269  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.reg_email_role_assignments.html','Services/Registration');
270  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
271  $this->tpl->setVariable("TXT_EMAIL_ROLE_ASSIGN",$this->lng->txt('reg_email_role_assignment'));
272  $this->tpl->setVariable("TXT_MAIL",$this->lng->txt('reg_email'));
273  $this->tpl->setVariable("TXT_ROLE",$this->lng->txt('obj_role'));
274  $this->tpl->setVariable("TXT_DEFAULT",$this->lng->txt('reg_default'));
275  $this->tpl->setVariable("ARR_DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
276  $this->tpl->setVariable("TXT_DOMAIN",$this->lng->txt('reg_domain'));
277 
278 
279  $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
280  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
281  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('reg_add_assignment'));
282  $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
283 
284  $counter = 0;
285  foreach($this->assignments_obj->getAssignments() as $assignment)
286  {
287  $this->tpl->setCurrentBlock("roles");
288  $this->tpl->setVariable("CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow1'));
289  $this->tpl->setVariable("ASSIGN_ID",$assignment['id']);
290  $this->tpl->setVariable("DOMAIN",$assignment['domain']);
291  $this->tpl->setVariable("CHECK_ROLE",ilUtil::formCheckbox(0,'del_assign[]',$assignment['id']));
292  $this->tpl->setVariable("ROLE_SEL",$this->__buildRoleSelection($assignment['id']));
293  $this->tpl->parseCurrentBlock();
294  }
295 
296  $this->tpl->setVariable("DEF_CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow1'));
297  $this->tpl->setVariable("TXT_DEFAULT",$this->lng->txt('default'));
298  $this->tpl->setVariable("DEF_ROLE",$this->__buildRoleSelection(-1));
299  }
300 
302  {
303  global $lng,$ilAccess,$ilErr,$rbacreview;
304 
305  if(!$ilAccess->checkAccess('write','',$this->ref_id))
306  {
307  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
308  }
309 
311 
312  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.reg_role_access_limitations.html','Services/Registration');
313 
314  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
315  $this->tpl->setVariable("TXT_REG_ROLE_ACCESS_LIMITATIONS",$lng->txt('reg_role_access_limitations'));
316  $this->tpl->setVariable("TXT_ROLE",$lng->txt('obj_role'));
317  $this->tpl->setVariable("TXT_ACCESS_LIMITATION_MODE",$lng->txt('reg_access_limitation_mode'));
318 
319  $this->tpl->setVariable("BTN_SAVE",$lng->txt('save'));
320  $this->tpl->setVariable("BTN_CANCEL",$lng->txt('cancel'));
321 
322  $counter = 0;
323  include_once './Services/AccessControl/classes/class.ilObjRole.php';
324 
325  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
326  {
327  $this->tpl->setCurrentBlock("roles");
328  $this->tpl->setVariable("CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow1'));
329  $this->tpl->setVariable("ROLE_ID",$role['id']);
330  $this->tpl->setVariable("ROLE_TITLE",$role['title']);
331  $this->tpl->setVariable("SEL_ACCESS_LIMITATION",$this->__buildAccessLimitationSelection($role['id']));
332  $this->tpl->setVariable("CSS_DISPLAY_ABSOLUTE",($this->access_limitations_obj->getMode($role['id']) == 'absolute') ? 'inline' : 'none');
333  $this->tpl->setVariable("CSS_DISPLAY_RELATIVE",($this->access_limitations_obj->getMode($role['id']) == 'relative') ? 'inline' : 'none');
334  $this->tpl->setVariable("CSS_DISPLAY_UNLIMITED",($this->access_limitations_obj->getMode($role['id']) == 'unlimited') ? 'inline' : 'none');
335  $this->tpl->setVariable("TXT_ACCESS_LIMITATION_UNLIMITED", $lng->txt('reg_access_limitation_none'));
336 
337  $date = $this->__prepareDateSelect($this->access_limitations_obj->getAbsolute($role['id']));
338  $this->tpl->setVariable("SEL_ACCESS_LIMITATION_ABSOLUTE",ilUtil::makeDateSelect('access_limitation_absolute_'.$role['id'],$date['y'],$date['m'],$date['d'],'2007'));
339 
340  $this->tpl->setVariable("TXT_DAYS",$lng->txt('days'));
341  $this->tpl->setVariable("TXT_MONTHS",$lng->txt('months'));
342  $this->tpl->setVariable("TXT_YEARS",$lng->txt('years'));
343 
344  $this->tpl->setVariable("DAYS",$this->access_limitations_obj->getRelative($role['id'],'d'));
345  $this->tpl->setVariable("MONTHS",$this->access_limitations_obj->getRelative($role['id'],'m'));
346  $this->tpl->setVariable("YEARS",$this->access_limitations_obj->getRelative($role['id'],'y'));
347  $this->tpl->parseCurrentBlock();
348  }
349  }
350 
351  function addAssignment()
352  {
353  global $ilAccess,$ilErr,$rbacreview;
354 
355  if(!$ilAccess->checkAccess('write','',$this->ref_id))
356  {
357  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
358  }
359 
360  $this->__initRoleAssignments();
361  $this->assignments_obj->add();
362 
363  ilUtil::sendInfo($this->lng->txt('reg_added_assignment'));
364  $this->editEmailAssignments();
365 
366  return true;
367  }
368 
369  function deleteAssignment()
370  {
371  global $ilAccess,$ilErr,$rbacreview;
372 
373  if(!$ilAccess->checkAccess('write','',$this->ref_id))
374  {
375  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
376  }
377 
378  if(!count($_POST['del_assign']))
379  {
380  ilUtil::sendInfo($this->lng->txt('reg_select_one'));
381  $this->editEmailAssignments();
382  return false;
383  }
384 
385  $this->__initRoleAssignments();
386 
387  foreach($_POST['del_assign'] as $assignment_id)
388  {
389  $this->assignments_obj->delete($assignment_id);
390  }
391 
392  ilUtil::sendInfo($this->lng->txt('reg_deleted_assignment'));
393  $this->editEmailAssignments();
394 
395  return true;
396  }
397 
398  function saveAssignment()
399  {
400  global $ilAccess,$ilErr,$rbacreview;
401 
402  if(!$ilAccess->checkAccess('write','',$this->ref_id))
403  {
404  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
405  }
406 
407  $this->__initRoleAssignments();
408 
409  if (!is_array($_POST['domain']))
410  {
411  $_POST['domain'] = array();
412  }
413 
414  foreach($_POST['domain'] as $id => $data)
415  {
416  $this->assignments_obj->setDomain($id,ilUtil::stripSlashes($_POST['domain'][$id]['domain']));
417  $this->assignments_obj->setRole($id,ilUtil::stripSlashes($_POST['role'][$id]['role']));
418  }
419  $this->assignments_obj->setDefaultRole((int) $_POST['default_role']);
420 
421  if($err = $this->assignments_obj->validate())
422  {
423  switch($err)
424  {
426  ilUtil::sendInfo($this->lng->txt('reg_missing_domain'));
427  break;
428 
429  case IL_REG_MISSING_ROLE:
430  ilUtil::sendInfo($this->lng->txt('reg_missing_role'));
431  break;
432  }
433  $this->editEmailAssignments();
434  return false;
435  }
436 
437 
438  $this->assignments_obj->save();
439  ilUtil::sendInfo($this->lng->txt('settings_saved'));
440  $this->view();
441  return true;
442  }
443 
445  {
446  global $ilAccess,$ilErr,$rbacreview;
447 
448  if(!$ilAccess->checkAccess('write','',$this->ref_id))
449  {
450  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
451  }
452 
454 
455  include_once './Services/AccessControl/classes/class.ilObjRole.php';
456 
457  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
458  {
459  $this->access_limitations_obj->setMode($_POST['access_limitation_mode_'.$role['id']],$role['id']);
460  $this->access_limitations_obj->setAbsolute($_POST['access_limitation_absolute_'.$role['id']],$role['id']);
461  $this->access_limitations_obj->setRelative($_POST['access_limitation_relative_'.$role['id']],$role['id']);
462  }
463 
464  //var_dump("<pre>",$_POST,$this->access_limitations_obj->getAbsolute(4),time(),"</pre>");exit;
465 
466  if($err = $this->access_limitations_obj->validate())
467  {
468  switch($err)
469  {
471  ilUtil::sendInfo($this->lng->txt('reg_access_limitation_missing_mode'));
472  break;
473 
475  ilUtil::sendInfo($this->lng->txt('reg_access_limitation_out_of_date'));
476  break;
477  }
478  $this->editRoleAccessLimitations();
479  return false;
480  }
481 
482 
483  $this->access_limitations_obj->save();
484  ilUtil::sendInfo($this->lng->txt('settings_saved'));
485  $this->view();
486  return true;
487  }
488 
489 
490  function __prepareRoleList()
491  {
492  include_once './Services/AccessControl/classes/class.ilObjRole.php';
493 
494  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
495  {
496  $this->tpl->setCurrentBlock("fixed_item");
497  $this->tpl->setVariable("FIXED_ITEM_TITLE",$role['title']);
498  $this->tpl->parseCurrentBlock();
499  }
500  }
501 
503  {
504  include_once './Services/AccessControl/classes/class.ilObjRole.php';
505  $this->__initRoleAssignments();
506 
507  foreach($this->assignments_obj->getAssignments() as $assignment)
508  {
509  if(strlen($assignment['domain']) and $assignment['role'])
510  {
511  $this->tpl->setCurrentBlock("auto_item");
512  $this->tpl->setVariable("AUTO_ITEM_TITLE",$assignment['domain']);
513  $this->tpl->setVariable("AUTO_ROLE",ilObjRole::_lookupTitle($assignment['role']));
514  $this->tpl->parseCurrentBlock();
515  }
516  }
517 
518  if(strlen($this->assignments_obj->getDefaultRole()))
519  {
520  $this->tpl->setCurrentBlock("auto_item");
521  $this->tpl->setVariable("AUTO_ITEM_TITLE",$this->lng->txt('reg_default'));
522  $this->tpl->setVariable("AUTO_ROLE",ilObjRole::_lookupTitle($this->assignments_obj->getDefaultRole()));
523  $this->tpl->parseCurrentBlock();
524  }
525 
526  $this->tpl->setCurrentBlock("auto");
527  $this->tpl->parseCurrentBlock();
528 
529  }
530 
532  {
533  global $lng;
534 
536 
537  include_once './Services/AccessControl/classes/class.ilObjRole.php';
538 
539  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
540  {
541  $this->tpl->setCurrentBlock("access_limitation_item");
542  $this->tpl->setVariable("ACCESS_LIMITATION_ITEM_TITLE",$role['title']);
543 
544  switch ($this->access_limitations_obj->getMode($role['id']))
545  {
546  case 'absolute':
547  $txt_access_value = $lng->txt('reg_access_limitation_limited_until');
548  $txt_access_value .= " ".ilDatePresentation::formatDate(new ilDateTime($this->access_limitations_obj->getAbsolute($role['id'],IL_CAL_UNIX)));
549  break;
550 
551  case 'relative':
552  $years = $this->access_limitations_obj->getRelative($role['id'],'y');
553  $months = $this->access_limitations_obj->getRelative($role['id'],'m');
554  $days = $this->access_limitations_obj->getRelative($role['id'],'d');
555 
556  $txt_access_value = $lng->txt('reg_access_limitation_limited_time')." ";
557 
558  if ($years)
559  {
560  $txt_access_value .= $years." ";
561  $txt_access_value .= ($years == 1) ? $lng->txt('year') : $lng->txt('years');
562 
563  if ($months)
564  {
565  if ($days)
566  {
567  $txt_access_value .= ", ";
568  }
569  else
570  {
571  $txt_access_value .= " ".$lng->txt('and')." ";
572  }
573  }
574  elseif ($days)
575  {
576  $txt_access_value .= " ".$lng->txt('and')." ";
577  }
578  }
579 
580  if ($months)
581  {
582  $txt_access_value .= $months." ";
583  $txt_access_value .= ($months == 1) ? $lng->txt('month') : $lng->txt('months');
584 
585  if ($days)
586  {
587  $txt_access_value .= " ".$lng->txt('and')." ";
588  }
589  }
590 
591  if ($days)
592  {
593  $txt_access_value .= $days." ";
594  $txt_access_value .= ($days == 1) ? $lng->txt('day') : $lng->txt('days');
595  }
596  break;
597 
598  default:
599  $txt_access_value = $lng->txt('reg_access_limitation_none');
600  break;
601  }
602 
603  $this->tpl->setVariable("ACCESS_LIMITATION_VALUE",$txt_access_value);
604  $this->tpl->setVariable("EDIT_ITEM",$lng->txt('edit'));
605  $this->tpl->parseCurrentBlock();
606  }
607  }
608 
610  {
611  if(is_object($this->assignments_obj))
612  {
613  return true;
614  }
615 
616  include_once 'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
617 
618  $this->assignments_obj = new ilRegistrationRoleAssignments();
619  }
620 
622  {
623  if(is_object($this->access_limitations_obj))
624  {
625  return true;
626  }
627 
628  include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
629 
630  $this->access_limitations_obj = new ilRegistrationRoleAccessLimitations();
631  }
632 
633  function __buildRoleSelection($assignment_id)
634  {
635  include_once './Services/AccessControl/classes/class.ilObjRole.php';
636 
637  global $rbacreview;
638 
639  $assignments = $this->assignments_obj->getAssignments();
640  $selected = ($assignment_id > 0) ?
641  $assignments[$assignment_id]['role'] :
642  $this->assignments_obj->getDefaultRole();
643 
644  if(!$selected)
645  {
646  $roles[0] = $this->lng->txt('please_choose');
647  }
648 
649  foreach($rbacreview->getGlobalRoles() as $role_id)
650  {
651  if($role_id == SYSTEM_ROLE_ID or
652  $role_id == ANONYMOUS_ROLE_ID)
653  {
654  continue;
655  }
656  $roles[$role_id] = ilObjRole::_lookupTitle($role_id);
657  }
658 
659  if($assignment_id > 0)
660  {
661  return ilUtil::formSelect($selected,
662  "role[$assignment_id][role]",
663  $roles,false,true);
664  }
665  else
666  {
667  return ilUtil::formSelect($selected,
668  "default_role",
669  $roles,false,true);
670  }
671  }
672 
673  function __buildAccessLimitationSelection($a_role_id)
674  {
675  global $lng;
676 
677  $options = array(
678  'null' => $lng->txt('please_choose'),
679  'unlimited' => $lng->txt('reg_access_limitation_mode_unlimited'),
680  'absolute' => $lng->txt('reg_access_limitation_mode_absolute'),
681  'relative' => $lng->txt('reg_access_limitation_mode_relative')
682  );
683 
684  $attribs = array('onchange' => 'displayAccessLimitationSelectionForm(document.cmd.access_limitation_mode_'.$a_role_id.','.$a_role_id.')');
685 
686  $selected = $this->access_limitations_obj->getMode($a_role_id);
687 
688  return ilUtil::formSelect($selected,'access_limitation_mode_'.$a_role_id,$options,false,true,0,"",$attribs);
689 
690  }
691 
692  function __prepareDateSelect($a_unix_time)
693  {
694  if (!$a_unix_time)
695  {
696  $a_unix_time = time();
697  }
698 
699  return array('y' => date('Y',$a_unix_time),
700  'm' => date('n',$a_unix_time),
701  'd' => date('d',$a_unix_time));
702  }
703 }
704 ?>