ILIAS  Release_4_0_x_branch Revision 61816
 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,$ilCtrl;
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_ACTIVATION_LINK",$this->lng->txt('reg_type_confirmation'));
104  $this->tpl->setVariable("REG_INFO_ACTIVATION",$this->lng->txt('reg_type_confirmation_info'));
105 
106  $this->tpl->setVariable("TXT_REG_ACCESS_LIMITATIONS",$this->lng->txt('reg_access_limitations'));
107  $this->tpl->setVariable("TXT_ENABLE_ACCESS_LIMITATIONS",$this->lng->txt('reg_enable_access_limitations'));
108 
109  $this->tpl->setVariable("EDIT",$this->lng->txt('edit'));
110  $this->tpl->setVariable("LINK_EDIT_FIXED",$this->ctrl->getLinkTarget($this,'editRoles'));
111  $this->tpl->setVariable("LINK_EDIT_EMAIL",$this->ctrl->getLinkTarget($this,'editEmailAssignments'));
112  $this->tpl->setVariable("LINK_EDIT_ACCESS_LIMITATIONS",$this->ctrl->getLinkTarget($this,'editRoleAccessLimitations'));
113 
114  $this->__prepareRoleList();
117 
118  // jump to new account mail
119  $this->tpl->setVariable("TXT_NEW_ACCOUNT_MAIL",
120  $this->lng->txt('user_new_account_mail'));
121  $this->tpl->setVariable("TXT_JUMP_ACCOUNT_MAIL",
122  $this->lng->txt('edit'));
123  $ilCtrl->setParameterByClass("ilobjuserfoldergui", "ref_id", USER_FOLDER_ID);
124  $this->tpl->setVariable("HREF_NEW_ACCOUNT_MAIL",
125  $ilCtrl->getLinkTargetByClass(array("iladministrationgui", "ilobjuserfoldergui"), "newAccountMail"));
126  $ilCtrl->setParameterByClass("ilobjuserfoldergui", "ref_id", $_GET["ref_id"]);
127 
128  // pwd forwarding
129  $this->tpl->setVariable("TXT_REG_PWD_FORWARD",$this->lng->txt('passwd_generation'));
130  $this->tpl->setVariable("REG_INFO_PWD",$this->lng->txt('reg_info_pwd'));
131 
132  $this->tpl->setVariable("RADIO_DEACTIVATE",ilUtil::formRadioButton(!$this->registration_settings->enabled(),
133  'reg_type',
134  IL_REG_DISABLED));
135 
136  $this->tpl->setVariable("RADIO_DIRECT",ilUtil::formRadioButton($this->registration_settings->directEnabled(),
137  'reg_type',
138  IL_REG_DIRECT));
139 
140  $this->tpl->setVariable("RADIO_APPROVE",ilUtil::formRadioButton($this->registration_settings->approveEnabled(),
141  'reg_type',
142  IL_REG_APPROVE));
143 
144  $this->tpl->setVariable("CHECK_ACTIVATION_REG",ilUtil::formRadioButton($this->registration_settings->activationEnabled(),
145  'reg_type',
147 
148  $this->tpl->setVariable("APPROVER",ilUtil::prepareFormOutput($this->registration_settings->getApproveRecipientLogins()));
149 
150 
151  $this->tpl->setVariable("CHECK_PWD",ilUtil::formCheckbox($this->registration_settings->passwordGenerationEnabled(),
152  'reg_pwd',
153  1));
154 
155  $this->tpl->setVariable("RADIO_FIXED",ilUtil::formRadioButton($this->registration_settings->roleSelectionEnabled(),
156  'reg_role_type',
158 
159  $this->tpl->setVariable("RADIO_EMAIL",ilUtil::formRadioButton($this->registration_settings->automaticRoleAssignmentEnabled(),
160  'reg_role_type',
162  // access limitation
163  if ($this->registration_settings->getAccessLimitation())
164  {
165  $this->tpl->setVariable("REG_ACCESS_LIMITATION_CHECK","checked=\"checked\"");
166  $this->tpl->setVariable("CSS_DISPLAY_ACCESS_LIMITATION","block");
167  }
168  else
169  {
170  $this->tpl->setVariable("CSS_DISPLAY_ACCESS_LIMITATION","none");
171  }
172 
173  $this->tpl->setVariable('REG_HASH_LIFE_TIME', (int)$this->registration_settings->getRegistrationHashLifetime());
174  $this->tpl->setVariable('REG_HASH_LIFE_TIME_INFO', $this->lng->txt('reg_confirmation_hash_life_time_info'));
175 
176 
177  $this->tpl->setVariable("TXT_SAVE",$this->lng->txt('save'));
178  }
179 
180  function save()
181  {
182  global $ilAccess,$ilErr;
183 
184  if(!$ilAccess->checkAccess('write','',$this->ref_id))
185  {
186  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
187  }
188 
189  $this->registration_settings->setRegistrationType((int) $_POST['reg_type']);
190  $this->registration_settings->setPasswordGenerationStatus((int) $_POST['reg_pwd']);
191  $this->registration_settings->setApproveRecipientLogins(ilUtil::stripSlashes($_POST['reg_approver']));
192  $this->registration_settings->setRoleType((int) $_POST['reg_role_type']);
193  $this->registration_settings->setAccessLimitation((int) $_POST['reg_access_limitation']);
194 
195  if(!preg_match('/^([0]|([1-9][0-9]*))([\.,][0-9][0-9]*)?$/', (int)$_POST['reg_hash_life_time']))
196  $this->registration_settings->setRegistrationHashLifetime(0);
197  else
198  $this->registration_settings->setRegistrationHashLifetime((int)$_POST['reg_hash_life_time']);
199 
200  if($error_code = $this->registration_settings->validate())
201  {
202  switch($error_code)
203  {
205 
206  ilUtil::sendFailure($this->lng->txt('reg_unknown_recipients').' '.$this->registration_settings->getUnknown());
207  $this->view();
208  return false;
209 
211 
212  ilUtil::sendFailure($this->lng->txt('reg_approve_needs_recipient').' '.$this->registration_settings->getUnknown());
213  $this->view();
214  return false;
215 
216  }
217  }
218 
219  $this->registration_settings->save();
220  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
221  $this->view();
222 
223  return true;
224  }
225 
226  function editRoles()
227  {
228  include_once './Services/AccessControl/classes/class.ilObjRole.php';
229 
230  global $ilAccess,$ilErr,$rbacreview;
231 
232  if(!$ilAccess->checkAccess('write','',$this->ref_id))
233  {
234  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
235  }
236 
237  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.edit_roles.html','Services/Registration');
238 
239  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
240  $this->tpl->setVariable("TXT_SELECTABLE_ROLES",$this->lng->txt('reg_selectable_roles'));
241  $this->tpl->setVariable("ARR_DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
242  $this->tpl->setVariable("ACTIONS",$this->lng->txt('actions'));
243  $this->tpl->setVariable("UPDATE",$this->lng->txt('save'));
244  $this->tpl->setVariable("CANCEL",$this->lng->txt('cancel'));
245 
246  $counter = 0;
247  foreach($rbacreview->getGlobalRoles() as $role)
248  {
249  if($role == SYSTEM_ROLE_ID or
250  $role == ANONYMOUS_ROLE_ID)
251  {
252  continue;
253  }
254  $this->tpl->setCurrentBlock("roles");
255  $this->tpl->setVariable("CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow2'));
256  $this->tpl->setVariable("CHECK_ROLE",ilUtil::formCheckbox(ilObjRole::_lookupAllowRegister($role),
257  "roles[$role]",
258  1));
259  $this->tpl->setVariable("ROLE",ilObjRole::_lookupTitle($role));
260  $this->tpl->parseCurrentBlock();
261 
262  }
263  }
264 
265  function updateRoles()
266  {
267  global $ilAccess,$ilErr,$rbacreview;
268 
269  if(!$ilAccess->checkAccess('write','',$this->ref_id))
270  {
271  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
272  }
273  // Minimum one role
274  if(count($_POST['roles']) < 1)
275  {
276  ilUtil::sendFailure($this->lng->txt('msg_last_role_for_registration'));
277  $this->editRoles();
278  return false;
279  }
280  // update allow register
281  foreach($rbacreview->getGlobalRoles() as $role)
282  {
283  if($role_obj = ilObjectFactory::getInstanceByObjId($role,false))
284  {
285  $role_obj->setAllowRegister($_POST['roles'][$role] ? 1 : 0);
286  $role_obj->update();
287  }
288  }
289 
290  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
291  $this->view();
292 
293  return true;
294  }
295 
297  {
298  global $ilAccess,$ilErr,$rbacreview;
299 
300  if(!$ilAccess->checkAccess('write','',$this->ref_id))
301  {
302  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
303  }
304 
305  $this->__initRoleAssignments();
306 
307  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.reg_email_role_assignments.html','Services/Registration');
308  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
309  $this->tpl->setVariable("TXT_EMAIL_ROLE_ASSIGN",$this->lng->txt('reg_email_role_assignment'));
310  $this->tpl->setVariable("TXT_MAIL",$this->lng->txt('reg_email'));
311  $this->tpl->setVariable("TXT_ROLE",$this->lng->txt('obj_role'));
312  $this->tpl->setVariable("TXT_DEFAULT",$this->lng->txt('reg_default'));
313  $this->tpl->setVariable("ARR_DOWNRIGHT",ilUtil::getImagePath('arrow_downright.gif'));
314  $this->tpl->setVariable("TXT_DOMAIN",$this->lng->txt('reg_domain'));
315 
316 
317  $this->tpl->setVariable("BTN_DELETE",$this->lng->txt('delete'));
318  $this->tpl->setVariable("BTN_SAVE",$this->lng->txt('save'));
319  $this->tpl->setVariable("BTN_ADD",$this->lng->txt('reg_add_assignment'));
320  $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt('cancel'));
321 
322  $counter = 0;
323  foreach($this->assignments_obj->getAssignments() as $assignment)
324  {
325  $this->tpl->setCurrentBlock("roles");
326  $this->tpl->setVariable("CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow1'));
327  $this->tpl->setVariable("ASSIGN_ID",$assignment['id']);
328  $this->tpl->setVariable("DOMAIN",$assignment['domain']);
329  $this->tpl->setVariable("CHECK_ROLE",ilUtil::formCheckbox(0,'del_assign[]',$assignment['id']));
330  $this->tpl->setVariable("ROLE_SEL",$this->__buildRoleSelection($assignment['id']));
331  $this->tpl->parseCurrentBlock();
332  }
333 
334  $this->tpl->setVariable("DEF_CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow1'));
335  $this->tpl->setVariable("TXT_DEFAULT",$this->lng->txt('default'));
336  $this->tpl->setVariable("DEF_ROLE",$this->__buildRoleSelection(-1));
337  }
338 
340  {
341  global $lng,$ilAccess,$ilErr,$rbacreview;
342 
343  if(!$ilAccess->checkAccess('write','',$this->ref_id))
344  {
345  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
346  }
347 
349 
350  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.reg_role_access_limitations.html','Services/Registration');
351 
352  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
353  $this->tpl->setVariable("TXT_REG_ROLE_ACCESS_LIMITATIONS",$lng->txt('reg_role_access_limitations'));
354  $this->tpl->setVariable("TXT_ROLE",$lng->txt('obj_role'));
355  $this->tpl->setVariable("TXT_ACCESS_LIMITATION_MODE",$lng->txt('reg_access_limitation_mode'));
356 
357  $this->tpl->setVariable("BTN_SAVE",$lng->txt('save'));
358  $this->tpl->setVariable("BTN_CANCEL",$lng->txt('cancel'));
359 
360  $counter = 0;
361  include_once './Services/AccessControl/classes/class.ilObjRole.php';
362 
363  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
364  {
365  $this->tpl->setCurrentBlock("roles");
366  $this->tpl->setVariable("CSSROW",ilUtil::switchColor(++$counter,'tblrow1','tblrow1'));
367  $this->tpl->setVariable("ROLE_ID",$role['id']);
368  $this->tpl->setVariable("ROLE_TITLE",$role['title']);
369  $this->tpl->setVariable("SEL_ACCESS_LIMITATION",$this->__buildAccessLimitationSelection($role['id']));
370  $this->tpl->setVariable("CSS_DISPLAY_ABSOLUTE",($this->access_limitations_obj->getMode($role['id']) == 'absolute') ? 'inline' : 'none');
371  $this->tpl->setVariable("CSS_DISPLAY_RELATIVE",($this->access_limitations_obj->getMode($role['id']) == 'relative') ? 'inline' : 'none');
372  $this->tpl->setVariable("CSS_DISPLAY_UNLIMITED",($this->access_limitations_obj->getMode($role['id']) == 'unlimited') ? 'inline' : 'none');
373  $this->tpl->setVariable("TXT_ACCESS_LIMITATION_UNLIMITED", $lng->txt('reg_access_limitation_none'));
374 
375  $date = $this->__prepareDateSelect($this->access_limitations_obj->getAbsolute($role['id']));
376  $this->tpl->setVariable("SEL_ACCESS_LIMITATION_ABSOLUTE",ilUtil::makeDateSelect('access_limitation_absolute_'.$role['id'],$date['y'],$date['m'],$date['d'],'2007'));
377 
378  $this->tpl->setVariable("TXT_DAYS",$lng->txt('days'));
379  $this->tpl->setVariable("TXT_MONTHS",$lng->txt('months'));
380  $this->tpl->setVariable("TXT_YEARS",$lng->txt('years'));
381 
382  $this->tpl->setVariable("DAYS",$this->access_limitations_obj->getRelative($role['id'],'d'));
383  $this->tpl->setVariable("MONTHS",$this->access_limitations_obj->getRelative($role['id'],'m'));
384  $this->tpl->setVariable("YEARS",$this->access_limitations_obj->getRelative($role['id'],'y'));
385  $this->tpl->parseCurrentBlock();
386  }
387  }
388 
389  function addAssignment()
390  {
391  global $ilAccess,$ilErr,$rbacreview;
392 
393  if(!$ilAccess->checkAccess('write','',$this->ref_id))
394  {
395  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
396  }
397 
398  $this->__initRoleAssignments();
399  $this->assignments_obj->add();
400 
401  ilUtil::sendSuccess($this->lng->txt('reg_added_assignment'));
402  $this->editEmailAssignments();
403 
404  return true;
405  }
406 
407  function deleteAssignment()
408  {
409  global $ilAccess,$ilErr,$rbacreview;
410 
411  if(!$ilAccess->checkAccess('write','',$this->ref_id))
412  {
413  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
414  }
415 
416  if(!count($_POST['del_assign']))
417  {
418  ilUtil::sendFailure($this->lng->txt('reg_select_one'));
419  $this->editEmailAssignments();
420  return false;
421  }
422 
423  $this->__initRoleAssignments();
424 
425  foreach($_POST['del_assign'] as $assignment_id)
426  {
427  $this->assignments_obj->delete($assignment_id);
428  }
429 
430  ilUtil::sendSuccess($this->lng->txt('reg_deleted_assignment'));
431  $this->editEmailAssignments();
432 
433  return true;
434  }
435 
436  function saveAssignment()
437  {
438  global $ilAccess,$ilErr,$rbacreview;
439 
440  if(!$ilAccess->checkAccess('write','',$this->ref_id))
441  {
442  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
443  }
444 
445  $this->__initRoleAssignments();
446 
447  if (!is_array($_POST['domain']))
448  {
449  $_POST['domain'] = array();
450  }
451 
452  foreach($_POST['domain'] as $id => $data)
453  {
454  $this->assignments_obj->setDomain($id,ilUtil::stripSlashes($_POST['domain'][$id]['domain']));
455  $this->assignments_obj->setRole($id,ilUtil::stripSlashes($_POST['role'][$id]['role']));
456  }
457  $this->assignments_obj->setDefaultRole((int) $_POST['default_role']);
458 
459  if($err = $this->assignments_obj->validate())
460  {
461  switch($err)
462  {
464  ilUtil::sendFailure($this->lng->txt('reg_missing_domain'));
465  break;
466 
467  case IL_REG_MISSING_ROLE:
468  ilUtil::sendFailure($this->lng->txt('reg_missing_role'));
469  break;
470  }
471  $this->editEmailAssignments();
472  return false;
473  }
474 
475 
476  $this->assignments_obj->save();
477  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
478  $this->view();
479  return true;
480  }
481 
483  {
484  global $ilAccess,$ilErr,$rbacreview;
485 
486  if(!$ilAccess->checkAccess('write','',$this->ref_id))
487  {
488  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"),$ilErr->MESSAGE);
489  }
490 
492 
493  include_once './Services/AccessControl/classes/class.ilObjRole.php';
494 
495  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
496  {
497  $this->access_limitations_obj->setMode($_POST['access_limitation_mode_'.$role['id']],$role['id']);
498  $this->access_limitations_obj->setAbsolute($_POST['access_limitation_absolute_'.$role['id']],$role['id']);
499  $this->access_limitations_obj->setRelative($_POST['access_limitation_relative_'.$role['id']],$role['id']);
500  }
501 
502  //var_dump("<pre>",$_POST,$this->access_limitations_obj->getAbsolute(4),time(),"</pre>");exit;
503 
504  if($err = $this->access_limitations_obj->validate())
505  {
506  switch($err)
507  {
509  ilUtil::sendFailure($this->lng->txt('reg_access_limitation_missing_mode'));
510  break;
511 
513  ilUtil::sendFailure($this->lng->txt('reg_access_limitation_out_of_date'));
514  break;
515  }
516  $this->editRoleAccessLimitations();
517  return false;
518  }
519 
520 
521  $this->access_limitations_obj->save();
522  ilUtil::sendSuccess($this->lng->txt('settings_saved'));
523  $this->view();
524  return true;
525  }
526 
527 
528  function __prepareRoleList()
529  {
530  include_once './Services/AccessControl/classes/class.ilObjRole.php';
531 
532  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
533  {
534  $this->tpl->setCurrentBlock("fixed_item");
535  $this->tpl->setVariable("FIXED_ITEM_TITLE",$role['title']);
536  $this->tpl->parseCurrentBlock();
537  }
538  }
539 
541  {
542  include_once './Services/AccessControl/classes/class.ilObjRole.php';
543  $this->__initRoleAssignments();
544 
545  foreach($this->assignments_obj->getAssignments() as $assignment)
546  {
547  if(strlen($assignment['domain']) and $assignment['role'])
548  {
549  $this->tpl->setCurrentBlock("auto_item");
550  $this->tpl->setVariable("AUTO_ITEM_TITLE",$assignment['domain']);
551  $this->tpl->setVariable("AUTO_ROLE",ilObjRole::_lookupTitle($assignment['role']));
552  $this->tpl->parseCurrentBlock();
553  }
554  }
555 
556  if(strlen($this->assignments_obj->getDefaultRole()))
557  {
558  $this->tpl->setCurrentBlock("auto_item");
559  $this->tpl->setVariable("AUTO_ITEM_TITLE",$this->lng->txt('reg_default'));
560  $this->tpl->setVariable("AUTO_ROLE",ilObjRole::_lookupTitle($this->assignments_obj->getDefaultRole()));
561  $this->tpl->parseCurrentBlock();
562  }
563 
564  $this->tpl->setCurrentBlock("auto");
565  $this->tpl->parseCurrentBlock();
566 
567  }
568 
570  {
571  global $lng;
572 
574 
575  include_once './Services/AccessControl/classes/class.ilObjRole.php';
576 
577  foreach(ilObjRole::_lookupRegisterAllowed() as $role)
578  {
579  $this->tpl->setCurrentBlock("access_limitation_item");
580  $this->tpl->setVariable("ACCESS_LIMITATION_ITEM_TITLE",$role['title']);
581 
582  switch ($this->access_limitations_obj->getMode($role['id']))
583  {
584  case 'absolute':
585  $txt_access_value = $lng->txt('reg_access_limitation_limited_until');
586  $txt_access_value .= " ".ilDatePresentation::formatDate(new ilDateTime($this->access_limitations_obj->getAbsolute($role['id'],IL_CAL_UNIX)));
587  break;
588 
589  case 'relative':
590  $years = $this->access_limitations_obj->getRelative($role['id'],'y');
591  $months = $this->access_limitations_obj->getRelative($role['id'],'m');
592  $days = $this->access_limitations_obj->getRelative($role['id'],'d');
593 
594  $txt_access_value = $lng->txt('reg_access_limitation_limited_time')." ";
595 
596  if ($years)
597  {
598  $txt_access_value .= $years." ";
599  $txt_access_value .= ($years == 1) ? $lng->txt('year') : $lng->txt('years');
600 
601  if ($months)
602  {
603  if ($days)
604  {
605  $txt_access_value .= ", ";
606  }
607  else
608  {
609  $txt_access_value .= " ".$lng->txt('and')." ";
610  }
611  }
612  elseif ($days)
613  {
614  $txt_access_value .= " ".$lng->txt('and')." ";
615  }
616  }
617 
618  if ($months)
619  {
620  $txt_access_value .= $months." ";
621  $txt_access_value .= ($months == 1) ? $lng->txt('month') : $lng->txt('months');
622 
623  if ($days)
624  {
625  $txt_access_value .= " ".$lng->txt('and')." ";
626  }
627  }
628 
629  if ($days)
630  {
631  $txt_access_value .= $days." ";
632  $txt_access_value .= ($days == 1) ? $lng->txt('day') : $lng->txt('days');
633  }
634  break;
635 
636  default:
637  $txt_access_value = $lng->txt('reg_access_limitation_none');
638  break;
639  }
640 
641  $this->tpl->setVariable("ACCESS_LIMITATION_VALUE",$txt_access_value);
642  $this->tpl->setVariable("EDIT_ITEM",$lng->txt('edit'));
643  $this->tpl->parseCurrentBlock();
644  }
645  }
646 
648  {
649  if(is_object($this->assignments_obj))
650  {
651  return true;
652  }
653 
654  include_once 'Services/Registration/classes/class.ilRegistrationEmailRoleAssignments.php';
655 
656  $this->assignments_obj = new ilRegistrationRoleAssignments();
657  }
658 
660  {
661  if(is_object($this->access_limitations_obj))
662  {
663  return true;
664  }
665 
666  include_once 'Services/Registration/classes/class.ilRegistrationRoleAccessLimitations.php';
667 
668  $this->access_limitations_obj = new ilRegistrationRoleAccessLimitations();
669  }
670 
671  function __buildRoleSelection($assignment_id)
672  {
673  include_once './Services/AccessControl/classes/class.ilObjRole.php';
674 
675  global $rbacreview;
676 
677  $assignments = $this->assignments_obj->getAssignments();
678  $selected = ($assignment_id > 0) ?
679  $assignments[$assignment_id]['role'] :
680  $this->assignments_obj->getDefaultRole();
681 
682  if(!$selected)
683  {
684  $roles[0] = $this->lng->txt('please_choose');
685  }
686 
687  foreach($rbacreview->getGlobalRoles() as $role_id)
688  {
689  if($role_id == SYSTEM_ROLE_ID or
690  $role_id == ANONYMOUS_ROLE_ID)
691  {
692  continue;
693  }
694  $roles[$role_id] = ilObjRole::_lookupTitle($role_id);
695  }
696 
697  if($assignment_id > 0)
698  {
699  return ilUtil::formSelect($selected,
700  "role[$assignment_id][role]",
701  $roles,false,true);
702  }
703  else
704  {
705  return ilUtil::formSelect($selected,
706  "default_role",
707  $roles,false,true);
708  }
709  }
710 
711  function __buildAccessLimitationSelection($a_role_id)
712  {
713  global $lng;
714 
715  $options = array(
716  'null' => $lng->txt('please_choose'),
717  'unlimited' => $lng->txt('reg_access_limitation_mode_unlimited'),
718  'absolute' => $lng->txt('reg_access_limitation_mode_absolute'),
719  'relative' => $lng->txt('reg_access_limitation_mode_relative')
720  );
721 
722  $attribs = array('onchange' => 'displayAccessLimitationSelectionForm(document.cmd.access_limitation_mode_'.$a_role_id.','.$a_role_id.')');
723 
724  $selected = $this->access_limitations_obj->getMode($a_role_id);
725 
726  return ilUtil::formSelect($selected,'access_limitation_mode_'.$a_role_id,$options,false,true,0,"",$attribs);
727 
728  }
729 
730  function __prepareDateSelect($a_unix_time)
731  {
732  if (!$a_unix_time)
733  {
734  $a_unix_time = time();
735  }
736 
737  return array('y' => date('Y',$a_unix_time),
738  'm' => date('n',$a_unix_time),
739  'd' => date('d',$a_unix_time));
740  }
741 }
742 ?>