ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjUserGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./Services/Object/classes/class.ilObjectGUI.php";
5 include_once('./Services/Calendar/classes/class.ilDatePresentation.php');
6 
19 {
20  var $ilCtrl;
21 
27  var $gender;
28 
34  var $type;
35 
42 
47  function ilObjUserGUI($a_data,$a_id,$a_call_by_reference = false, $a_prepare_output = true)
48  {
49  global $ilCtrl, $lng;
50 
51  define('USER_FOLDER_ID',7);
52 
53  $this->type = "usr";
54  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
55  $this->usrf_ref_id =& $this->ref_id;
56 
57  $this->ctrl =& $ilCtrl;
58  $this->ctrl->saveParameter($this, array('obj_id', 'letter'));
59  $this->ctrl->setParameterByClass("ilobjuserfoldergui", "letter", $_GET["letter"]);
60 
61  $lng->loadLanguageModule('user');
62 
63  // for gender selection. don't change this
64  // maybe deprecated
65  $this->gender = array(
66  'm' => "salutation_m",
67  'f' => "salutation_f"
68  );
69  }
70 
71  function &executeCommand()
72  {
73  global $rbacsystem;
74 
75  $next_class = $this->ctrl->getNextClass($this);
76  $cmd = $this->ctrl->getCmd();
77 
78  $this->prepareOutput();
79 
80  switch($next_class)
81  {
82  case "illearningprogressgui":
83  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
85  $this->ctrl->forwardCommand($new_gui);
86  break;
87 
88  case "ilobjectownershipmanagementgui":
89  include_once("Services/Object/classes/class.ilObjectOwnershipManagementGUI.php");
90  $gui = new ilObjectOwnershipManagementGUI($this->object->getId());
91  $this->ctrl->forwardCommand($gui);
92  break;
93 
94  default:
95  if($cmd == "" || $cmd == "view")
96  {
97  $cmd = "edit";
98  }
99  $cmd .= "Object";
100  $return = $this->$cmd();
101 
102  break;
103  }
104  return $return;
105  }
106 
107  /* Overwritten from base class
108  */
110  {
111  if(strtolower(get_class($this->object)) == 'ilobjuser')
112  {
113  $this->tpl->setTitle('['.$this->object->getLogin().'] '.$this->object->getTitle());
114  $this->tpl->setDescription($this->object->getLongDescription());
115  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"), $this->lng->txt("obj_" . $this->object->getType()));
116  }
117  else
118  {
120  }
121  }
122 
123 
124 
125  function cancelObject()
126  {
127  ilSession::clear("saved_post");
128 
129  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
130  {
131  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
132  //$return_location = $_GET["cmd_return_location"];
133  //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
134  }
135  else
136  {
137  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
138  }
139  }
140 
144  function getAdminTabs(&$tabs_gui)
145  {
146  $this->getTabs($tabs_gui);
147  }
148 
152  function getTabs(&$tabs_gui)
153  {
154  global $rbacsystem, $ilHelp;
155 
156  $tabs_gui->clearTargets();
157 
158  $ilHelp->setScreenIdComponent("usr");
159 
160  if ($_GET["search"])
161  {
162  $tabs_gui->setBackTarget(
163  $this->lng->txt("search_results"),$_SESSION["usr_search_link"]);
164 
165  $tabs_gui->addTarget("properties",
166  $this->ctrl->getLinkTarget($this, "edit"), array("edit","","view"), get_class($this),"",true);
167  }
168  else
169  {
170  $tabs_gui->addTarget("properties",
171  $this->ctrl->getLinkTarget($this, "edit"), array("edit","","view"), get_class($this));
172  }
173 
174  $tabs_gui->addTarget("role_assignment",
175  $this->ctrl->getLinkTarget($this, "roleassignment"), array("roleassignment"), get_class($this));
176 
177  // learning progress
178  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
179  if($rbacsystem->checkAccess('read',$this->ref_id) and
182  {
183 
184  $tabs_gui->addTarget('learning_progress',
185  $this->ctrl->getLinkTargetByClass('illearningprogressgui',''),
186  '',
187  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
188  }
189 
190  $tabs_gui->addTarget('user_ownership',
191  $this->ctrl->getLinkTargetByClass('ilobjectownershipmanagementgui',''),
192  '',
193  'ilobjectownershipmanagementgui');
194  }
195 
199  function setBackTarget($a_text, $a_link)
200  {
201  $this->back_target = array("text" => $a_text,
202  "link" => $a_link);
203  }
204 
210  {
211  include_once './Services/User/classes/class.ilUserDefinedFields.php';
212  $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
213 
214  foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
215  {
216  if($definition['required'] and !strlen($_POST['udf'][$field_id]))
217  {
218  return false;
219  }
220  }
221  return true;
222  }
223 
224 
226  {
227  include_once './Services/User/classes/class.ilUserDefinedFields.php';
228  $this->user_defined_fields =& ilUserDefinedFields::_getInstance();
229 
230  if($this->object->getType() == 'usr')
231  {
232  $user_defined_data = $this->object->getUserDefinedData();
233  }
234  foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
235  {
236  $old = isset($_SESSION["error_post_vars"]["udf"][$field_id]) ?
237  $_SESSION["error_post_vars"]["udf"][$field_id] : $user_defined_data[$field_id];
238 
239  if($definition['field_type'] == UDF_TYPE_TEXT)
240  {
241  $this->tpl->setCurrentBlock("field_text");
242  $this->tpl->setVariable("FIELD_NAME",'udf['.$definition['field_id'].']');
243  $this->tpl->setVariable("FIELD_VALUE",ilUtil::prepareFormOutput($old));
244  $this->tpl->parseCurrentBlock();
245  }
246  else
247  {
248  $this->tpl->setCurrentBlock("field_select");
249  $this->tpl->setVariable("SELECT_BOX",ilUtil::formSelect($old,
250  'udf['.$definition['field_id'].']',
251  $this->user_defined_fields->fieldValuesToSelectArray(
252  $definition['field_values']),
253  false,
254  true));
255  $this->tpl->parseCurrentBlock();
256  }
257  $this->tpl->setCurrentBlock("user_defined");
258 
259  if($definition['required'])
260  {
261  $name = $definition['field_name']."<span class=\"asterisk\">*</span>";
262  }
263  else
264  {
265  $name = $definition['field_name'];
266  }
267  $this->tpl->setVariable("TXT_FIELD_NAME",$name);
268  $this->tpl->parseCurrentBlock();
269  }
270  return true;
271  }
272 
273  function initCreate()
274  {
275  global $tpl, $rbacsystem, $rbacreview, $ilUser;
276 
277  if($this->usrf_ref_id != USER_FOLDER_ID)
278  {
279  $this->tabs_gui->clearTargets();
280  }
281 
282  // role selection
283  $obj_list = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
284  $rol = array();
285  foreach ($obj_list as $obj_data)
286  {
287  // allow only 'assign_users' marked roles if called from category
288  if($this->object->getRefId() != USER_FOLDER_ID and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
289  {
290  include_once './Services/AccessControl/classes/class.ilObjRole.php';
291 
292  if(!ilObjRole::_getAssignUsersStatus($obj_data['obj_id']))
293  {
294  continue;
295  }
296  }
297  // exclude anonymous role from list
298  if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID)
299  {
300  // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
301  if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
302  {
303  $rol[$obj_data["obj_id"]] = $obj_data["title"];
304  }
305  }
306  }
307 
308  // raise error if there is no global role user can be assigned to
309  if(!count($rol))
310  {
311  $this->ilias->raiseError($this->lng->txt("msg_no_roles_users_can_be_assigned_to"),$this->ilias->error_obj->MESSAGE);
312  }
313 
314  $keys = array_keys($rol);
315 
316  // set pre defined user role to default
317  if (in_array(4,$keys))
318  {
319  $this->default_role = 4;
320  }
321  else
322  {
323  if (count($keys) > 1 and in_array(2,$keys))
324  {
325  // remove admin role as preselectable role
326  foreach ($keys as $key => $val)
327  {
328  if ($val == 2)
329  {
330  unset($keys[$key]);
331  break;
332  }
333  }
334  }
335 
336  $this->default_role = array_shift($keys);
337  }
338  $this->selectable_roles = $rol;
339  }
340 
344  function createObject()
345  {
346  global $tpl, $rbacsystem, $rbacreview, $ilUser;
347 
348  if (!$rbacsystem->checkAccess('create_usr', $this->usrf_ref_id) and
349  !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
350  {
351  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
352  }
353 
354  $this->initCreate();
355  $this->initForm("create");
356  return $tpl->setContent($this->form_gui->getHtml());
357  }
358 
363  function saveObject()
364  {
365  global $ilAccess, $ilSetting, $tpl, $ilUser, $rbacadmin;
366 
367  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
368 
369  // User folder
370  if (!$ilAccess->checkAccess('create_usr', "", $this->usrf_ref_id) &&
371  !$ilAccess->checkAccess('cat_administrate_users', "", $this->usrf_ref_id))
372  {
373  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
374  }
375 
376  $this->initCreate();
377  $this->initForm("create");
378 
379  // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
380  $profileMaybeIncomplete = false;
381  if($this->form_gui->getInput('ignore_rf', false))
382  {
383  $profileMaybeIncomplete = $this->handleIgnoredRequiredFields();
384  }
385 
386  if ($this->form_gui->checkInput())
387  {
388 // @todo: external account; time limit check and savings
389 
390  // checks passed. save user
391  $userObj = $this->loadValuesFromForm();
392 
393  $userObj->setPasswd($this->form_gui->getInput('passwd'),IL_PASSWD_PLAIN);
394  $userObj->setTitle($userObj->getFullname());
395  $userObj->setDescription($userObj->getEmail());
396 
397  $udf = array();
398  foreach($_POST as $k => $v)
399  {
400  if (substr($k, 0, 4) == "udf_")
401  {
402  $udf[substr($k, 4)] = $v;
403  }
404  }
405  $userObj->setUserDefinedData($udf);
406 
407  $userObj->create();
408 
409  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
411  {
412  $userObj->setExternalAccount($_POST["ext_account"]);
413  }
414 
415  // set a timestamp for last_password_change
416  // this ts is needed by ilSecuritySettings
417  $userObj->setLastPasswordChangeTS( time() );
418 
419  //insert user data in table user_data
420  $userObj->saveAsNew();
421 
422  // setup user preferences
423  if($this->isSettingChangeable('language'))
424  {
425  $userObj->setLanguage($_POST["language"]);
426  }
427 
428  // Set disk quota
429  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
431  {
432  // The disk quota is entered in megabytes but stored in bytes
433  $userObj->setPref("disk_quota", trim($_POST["disk_quota"]) * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
434  }
435 
436  if($this->isSettingChangeable('skin_style'))
437  {
438  //set user skin and style
439  $sknst = explode(":", $_POST["skin_style"]);
440 
441  if ($userObj->getPref("style") != $sknst[1] ||
442  $userObj->getPref("skin") != $sknst[0])
443  {
444  $userObj->setPref("skin", $sknst[0]);
445  $userObj->setPref("style", $sknst[1]);
446  }
447  }
448  if($this->isSettingChangeable('hits_per_page'))
449  {
450  $userObj->setPref("hits_per_page", $_POST["hits_per_page"]);
451  }
452  if($this->isSettingChangeable('show_users_online'))
453  {
454  $userObj->setPref("show_users_online", $_POST["show_users_online"]);
455  }
456  if($this->isSettingChangeable('hide_own_online_status'))
457  {
458  $userObj->setPref("hide_own_online_status", $_POST["hide_own_online_status"] ? 'y' : 'n');
459  }
460  if((int)$ilSetting->get('session_reminder_enabled'))
461  {
462  $userObj->setPref('session_reminder_enabled', (int)$_POST['session_reminder_enabled']);
463  }
464  $userObj->writePrefs();
465 
466  //set role entries
467  $rbacadmin->assignUser($_POST["default_role"],$userObj->getId(),true);
468 
469  $msg = $this->lng->txt("user_added");
470 
471  $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
472  $ilUser->writePrefs();
473 
474  $this->object = $userObj;
475 
476  if($this->isSettingChangeable('upload'))
477  {
478  $this->uploadUserPictureObject();
479  }
480 
481  if( $profileMaybeIncomplete )
482  {
483  include_once 'Services/User/classes/class.ilUserProfile.php';
484  if( ilUserProfile::isProfileIncomplete($this->object) )
485  {
486  $this->object->setProfileIncomplete( true );
487  $this->object->update();
488  }
489  }
490 
491  // send new account mail
492  if($_POST['send_mail'] == 'y')
493  {
494  include_once('Services/Mail/classes/class.ilAccountMail.php');
495  $acc_mail = new ilAccountMail();
496  $acc_mail->useLangVariablesAsFallback(true);
497  $acc_mail->setUserPassword($_POST['passwd']);
498  $acc_mail->setUser($userObj);
499 
500  if ($acc_mail->send())
501  {
502  $msg = $msg.'<br />'.$this->lng->txt('mail_sent');
503  ilUtil::sendSuccess($msg, true);
504  }
505  else
506  {
507  $msg = $msg.'<br />'.$this->lng->txt('mail_not_sent');
508  ilUtil::sendInfo($msg, true);
509  }
510  }
511  else
512  {
513  ilUtil::sendSuccess($msg, true);
514  }
515 
516 
517  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
518  {
519  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
520  }
521  else
522  {
523  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
524  }
525  }
526  else
527  {
528  $this->form_gui->setValuesByPost();
529  $tpl->setContent($this->form_gui->getHtml());
530  }
531  }
532 
538  function editObject()
539  {
540  global $ilias, $rbacsystem, $rbacreview, $rbacadmin, $styleDefinition, $ilUser
542 
543  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
544 
545  //load ILIAS settings
546  $settings = $ilias->getAllSettings();
547 
548  // User folder
549  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
550  {
551  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
552  }
553  // if called from local administration $this->usrf_ref_id is category id
554  // Todo: this has to be fixed. Do not mix user folder id and category id
555  if($this->usrf_ref_id != USER_FOLDER_ID)
556  {
557  // check if user is assigned to category
558  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
559  {
560  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
561  }
562  }
563 
564  if($this->usrf_ref_id != USER_FOLDER_ID)
565  {
566  $this->tabs_gui->clearTargets();
567  }
568 
569  // get form
570  $this->initForm("edit");
571  $this->getValues();
572  $this->showAcceptedTermsOfService();
573  $this->tpl->setContent($this->form_gui->getHTML());
574  }
575 
580  protected function loadValuesFromForm($a_mode = 'create')
581  {
582  global $ilSetting,$ilUser;
583 
584  switch($a_mode)
585  {
586  case 'create':
587  $user = new ilObjUser();
588  break;
589 
590  case 'update':
591  $user = $this->object;
592  break;
593  }
594 
595  $from = new ilDateTime($_POST['time_limit_from']['date'].' '.$_POST['time_limit_from']['time'],IL_CAL_DATETIME);
596  $user->setTimeLimitFrom($from->get(IL_CAL_UNIX));
597 
598  $until = new ilDateTime($_POST['time_limit_until']['date'].' '.$_POST['time_limit_until']['time'],IL_CAL_DATETIME);
599  $user->setTimeLimitUntil($until->get(IL_CAL_UNIX));
600 
601  $user->setTimeLimitUnlimited($this->form_gui->getInput('time_limit_unlimited'));
602 
603  if($a_mode == 'create')
604  {
605  $user->setTimeLimitOwner($this->usrf_ref_id);
606  }
607 
608  // Birthday
609  if($this->isSettingChangeable('birthday'))
610  {
611  $bd = $this->form_gui->getInput('birthday');
612  if($bd['date'])
613  {
614  $user->setBirthday($bd['date']);
615  }
616  else
617  {
618  $user->setBirthday(null);
619  }
620  }
621 
622  // Login
623  $user->setLogin($this->form_gui->getInput('login'));
624 
625 
626  // Gender
627  if($this->isSettingChangeable('gender'))
628  {
629  $user->setGender($this->form_gui->getInput('gender'));
630  }
631 
632  // Title
633  if($this->isSettingChangeable('title'))
634  {
635  $user->setUTitle($this->form_gui->getInput('title'));
636  }
637 
638  // Firstname
639  if($this->isSettingChangeable('firstname'))
640  {
641  $user->setFirstname($this->form_gui->getInput('firstname'));
642  }
643  // Lastname
644  if($this->isSettingChangeable('lastname'))
645  {
646  $user->setLastname($this->form_gui->getInput('lastname'));
647  }
648  $user->setFullname();
649 
650  // Institution
651  if($this->isSettingChangeable('institution'))
652  {
653  $user->setInstitution($this->form_gui->getInput('institution'));
654  }
655 
656  // Department
657  if($this->isSettingChangeable('department'))
658  {
659  $user->setDepartment($this->form_gui->getInput('department'));
660  }
661  // Street
662  if($this->isSettingChangeable('street'))
663  {
664  $user->setStreet($this->form_gui->getInput('street'));
665  }
666  // City
667  if($this->isSettingChangeable('city'))
668  {
669  $user->setCity($this->form_gui->getInput('city'));
670  }
671  // Zipcode
672  if($this->isSettingChangeable('zipcode'))
673  {
674  $user->setZipcode($this->form_gui->getInput('zipcode'));
675  }
676  // Country
677  if($this->isSettingChangeable('country'))
678  {
679  $user->setCountry($this->form_gui->getInput('country'));
680  }
681  // Selected Country
682  if($this->isSettingChangeable('sel_country'))
683  {
684  $user->setSelectedCountry($this->form_gui->getInput('sel_country'));
685  }
686  // Phone Office
687  if($this->isSettingChangeable('phone_office'))
688  {
689  $user->setPhoneOffice($this->form_gui->getInput('phone_office'));
690  }
691  // Phone Home
692  if($this->isSettingChangeable('phone_home'))
693  {
694  $user->setPhoneHome($this->form_gui->getInput('phone_home'));
695  }
696  // Phone Mobile
697  if($this->isSettingChangeable('phone_mobile'))
698  {
699  $user->setPhoneMobile($this->form_gui->getInput('phone_mobile'));
700  }
701  // Fax
702  if($this->isSettingChangeable('fax'))
703  {
704  $user->setFax($this->form_gui->getInput('fax'));
705  }
706  // Matriculation
707  if($this->isSettingChangeable('matriculation'))
708  {
709  $user->setMatriculation($this->form_gui->getInput('matriculation'));
710  }
711  // Email
712  if($this->isSettingChangeable('email'))
713  {
714  $user->setEmail($this->form_gui->getInput('email'));
715  }
716  // Hobby
717  if($this->isSettingChangeable('hobby'))
718  {
719  $user->setHobby($this->form_gui->getInput('hobby'));
720  }
721  // Referral Comment
722  if($this->isSettingChangeable('referral_comment'))
723  {
724  $user->setComment($this->form_gui->getInput('referral_comment'));
725  }
726  // ClientIP
727  $user->setClientIP($this->form_gui->getInput('client_ip'));
728 
729  if($this->isSettingChangeable('instant_messengers'))
730  {
731  $user->setInstantMessengerId('icq', $this->form_gui->getInput('im_icq'));
732  $user->setInstantMessengerId('yahoo', $this->form_gui->getInput('im_yahoo'));
733  $user->setInstantMessengerId('msn', $this->form_gui->getInput('im_msn'));
734  $user->setInstantMessengerId('aim', $this->form_gui->getInput('im_aim'));
735  $user->setInstantMessengerId('skype', $this->form_gui->getInput('im_skype'));
736  $user->setInstantMessengerId('jabber', $this->form_gui->getInput('im_jabber'));
737  $user->setInstantMessengerId('voip', $this->form_gui->getInput('im_voip'));
738  }
739  // Delicious
740  if($this->isSettingChangeable('delicious'))
741  {
742  $user->setDelicious($this->form_gui->getInput('delicious'));
743  }
744  // Google maps
745  $user->setLatitude($this->form_gui->getInput('latitude'));
746  $user->setLongitude($this->form_gui->getInput('longitude'));
747  $user->setLocationZoom($this->form_gui->getInput('loc_zoom'));
748 
749  // External account
750  $user->setAuthMode($this->form_gui->getInput('auth_mode'));
751  $user->setExternalAccount($this->form_gui->getInput('ext_account'));
752 
753  if((int) $user->getActive() != (int) $this->form_gui->getInput('active'))
754  {
755  $user->setActive($this->form_gui->getInput('active'), $ilUser->getId());
756  }
757 
758  return $user;
759  }
760 
761 
765  public function updateObject()
766  {
767  global $tpl, $rbacsystem, $ilias, $ilUser, $ilSetting;
768 
769  // User folder
770  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write',$this->usrf_ref_id))
771  {
772  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
773  }
774  // if called from local administration $this->usrf_ref_id is category id
775  // Todo: this has to be fixed. Do not mix user folder id and category id
776  if($this->usrf_ref_id != USER_FOLDER_ID)
777  {
778  // check if user is assigned to category
779  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
780  {
781  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
782  }
783  }
784  $this->initForm("edit");
785 
786  // we do not want to store this dates, they are only printed out
787  unset($_POST['approve_date']);
788  $_POST['agree_date'] = $this->object->getAgreeDate();
789  unset($_POST['last_login']);
790 
791  // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
792  $profileMaybeIncomplete = false;
793  if($this->form_gui->getInput('ignore_rf', false))
794  {
795  $profileMaybeIncomplete = $this->handleIgnoredRequiredFields();
796  }
797 
798  if ($this->form_gui->checkInput())
799  {
800  // @todo: external account; time limit
801  // if not allowed or empty -> do no change password
803  && trim($_POST['passwd']) != "")
804  {
805  $this->object->setPasswd($_POST['passwd'], IL_PASSWD_PLAIN);
806  }
807 
808  /*
809  * reset counter for failed logins
810  * if $_POST['active'] is set to 1
811  */
812  if( $_POST['active'] == 1 )
813  {
814  ilObjUser::_resetLoginAttempts( $this->object->getId() );
815  }
816 
817  #$this->object->assignData($_POST);
818  $this->loadValuesFromForm('update');
819 
820  $udf = array();
821  foreach($_POST as $k => $v)
822  {
823  if (substr($k, 0, 4) == "udf_")
824  {
825  $udf[substr($k, 4)] = $v;
826  }
827  }
828  $this->object->setUserDefinedData($udf);
829 
830  try
831  {
832  $this->object->updateLogin($_POST['login']);
833  }
834  catch (ilUserException $e)
835  {
836  ilUtil::sendFailure($e->getMessage());
837  $this->form_gui->setValuesByPost();
838  return $tpl->setContent($this->form_gui->getHtml());
839  }
840 
841  $this->object->setTitle($this->object->getFullname());
842  $this->object->setDescription($this->object->getEmail());
843 
844  if($this->isSettingChangeable('language'))
845  {
846  $this->object->setLanguage($this->form_gui->getInput('language'));
847  }
848 
849  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
851  {
852  // set disk quota
853  $this->object->setPref("disk_quota", $_POST["disk_quota"] * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
854  }
856  {
857  // set personal workspace disk quota
858  $this->object->setPref("wsp_disk_quota", $_POST["wsp_disk_quota"] * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
859  }
860 
861  if($this->isSettingChangeable('skin_style'))
862  {
863  //set user skin and style
864  $sknst = explode(":", $_POST["skin_style"]);
865 
866  if ($this->object->getPref("style") != $sknst[1] ||
867  $this->object->getPref("skin") != $sknst[0])
868  {
869  $this->object->setPref("skin", $sknst[0]);
870  $this->object->setPref("style", $sknst[1]);
871  }
872  }
873  if($this->isSettingChangeable('hits_per_page'))
874  {
875  $this->object->setPref("hits_per_page", $_POST["hits_per_page"]);
876  }
877  if($this->isSettingChangeable('show_users_online'))
878  {
879  $this->object->setPref("show_users_online", $_POST["show_users_online"]);
880  }
881  if($this->isSettingChangeable('hide_own_online_status'))
882  {
883  $this->object->setPref("hide_own_online_status", $_POST["hide_own_online_status"] ? 'y' : 'n');
884  }
885 
886  // set a timestamp for last_password_change
887  // this ts is needed by ilSecuritySettings
888  $this->object->setLastPasswordChangeTS( time() );
889 
890  global $ilSetting;
891  if((int)$ilSetting->get('session_reminder_enabled'))
892  {
893  $this->object->setPref('session_reminder_enabled', (int)$_POST['session_reminder_enabled']);
894  }
895 
896  // #10054 - profile may have been completed, check below is only for incomplete
897  $this->object->setProfileIncomplete( false );
898 
899  $this->update = $this->object->update();
900 
901 
902  // If the current user is editing its own user account,
903  // we update his preferences.
904  if ($ilUser->getId() == $this->object->getId())
905  {
906  $ilUser->readPrefs();
907  }
908  $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
909  $ilUser->writePrefs();
910 
911  $mail_message = $this->__sendProfileMail();
912  $msg = $this->lng->txt('saved_successfully').$mail_message;
913 
914  // same personal image
915  if($this->isSettingChangeable('upload'))
916  {
917  $this->uploadUserPictureObject();
918  }
919 
920  if( $profileMaybeIncomplete )
921  {
922  include_once 'Services/User/classes/class.ilUserProfile.php';
923  if( ilUserProfile::isProfileIncomplete($this->object) )
924  {
925  $this->object->setProfileIncomplete( true );
926  $this->object->update();
927  }
928  }
929 
930  // feedback
931  ilUtil::sendSuccess($msg,true);
932 
933  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
934  {
935  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
936  }
937  else
938  {
939  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
940  }
941  }
942  else
943  {
944  $this->form_gui->setValuesByPost();
945  $tpl->setContent($this->form_gui->getHtml());
946  }
947  }
948 
952  function getValues()
953  {
954  global $ilUser, $ilSetting;
955 
956  $data = array();
957 
958  // login data
959  $data["auth_mode"] = $this->object->getAuthMode();
960  $data["login"] = $this->object->getLogin();
961  //$data["passwd"] = "********";
962  //$data["passwd2"] = "********";
963  $data["ext_account"] = $this->object->getExternalAccount();
964 
965  // system information
966  require_once './Services/Utilities/classes/class.ilFormat.php';
967  $data["create_date"] = ilFormat::formatDate($this->object->getCreateDate(),'datetime',true);
968  $data["owner"] = ilObjUser::_lookupLogin($this->object->getOwner());
969  $data["approve_date"] = ($this->object->getApproveDate() != "")
970  ? ilFormat::formatDate($this->object->getApproveDate(),'datetime',true)
971  : null;
972  $data["agree_date"] = ($this->object->getAgreeDate() != "")
973  ? ilFormat::formatDate($this->object->getAgreeDate(),'datetime',true)
974  : null;
975  $data["last_login"] = ($this->object->getLastLogin() != "")
976  ? ilFormat::formatDate($this->object->getLastLogin(),'datetime',true)
977  : null;
978  $data["active"] = $this->object->getActive();
979  $data["time_limit_unlimited"] = $this->object->getTimeLimitUnlimited();
980 
981  $from = new ilDateTime($this->object->getTimeLimitFrom() ? $this->object->getTimeLimitFrom() : time(),IL_CAL_UNIX);
982  $data["time_limit_from"]["date"] = $from->get(IL_CAL_FKT_DATE,'Y-m-d',$ilUser->getTimeZone());
983  $data["time_limit_from"]["time"] = $from->get(IL_CAL_FKT_DATE,'H:i:s',$ilUser->getTimeZone());
984 
985  $until = new ilDateTime($this->object->getTimeLimitUntil() ? $this->object->getTimeLimitUntil() : time(),IL_CAL_UNIX);
986  $data['time_limit_until']['date'] = $until->get(IL_CAL_FKT_DATE,'Y-m-d',$ilUser->getTimeZone());
987  $data['time_limit_until']['time'] = $until->get(IL_CAL_FKT_DATE,'H:i:s',$ilUser->getTimeZone());
988 
989 
990  // BEGIN DiskQuota, Show disk space used
991  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
993  {
994  $data["disk_quota"] = $this->object->getDiskQuota() / ilFormat::_getSizeMagnitude() / ilFormat::_getSizeMagnitude();
995  }
997  {
998  $data["wsp_disk_quota"] = $this->object->getPersonalWorkspaceDiskQuota() / ilFormat::_getSizeMagnitude() / ilFormat::_getSizeMagnitude();
999  }
1000  // W. Randelshofer 2008-09-09: Deactivated display of disk space usage,
1001  // because determining the disk space usage may take several minutes.
1002  /*
1003  require_once "Modules/File/classes/class.ilObjFileAccess.php";
1004  require_once "Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php";
1005  require_once "Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
1006  require_once "Services/Mail/classes/class.ilObjMailAccess.php";
1007  require_once "Modules/Forum/classes/class.ilObjForumAccess.php";
1008  require_once "Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
1009  $data["disk_space_used"] =
1010  ilObjFileAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1011  ilObjFileBasedLMAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1012  ilObjSAHSLearningModuleAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1013  ilObjMailAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1014  ilObjForumAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1015  ilObjMediaCastAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>';
1016  */
1017  // END DiskQuota, Show disk space used
1018 
1019  // personal data
1020  $data["gender"] = $this->object->getGender();
1021  $data["firstname"] = $this->object->getFirstname();
1022  $data["lastname"] = $this->object->getLastname();
1023  $data["title"] = $this->object->getUTitle();
1024  $data['birthday'] = $this->object->getBirthday();
1025  $data["institution"] = $this->object->getInstitution();
1026  $data["department"] = $this->object->getDepartment();
1027  $data["street"] = $this->object->getStreet();
1028  $data["city"] = $this->object->getCity();
1029  $data["zipcode"] = $this->object->getZipcode();
1030  $data["country"] = $this->object->getCountry();
1031  $data["sel_country"] = $this->object->getSelectedCountry();
1032  $data["phone_office"] = $this->object->getPhoneOffice();
1033  $data["phone_home"] = $this->object->getPhoneHome();
1034  $data["phone_mobile"] = $this->object->getPhoneMobile();
1035  $data["fax"] = $this->object->getFax();
1036  $data["email"] = $this->object->getEmail();
1037  $data["hobby"] = $this->object->getHobby();
1038  $data["referral_comment"] = $this->object->getComment();
1039 
1040  // instant messengers
1041  $data["im_icq"] = $this->object->getInstantMessengerId('icq');
1042  $data["im_yahoo"] = $this->object->getInstantMessengerId('yahoo');
1043  $data["im_msn"] = $this->object->getInstantMessengerId('msn');
1044  $data["im_aim"] = $this->object->getInstantMessengerId('aim');
1045  $data["im_skype"] = $this->object->getInstantMessengerId('skype');
1046  $data["im_jabber"] = $this->object->getInstantMessengerId('jabber');
1047  $data["im_voip"] = $this->object->getInstantMessengerId('voip');
1048 
1049  // other data
1050  $data["matriculation"] = $this->object->getMatriculation();
1051  $data["delicious"] = $this->object->getDelicious();
1052  $data["client_ip"] = $this->object->getClientIP();
1053 
1054  // user defined fields
1055  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1056  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
1057  $user_defined_data = $this->object->getUserDefinedData();
1058  foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
1059  {
1060  $data["udf_".$field_id] = $user_defined_data["f_".$field_id];
1061  }
1062 
1063  // settings
1064  $data["language"] = $this->object->getLanguage();
1065  $data["skin_style"] = $this->object->skin.":".$this->object->prefs["style"];
1066  $data["hits_per_page"] = $this->object->prefs["hits_per_page"];
1067  $data["show_users_online"] = $this->object->prefs["show_users_online"];
1068  $data["hide_own_online_status"] = $this->object->prefs["hide_own_online_status"] == 'y';
1069  $data["session_reminder_enabled"] = (int)$this->object->prefs["session_reminder_enabled"];
1070 
1071  $this->form_gui->setValuesByArray($data);
1072  }
1073 
1077  function initForm($a_mode)
1078  {
1079  global $lng, $ilCtrl, $styleDefinition, $ilSetting, $ilClientIniFile, $ilUser;
1080 
1081  $settings = $ilSetting->getAll();
1082 
1083  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1084 
1085  $this->form_gui = new ilPropertyFormGUI();
1086  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1087  if ($a_mode == "create")
1088  {
1089  $this->form_gui->setTitle($lng->txt("usr_new"));
1090  }
1091  else
1092  {
1093  $this->form_gui->setTitle($lng->txt("usr_edit"));
1094  }
1095 
1096  // login data
1097  $sec_l = new ilFormSectionHeaderGUI();
1098  $sec_l->setTitle($lng->txt("login_data"));
1099  $this->form_gui->addItem($sec_l);
1100 
1101  // authentication mode
1102  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1103  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
1104  $am = new ilSelectInputGUI($lng->txt("auth_mode"), "auth_mode");
1105  $option = array();
1106  foreach ($active_auth_modes as $auth_name => $auth_key)
1107  {
1108  if ($auth_name == 'default')
1109  {
1110  $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
1111  }
1112  else
1113  {
1114  $name = $this->lng->txt('auth_'.$auth_name);
1115  }
1116  $option[$auth_name] = $name;
1117  }
1118  $am->setOptions($option);
1119  $this->form_gui->addItem($am);
1120 
1121  // login
1122  $lo = new ilUserLoginInputGUI($lng->txt("login"), "login");
1123  $lo->setRequired(true);
1124  if ($a_mode == "edit")
1125  {
1126  $lo->setCurrentUserId($this->object->getId());
1127  try
1128  {
1129  include_once 'Services/Calendar/classes/class.ilDate.php';
1130 
1131  $last_history_entry = ilObjUser::_getLastHistoryDataByUserId($this->object->getId());
1132  $lo->setInfo(
1133  sprintf(
1134  $this->lng->txt('usr_loginname_history_info'),
1135  ilDatePresentation::formatDate(new ilDateTime($last_history_entry[1], IL_CAL_UNIX)),
1136  $last_history_entry[0]
1137  )
1138  );
1139  }
1140  catch(ilUserException $e) { }
1141  }
1142 
1143  $this->form_gui->addItem($lo);
1144 
1145  // passwords
1146 // @todo: do not show passwords, if there is not a single auth, that
1147 // allows password setting
1148  {
1149  $pw = new ilPasswordInputGUI($lng->txt("passwd"), "passwd");
1150  $pw->setSize(32);
1151  $pw->setMaxLength(32);
1152  $pw->setValidateAuthPost("auth_mode");
1153  if ($a_mode == "create")
1154  {
1155  $pw->setRequiredOnAuth(true);
1156  }
1157  $pw->setInfo(ilUtil::getPasswordRequirementsInfo());
1158  $this->form_gui->addItem($pw);
1159  }
1160  // @todo: invisible/hidden passwords
1161 
1162  // external account
1163  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1165  {
1166  $ext = new ilTextInputGUI($lng->txt("user_ext_account"), "ext_account");
1167  $ext->setSize(40);
1168  $ext->setMaxLength(50);
1169  $ext->setInfo($lng->txt("user_ext_account_desc"));
1170  $this->form_gui->addItem($ext);
1171  }
1172 
1173  // login data
1174  $sec_si = new ilFormSectionHeaderGUI();
1175  $sec_si->setTitle($this->lng->txt("system_information"));
1176  $this->form_gui->addItem($sec_si);
1177 
1178  // create date, approve date, agreement date, last login
1179  if ($a_mode == "edit")
1180  {
1181  $sia = array("create_date", "approve_date", "agree_date", "last_login", "owner");
1182  foreach($sia as $a)
1183  {
1184  $siai = new ilNonEditableValueGUI($lng->txt($a), $a);
1185  $this->form_gui->addItem($siai);
1186  }
1187  }
1188 
1189  // active
1190  $ac = new ilCheckboxInputGUI($lng->txt("active"), "active");
1191  $ac->setChecked(true);
1192  $this->form_gui->addItem($ac);
1193 
1194  // access @todo: get fields right (names change)
1195  $lng->loadLanguageModule('crs');
1196 
1197  // access
1198  $radg = new ilRadioGroupInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1199  $radg->setValue(1);
1200  $op1 = new ilRadioOption($lng->txt("user_access_unlimited"), 1);
1201  $radg->addOption($op1);
1202  $op2 = new ilRadioOption($lng->txt("user_access_limited"), 0);
1203  $radg->addOption($op2);
1204 
1205 // $ac = new ilCheckboxInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1206 // $ac->setChecked(true);
1207 // $ac->setOptionTitle($lng->txt("crs_unlimited"));
1208 
1209  // access.from
1210  $acfrom = new ilDateTimeInputGUI($this->lng->txt("crs_from"), "time_limit_from");
1211  $acfrom->setShowTime(true);
1212 // $ac->addSubItem($acfrom);
1213  $op2->addSubItem($acfrom);
1214 
1215  // access.to
1216  $acto = new ilDateTimeInputGUI($this->lng->txt("crs_to"), "time_limit_until");
1217  $acto->setShowTime(true);
1218 // $ac->addSubItem($acto);
1219  $op2->addSubItem($acto);
1220 
1221 // $this->form_gui->addItem($ac);
1222  $this->form_gui->addItem($radg);
1223 
1224  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
1226  {
1227  $lng->loadLanguageModule("file");
1228 
1229  $quota_head = new ilFormSectionHeaderGUI();
1230  $quota_head->setTitle($lng->txt("repository_disk_quota"));
1231  $this->form_gui->addItem($quota_head);
1232 
1233  // disk quota
1234  $disk_quota = new ilTextInputGUI($lng->txt("disk_quota"), "disk_quota");
1235  $disk_quota->setSize(10);
1236  $disk_quota->setMaxLength(11);
1237  $disk_quota->setInfo($this->lng->txt("enter_in_mb_desc"));
1238  $this->form_gui->addItem($disk_quota);
1239 
1240  if ($a_mode == "edit")
1241  {
1242  // show which disk quota is in effect, and explain why
1243  require_once 'Services/WebDAV/classes/class.ilDiskQuotaChecker.php';
1244  $dq_info = ilDiskQuotaChecker::_lookupDiskQuota($this->object->getId());
1245  if ($dq_info['user_disk_quota'] > $dq_info['role_disk_quota'])
1246  {
1247  $info_text = sprintf($lng->txt('disk_quota_is_1_instead_of_2_by_3'),
1248  ilFormat::formatSize($dq_info['user_disk_quota'],'short'),
1249  ilFormat::formatSize($dq_info['role_disk_quota'],'short'),
1250  $dq_info['role_title']);
1251  }
1252  else if (is_infinite($dq_info['role_disk_quota']))
1253  {
1254  $info_text = sprintf($lng->txt('disk_quota_is_unlimited_by_1'), $dq_info['role_title']);
1255  }
1256  else
1257  {
1258  $info_text = sprintf($lng->txt('disk_quota_is_1_by_2'),
1259  ilFormat::formatSize($dq_info['role_disk_quota'],'short'),
1260  $dq_info['role_title']);
1261  }
1262  $disk_quota->setInfo($this->lng->txt("enter_in_mb_desc").'<br>'.$info_text);
1263 
1264 
1265  // disk usage
1266  $du_info = ilDiskQuotaChecker::_lookupDiskUsage($this->object->getId());
1267  $disk_usage = new ilNonEditableValueGUI($lng->txt("disk_usage"), "disk_usage");
1268  if ($du_info['last_update'] === null)
1269  {
1270  $disk_usage->setValue($lng->txt('unknown'));
1271  }
1272  else
1273  {
1274  require_once './Services/Utilities/classes/class.ilFormat.php';
1275  $disk_usage->setValue(ilFormat::formatSize($du_info['disk_usage'],'short'));
1276  $info = '<table class="il_user_quota_disk_usage_overview">';
1277  // write the count and size of each object type
1278  foreach ($du_info['details'] as $detail_data)
1279  {
1280  $info .= '<tr>'.
1281  '<td class="std">'.$detail_data['count'].'</td>'.
1282  '<td class="std">'.$lng->txt($detail_data['type']).'</td>'.
1283  '<td class="std">'.ilFormat::formatSize($detail_data['size'], 'short').'</td>'.
1284  '</tr>'
1285  ;
1286  }
1287  $info .= '</table>';
1288  $info .= '<br>'.$this->lng->txt('last_update').': '.
1289  ilDatePresentation::formatDate(new ilDateTime($du_info['last_update'], IL_CAL_DATETIME));
1290  $disk_usage->setInfo($info);
1291 
1292  }
1293  $this->form_gui->addItem($disk_usage);
1294 
1295  // date when the last disk quota reminder was sent to the user
1296  if (true || $dq_info['last_reminder'])
1297  {
1298  $reminder = new ilNonEditableValueGUI($lng->txt("disk_quota_last_reminder_sent"), "last_reminder");
1299  $reminder->setValue(
1300  ilDatePresentation::formatDate(new ilDateTime($dq_info['last_reminder'], IL_CAL_DATETIME))
1301  );
1302  $reminder->setInfo($this->lng->txt("disk_quota_last_reminder_sent_desc"));
1303  $this->form_gui->addItem($reminder);
1304  }
1305  }
1306  }
1307 
1309  {
1310  $lng->loadLanguageModule("file");
1311 
1312  $quota_head = new ilFormSectionHeaderGUI();
1313  $quota_head->setTitle($lng->txt("personal_workspace_disk_quota"));
1314  $this->form_gui->addItem($quota_head);
1315 
1316  // personal workspace disk quota
1317  $wsp_disk_quota = new ilTextInputGUI($lng->txt("disk_quota"), "wsp_disk_quota");
1318  $wsp_disk_quota->setSize(10);
1319  $wsp_disk_quota->setMaxLength(11);
1320  $wsp_disk_quota->setInfo($this->lng->txt("enter_in_mb_desc"));
1321  $this->form_gui->addItem($wsp_disk_quota);
1322 
1323  if ($a_mode == "edit")
1324  {
1325  // show which disk quota is in effect, and explain why
1326  require_once 'Services/WebDAV/classes/class.ilDiskQuotaChecker.php';
1327  $dq_info = ilDiskQuotaChecker::_lookupPersonalWorkspaceDiskQuota($this->object->getId());
1328  if ($dq_info['user_wsp_disk_quota'] > $dq_info['role_wsp_disk_quota'])
1329  {
1330  $info_text = sprintf($lng->txt('disk_quota_is_1_instead_of_2_by_3'),
1331  ilFormat::formatSize($dq_info['user_wsp_disk_quota'],'short'),
1332  ilFormat::formatSize($dq_info['role_wsp_disk_quota'],'short'),
1333  $dq_info['role_title']);
1334  }
1335  else if (is_infinite($dq_info['role_wsp_disk_quota']))
1336  {
1337  $info_text = sprintf($lng->txt('disk_quota_is_unlimited_by_1'), $dq_info['role_title']);
1338  }
1339  else
1340  {
1341  $info_text = sprintf($lng->txt('disk_quota_is_1_by_2'),
1342  ilFormat::formatSize($dq_info['role_wsp_disk_quota'],'short'),
1343  $dq_info['role_title']);
1344  }
1345  $wsp_disk_quota->setInfo($this->lng->txt("enter_in_mb_desc").'<br>'.$info_text);
1346  }
1347 
1348  // disk usage
1349  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1350  $du_info = ilDiskQuotaHandler::getFilesizeByTypeAndOwner($this->object->getId());
1351  $disk_usage = new ilNonEditableValueGUI($lng->txt("disk_usage"), "disk_usage");
1352  if (!sizeof($du_info))
1353  {
1354  $disk_usage->setValue($lng->txt('unknown'));
1355  }
1356  else
1357  {
1358  require_once './Services/Utilities/classes/class.ilFormat.php';
1359  $disk_usage->setValue(ilFormat::formatSize(ilDiskQuotaHandler::getFilesizeByOwner($this->object->getId())));
1360  $info = '<table class="il_user_quota_disk_usage_overview">';
1361  // write the count and size of each object type
1362  foreach ($du_info as $detail_data)
1363  {
1364  $info .= '<tr>'.
1365  '<td class="std">'.$detail_data['count'].'</td>'.
1366  '<td class="std">'.$lng->txt("obj_".$detail_data["src_type"]).'</td>'.
1367  '<td class="std">'.ilFormat::formatSize($detail_data['filesize'], 'short').'</td>'.
1368  '</tr>'
1369  ;
1370  }
1371  $info .= '</table>';
1372  $disk_usage->setInfo($info);
1373 
1374  }
1375  $this->form_gui->addItem($disk_usage);
1376  }
1377 
1378  // personal data
1379  if(
1380  $this->isSettingChangeable('gender') or
1381  $this->isSettingChangeable('firstname') or
1382  $this->isSettingChangeable('lastname') or
1383  $this->isSettingChangeable('title') or
1384  $this->isSettingChangeable('personal_image') or
1385  $this->isSettingChangeable('birhtday')
1386  )
1387  {
1388  $sec_pd = new ilFormSectionHeaderGUI();
1389  $sec_pd->setTitle($this->lng->txt("personal_data"));
1390  $this->form_gui->addItem($sec_pd);
1391  }
1392 
1393  // gender
1394  if($this->isSettingChangeable('gender'))
1395  {
1396  $gndr = new ilRadioGroupInputGUI($lng->txt("gender"), "gender");
1397  $gndr->setRequired(isset($settings["require_gender"]) && $settings["require_gender"]);
1398  $female = new ilRadioOption($lng->txt("gender_f"), "f");
1399  $gndr->addOption($female);
1400  $male = new ilRadioOption($lng->txt("gender_m"), "m");
1401  $gndr->addOption($male);
1402  $this->form_gui->addItem($gndr);
1403  }
1404 
1405  // firstname, lastname, title
1406  $fields = array("firstname" => true, "lastname" => true,
1407  "title" => isset($settings["require_title"]) && $settings["require_title"]);
1408  foreach($fields as $field => $req)
1409  {
1410  if($this->isSettingChangeable($field))
1411  {
1412  $inp = new ilTextInputGUI($lng->txt($field), $field);
1413  $inp->setSize(32);
1414  $inp->setMaxLength(32);
1415  $inp->setRequired($req);
1416  $this->form_gui->addItem($inp);
1417  }
1418  }
1419 
1420  // personal image
1421  if($this->isSettingChangeable('upload'))
1422  {
1423  $pi = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
1424  if ($a_mode == "edit" || $a_mode == "upload")
1425  {
1426  $pi->setImage(ilObjUser::_getPersonalPicturePath($this->object->getId(), "small", true,
1427  true));
1428  }
1429  $this->form_gui->addItem($pi);
1430  }
1431 
1432  if($this->isSettingChangeable('birthday'))
1433  {
1434  $birthday = new ilBirthdayInputGUI($lng->txt('birthday'), 'birthday');
1435  $birthday->setRequired(isset($settings["require_birthday"]) && $settings["require_birthday"]);
1436  $birthday->setShowEmpty(true);
1437  $birthday->setStartYear(1900);
1438  $this->form_gui->addItem($birthday);
1439  }
1440 
1441 
1442  // institution, department, street, city, zip code, country, phone office
1443  // phone home, phone mobile, fax, e-mail
1444  $fields = array(
1445  array("institution", 40, 80),
1446  array("department", 40, 80),
1447  array("street", 40, 40),
1448  array("city", 40, 40),
1449  array("zipcode", 10, 10),
1450  array("country", 40, 40),
1451  array("sel_country"),
1452  array("phone_office", 30, 30),
1453  array("phone_home", 30, 30),
1454  array("phone_mobile", 30, 30),
1455  array("fax", 30, 30));
1456 
1457  $counter = 0;
1458  foreach ($fields as $field)
1459  {
1460  if(!$counter++ and $this->isSettingChangeable($field[0]))
1461  {
1462  // contact data
1463  $sec_cd = new ilFormSectionHeaderGUI();
1464  $sec_cd->setTitle($this->lng->txt("contact_data"));
1465  $this->form_gui->addItem($sec_cd);
1466  }
1467  if($this->isSettingChangeable($field[0]))
1468  {
1469  if ($field[0] != "sel_country")
1470  {
1471  $inp = new ilTextInputGUI($lng->txt($field[0]), $field[0]);
1472  $inp->setSize($field[1]);
1473  $inp->setMaxLength($field[2]);
1474  $inp->setRequired(isset($settings["require_".$field[0]]) &&
1475  $settings["require_".$field[0]]);
1476  $this->form_gui->addItem($inp);
1477  }
1478  else
1479  {
1480  // country selection
1481  include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
1482  $cs = new ilCountrySelectInputGUI($lng->txt($field[0]), $field[0]);
1483  $cs->setRequired(isset($settings["require_".$field[0]]) &&
1484  $settings["require_".$field[0]]);
1485  $this->form_gui->addItem($cs);
1486  }
1487  }
1488  }
1489 
1490  // email
1491  if($this->isSettingChangeable('email'))
1492  {
1493  $em = new ilEMailInputGUI($lng->txt("email"), "email");
1494  $em->setRequired(isset($settings["require_email"]) &&
1495  $settings["require_email"]);
1496  $this->form_gui->addItem($em);
1497  }
1498 
1499  // interests/hobbies
1500  if($this->isSettingChangeable('hobby'))
1501  {
1502  $hob = new ilTextAreaInputGUI($lng->txt("hobby"), "hobby");
1503  $hob->setRows(3);
1504  $hob->setCols(40);
1505  $hob->setRequired(isset($settings["require_hobby"]) &&
1506  $settings["require_hobby"]);
1507  $this->form_gui->addItem($hob);
1508  }
1509 
1510  // referral comment
1511  if($this->isSettingChangeable('referral_comment'))
1512  {
1513  $rc = new ilTextAreaInputGUI($lng->txt("referral_comment"), "referral_comment");
1514  $rc->setRows(3);
1515  $rc->setCols(40);
1516  $rc->setRequired(isset($settings["require_referral_comment"]) &&
1517  $settings["require_referral_comment"]);
1518  $this->form_gui->addItem($rc);
1519  }
1520 
1521  // instant messengers
1522  if($this->isSettingChangeable('instant_messengers'))
1523  {
1524  $sec_im = new ilFormSectionHeaderGUI();
1525  $sec_im->setTitle($this->lng->txt("instant_messengers"));
1526  $this->form_gui->addItem($sec_im);
1527  }
1528 
1529  // icq, yahoo, msn, aim, skype
1530  $fields = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
1531  foreach ($fields as $field)
1532  {
1533  if($this->isSettingChangeable('instant_messengers'))
1534  {
1535  $im = new ilTextInputGUI($lng->txt("im_".$field), "im_".$field);
1536  $im->setSize(40);
1537  $im->setMaxLength(40);
1538  $this->form_gui->addItem($im);
1539  }
1540  }
1541 
1542  // other information
1543  if($this->isSettingChangeable('user_profile_other'))
1544  {
1545  $sec_oi = new ilFormSectionHeaderGUI();
1546  $sec_oi->setTitle($this->lng->txt("user_profile_other"));
1547  $this->form_gui->addItem($sec_oi);
1548  }
1549 
1550  // matriculation number
1551  if($this->isSettingChangeable('matriculation'))
1552  {
1553  $mr = new ilTextInputGUI($lng->txt("matriculation"), "matriculation");
1554  $mr->setSize(40);
1555  $mr->setMaxLength(40);
1556  $mr->setRequired(isset($settings["require_matriculation"]) &&
1557  $settings["require_matriculation"]);
1558  $this->form_gui->addItem($mr);
1559  }
1560 
1561  // delicious
1562  if($this->isSettingChangeable('delicious'))
1563  {
1564  $mr = new ilTextInputGUI($lng->txt("delicious"), "delicious");
1565  $mr->setSize(40);
1566  $mr->setMaxLength(40);
1567  $mr->setRequired(isset($settings["require_delicious"]) &&
1568  $settings["require_delicious"]);
1569  $this->form_gui->addItem($mr);
1570  }
1571 
1572  // client IP
1573  $ip = new ilTextInputGUI($lng->txt("client_ip"), "client_ip");
1574  $ip->setSize(40);
1575  $ip->setMaxLength(255);
1576  $ip->setInfo($this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"]." <br />".
1577  '<span class="warning">'.$this->lng->txt("current_ip_alert")."</span>");
1578  $this->form_gui->addItem($ip);
1579 
1580  // additional user defined fields
1581  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1582  $user_defined_fields = ilUserDefinedFields::_getInstance();
1583 
1584  if($this->usrf_ref_id == USER_FOLDER_ID)
1585  {
1586  $all_defs = $user_defined_fields->getDefinitions();
1587  }
1588  else
1589  {
1590  $all_defs = $user_defined_fields->getChangeableLocalUserAdministrationDefinitions();
1591  }
1592 
1593  foreach($all_defs as $field_id => $definition)
1594  {
1595  if($definition['field_type'] == UDF_TYPE_TEXT) // text input
1596  {
1597  $udf = new ilTextInputGUI($definition['field_name'],
1598  "udf_".$definition['field_id']);
1599  $udf->setSize(40);
1600  $udf->setMaxLength(255);
1601  }
1602  else if($definition['field_type'] == UDF_TYPE_WYSIWYG) // text area input
1603  {
1604  $udf = new ilTextAreaInputGUI($definition['field_name'],
1605  "udf_".$definition['field_id']);
1606  $udf->setUseRte(true);
1607  }
1608  else // selection input
1609  {
1610  $udf = new ilSelectInputGUI($definition['field_name'],
1611  "udf_".$definition['field_id']);
1612  $udf->setOptions($user_defined_fields->fieldValuesToSelectArray(
1613  $definition['field_values']));
1614  }
1615  $udf->setRequired($definition['required']);
1616  $this->form_gui->addItem($udf);
1617  }
1618 
1619  // settings
1620  if(
1621  $a_mode == 'create' or
1622  $this->isSettingChangeable( 'language') or
1623  $this->isSettingChangeable( 'skin_style') or
1624  $this->isSettingChangeable( 'hits_per_page') or
1625  $this->isSettingChangeable( 'hide_own_online_status')
1626  )
1627  {
1628  $sec_st = new ilFormSectionHeaderGUI();
1629  $sec_st->setTitle($this->lng->txt("settings"));
1630  $this->form_gui->addItem($sec_st);
1631  }
1632 
1633  // role
1634  if ($a_mode == "create")
1635  {
1636  $role = new ilSelectInputGUI($lng->txt("default_role"),
1637  'default_role');
1638  $role->setRequired(true);
1639  $role->setValue($this->default_role);
1640  $role->setOptions($this->selectable_roles);
1641  $this->form_gui->addItem($role);
1642  }
1643 
1644  // language
1645  if($this->isSettingChangeable('language'))
1646  {
1647  $lang = new ilSelectInputGUI($lng->txt("language"),
1648  'language');
1649  $languages = $lng->getInstalledLanguages();
1650  $lng->loadLanguageModule("meta");
1651  $options = array();
1652  foreach($languages as $l)
1653  {
1654  $options[$l] = $lng->txt("meta_l_".$l);
1655  }
1656  $lang->setOptions($options);
1657  $lang->setValue($ilSetting->get("language"));
1658  $this->form_gui->addItem($lang);
1659  }
1660 
1661  // skin/style
1662  if($this->isSettingChangeable('skin_style'))
1663  {
1664  $sk = new ilSelectInputGUI($lng->txt("skin_style"),
1665  'skin_style');
1666  $templates = $styleDefinition->getAllTemplates();
1667 
1668  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
1669 
1670  $options = array();
1671  if (count($templates) > 0 && is_array ($templates))
1672  {
1673  foreach ($templates as $template)
1674  {
1675  $styleDef =& new ilStyleDefinition($template["id"]);
1676  $styleDef->startParsing();
1677  $styles = $styleDef->getStyles();
1678  foreach ($styles as $style)
1679  {
1680  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
1681  {
1682  continue;
1683  }
1684  $options[$template["id"].":".$style["id"]] =
1685  $styleDef->getTemplateName()." / ".$style["name"];
1686  }
1687  }
1688  }
1689  $sk->setOptions($options);
1690  $sk->setValue($ilClientIniFile->readVariable("layout","skin").
1691  ":".$ilClientIniFile->readVariable("layout","style"));
1692 
1693  $this->form_gui->addItem($sk);
1694  }
1695 
1696  // hits per page
1697  if($this->isSettingChangeable('hits_per_page'))
1698  {
1699  $hpp = new ilSelectInputGUI($lng->txt("hits_per_page"),
1700  'hits_per_page');
1701  $options = array(10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
1702  50 => 50, 100 => 100, 9999 => $this->lng->txt("no_limit"));
1703  $hpp->setOptions($options);
1704  $hpp->setValue($ilSetting->get("hits_per_page"));
1705  $this->form_gui->addItem($hpp);
1706 
1707  // users online
1708  $uo = new ilSelectInputGUI($lng->txt("users_online"),
1709  'show_users_online');
1710  $options = array(
1711  "y" => $lng->txt("users_online_show_y"),
1712  "associated" => $lng->txt("users_online_show_associated"),
1713  "n" => $lng->txt("users_online_show_n"));
1714  $uo->setOptions($options);
1715  $uo->setValue($ilSetting->get("show_users_online"));
1716  $this->form_gui->addItem($uo);
1717  }
1718 
1719  // hide online status
1720  if($this->isSettingChangeable('hide_own_online_status'))
1721  {
1722  $os = new ilCheckboxInputGUI($lng->txt("hide_own_online_status"), "hide_own_online_status");
1723  $this->form_gui->addItem($os);
1724  }
1725 
1726  if((int)$ilSetting->get('session_reminder_enabled'))
1727  {
1728  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
1729  $cb->setValue(1);
1730  $this->form_gui->addItem($cb);
1731  }
1732 
1733  // Options
1734  if($this->isSettingChangeable('send_mail'))
1735  {
1736  $sec_op = new ilFormSectionHeaderGUI();
1737  $sec_op->setTitle($this->lng->txt("options"));
1738  $this->form_gui->addItem($sec_op);
1739  }
1740 
1741  // send email
1742  $se = new ilCheckboxInputGUI($lng->txt('inform_user_mail'), 'send_mail');
1743  $se->setInfo($lng->txt('inform_user_mail_info'));
1744  $se->setValue('y');
1745  $se->setChecked(($ilUser->getPref('send_info_mails') == 'y'));
1746  $this->form_gui->addItem($se);
1747 
1748  // ignore required fields
1749  $irf = new ilCheckboxInputGUI($lng->txt('ignore_required_fields'), 'ignore_rf');
1750  $irf->setInfo($lng->txt('ignore_required_fields_info'));
1751  $irf->setValue(1);
1752  $this->form_gui->addItem($irf);
1753 
1754  // @todo: handle all required fields
1755 
1756  // command buttons
1757  if ($a_mode == "create" || $a_mode == "save")
1758  {
1759  $this->form_gui->addCommandButton("save", $lng->txt("save"));
1760  }
1761  if ($a_mode == "edit" || $a_mode == "update")
1762  {
1763  $this->form_gui->addCommandButton("update", $lng->txt("save"));
1764  }
1765  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
1766  }
1767 
1776  protected function isSettingChangeable($a_field)
1777  {
1778  // TODO: Allow mixed field parameter to support checks against an array of field names.
1779 
1780  global $ilSetting;
1781  static $settings = null;
1782 
1783 
1784 
1785  if($this->usrf_ref_id == USER_FOLDER_ID)
1786  {
1787  return true;
1788  }
1789 
1790  if($settings == NULL)
1791  {
1792  $settings = $ilSetting->getAll();
1793  }
1794  return (bool) $settings['usr_settings_changeable_lua_'.$a_field];
1795  }
1796 
1802  function editOldObject()
1803  {
1804  global $ilias, $rbacsystem, $rbacreview, $rbacadmin, $styleDefinition, $ilUser
1805  ,$ilSetting;
1806 
1807  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1808 
1809 
1810  //load ILIAS settings
1811  $settings = $ilias->getAllSettings();
1812 
1813  // User folder
1814  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
1815  {
1816  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
1817  }
1818  // if called from local administration $this->usrf_ref_id is category id
1819  // Todo: this has to be fixed. Do not mix user folder id and category id
1820  if($this->usrf_ref_id != USER_FOLDER_ID)
1821  {
1822  // check if user is assigned to category
1823  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
1824  {
1825  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
1826  }
1827  }
1828 
1829  if($this->usrf_ref_id != USER_FOLDER_ID)
1830  {
1831  $this->tabs_gui->clearTargets();
1832  }
1833 
1834  $data = array();
1835  $data["fields"] = array();
1836  $data["fields"]["login"] = $this->object->getLogin();
1837  $data["fields"]["passwd"] = "********"; // will not be saved
1838  #$data["fields"]["passwd2"] = "********"; // will not be saved
1839  $data["fields"]["ext_account"] = $this->object->getExternalAccount();
1840  $data["fields"]["title"] = $this->object->getUTitle();
1841  $data["fields"]["gender"] = $this->object->getGender();
1842  $data["fields"]["firstname"] = $this->object->getFirstname();
1843  $data["fields"]["lastname"] = $this->object->getLastname();
1844  $data["fields"]["institution"] = $this->object->getInstitution();
1845  $data["fields"]["department"] = $this->object->getDepartment();
1846  $data["fields"]["street"] = $this->object->getStreet();
1847  $data["fields"]["city"] = $this->object->getCity();
1848  $data["fields"]["zipcode"] = $this->object->getZipcode();
1849  $data["fields"]["country"] = $this->object->getCountry();
1850  $data["fields"]["sel_country"] = $this->object->getSelectedCountry();
1851  $data["fields"]["phone_office"] = $this->object->getPhoneOffice();
1852  $data["fields"]["phone_home"] = $this->object->getPhoneHome();
1853  $data["fields"]["phone_mobile"] = $this->object->getPhoneMobile();
1854  $data["fields"]["fax"] = $this->object->getFax();
1855  $data["fields"]["email"] = $this->object->getEmail();
1856  $data["fields"]["hobby"] = $this->object->getHobby();
1857  $data["fields"]["im_icq"] = $this->object->getInstantMessengerId('icq');
1858  $data["fields"]["im_yahoo"] = $this->object->getInstantMessengerId('yahoo');
1859  $data["fields"]["im_msn"] = $this->object->getInstantMessengerId('msn');
1860  $data["fields"]["im_aim"] = $this->object->getInstantMessengerId('aim');
1861  $data["fields"]["im_skype"] = $this->object->getInstantMessengerId('skype');
1862  $data["fields"]["im_jabber"] = $this->object->getInstantMessengerId('jabber');
1863  $data["fields"]["im_voip"] = $this->object->getInstantMessengerId('voip');
1864  $data["fields"]["matriculation"] = $this->object->getMatriculation();
1865  $data["fields"]["client_ip"] = $this->object->getClientIP();
1866  $data["fields"]["referral_comment"] = $this->object->getComment();
1867  $data["fields"]["owner"] = ilObjUser::_lookupLogin($this->object->getOwner());
1868  $data["fields"]["create_date"] = $this->object->getCreateDate();
1869  $data["fields"]["approve_date"] = $this->object->getApproveDate();
1870  $data["fields"]["agree_date"] = $this->object->getAgreeDate();
1871  $data["fields"]["last_login"] = $this->object->getLastLogin();
1872  $data["fields"]["active"] = $this->object->getActive();
1873  $data["fields"]["auth_mode"] = $this->object->getAuthMode();
1874  $data["fields"]["ext_account"] = $this->object->getExternalAccount();
1875 
1876  // BEGIN DiskQuota Get Picture, Owner, Last login, Approve Date and AgreeDate
1877  $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("personal_picture"));
1878  $webspace_dir = ilUtil::getWebspaceDir("output");
1879  $full_img = $this->object->getPref("profile_image");
1880  $last_dot = strrpos($full_img, ".");
1881  $small_img = substr($full_img, 0, $last_dot).
1882  "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
1883  $image_file = $webspace_dir."/usr_images/".$small_img;
1884  if (@is_file($image_file))
1885  {
1886  $this->tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
1887  $this->tpl->setVariable("ALT_IMG_PERSONAL",$this->lng->txt("personal_picture"));
1888  $this->tpl->setVariable("TXT_REMOVE_PIC", $this->lng->txt("remove_personal_picture"));
1889  }
1890 
1891  $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
1892  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("userfile"));
1893  $this->tpl->setVariable("USER_FILE", $this->lng->txt("user_file"));
1894  // END DiskQuota Get Picture, Owner, Last login, Approve Date and AgreeDate
1895 
1896  // BEGIN DiskQuota, Show disk space used
1897  // W. Randelshofer 2008-07-07: Deactivated display of disk space usage,
1898  // because determining the disk space usage may take several minutes.
1899  /*
1900  require_once "Modules/File/classes/class.ilObjFileAccess.php";
1901  require_once "Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php";
1902  require_once "Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
1903  require_once "Services/Mail/classes/class.ilObjMailAccess.php";
1904  require_once "Modules/Forum/classes/class.ilObjForumAccess.php";
1905  $this->tpl->setVariable('TXT_DISK_SPACE_USED',$this->lng->txt('disk_space_used'));
1906  $this->tpl->setVariable('DISK_SPACE_USED',
1907  ilObjFileAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1908  ilObjFileBasedLMAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1909  ilObjSAHSLearningModuleAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1910  ilObjMailAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1911  ilObjForumAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'
1912  );
1913  */
1914  // END DiskQuota, Show disk space used
1915 
1916  if (!count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
1917  {
1918  $user_is_online = false;
1919  }
1920  else
1921  {
1922  $user_is_online = true;
1923 
1924  // extract serialized role Ids from session data
1925  preg_match("/RoleId.*?;\}/",$user_online[$this->object->getId()]["data"],$matches);
1926 
1927  $active_roles = unserialize(substr($matches[0],7));
1928 
1929  // gather data for active roles
1930  $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
1931 
1932  foreach ($assigned_roles as $key => $role)
1933  {
1934  $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role);
1935 
1936  // fetch context path of role
1937  $rolf = $rbacreview->getFoldersAssignedToRole($role,true);
1938 
1939  // only list roles that are not set to status "deleted"
1940  if (count($rolf) > 0)
1941  {
1942  if (!$rbacreview->isDeleted($rolf[0]))
1943  {
1944  $path = "";
1945 
1946  if ($this->tree->isInTree($rolf[0]))
1947  {
1948  $tmpPath = $this->tree->getPathFull($rolf[0]);
1949 
1950  // count -1, to exclude the role folder itself
1951  for ($i = 0; $i < (count($tmpPath)-1); $i++)
1952  {
1953  if ($path != "")
1954  {
1955  $path .= " > ";
1956  }
1957 
1958  $path .= $tmpPath[$i]["title"];
1959  }
1960  }
1961  else
1962  {
1963  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role.")</b>";
1964  }
1965  $active_roles = $active_roles ? $active_roles : array();
1966  if (in_array($role,$active_roles))
1967  {
1968  $data["active_role"][$role]["active"] = true;
1969  }
1970 
1971  $data["active_role"][$role]["title"] = $roleObj->getTitle();
1972  $data["active_role"][$role]["context"] = $path;
1973 
1974  unset($roleObj);
1975  }
1976  }
1977  else
1978  {
1979  $path = "<b>No role folder found for role ".$role."!</b>";
1980  }
1981  }
1982  }
1983 
1984  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_edit.html','Services/User');
1985 
1986  // FILL SAVED VALUES IN CASE OF ERROR
1987  if (isset($_SESSION["error_post_vars"]["Fobject"]))
1988  {
1989  if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
1990  {
1991  $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
1992  }
1993 
1994  foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
1995  {
1996  $str = $this->lng->txt($key);
1997  if ($key == "title")
1998  {
1999  $str = $this->lng->txt("person_title");
2000  }
2001  if($key == 'passwd2')
2002  {
2003  continue;
2004  }
2005  if($key == 'passwd')
2006  {
2008  ilAuthUtils::_getAuthMode($_SESSION['error_post_vars']['Fobject']['auth_mode'])))
2009  {
2010  $this->tpl->setCurrentBlock('passwords_visible');
2011  $this->tpl->setVariable('VISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
2012  $this->tpl->setVariable('VISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
2013  $this->tpl->setVariable('VISIBLE_PASSWD',$_SESSION['error_post_vars']['Fobject']['passwd']);
2014  $this->tpl->setVariable('VISIBLE_PASSWD2',$_SESSION['error_post_vars']['Fobject']['passwd2']);
2015  $this->tpl->parseCurrentBlock();
2016  }
2017  else
2018  {
2019  $this->tpl->setCurrentBlock('passwords_invisible');
2020  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
2021  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
2022  $this->tpl->setVariable('INVISIBLE_PASSWD',strlen($this->object->getPasswd()) ?
2023  "********" :
2024  "");
2025  $this->tpl->setVariable('INVISIBLE_PASSWD2',strlen($this->object->getPasswd()) ?
2026  "********" :
2027  "");
2028  $this->tpl->setVariable('INVISIBLE_PASSWD_HIDDEN',"********");
2029  $this->tpl->parseCurrentBlock();
2030 
2031  }
2032  continue;
2033  }
2034 
2035  // check to see if dynamically required
2036  if (isset($settings["require_" . $key]) && $settings["require_" . $key])
2037  {
2038  $str = $str . '<span class="asterisk">*</span>';
2039  }
2040 
2041  $this->tpl->setVariable("TXT_".strtoupper($key), $str);
2042 
2043  if ($key != "default_role" and $key != "language"
2044  and $key != "skin_style" and $key != "hits_per_page"
2045  and $key != "show_users_online")
2046  {
2047  $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
2048  }
2049  }
2050 
2051  // gender selection
2052  $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
2053 
2054 
2055  if (!empty($gender))
2056  {
2057  $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
2058  }
2059 
2060  $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
2061  if ($active)
2062  {
2063  $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
2064  }
2065  }
2066  else
2067  {
2068  if (!isset($data["fields"]["active"]))
2069  {
2070  $data["fields"]["active"] = 0;
2071  }
2072 
2073  foreach ($data["fields"] as $key => $val)
2074  {
2075  $str = $this->lng->txt($key);
2076  if ($key == "title")
2077  {
2078  $str = $this->lng->txt("person_title");
2079  }
2080  if ($key == "ext_account")
2081  {
2082  continue;
2083  }
2084  if($key == 'passwd')
2085  {
2086  $auth_mode = $this->object->getAuthMode(true);
2088  {
2089  $this->tpl->setCurrentBlock('passwords_visible');
2090  $this->tpl->setVariable('VISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
2091  $this->tpl->setVariable('VISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
2092  $this->tpl->setVariable('VISIBLE_PASSWD',"********");
2093  $this->tpl->setVariable('VISIBLE_PASSWD2',"********");
2094  $this->tpl->parseCurrentBlock();
2095  }
2096  else
2097  {
2098  $this->tpl->setCurrentBlock('passwords_invisible');
2099  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
2100  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
2101  $this->tpl->setVariable('INVISIBLE_PASSWD',strlen($this->object->getPasswd()) ?
2102  "********" :
2103  "");
2104  $this->tpl->setVariable('INVISIBLE_PASSWD2',strlen($this->object->getPasswd()) ?
2105  "********" :
2106  "");
2107  $this->tpl->setVariable('INVISIBLE_PASSWD_HIDDEN',"********");
2108  $this->tpl->parseCurrentBlock();
2109  }
2110  continue;
2111  }
2112 
2113  // check to see if dynamically required
2114  if (isset($settings["require_" . $key]) && $settings["require_" . $key])
2115  {
2116  $str = $str . '<span class="asterisk">*</span>';
2117  }
2118 
2119  $this->tpl->setVariable("TXT_".strtoupper($key), $str);
2120 
2121  $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
2122  #$this->tpl->parseCurrentBlock();
2123  }
2124 
2125  // gender selection
2126  $gender = strtoupper($data["fields"]["gender"]);
2127 
2128  if (!empty($gender))
2129  {
2130  $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
2131  }
2132 
2133  $active = $data["fields"]["active"];
2134  if ($active)
2135  {
2136  $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
2137  }
2138  }
2139 
2140  // external account
2141  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2143  {
2144  $this->tpl->setCurrentBlock("ext_account");
2145  $this->tpl->setVariable("TXT_EXT_ACCOUNT",$this->lng->txt("user_ext_account"));
2146  $this->tpl->setVariable("TXT_EXT_ACCOUNT_DESC",$this->lng->txt("user_ext_account_desc"));
2147  if (isset($_SESSION["error_post_vars"]["Fobject"]["ext_account"]))
2148  {
2149  $this->tpl->setVariable("EXT_ACCOUNT_VAL",
2150  $_SESSION["error_post_vars"]["Fobject"]["ext_account"]);
2151  }
2152  else
2153  {
2154  $this->tpl->setVariable("EXT_ACCOUNT_VAL",
2155  $data["fields"]["ext_account"]);
2156  }
2157  /* Disabled: external account names should be changeable by admins
2158  if ($this->object->getAuthMode(true) != AUTH_LOCAL &&
2159  $this->object->getAuthMode(true) != AUTH_CAS &&
2160  $this->object->getAuthMode(true) != AUTH_SHIBBOLETH &&
2161  $this->object->getAuthMode(true) != AUTH_SOAP)
2162  {
2163  $this->tpl->setVariable("OPTION_DISABLED_EXT", "\"disabled=disabled\"");
2164  }
2165  */
2166  $this->tpl->parseCurrentBlock();
2167  }
2168  $auth_mode = $_SESSION['error_post_vars']['Fobject']['auth_mode'] ?
2169  ilAuthUtils::_getAuthMode($_SESSION['error_post_vars']['Fobject']['auth_mode']) :
2170  $this->object->getAuthMode(true);
2172  {
2173  $this->tpl->setVariable("OPTION_DISABLED", "\"disabled=disabled\"");
2174  }
2175  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
2176 
2177  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2178  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
2179  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2180  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
2181  $this->tpl->setVariable("CMD_SUBMIT", "update");
2182  $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
2183  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
2184 
2185  $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
2186  $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
2187  $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
2188  $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
2189  $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
2190  $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
2191  $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
2192  $this->tpl->setVariable("TXT_HITS_PER_PAGE",$this->lng->txt("hits_per_page"));
2193  $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE",$this->lng->txt("show_users_online"));
2194  $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
2195  $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
2196  $this->tpl->setVariable("TXT_INSTANT_MESSENGERS",$this->lng->txt("user_profile_instant_messengers"));
2197  $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
2198  if ($this->object->getId() == $ilUser->getId())
2199  {
2200  $this->tpl->setVariable("TXT_CURRENT_IP","(".$this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"].")");
2201  }
2202  $this->tpl->setVariable("TXT_CURRENT_IP_ALERT",$this->lng->txt("current_ip_alert"));
2203 
2204  // auth mode selection
2205  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2206  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
2207 //var_dump($active_auth_modes);
2208  // preselect previous chosen auth mode otherwise default auth mode
2209  $selected_auth_mode = (isset($_SESSION["error_post_vars"]["Fobject"]["auth_mode"])) ? $_SESSION["error_post_vars"]["Fobject"]["auth_mode"] : $this->object->getAuthMode();
2210 
2211  foreach ($active_auth_modes as $auth_name => $auth_key)
2212  {
2213  $this->tpl->setCurrentBlock("auth_mode_selection");
2214 
2215  if ($auth_name == 'default')
2216  {
2217  $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
2218  }
2219  else
2220  {
2221  $name = $this->lng->txt('auth_'.$auth_name);
2222  }
2223 
2224  $this->tpl->setVariable("AUTH_MODE_NAME", $name);
2225 
2226  $this->tpl->setVariable("AUTH_MODE", $auth_name);
2227 
2228  if ($selected_auth_mode == $auth_name)
2229  {
2230  $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
2231  }
2232 
2233  $this->tpl->parseCurrentBlock();
2234  } // END auth_mode selection
2235 
2236 
2237  // language selection
2238  $languages = $this->lng->getInstalledLanguages();
2239 
2240  // preselect previous chosen language otherwise default language
2241  $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->object->getLanguage();
2242 
2243  foreach ($languages as $lang_key)
2244  {
2245  $this->tpl->setCurrentBlock("language_selection");
2246  $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
2247  $this->tpl->setVariable("LANGSHORT", $lang_key);
2248 
2249  if ($selected_lang == $lang_key)
2250  {
2251  $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
2252  }
2253 
2254  $this->tpl->parseCurrentBlock();
2255  } // END language selection
2256 
2257  // BEGIN skin & style selection
2258  //$this->ilias->getSkins();
2259  $templates = $styleDefinition->getAllTemplates();
2260 
2261  // preselect previous chosen skin/style otherwise default skin/style
2262  if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
2263  {
2264  $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
2265 
2266  $selected_style = $sknst[1];
2267  $selected_skin = $sknst[0];
2268  }
2269  else
2270  {
2271  $selected_style = $this->object->prefs["style"];
2272  $selected_skin = $this->object->skin;
2273  }
2274 
2275  include("./Services/Style/classes/class.ilObjStyleSettings.php");
2276  if (count($templates) > 0 && is_array ($templates))
2277  {
2278  foreach ($templates as $template)
2279  {
2280  // get styles for skin
2281  //$this->ilias->getStyles($skin["name"]);
2282  $styleDef =& new ilStyleDefinition($template["id"]);
2283  $styleDef->startParsing();
2284  $styles = $styleDef->getStyles();
2285  foreach ($styles as $style)
2286  {
2287  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
2288  {
2289  continue;
2290  }
2291 
2292  $this->tpl->setCurrentBlock("selectskin");
2293 
2294  if ($selected_skin == $template["id"] &&
2295  $selected_style == $style["id"])
2296  {
2297  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
2298  }
2299 
2300  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
2301  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
2302  $this->tpl->parseCurrentBlock();
2303  }
2304  } // END skin & style selection
2305  }
2306  // BEGIN hits per page
2307  $hits_options = array(2,10,15,20,30,40,50,100,9999);
2308  // preselect previous chosen option otherwise default option
2309  if (isset($_SESSION["error_post_vars"]["Fobject"]["hits_per_page"]))
2310  {
2311  $selected_option = $_SESSION["error_post_vars"]["Fobject"]["hits_per_page"];
2312  }
2313  else
2314  {
2315  $selected_option = $this->object->prefs["hits_per_page"];
2316  }
2317  foreach($hits_options as $hits_option)
2318  {
2319  $this->tpl->setCurrentBlock("selecthits");
2320 
2321  if ($selected_option == $hits_option)
2322  {
2323  $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
2324  }
2325 
2326  $this->tpl->setVariable("HITSVALUE", $hits_option);
2327 
2328  if ($hits_option == 9999)
2329  {
2330  $hits_option = $this->lng->txt("no_limit");
2331  }
2332 
2333  $this->tpl->setVariable("HITSOPTION", $hits_option);
2334  $this->tpl->parseCurrentBlock();
2335  }
2336  // END hits per page
2337 
2338  // BEGIN show users online
2339  $users_online_options = array("y","associated","n");
2340  // preselect previous chosen option otherwise default option
2341  if (isset($_SESSION["error_post_vars"]["Fobject"]["show_users_online"]))
2342  {
2343  $selected_option = $_SESSION["error_post_vars"]["Fobject"]["show_users_online"];
2344  }
2345  else
2346  {
2347  $selected_option = $this->object->prefs["show_users_online"];
2348  }
2349  foreach($users_online_options as $an_option)
2350  {
2351  $this->tpl->setCurrentBlock("show_users_online");
2352 
2353  if ($selected_option == $an_option)
2354  {
2355  $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
2356  }
2357 
2358  $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
2359 
2360  $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
2361  $this->tpl->parseCurrentBlock();
2362  }
2363  // END show users online
2364 
2365  // BEGIN hide_own_online_status
2366  if (isset($_SESSION["error_post_vars"]["Fobject"]["hide_own_online_status"]))
2367  {
2368  $hide_own_online_status = $_SESSION["error_post_vars"]["Fobject"]["hide_own_online_status"];
2369  }
2370  else
2371  {
2372  $hide_own_online_status = ($this->object->prefs["hide_own_online_status"] != '') ? $this->object->prefs["hide_own_online_status"] : "n";
2373  }
2374  $this->tpl->setCurrentBlock("hide_own_online_status");
2375  $this->tpl->setVariable("TXT_HIDE_OWN_ONLINE_STATUS", $this->lng->txt("hide_own_online_status"));
2376  if ($hide_own_online_status == "y") {
2377  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked=\"checked\"");
2378  }
2379  else {
2380  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "");
2381  }
2382  $this->tpl->parseCurrentBlock();
2383  //END hide_own_online_status
2384 
2385  // inform user about changes option
2386  $this->tpl->setCurrentBlock("inform_user");
2387 
2388  // BEGIN DiskQuota Remember the state of the "send info mail" checkbox
2389  $sendInfoMail = $ilUser->getPref('send_info_mails') == 'y';
2390  if ($sendInfoMail)
2391  // END DiskQuota Remember the state of the "send info mail" checkbox
2392  {
2393  $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
2394  }
2395 
2396  $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("inform_user_mail"));
2397  $this->tpl->parseCurrentBlock();
2398 
2399  $this->lng->loadLanguageModule('crs');
2400 
2401  $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"] ?
2402  $_SESSION["error_post_vars"]["time_limit"]["unlimited"] :
2403  $this->object->getTimeLimitUnlimited();
2404  $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
2405  $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
2406  $this->object->getTimeLimitFrom();
2407 
2408  $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
2409  $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
2410  $this->object->getTimeLimitUntil();
2411 
2412  $this->tpl->setCurrentBlock("time_limit");
2413  $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
2414  $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
2415  $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
2416  $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
2417 
2418  $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
2419  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
2420  date("i",$time_limit_from)));
2421  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
2422  date("G",$time_limit_from)));
2423  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
2424  date("d",$time_limit_from)));
2425  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
2426  date("m",$time_limit_from)));
2427  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
2428  date("Y",$time_limit_from)));
2429  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
2430  date("i",$time_limit_until)));
2431  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
2432  date("G",$time_limit_until)));
2433  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
2434  date("d",$time_limit_until)));
2435  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
2436  date("m",$time_limit_until)));
2437  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
2438  date("Y",$time_limit_until)));
2439  $this->tpl->parseCurrentBlock();
2440 
2441  $this->__showUserDefinedFields();
2442  }
2443 
2444 // BEGIN DiskQuota: Allow administrators to edit user picture
2451  {
2452  global $ilUser, $rbacsystem;
2453 
2454  // User folder
2455  if($this->usrf_ref_id == USER_FOLDER_ID and
2456  !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
2457  {
2458  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2459  }
2460  // if called from local administration $this->usrf_ref_id is category id
2461  // Todo: this has to be fixed. Do not mix user folder id and category id
2462  if($this->usrf_ref_id != USER_FOLDER_ID)
2463  {
2464  // check if user is assigned to category
2465  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
2466  {
2467  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2468  }
2469  }
2470 
2471  $userfile_input = $this->form_gui->getItemByPostVar("userfile");
2472 
2473  if ($_FILES["userfile"]["tmp_name"] == "")
2474  {
2475  if ($userfile_input->getDeletionFlag())
2476  {
2477  $this->object->removeUserPicture();
2478  }
2479  return;
2480  }
2481  if ($_FILES["userfile"]["size"] == 0)
2482  {
2483  ilUtil::sendFailure($this->lng->txt("msg_no_file"));
2484  }
2485  else
2486  {
2487  $webspace_dir = ilUtil::getWebspaceDir();
2488  $image_dir = $webspace_dir."/usr_images";
2489  $store_file = "usr_".$this->object->getId()."."."jpg";
2490 
2491  // store filename
2492  $this->object->setPref("profile_image", $store_file);
2493  $this->object->update();
2494 
2495  // move uploaded file
2496  $uploaded_file = $image_dir."/upload_".$this->object->getId()."pic";
2497  if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
2498  $uploaded_file, false))
2499  {
2500  ilUtil::sendFailure($this->lng->txt("upload_error", true));
2501  $this->ctrl->redirect($this, "showProfile");
2502  }
2503  chmod($uploaded_file, 0770);
2504 
2505  // take quality 100 to avoid jpeg artefacts when uploading jpeg files
2506  // taking only frame [0] to avoid problems with animated gifs
2507  $show_file = "$image_dir/usr_".$this->object->getId().".jpg";
2508  $thumb_file = "$image_dir/usr_".$this->object->getId()."_small.jpg";
2509  $xthumb_file = "$image_dir/usr_".$this->object->getId()."_xsmall.jpg";
2510  $xxthumb_file = "$image_dir/usr_".$this->object->getId()."_xxsmall.jpg";
2511  $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
2512  $show_file = ilUtil::escapeShellArg($show_file);
2513  $thumb_file = ilUtil::escapeShellArg($thumb_file);
2514  $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
2515  $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
2516 
2517  if(ilUtil::isConvertVersionAtLeast("6.3.8-3"))
2518  {
2519  ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200^ -gravity center -extent 200x200 -quality 100 JPEG:".$show_file);
2520  ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100^ -gravity center -extent 100x100 -quality 100 JPEG:".$thumb_file);
2521  ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75^ -gravity center -extent 75x75 -quality 100 JPEG:".$xthumb_file);
2522  ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30^ -gravity center -extent 30x30 -quality 100 JPEG:".$xxthumb_file);
2523  }
2524  else
2525  {
2526  ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200 -quality 100 JPEG:".$show_file);
2527  ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100 -quality 100 JPEG:".$thumb_file);
2528  ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75 -quality 100 JPEG:".$xthumb_file);
2529  ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30 -quality 100 JPEG:".$xxthumb_file);
2530  }
2531  }
2532  }
2533 
2538  {
2539  $webspace_dir = ilUtil::getWebspaceDir();
2540  $image_dir = $webspace_dir."/usr_images";
2541  $file = $image_dir."/usr_".$this->object->getID()."."."jpg";
2542  $thumb_file = $image_dir."/usr_".$this->object->getID()."_small.jpg";
2543  $xthumb_file = $image_dir."/usr_".$this->object->getID()."_xsmall.jpg";
2544  $xxthumb_file = $image_dir."/usr_".$this->object->getID()."_xxsmall.jpg";
2545  $upload_file = $image_dir."/upload_".$this->object->getID();
2546 
2547  // remove user pref file name
2548  $this->object->setPref("profile_image", "");
2549  $this->object->update();
2550  ilUtil::sendSuccess($this->lng->txt("user_image_removed"));
2551 
2552  if (@is_file($file))
2553  {
2554  unlink($file);
2555  }
2556  if (@is_file($thumb_file))
2557  {
2558  unlink($thumb_file);
2559  }
2560  if (@is_file($xthumb_file))
2561  {
2562  unlink($xthumb_file);
2563  }
2564  if (@is_file($xxthumb_file))
2565  {
2566  unlink($xxthumb_file);
2567  }
2568  if (@is_file($upload_file))
2569  {
2570  unlink($upload_file);
2571  }
2572 
2573  $this->editObject();
2574  }
2575 // END DiskQuota: Allow administrators to edit user picture
2576 
2581 /*
2582  function saveObjectOld()
2583  {
2584  global $ilias, $rbacsystem, $rbacadmin, $ilSetting;
2585 
2586  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2587 
2588  //load ILIAS settings
2589  $settings = $ilias->getAllSettings();
2590 
2591  // User folder
2592  if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
2593  !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
2594  {
2595  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
2596  }
2597 
2598  // check dynamically required fields
2599  foreach ($settings as $key => $val)
2600  {
2601  if (substr($key,0,8) == "require_")
2602  {
2603  $field = substr($key,8);
2604 
2605  switch($field)
2606  {
2607  case 'passwd':
2608  case 'passwd2':
2609  if(ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2610  {
2611  $require_keys[] = $field;
2612  }
2613  break;
2614  default:
2615  $require_keys[] = $field;
2616  break;
2617  }
2618  }
2619  }
2620 
2621  foreach ($require_keys as $key => $val)
2622  {
2623  if (isset($settings["require_" . $val]) && $settings["require_" . $val])
2624  {
2625  if (empty($_POST["Fobject"][$val]))
2626  {
2627  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2628  $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
2629  }
2630  }
2631  }
2632 
2633  if(!$this->__checkUserDefinedRequiredFields())
2634  {
2635  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
2636  }
2637 
2638  // validate login
2639  if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
2640  {
2641  $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
2642  }
2643 
2644  // check loginname
2645  if (ilObjUser::_loginExists($_POST["Fobject"]["login"]))
2646  {
2647  $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
2648  }
2649 
2650  // Do password checks only if auth mode allows password modifications
2651  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2652  if(ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2653  {
2654  // check passwords
2655  if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
2656  {
2657  $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
2658  }
2659 
2660  // validate password
2661  if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
2662  {
2663  $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
2664  }
2665  }
2666  if(ilAuthUtils::_needsExternalAccountByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2667  {
2668  if(!strlen($_POST['Fobject']['ext_account']))
2669  {
2670  $this->ilias->raiseError($this->lng->txt('ext_acccount_required'),$this->ilias->error_obj->MESSAGE);
2671  }
2672  }
2673 
2674  if($_POST['Fobject']['ext_account'] &&
2675  ($elogin = ilObjUser::_checkExternalAuthAccount($_POST['Fobject']['auth_mode'],$_POST['Fobject']['ext_account'])))
2676  {
2677  if($elogin != '')
2678  {
2679  $this->ilias->raiseError(
2680  sprintf($this->lng->txt("err_auth_ext_user_exists"),
2681  $_POST["Fobject"]["ext_account"],
2682  $_POST['Fobject']['auth_mode'],
2683  $elogin),
2684  $this->ilias->error_obj->MESSAGE);
2685  }
2686  }
2687 
2688 
2689  // The password type is not passed in the post data. Therefore we
2690  // append it here manually.
2691  include_once ('./Services/User/classes/class.ilObjUser.php');
2692  $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
2693 
2694  // validate email
2695  if (strlen($_POST['Fobject']['email']) and !ilUtil::is_email($_POST["Fobject"]["email"]))
2696  {
2697  $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
2698  }
2699 
2700  // validate time limit
2701  if ($_POST["time_limit"]["unlimited"] != 1 and
2702  ($this->__toUnix($_POST["time_limit"]["until"]) < $this->__toUnix($_POST["time_limit"]["from"])))
2703  {
2704  $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
2705  }
2706  if(!$this->ilias->account->getTimeLimitUnlimited())
2707  {
2708  if($this->__toUnix($_POST["time_limit"]["from"]) < $this->ilias->account->getTimeLimitFrom() or
2709  $this->__toUnix($_POST["time_limit"]["until"])> $this->ilias->account->getTimeLimitUntil() or
2710  $_POST['time_limit']['unlimited'])
2711  {
2712  $this->ilias->raiseError($this->lng->txt("time_limit_not_within_owners"),$this->ilias->error_obj->MESSAGE);
2713  }
2714  }
2715 
2716  // TODO: check if login or passwd already exists
2717  // TODO: check length of login and passwd
2718 
2719  // checks passed. save user
2720  $userObj = new ilObjUser();
2721  $userObj->assignData($_POST["Fobject"]);
2722  $userObj->setTitle($userObj->getFullname());
2723  $userObj->setDescription($userObj->getEmail());
2724 
2725  $userObj->setTimeLimitOwner($this->object->getRefId());
2726  $userObj->setTimeLimitUnlimited($_POST["time_limit"]["unlimited"]);
2727  $userObj->setTimeLimitFrom($this->__toUnix($_POST["time_limit"]["from"]));
2728  $userObj->setTimeLimitUntil($this->__toUnix($_POST["time_limit"]["until"]));
2729 
2730  $userObj->setUserDefinedData($_POST['udf']);
2731 
2732  $userObj->create();
2733 
2734  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2735  if(ilAuthUtils::_isExternalAccountEnabled())
2736  {
2737  $userObj->setExternalAccount($_POST["Fobject"]["ext_account"]);
2738  }
2739 
2740  //$user->setId($userObj->getId());
2741 
2742  //insert user data in table user_data
2743  $userObj->saveAsNew();
2744 
2745  // setup user preferences
2746  $userObj->setLanguage($_POST["Fobject"]["language"]);
2747 
2748  //set user skin and style
2749  $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
2750 
2751  if ($userObj->getPref("style") != $sknst[1] ||
2752  $userObj->getPref("skin") != $sknst[0])
2753  {
2754  $userObj->setPref("skin", $sknst[0]);
2755  $userObj->setPref("style", $sknst[1]);
2756  }
2757 
2758  // set hits per pages
2759  $userObj->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
2760  // set show users online
2761  $userObj->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
2762  // set hide_own_online_status
2763  $userObj->setPref("hide_own_online_status", $_POST["Fobject"]["hide_own_online_status"]);
2764 
2765  $userObj->writePrefs();
2766 
2767  //set role entries
2768  $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
2769 
2770  $msg = $this->lng->txt("user_added");
2771 
2772  // BEGIN DiskQuota: Remember the state of the "send info mail" checkbox
2773  global $ilUser;
2774  $ilUser->setPref('send_info_mails', ($_POST["send_mail"] != "") ? 'y' : 'n');
2775  $ilUser->writePrefs();
2776  // END DiskQuota: Remember the state of the "send info mail" checkbox
2777 
2778  // send new account mail
2779  if ($_POST["send_mail"] != "")
2780  {
2781  include_once("Services/Mail/classes/class.ilAccountMail.php");
2782  $acc_mail = new ilAccountMail();
2783  $acc_mail->setUserPassword($_POST["Fobject"]["passwd"]);
2784  $acc_mail->setUser($userObj);
2785 
2786  if ($acc_mail->send())
2787  {
2788  $msg = $msg."<br />".$this->lng->txt("mail_sent");
2789  }
2790  else
2791  {
2792  $msg = $msg."<br />".$this->lng->txt("mail_not_sent");
2793  }
2794  }
2795 
2796  ilUtil::sendInfo($msg, true);
2797 
2798  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
2799  {
2800  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
2801  }
2802  else
2803  {
2804  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2805  }
2806  }
2807 */
2812  function updateObjectOld()
2813  {
2814  global $ilias, $rbacsystem, $rbacadmin,$ilUser;
2815 
2816  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2817 
2818  //load ILIAS settings
2819  $settings = $ilias->getAllSettings();
2820 
2821  // User folder
2822  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write',$this->usrf_ref_id))
2823  {
2824  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2825  }
2826  // if called from local administration $this->usrf_ref_id is category id
2827  // Todo: this has to be fixed. Do not mix user folder id and category id
2828  if($this->usrf_ref_id != USER_FOLDER_ID)
2829  {
2830  // check if user is assigned to category
2831  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
2832  {
2833  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2834  }
2835  }
2836 
2837  foreach ($_POST["Fobject"] as $key => $val)
2838  {
2839  $_POST["Fobject"][$key] = ilUtil::stripSlashes($val);
2840  }
2841 
2842  // check dynamically required fields
2843  foreach ($settings as $key => $val)
2844  {
2845  $field = substr($key,8);
2846  switch($field)
2847  {
2848  case 'passwd':
2849  case 'passwd2':
2851  {
2852  $require_keys[] = $field;
2853  }
2854  break;
2855  default:
2856  $require_keys[] = $field;
2857  break;
2858 
2859  }
2860  }
2861 
2862  foreach ($require_keys as $key => $val)
2863  {
2864  // exclude required system and registration-only fields
2865  $system_fields = array("default_role");
2866  if (!in_array($val, $system_fields))
2867  {
2868  if (isset($settings["require_" . $val]) && $settings["require_" . $val])
2869  {
2870  if (empty($_POST["Fobject"][$val]))
2871  {
2872  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2873  $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
2874  }
2875  }
2876  }
2877  }
2878 
2879  if(!$this->__checkUserDefinedRequiredFields())
2880  {
2881  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
2882  }
2883  // validate login
2884  if ($this->object->getLogin() != $_POST["Fobject"]["login"] &&
2885  !ilUtil::isLogin($_POST["Fobject"]["login"]))
2886  {
2887  $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
2888  }
2889 
2890  // check loginname
2891  if (ilObjUser::_loginExists($_POST["Fobject"]["login"],$this->id))
2892  {
2893  $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
2894  }
2895 
2897  {
2898  if($_POST['Fobject']['passwd'] == "********" and
2899  !strlen($this->object->getPasswd()))
2900  {
2901  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2902  $this->lng->txt('password'),$this->ilias->error_obj->MESSAGE);
2903  }
2904  // check passwords
2905  if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
2906  {
2907  $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
2908  }
2909 
2910  // validate password
2911  if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
2912  {
2913  $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
2914  }
2915  }
2916  else
2917  {
2918  // Password will not be changed...
2919  $_POST['Fobject']['passwd'] = "********";
2920  }
2922  {
2923  if(!strlen($_POST['Fobject']['ext_account']))
2924  {
2925  $this->ilias->raiseError($this->lng->txt('ext_acccount_required'),$this->ilias->error_obj->MESSAGE);
2926  }
2927  }
2928  if($_POST['Fobject']['ext_account'] &&
2929  ($elogin = ilObjUser::_checkExternalAuthAccount($_POST['Fobject']['auth_mode'],$_POST['Fobject']['ext_account'])))
2930  {
2931  if($elogin != $this->object->getLogin())
2932  {
2933  $this->ilias->raiseError(
2934  sprintf($this->lng->txt("err_auth_ext_user_exists"),
2935  $_POST["Fobject"]["ext_account"],
2936  $_POST['Fobject']['auth_mode'],
2937  $elogin),
2938  $this->ilias->error_obj->MESSAGE);
2939  }
2940  }
2941 
2942  // The password type is not passed with the post data. Therefore we
2943  // append it here manually.
2944  include_once ('./Services/User/classes/class.ilObjUser.php');
2945  $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
2946 
2947  // validate email
2948  if (strlen($_POST['Fobject']['email']) and !ilUtil::is_email($_POST["Fobject"]["email"]))
2949  {
2950  $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
2951  }
2952 
2953  $start = $this->__toUnix($_POST["time_limit"]["from"]);
2954  $end = $this->__toUnix($_POST["time_limit"]["until"]);
2955 
2956  // validate time limit
2957  if (!$_POST["time_limit"]["unlimited"] and
2958  ( $start > $end))
2959  {
2960  $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
2961  }
2962 
2963  if(!$this->ilias->account->getTimeLimitUnlimited())
2964  {
2965  if($start < $this->ilias->account->getTimeLimitFrom() or
2966  $end > $this->ilias->account->getTimeLimitUntil() or
2967  $_POST['time_limit']['unlimited'])
2968  {
2969  $_SESSION['error_post_vars'] = $_POST;
2970 
2971  ilUtil::sendFailure($this->lng->txt('time_limit_not_within_owners'));
2972  $this->editObject();
2973 
2974  return false;
2975  }
2976  }
2977 
2978  // TODO: check length of login and passwd
2979 
2980  // checks passed. save user
2981  $_POST['Fobject']['time_limit_owner'] = $this->object->getTimeLimitOwner();
2982 
2983  $_POST['Fobject']['time_limit_unlimited'] = (int) $_POST['time_limit']['unlimited'];
2984  $_POST['Fobject']['time_limit_from'] = $this->__toUnix($_POST['time_limit']['from']);
2985  $_POST['Fobject']['time_limit_until'] = $this->__toUnix($_POST['time_limit']['until']);
2986 
2987  if($_POST['Fobject']['time_limit_unlimited'] != $this->object->getTimeLimitUnlimited() or
2988  $_POST['Fobject']['time_limit_from'] != $this->object->getTimeLimitFrom() or
2989  $_POST['Fobject']['time_limit_until'] != $this->object->getTimeLimitUntil())
2990  {
2991  $_POST['Fobject']['time_limit_message'] = 0;
2992  }
2993  else
2994  {
2995  $_POST['Fobject']['time_limit_message'] = $this->object->getTimeLimitMessage();
2996  }
2997 
2998  $this->object->assignData($_POST["Fobject"]);
2999  $this->object->setUserDefinedData($_POST['udf']);
3000 
3001  try
3002  {
3003  $this->object->updateLogin($_POST['Fobject']['login']);
3004  }
3005  catch (ilUserException $e)
3006  {
3007  ilUtil::sendFailure($e->getMessage());
3008  $this->form_gui->setValuesByPost();
3009  return $tpl->setContent($this->form_gui->getHtml());
3010  }
3011 
3012  $this->object->setTitle($this->object->getFullname());
3013  $this->object->setDescription($this->object->getEmail());
3014  $this->object->setLanguage($_POST["Fobject"]["language"]);
3015 
3016  //set user skin and style
3017  $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
3018 
3019  if ($this->object->getPref("style") != $sknst[1] ||
3020  $this->object->getPref("skin") != $sknst[0])
3021  {
3022  $this->object->setPref("skin", $sknst[0]);
3023  $this->object->setPref("style", $sknst[1]);
3024  }
3025 
3026  // set hits per pages
3027  $this->object->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
3028  // set show users online
3029  $this->object->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
3030  // set hide_own_online_status
3031  if ($_POST["Fobject"]["hide_own_online_status"]) {
3032  $this->object->setPref("hide_own_online_status", $_POST["Fobject"]["hide_own_online_status"]);
3033  }
3034  else {
3035  $this->object->setPref("hide_own_online_status", "n");
3036  }
3037 
3038  $this->update = $this->object->update();
3039  //$rbacadmin->updateDefaultRole($_POST["Fobject"]["default_role"], $this->object->getId());
3040 
3041  // BEGIN DiskQuota: Remember the state of the "send info mail" checkbox
3042  global $ilUser;
3043  $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
3044  $ilUser->writePrefs();
3045  // END DiskQuota: Remember the state of the "send info mail" checkbox
3046 
3047  $mail_message = $this->__sendProfileMail();
3048  $msg = $this->lng->txt('saved_successfully').$mail_message;
3049 
3050  // feedback
3051  ilUtil::sendSuccess($msg,true);
3052 
3053  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
3054  {
3055  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
3056  }
3057  else
3058  {
3059  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
3060  }
3061  }
3062 
3063 
3064 
3070  function assignSaveObject()
3071  {
3072  global $rbacsystem, $rbacadmin, $rbacreview;
3073 
3074  if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
3075  {
3076  $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
3077  }
3078 
3079  $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
3080  $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
3081 
3082  // prevent unassignment of system role from system user
3083  if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles))
3084  {
3085  array_push($selected_roles,SYSTEM_ROLE_ID);
3086  }
3087 
3088  $global_roles_all = $rbacreview->getGlobalRoles();
3089  $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
3090  $assigned_roles = array_intersect($assigned_roles_all,$posted_roles);
3091  $assigned_global_roles_all = array_intersect($assigned_roles_all,$global_roles_all);
3092  $assigned_global_roles = array_intersect($assigned_global_roles_all,$posted_roles);
3093  $posted_global_roles = array_intersect($selected_roles,$global_roles_all);
3094 
3095  if ((empty($selected_roles) and count($assigned_roles_all) == count($assigned_roles))
3096  or (empty($posted_global_roles) and count($assigned_global_roles_all) == count($assigned_global_roles)))
3097  {
3098  //$this->ilias->raiseError($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
3099  // workaround. sometimes jumps back to wrong page
3100  ilUtil::sendFailure($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),true);
3101  $this->ctrl->redirect($this,'roleassignment');
3102  }
3103 
3104  foreach (array_diff($assigned_roles,$selected_roles) as $role)
3105  {
3106  $rbacadmin->deassignUser($role,$this->object->getId());
3107  }
3108 
3109  foreach (array_diff($selected_roles,$assigned_roles) as $role)
3110  {
3111  $rbacadmin->assignUser($role,$this->object->getId(),false);
3112  }
3113 
3114  include_once "./Services/AccessControl/classes/class.ilObjRole.php";
3115 
3116  // update object data entry (to update last modification date)
3117  $this->object->update();
3118 
3119  ilUtil::sendSuccess($this->lng->txt("msg_roleassignment_changed"),true);
3120 
3121  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
3122  {
3123  $this->ctrl->redirect($this,'roleassignment');
3124  }
3125  else
3126  {
3127  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
3128  }
3129 
3130  }
3131 
3138  {
3139  global $rbacreview,$rbacsystem,$ilUser, $ilTabs;
3140 
3141  $ilTabs->activateTab("role_assignment");
3142 
3143  if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
3144  {
3145  $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
3146  }
3147 
3148  $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
3149 
3150  if ($_SESSION['filtered_roles'] > 5)
3151  {
3152  $_SESSION['filtered_roles'] = 0;
3153  }
3154 
3155  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html','Services/User');
3156 
3157  if(false)
3158  {
3159  $this->tpl->setCurrentBlock("filter");
3160  $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
3161  $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
3162  $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
3163  $this->tpl->setVariable("FILTER_NAME",'roleassignment');
3164  $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
3165  $this->tpl->parseCurrentBlock();
3166  }
3167 
3168  // init table
3169  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
3170  $tab = new ilRoleAssignmentTableGUI($this, "roleassignment");
3171 
3172  // now get roles depending on filter settings
3173  $role_list = $rbacreview->getRolesByFilter($tab->filter["role_filter"],$this->object->getId());
3174  $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
3175 
3176  $counter = 0;
3177 
3178  include_once ('./Services/AccessControl/classes/class.ilObjRole.php');
3179 
3180  $records = array();
3181  foreach ($role_list as $role)
3182  {
3183  // fetch context path of role
3184  $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
3185 
3186  // only list roles that are not set to status "deleted"
3187  if ($rbacreview->isDeleted($rolf[0]))
3188  {
3189  continue;
3190  }
3191 
3192  // build context path
3193  $path = "";
3194 
3195  if ($this->tree->isInTree($rolf[0]))
3196  {
3197  if ($rolf[0] == ROLE_FOLDER_ID)
3198  {
3199  $path = $this->lng->txt("global");
3200  }
3201  else
3202  {
3203  $tmpPath = $this->tree->getPathFull($rolf[0]);
3204 
3205  // count -1, to exclude the role folder itself
3206  /*for ($i = 1; $i < (count($tmpPath)-1); $i++)
3207  {
3208  if ($path != "")
3209  {
3210  $path .= " > ";
3211  }
3212 
3213  $path .= $tmpPath[$i]["title"];
3214  }*/
3215 
3216  $path = $tmpPath[count($tmpPath)-2]["title"];
3217  }
3218  }
3219  else
3220  {
3221  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role["obj_id"].")</b>";
3222  }
3223 
3224  $disabled = false;
3225 
3226  // disable checkbox for system role for the system user
3227  if (($this->object->getId() == SYSTEM_USER_ID and $role["obj_id"] == SYSTEM_ROLE_ID)
3228  or (!in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())) and $role["obj_id"] == SYSTEM_ROLE_ID))
3229  {
3230  $disabled = true;
3231  }
3232 
3233  // protected admin role
3234  if($role['obj_id'] == SYSTEM_ROLE_ID && !$rbacreview->isAssigned($ilUser->getId(),SYSTEM_ROLE_ID))
3235  {
3236  include_once './Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
3237  if(ilSecuritySettings::_getInstance()->isAdminRoleProtected())
3238  {
3239  $disabled = true;
3240  }
3241  }
3242 
3243  if (substr($role["title"],0,3) == "il_")
3244  {
3245  if (!$assignable)
3246  {
3247  $rolf_arr = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
3248  $rolf2 = $rolf_arr[0];
3249  }
3250  else
3251  {
3252  $rolf2 = $rolf;
3253  }
3254 
3255  $parent_node = $this->tree->getParentNodeData($rolf2);
3256 
3257  $role["description"] = $this->lng->txt("obj_".$parent_node["type"])."&nbsp;(#".$parent_node["obj_id"].")";
3258  }
3259 
3260  $role_ids[$counter] = $role["obj_id"];
3261 
3262  $result_set[$counter][] = $checkbox = ilUtil::formCheckBox(in_array($role["obj_id"],$assigned_roles),"role_id[]",$role["obj_id"],$disabled)."<input type=\"hidden\" name=\"role_id_ctrl[]\" value=\"".$role["obj_id"]."\"/>";
3263  $this->ctrl->setParameterByClass("ilobjrolegui", "ref_id", $rolf[0]);
3264  $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $role["obj_id"]);
3265  $result_set[$counter][] = $link = "<a href=\"".$this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm")."\">".ilObjRole::_getTranslation($role["title"])."</a>";
3266  $title = ilObjRole::_getTranslation($role["title"]);
3267  $result_set[$counter][] = $role["description"];
3268 
3269  // Add link to objector local Rores
3270  if ($role["role_type"] == "local") {
3271  // Get Object to the role
3272  $obj_id = ilRbacReview::getObjectOfRole($role["rol_id"]);
3273 
3274  $obj_type = ilObject::_lookupType($obj_id);
3275 
3277 
3278  foreach ($ref_ids as $ref_id) {}
3279 
3280  require_once("./Services/Link/classes/class.ilLink.php");
3281 
3282  $result_set[$counter][] = $context = "<a href='".ilLink::_getLink($ref_id, ilObject::_lookupType($obj_id))."' target='_top'>".$path."</a>";
3283  }
3284  else
3285  {
3286  $result_set[$counter][] = $path;
3287  $context = $path;
3288  }
3289 
3290  $records[] = array("path" => $path, "description" => $role["description"],
3291  "context" => $context, "checkbox" => $checkbox,
3292  "role" => $link, "title" => $title);
3293  ++$counter;
3294  }
3295 
3296  if (true)
3297  {
3298  $tab->setData($records);
3299  $this->tpl->setVariable("ROLES_TABLE",$tab->getHTML());
3300  return;
3301  }
3302 
3303  return $this->__showRolesTable($result_set,$role_ids);
3304  }
3305 
3310  {
3311  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
3312  $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
3313  $table_gui->writeFilterToSession(); // writes filter to session
3314  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3315  $this->roleassignmentObject();
3316  }
3317 
3322  {
3323  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
3324  $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
3325  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3326  $table_gui->resetFilter(); // clears filter
3327  $this->roleassignmentObject();
3328  }
3329 
3330  function __getDateSelect($a_type,$a_varname,$a_selected)
3331  {
3332  switch($a_type)
3333  {
3334  case "minute":
3335  for($i=0;$i<=60;$i++)
3336  {
3337  $days[$i] = $i < 10 ? "0".$i : $i;
3338  }
3339  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
3340 
3341  case "hour":
3342  for($i=0;$i<24;$i++)
3343  {
3344  $days[$i] = $i < 10 ? "0".$i : $i;
3345  }
3346  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
3347 
3348  case "day":
3349  for($i=1;$i<32;$i++)
3350  {
3351  $days[$i] = $i < 10 ? "0".$i : $i;
3352  }
3353  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
3354 
3355  case "month":
3356  for($i=1;$i<13;$i++)
3357  {
3358  $month[$i] = $i < 10 ? "0".$i : $i;
3359  }
3360  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
3361 
3362  case "year":
3363  if($a_selected < date('Y',time()))
3364  {
3365  $start = $a_selected;
3366  }
3367  else
3368  {
3369  $start = date('Y',time());
3370  }
3371 
3372  for($i = $start;$i < date("Y",time()) + 11;++$i)
3373  {
3374  $year[$i] = $i;
3375  }
3376  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
3377  }
3378  }
3379 
3380  function __toUnix($a_time_arr)
3381  {
3382  return mktime($a_time_arr["hour"],
3383  $a_time_arr["minute"],
3384  $a_time_arr["second"],
3385  $a_time_arr["month"],
3386  $a_time_arr["day"],
3387  $a_time_arr["year"]);
3388  }
3389 
3390  function __showRolesTable($a_result_set,$a_role_ids = NULL)
3391  {
3392  global $rbacsystem;
3393 
3394  $actions = array("assignSave" => $this->lng->txt("change_assignment"));
3395 
3396  $tbl =& $this->__initTableGUI();
3397  $tpl =& $tbl->getTemplateObject();
3398 
3399  $tpl->setCurrentBlock("tbl_form_header");
3400  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3401  $tpl->parseCurrentBlock();
3402 
3403  $tpl->setCurrentBlock("tbl_action_row");
3404 
3405  $tpl->setVariable("COLUMN_COUNTS",4);
3406  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
3407 
3408  foreach ($actions as $name => $value)
3409  {
3410  $tpl->setCurrentBlock("tbl_action_btn");
3411  $tpl->setVariable("BTN_NAME",$name);
3412  $tpl->setVariable("BTN_VALUE",$value);
3413  $tpl->parseCurrentBlock();
3414  }
3415 
3416  if (!empty($a_role_ids))
3417  {
3418  // set checkbox toggles
3419  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
3420  $tpl->setVariable("JS_VARNAME","role_id");
3421  $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
3422  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3423  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3424  $tpl->parseCurrentBlock();
3425  }
3426 
3427  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
3428 
3429 
3430  $this->ctrl->setParameter($this,"cmd","roleassignment");
3431 
3432  // title & header columns
3433  $tbl->setTitle($this->lng->txt("edit_roleassignment"),"icon_role.png",$this->lng->txt("roles"));
3434 
3435  //user must be administrator
3436  $tbl->setHeaderNames(array("",$this->lng->txt("role"),$this->lng->txt("description"),$this->lng->txt("context")));
3437  $tbl->setHeaderVars(array("","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
3438  $tbl->setColumnWidth(array("","30%","40%","30%"));
3439 
3440  $this->__setTableGUIBasicData($tbl,$a_result_set,"roleassignment");
3441  $tbl->render();
3442  $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
3443 
3444  return true;
3445  }
3446 
3447  function &__initTableGUI()
3448  {
3449  include_once "./Services/Table/classes/class.ilTableGUI.php";
3450 
3451  return new ilTableGUI(0,false);
3452  }
3453 
3454  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
3455  {
3456  switch($from)
3457  {
3458  default:
3459  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
3460  break;
3461  }
3462 
3463  //$tbl->enable("hits");
3464  $tbl->setOrderColumn($order);
3465  $tbl->setOrderDirection($_GET["sort_order"]);
3466  $tbl->setOffset($_GET["offset"]);
3467  $tbl->setLimit($_GET["limit"]);
3468  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3469  $tbl->setData($result_set);
3470  }
3471 
3473  {
3474  unset($_SESSION["filtered_roles"]);
3475  }
3476 
3478  {
3479  $action[0] = $this->lng->txt('assigned_roles');
3480  $action[1] = $this->lng->txt('all_roles');
3481  $action[2] = $this->lng->txt('all_global_roles');
3482  $action[3] = $this->lng->txt('all_local_roles');
3483  $action[4] = $this->lng->txt('internal_local_roles_only');
3484  $action[5] = $this->lng->txt('non_internal_local_roles_only');
3485 
3486  return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
3487  }
3488 
3490  {
3492  $this->roleassignmentObject();
3493  }
3494 
3500  {
3501  global $ilLocator;
3502 
3503  $ilLocator->clearItems();
3504 
3505  if ($_GET["admin_mode"] == "settings") // system settings
3506  {
3507  $this->ctrl->setParameterByClass("ilobjsystemfoldergui",
3508  "ref_id", SYSTEM_FOLDER_ID);
3509  $ilLocator->addItem($this->lng->txt("administration"),
3510  $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), ""),
3511  ilFrameTargetInfo::_getFrame("MainContent"));
3512 
3513  if ($_GET['ref_id'] == USER_FOLDER_ID)
3514  {
3515  $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
3516  ilObject::_lookupObjId($_GET["ref_id"]))),
3517  $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
3518  }
3519  elseif ($_GET['ref_id'] == ROLE_FOLDER_ID)
3520  {
3521  $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
3522  ilObject::_lookupObjId($_GET["ref_id"]))),
3523  $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", "view"));
3524  }
3525 
3526  if ($_GET["obj_id"] > 0)
3527  {
3528  $ilLocator->addItem($this->object->getTitle(),
3529  $this->ctrl->getLinkTarget($this, "view"));
3530  }
3531  }
3532  else // repository administration
3533  {
3534  // ?
3535  }
3536  }
3537 
3538  function showUpperIcon()
3539  {
3540  }
3541 
3543  {
3544  global $ilUser,$ilias;
3545 
3546  if($_POST['send_mail'] != 'y')
3547  {
3548  return '';
3549  }
3550  if(!strlen($this->object->getEmail()))
3551  {
3552  return '';
3553  }
3554 
3555  // Choose language of user
3556  $usr_lang = new ilLanguage($this->object->getLanguage());
3557  $usr_lang->loadLanguageModule('crs');
3558  $usr_lang->loadLanguageModule('registration');
3559 
3560  include_once "Services/Mail/classes/class.ilMimeMail.php";
3561 
3562  $mmail = new ilMimeMail();
3563  $mmail->autoCheck(false);
3564  $mmail->From($ilUser->getEmail());
3565  $mmail->To($this->object->getEmail());
3566 
3567  // mail subject
3568  $subject = $usr_lang->txt("profile_changed");
3569 
3570 
3571  // mail body
3572  $body = ($usr_lang->txt("reg_mail_body_salutation")." ".$this->object->getFullname().",\n\n");
3573 
3574  $date = $this->object->getApproveDate();
3575  // Approve
3576  if((time() - strtotime($date)) < 10)
3577  {
3578  $body .= ($usr_lang->txt('reg_mail_body_approve')."\n\n");
3579  }
3580  else
3581  {
3582  $body .= ($usr_lang->txt('reg_mail_body_profile_changed')."\n\n");
3583  }
3584 
3585  // Append login info only if password has been chacnged
3586  if($_POST['passwd'] != '********')
3587  {
3588  $body .= $usr_lang->txt("reg_mail_body_text2")."\n".
3589  ILIAS_HTTP_PATH."/login.php?client_id=".$ilias->client_id."\n".
3590  $usr_lang->txt("login").": ".$this->object->getLogin()."\n".
3591  $usr_lang->txt("passwd").": ".$_POST['passwd']."\n\n";
3592  }
3593  $body .= ($usr_lang->txt("reg_mail_body_text3")."\n");
3594  $body .= $this->object->getProfileAsString($usr_lang);
3595 
3596  $mmail->Subject($subject);
3597  $mmail->Body($body);
3598  $mmail->Send();
3599 
3600 
3601  return "<br/>".$this->lng->txt("mail_sent");
3602  }
3603 
3607  function _goto($a_target)
3608  {
3609  global $ilUser, $ilCtrl;
3610 
3611  // #10888
3612  if($a_target == md5("usrdelown"))
3613  {
3614  if($ilUser->getId() != ANONYMOUS_USER_ID &&
3615  $ilUser->hasDeletionFlag())
3616  {
3617  $ilCtrl->setTargetScript("ilias.php");
3618  $ilCtrl->initBaseClass("ilpersonaldesktopgui");
3619  $ilCtrl->redirectByClass(array("ilpersonaldesktopgui", "ilpersonalsettingsgui"), "deleteOwnAccount3");
3620  }
3621  exit("This account is not flagged for deletion."); // #12160
3622  }
3623 
3624  if (substr($a_target, 0, 1) == "n")
3625  {
3626  $a_target = ilObjUser::_lookupId(ilUtil::stripSlashes(substr($a_target, 1)));
3627  }
3628 
3629  $_GET["cmd"] = "view";
3630  $_GET["user_id"] = (int) $a_target;
3631  $_GET["baseClass"] = "ilPublicUserProfileGUI";
3632  $_GET["cmdClass"] = "ilpublicuserprofilegui";
3633  include("ilias.php");
3634  exit;
3635  }
3636 
3645  protected function handleIgnoredRequiredFields()
3646  {
3647  $profileMaybeIncomplete = false;
3648 
3649  require_once 'Services/User/classes/class.ilUserProfile.php';
3650 
3651  foreach( ilUserProfile::getIgnorableRequiredSettings() as $fieldName )
3652  {
3653  $elm = $this->form_gui->getItemByPostVar($fieldName);
3654 
3655  if( !$elm ) continue;
3656 
3657  if( $elm->getRequired() )
3658  {
3659  $profileMaybeIncomplete = true;
3660 
3661  // Flag as optional
3662  $elm->setRequired( false );
3663  }
3664  }
3665 
3666  include_once 'Services/User/classes/class.ilUserDefinedFields.php';
3667  $user_defined_fields = ilUserDefinedFields::_getInstance();
3668  foreach($user_defined_fields->getDefinitions() as $field_id => $definition)
3669  {
3670  $elm = $this->form_gui->getItemByPostVar('udf_'.$definition['field_id']);
3671 
3672  if( !$elm ) continue;
3673 
3674  if( $elm->getRequired() && $definition['changeable'] && $definition['required'] && $definition['visible'] )
3675  {
3676  $profileMaybeIncomplete = true;
3677 
3678  // Flag as optional
3679  $elm->setRequired( false );
3680  }
3681  }
3682 
3683  return $profileMaybeIncomplete;
3684  }
3685 
3689  protected function showAgreementTextAsynchObject()
3690  {
3691  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
3695  $entity = ilTermsOfServiceHelper::getCurrentAcceptanceForUser($this->object);
3696  if($entity->getId())
3697  {
3698  echo '<div style="max-width:640px;max-height:480px;overflow:auto;padding:5px">' . $entity->getText() . '</div>';
3699  }
3700  exit();
3701  }
3702 
3706  protected function showAcceptedTermsOfService()
3707  {
3711  $agree_date = $this->form_gui->getItemByPostVar('agree_date');
3712  if($agree_date && $agree_date->getValue())
3713  {
3714  $this->lng->loadLanguageModule('tos');
3715  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
3719  $entity = ilTermsOfServiceHelper::getCurrentAcceptanceForUser($this->object);
3720  if($entity->getId())
3721  {
3722  $show_agreement_text = new ilCheckboxInputGUI($this->lng->txt('tos_show_signed_text'), 'tos_show_signed_text');
3723 
3724  $agreement_lang = new ilNonEditableValueGUI($this->lng->txt('language'), '');
3725  $agreement_lang->setValue($this->lng->txt('meta_l_' . $entity->getIso2LanguageCode()));
3726  $show_agreement_text->addSubItem($agreement_lang);
3727 
3728  $agreement_document = new ilNonEditableValueGUI($this->lng->txt('tos_agreement_document'), '', true);
3729 
3730  require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
3731  $action = new ilAdvancedSelectionListGUI();
3732  $action->setId('asl_content_accepted_content');
3733  $action->setListTitle($this->lng->txt('tos_accepted_content'));
3734  $action->setHeaderIcon(ilUtil::getImagePath('icon_preview.png'));
3735  $action->setAsynch(true);
3736  $action->setAsynchUrl($this->ctrl->getLinkTarget($this, 'showAgreementTextAsynch', '', true, false));
3737  $agreement_document->setValue($entity->getSource().$action->getHtml());
3738 
3739  $show_agreement_text->addSubItem($agreement_document);
3740  $agree_date->addSubItem($show_agreement_text);
3741  }
3742  }
3743  else if($agree_date)
3744  {
3745  $agree_date->setValue($this->lng->txt('tos_not_accepted_yet'));
3746  }
3747  }
3748 } // END class.ilObjUserGUI
3749 ?>