ILIAS  Release_5_0_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().".svg"), $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, $rbacsystem;
366 
367  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
368 
369  // User folder
370  if (!$rbacsystem->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 
727  // interests
728  $user->setGeneralInterests($this->form_gui->getInput('interests_general'));
729  $user->setOfferingHelp($this->form_gui->getInput('interests_help_offered'));
730  $user->setLookingForHelp($this->form_gui->getInput('interests_help_looking'));
731 
732  // ClientIP
733  $user->setClientIP($this->form_gui->getInput('client_ip'));
734 
735  if($this->isSettingChangeable('instant_messengers'))
736  {
737  $user->setInstantMessengerId('icq', $this->form_gui->getInput('im_icq'));
738  $user->setInstantMessengerId('yahoo', $this->form_gui->getInput('im_yahoo'));
739  $user->setInstantMessengerId('msn', $this->form_gui->getInput('im_msn'));
740  $user->setInstantMessengerId('aim', $this->form_gui->getInput('im_aim'));
741  $user->setInstantMessengerId('skype', $this->form_gui->getInput('im_skype'));
742  $user->setInstantMessengerId('jabber', $this->form_gui->getInput('im_jabber'));
743  $user->setInstantMessengerId('voip', $this->form_gui->getInput('im_voip'));
744  }
745  // Delicious
746  if($this->isSettingChangeable('delicious'))
747  {
748  $user->setDelicious($this->form_gui->getInput('delicious'));
749  }
750  // Google maps
751  $user->setLatitude($this->form_gui->getInput('latitude'));
752  $user->setLongitude($this->form_gui->getInput('longitude'));
753  $user->setLocationZoom($this->form_gui->getInput('loc_zoom'));
754 
755  // External account
756  $user->setAuthMode($this->form_gui->getInput('auth_mode'));
757  $user->setExternalAccount($this->form_gui->getInput('ext_account'));
758 
759  if((int) $user->getActive() != (int) $this->form_gui->getInput('active'))
760  {
761  $user->setActive($this->form_gui->getInput('active'), $ilUser->getId());
762  }
763 
764  return $user;
765  }
766 
767 
771  public function updateObject()
772  {
773  global $tpl, $rbacsystem, $ilias, $ilUser, $ilSetting;
774 
775  // User folder
776  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write',$this->usrf_ref_id))
777  {
778  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
779  }
780  // if called from local administration $this->usrf_ref_id is category id
781  // Todo: this has to be fixed. Do not mix user folder id and category id
782  if($this->usrf_ref_id != USER_FOLDER_ID)
783  {
784  // check if user is assigned to category
785  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
786  {
787  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
788  }
789  }
790  $this->initForm("edit");
791 
792  // we do not want to store this dates, they are only printed out
793  unset($_POST['approve_date']);
794  $_POST['agree_date'] = $this->object->getAgreeDate();
795  unset($_POST['last_login']);
796 
797  // Manipulate form so ignore required fields are no more required. This has to be done before ilPropertyFormGUI::checkInput() is called.
798  $profileMaybeIncomplete = false;
799  if($this->form_gui->getInput('ignore_rf', false))
800  {
801  $profileMaybeIncomplete = $this->handleIgnoredRequiredFields();
802  }
803 
804  if ($this->form_gui->checkInput())
805  {
806  // @todo: external account; time limit
807  // if not allowed or empty -> do no change password
809  && trim($_POST['passwd']) != "")
810  {
811  $this->object->setPasswd($_POST['passwd'], IL_PASSWD_PLAIN);
812  }
813 
814  /*
815  * reset counter for failed logins
816  * if $_POST['active'] is set to 1
817  */
818  if( $_POST['active'] == 1 )
819  {
820  ilObjUser::_resetLoginAttempts( $this->object->getId() );
821  }
822 
823  #$this->object->assignData($_POST);
824  $this->loadValuesFromForm('update');
825 
826  $udf = array();
827  foreach($_POST as $k => $v)
828  {
829  if (substr($k, 0, 4) == "udf_")
830  {
831  $udf[substr($k, 4)] = $v;
832  }
833  }
834  $this->object->setUserDefinedData($udf);
835 
836  try
837  {
838  $this->object->updateLogin($_POST['login']);
839  }
840  catch (ilUserException $e)
841  {
842  ilUtil::sendFailure($e->getMessage());
843  $this->form_gui->setValuesByPost();
844  return $tpl->setContent($this->form_gui->getHtml());
845  }
846 
847  $this->object->setTitle($this->object->getFullname());
848  $this->object->setDescription($this->object->getEmail());
849 
850  if($this->isSettingChangeable('language'))
851  {
852  $this->object->setLanguage($this->form_gui->getInput('language'));
853  }
854 
855  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
857  {
858  // set disk quota
859  $this->object->setPref("disk_quota", $_POST["disk_quota"] * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
860  }
862  {
863  // set personal workspace disk quota
864  $this->object->setPref("wsp_disk_quota", $_POST["wsp_disk_quota"] * ilFormat::_getSizeMagnitude() * ilFormat::_getSizeMagnitude());
865  }
866 
867  if($this->isSettingChangeable('skin_style'))
868  {
869  //set user skin and style
870  $sknst = explode(":", $_POST["skin_style"]);
871 
872  if ($this->object->getPref("style") != $sknst[1] ||
873  $this->object->getPref("skin") != $sknst[0])
874  {
875  $this->object->setPref("skin", $sknst[0]);
876  $this->object->setPref("style", $sknst[1]);
877  }
878  }
879  if($this->isSettingChangeable('hits_per_page'))
880  {
881  $this->object->setPref("hits_per_page", $_POST["hits_per_page"]);
882  }
883  if($this->isSettingChangeable('show_users_online'))
884  {
885  $this->object->setPref("show_users_online", $_POST["show_users_online"]);
886  }
887  if($this->isSettingChangeable('hide_own_online_status'))
888  {
889  $this->object->setPref("hide_own_online_status", $_POST["hide_own_online_status"] ? 'y' : 'n');
890  }
891 
892  // set a timestamp for last_password_change
893  // this ts is needed by ilSecuritySettings
894  $this->object->setLastPasswordChangeTS( time() );
895 
896  global $ilSetting;
897  if((int)$ilSetting->get('session_reminder_enabled'))
898  {
899  $this->object->setPref('session_reminder_enabled', (int)$_POST['session_reminder_enabled']);
900  }
901 
902  // #10054 - profile may have been completed, check below is only for incomplete
903  $this->object->setProfileIncomplete( false );
904 
905  $this->update = $this->object->update();
906 
907 
908  // If the current user is editing its own user account,
909  // we update his preferences.
910  if ($ilUser->getId() == $this->object->getId())
911  {
912  $ilUser->readPrefs();
913  }
914  $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
915  $ilUser->writePrefs();
916 
917  $mail_message = $this->__sendProfileMail();
918  $msg = $this->lng->txt('saved_successfully').$mail_message;
919 
920  // same personal image
921  if($this->isSettingChangeable('upload'))
922  {
923  $this->uploadUserPictureObject();
924  }
925 
926  if( $profileMaybeIncomplete )
927  {
928  include_once 'Services/User/classes/class.ilUserProfile.php';
929  if( ilUserProfile::isProfileIncomplete($this->object) )
930  {
931  $this->object->setProfileIncomplete( true );
932  $this->object->update();
933  }
934  }
935 
936  // feedback
937  ilUtil::sendSuccess($msg,true);
938 
939  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
940  {
941  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
942  }
943  else
944  {
945  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
946  }
947  }
948  else
949  {
950  $this->form_gui->setValuesByPost();
951  $tpl->setContent($this->form_gui->getHtml());
952  }
953  }
954 
958  function getValues()
959  {
960  global $ilUser, $ilSetting;
961 
962  $data = array();
963 
964  // login data
965  $data["auth_mode"] = $this->object->getAuthMode();
966  $data["login"] = $this->object->getLogin();
967  //$data["passwd"] = "********";
968  //$data["passwd2"] = "********";
969  $data["ext_account"] = $this->object->getExternalAccount();
970 
971  // system information
972  require_once './Services/Utilities/classes/class.ilFormat.php';
973  $data["create_date"] = ilFormat::formatDate($this->object->getCreateDate(),'datetime',true);
974  $data["owner"] = ilObjUser::_lookupLogin($this->object->getOwner());
975  $data["approve_date"] = ($this->object->getApproveDate() != "")
976  ? ilFormat::formatDate($this->object->getApproveDate(),'datetime',true)
977  : null;
978  $data["agree_date"] = ($this->object->getAgreeDate() != "")
979  ? ilFormat::formatDate($this->object->getAgreeDate(),'datetime',true)
980  : null;
981  $data["last_login"] = ($this->object->getLastLogin() != "")
982  ? ilFormat::formatDate($this->object->getLastLogin(),'datetime',true)
983  : null;
984  $data["active"] = $this->object->getActive();
985  $data["time_limit_unlimited"] = $this->object->getTimeLimitUnlimited();
986 
987  $from = new ilDateTime($this->object->getTimeLimitFrom() ? $this->object->getTimeLimitFrom() : time(),IL_CAL_UNIX);
988  $data["time_limit_from"]["date"] = $from->get(IL_CAL_FKT_DATE,'Y-m-d',$ilUser->getTimeZone());
989  $data["time_limit_from"]["time"] = $from->get(IL_CAL_FKT_DATE,'H:i:s',$ilUser->getTimeZone());
990 
991  $until = new ilDateTime($this->object->getTimeLimitUntil() ? $this->object->getTimeLimitUntil() : time(),IL_CAL_UNIX);
992  $data['time_limit_until']['date'] = $until->get(IL_CAL_FKT_DATE,'Y-m-d',$ilUser->getTimeZone());
993  $data['time_limit_until']['time'] = $until->get(IL_CAL_FKT_DATE,'H:i:s',$ilUser->getTimeZone());
994 
995 
996  // BEGIN DiskQuota, Show disk space used
997  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
999  {
1000  $data["disk_quota"] = $this->object->getDiskQuota() / ilFormat::_getSizeMagnitude() / ilFormat::_getSizeMagnitude();
1001  }
1003  {
1004  $data["wsp_disk_quota"] = $this->object->getPersonalWorkspaceDiskQuota() / ilFormat::_getSizeMagnitude() / ilFormat::_getSizeMagnitude();
1005  }
1006  // W. Randelshofer 2008-09-09: Deactivated display of disk space usage,
1007  // because determining the disk space usage may take several minutes.
1008  /*
1009  require_once "Modules/File/classes/class.ilObjFileAccess.php";
1010  require_once "Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php";
1011  require_once "Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
1012  require_once "Services/Mail/classes/class.ilObjMailAccess.php";
1013  require_once "Modules/Forum/classes/class.ilObjForumAccess.php";
1014  require_once "Modules/MediaCast/classes/class.ilObjMediaCastAccess.php";
1015  $data["disk_space_used"] =
1016  ilObjFileAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1017  ilObjFileBasedLMAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1018  ilObjSAHSLearningModuleAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1019  ilObjMailAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1020  ilObjForumAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1021  ilObjMediaCastAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>';
1022  */
1023  // END DiskQuota, Show disk space used
1024 
1025  // personal data
1026  $data["gender"] = $this->object->getGender();
1027  $data["firstname"] = $this->object->getFirstname();
1028  $data["lastname"] = $this->object->getLastname();
1029  $data["title"] = $this->object->getUTitle();
1030  $data['birthday'] = $this->object->getBirthday();
1031  $data["institution"] = $this->object->getInstitution();
1032  $data["department"] = $this->object->getDepartment();
1033  $data["street"] = $this->object->getStreet();
1034  $data["city"] = $this->object->getCity();
1035  $data["zipcode"] = $this->object->getZipcode();
1036  $data["country"] = $this->object->getCountry();
1037  $data["sel_country"] = $this->object->getSelectedCountry();
1038  $data["phone_office"] = $this->object->getPhoneOffice();
1039  $data["phone_home"] = $this->object->getPhoneHome();
1040  $data["phone_mobile"] = $this->object->getPhoneMobile();
1041  $data["fax"] = $this->object->getFax();
1042  $data["email"] = $this->object->getEmail();
1043  $data["hobby"] = $this->object->getHobby();
1044  $data["referral_comment"] = $this->object->getComment();
1045 
1046  // interests
1047  $data["interests_general"] = $this->object->getGeneralInterests();
1048  $data["interests_help_offered"] = $this->object->getOfferingHelp();
1049  $data["interests_help_looking"] = $this->object->getLookingForHelp();
1050 
1051  // instant messengers
1052  $data["im_icq"] = $this->object->getInstantMessengerId('icq');
1053  $data["im_yahoo"] = $this->object->getInstantMessengerId('yahoo');
1054  $data["im_msn"] = $this->object->getInstantMessengerId('msn');
1055  $data["im_aim"] = $this->object->getInstantMessengerId('aim');
1056  $data["im_skype"] = $this->object->getInstantMessengerId('skype');
1057  $data["im_jabber"] = $this->object->getInstantMessengerId('jabber');
1058  $data["im_voip"] = $this->object->getInstantMessengerId('voip');
1059 
1060  // other data
1061  $data["matriculation"] = $this->object->getMatriculation();
1062  $data["delicious"] = $this->object->getDelicious();
1063  $data["client_ip"] = $this->object->getClientIP();
1064 
1065  // user defined fields
1066  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1067  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
1068  $user_defined_data = $this->object->getUserDefinedData();
1069  foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
1070  {
1071  $data["udf_".$field_id] = $user_defined_data["f_".$field_id];
1072  }
1073 
1074  // settings
1075  $data["language"] = $this->object->getLanguage();
1076  $data["skin_style"] = $this->object->skin.":".$this->object->prefs["style"];
1077  $data["hits_per_page"] = $this->object->prefs["hits_per_page"];
1078  $data["show_users_online"] = $this->object->prefs["show_users_online"];
1079  $data["hide_own_online_status"] = $this->object->prefs["hide_own_online_status"] == 'y';
1080  $data["session_reminder_enabled"] = (int)$this->object->prefs["session_reminder_enabled"];
1081 
1082  $this->form_gui->setValuesByArray($data);
1083  }
1084 
1088  function initForm($a_mode)
1089  {
1090  global $lng, $ilCtrl, $styleDefinition, $ilSetting, $ilClientIniFile, $ilUser;
1091 
1092  $settings = $ilSetting->getAll();
1093 
1094  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1095 
1096  $this->form_gui = new ilPropertyFormGUI();
1097  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1098  if ($a_mode == "create")
1099  {
1100  $this->form_gui->setTitle($lng->txt("usr_new"));
1101  }
1102  else
1103  {
1104  $this->form_gui->setTitle($lng->txt("usr_edit"));
1105  }
1106 
1107  // login data
1108  $sec_l = new ilFormSectionHeaderGUI();
1109  $sec_l->setTitle($lng->txt("login_data"));
1110  $this->form_gui->addItem($sec_l);
1111 
1112  // authentication mode
1113  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1114  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
1115  $am = new ilSelectInputGUI($lng->txt("auth_mode"), "auth_mode");
1116  $option = array();
1117  foreach ($active_auth_modes as $auth_name => $auth_key)
1118  {
1119  if ($auth_name == 'default')
1120  {
1121  $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
1122  }
1123  else
1124  {
1125  $name = $this->lng->txt('auth_'.$auth_name);
1126  }
1127  $option[$auth_name] = $name;
1128  }
1129  $am->setOptions($option);
1130  $this->form_gui->addItem($am);
1131 
1132  if($a_mode == "edit")
1133  {
1134  $id = new ilNonEditableValueGUI($lng->txt("usr_id"), "id");
1135  $id->setValue($this->object->getId());
1136  $this->form_gui->addItem($id);
1137  }
1138 
1139  // login
1140  $lo = new ilUserLoginInputGUI($lng->txt("login"), "login");
1141  $lo->setRequired(true);
1142  if ($a_mode == "edit")
1143  {
1144  $lo->setCurrentUserId($this->object->getId());
1145  try
1146  {
1147  include_once 'Services/Calendar/classes/class.ilDate.php';
1148 
1149  $last_history_entry = ilObjUser::_getLastHistoryDataByUserId($this->object->getId());
1150  $lo->setInfo(
1151  sprintf(
1152  $this->lng->txt('usr_loginname_history_info'),
1153  ilDatePresentation::formatDate(new ilDateTime($last_history_entry[1], IL_CAL_UNIX)),
1154  $last_history_entry[0]
1155  )
1156  );
1157  }
1158  catch(ilUserException $e) { }
1159  }
1160 
1161  $this->form_gui->addItem($lo);
1162 
1163  // passwords
1164 // @todo: do not show passwords, if there is not a single auth, that
1165 // allows password setting
1166  {
1167  $pw = new ilPasswordInputGUI($lng->txt("passwd"), "passwd");
1168  $pw->setSize(32);
1169  $pw->setMaxLength(32);
1170  $pw->setValidateAuthPost("auth_mode");
1171  if ($a_mode == "create")
1172  {
1173  $pw->setRequiredOnAuth(true);
1174  }
1175  $pw->setInfo(ilUtil::getPasswordRequirementsInfo());
1176  $this->form_gui->addItem($pw);
1177  }
1178  // @todo: invisible/hidden passwords
1179 
1180  // external account
1181  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1183  {
1184  $ext = new ilTextInputGUI($lng->txt("user_ext_account"), "ext_account");
1185  $ext->setSize(40);
1186  $ext->setMaxLength(250);
1187  $ext->setInfo($lng->txt("user_ext_account_desc"));
1188  $this->form_gui->addItem($ext);
1189  }
1190 
1191  // login data
1192  $sec_si = new ilFormSectionHeaderGUI();
1193  $sec_si->setTitle($this->lng->txt("system_information"));
1194  $this->form_gui->addItem($sec_si);
1195 
1196  // create date, approve date, agreement date, last login
1197  if ($a_mode == "edit")
1198  {
1199  $sia = array("create_date", "approve_date", "agree_date", "last_login", "owner");
1200  foreach($sia as $a)
1201  {
1202  $siai = new ilNonEditableValueGUI($lng->txt($a), $a);
1203  $this->form_gui->addItem($siai);
1204  }
1205  }
1206 
1207  // active
1208  $ac = new ilCheckboxInputGUI($lng->txt("active"), "active");
1209  $ac->setChecked(true);
1210  $this->form_gui->addItem($ac);
1211 
1212  // access @todo: get fields right (names change)
1213  $lng->loadLanguageModule('crs');
1214 
1215  // access
1216  $radg = new ilRadioGroupInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1217  $radg->setValue(1);
1218  $op1 = new ilRadioOption($lng->txt("user_access_unlimited"), 1);
1219  $radg->addOption($op1);
1220  $op2 = new ilRadioOption($lng->txt("user_access_limited"), 0);
1221  $radg->addOption($op2);
1222 
1223 // $ac = new ilCheckboxInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1224 // $ac->setChecked(true);
1225 // $ac->setOptionTitle($lng->txt("crs_unlimited"));
1226 
1227  // access.from
1228  $acfrom = new ilDateTimeInputGUI($this->lng->txt("crs_from"), "time_limit_from");
1229  $acfrom->setShowTime(true);
1230 // $ac->addSubItem($acfrom);
1231  $op2->addSubItem($acfrom);
1232 
1233  // access.to
1234  $acto = new ilDateTimeInputGUI($this->lng->txt("crs_to"), "time_limit_until");
1235  $acto->setShowTime(true);
1236 // $ac->addSubItem($acto);
1237  $op2->addSubItem($acto);
1238 
1239 // $this->form_gui->addItem($ac);
1240  $this->form_gui->addItem($radg);
1241 
1242  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
1244  {
1245  $lng->loadLanguageModule("file");
1246 
1247  $quota_head = new ilFormSectionHeaderGUI();
1248  $quota_head->setTitle($lng->txt("repository_disk_quota"));
1249  $this->form_gui->addItem($quota_head);
1250 
1251  // disk quota
1252  $disk_quota = new ilTextInputGUI($lng->txt("disk_quota"), "disk_quota");
1253  $disk_quota->setSize(10);
1254  $disk_quota->setMaxLength(11);
1255  $disk_quota->setInfo($this->lng->txt("enter_in_mb_desc"));
1256  $this->form_gui->addItem($disk_quota);
1257 
1258  if ($a_mode == "edit")
1259  {
1260  // show which disk quota is in effect, and explain why
1261  require_once 'Services/WebDAV/classes/class.ilDiskQuotaChecker.php';
1262  $dq_info = ilDiskQuotaChecker::_lookupDiskQuota($this->object->getId());
1263  if ($dq_info['user_disk_quota'] > $dq_info['role_disk_quota'])
1264  {
1265  $info_text = sprintf($lng->txt('disk_quota_is_1_instead_of_2_by_3'),
1266  ilFormat::formatSize($dq_info['user_disk_quota'],'short'),
1267  ilFormat::formatSize($dq_info['role_disk_quota'],'short'),
1268  $dq_info['role_title']);
1269  }
1270  else if (is_infinite($dq_info['role_disk_quota']))
1271  {
1272  $info_text = sprintf($lng->txt('disk_quota_is_unlimited_by_1'), $dq_info['role_title']);
1273  }
1274  else
1275  {
1276  $info_text = sprintf($lng->txt('disk_quota_is_1_by_2'),
1277  ilFormat::formatSize($dq_info['role_disk_quota'],'short'),
1278  $dq_info['role_title']);
1279  }
1280  $disk_quota->setInfo($this->lng->txt("enter_in_mb_desc").'<br>'.$info_text);
1281 
1282 
1283  // disk usage
1284  $du_info = ilDiskQuotaChecker::_lookupDiskUsage($this->object->getId());
1285  $disk_usage = new ilNonEditableValueGUI($lng->txt("disk_usage"), "disk_usage");
1286  if ($du_info['last_update'] === null)
1287  {
1288  $disk_usage->setValue($lng->txt('unknown'));
1289  }
1290  else
1291  {
1292  require_once './Services/Utilities/classes/class.ilFormat.php';
1293  $disk_usage->setValue(ilFormat::formatSize($du_info['disk_usage'],'short'));
1294  $info = '<table class="il_user_quota_disk_usage_overview">';
1295  // write the count and size of each object type
1296  foreach ($du_info['details'] as $detail_data)
1297  {
1298  $info .= '<tr>'.
1299  '<td class="std">'.$detail_data['count'].'</td>'.
1300  '<td class="std">'.$lng->txt($detail_data['type']).'</td>'.
1301  '<td class="std">'.ilFormat::formatSize($detail_data['size'], 'short').'</td>'.
1302  '</tr>'
1303  ;
1304  }
1305  $info .= '</table>';
1306  $info .= '<br>'.$this->lng->txt('last_update').': '.
1307  ilDatePresentation::formatDate(new ilDateTime($du_info['last_update'], IL_CAL_DATETIME));
1308  $disk_usage->setInfo($info);
1309 
1310  }
1311  $this->form_gui->addItem($disk_usage);
1312 
1313  // date when the last disk quota reminder was sent to the user
1314  if (true || $dq_info['last_reminder'])
1315  {
1316  $reminder = new ilNonEditableValueGUI($lng->txt("disk_quota_last_reminder_sent"), "last_reminder");
1317  $reminder->setValue(
1318  ilDatePresentation::formatDate(new ilDateTime($dq_info['last_reminder'], IL_CAL_DATETIME))
1319  );
1320  $reminder->setInfo($this->lng->txt("disk_quota_last_reminder_sent_desc"));
1321  $this->form_gui->addItem($reminder);
1322  }
1323  }
1324  }
1325 
1327  {
1328  $lng->loadLanguageModule("file");
1329 
1330  $quota_head = new ilFormSectionHeaderGUI();
1331  $quota_head->setTitle($lng->txt("personal_workspace_disk_quota"));
1332  $this->form_gui->addItem($quota_head);
1333 
1334  // personal workspace disk quota
1335  $wsp_disk_quota = new ilTextInputGUI($lng->txt("disk_quota"), "wsp_disk_quota");
1336  $wsp_disk_quota->setSize(10);
1337  $wsp_disk_quota->setMaxLength(11);
1338  $wsp_disk_quota->setInfo($this->lng->txt("enter_in_mb_desc"));
1339  $this->form_gui->addItem($wsp_disk_quota);
1340 
1341  if ($a_mode == "edit")
1342  {
1343  // show which disk quota is in effect, and explain why
1344  require_once 'Services/WebDAV/classes/class.ilDiskQuotaChecker.php';
1345  $dq_info = ilDiskQuotaChecker::_lookupPersonalWorkspaceDiskQuota($this->object->getId());
1346  if ($dq_info['user_wsp_disk_quota'] > $dq_info['role_wsp_disk_quota'])
1347  {
1348  $info_text = sprintf($lng->txt('disk_quota_is_1_instead_of_2_by_3'),
1349  ilFormat::formatSize($dq_info['user_wsp_disk_quota'],'short'),
1350  ilFormat::formatSize($dq_info['role_wsp_disk_quota'],'short'),
1351  $dq_info['role_title']);
1352  }
1353  else if (is_infinite($dq_info['role_wsp_disk_quota']))
1354  {
1355  $info_text = sprintf($lng->txt('disk_quota_is_unlimited_by_1'), $dq_info['role_title']);
1356  }
1357  else
1358  {
1359  $info_text = sprintf($lng->txt('disk_quota_is_1_by_2'),
1360  ilFormat::formatSize($dq_info['role_wsp_disk_quota'],'short'),
1361  $dq_info['role_title']);
1362  }
1363  $wsp_disk_quota->setInfo($this->lng->txt("enter_in_mb_desc").'<br>'.$info_text);
1364  }
1365 
1366  // disk usage
1367  include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
1368  $du_info = ilDiskQuotaHandler::getFilesizeByTypeAndOwner($this->object->getId());
1369  $disk_usage = new ilNonEditableValueGUI($lng->txt("disk_usage"), "disk_usage");
1370  if (!sizeof($du_info))
1371  {
1372  $disk_usage->setValue($lng->txt('unknown'));
1373  }
1374  else
1375  {
1376  require_once './Services/Utilities/classes/class.ilFormat.php';
1377  $disk_usage->setValue(ilFormat::formatSize(ilDiskQuotaHandler::getFilesizeByOwner($this->object->getId())));
1378  $info = '<table class="il_user_quota_disk_usage_overview">';
1379  // write the count and size of each object type
1380  foreach ($du_info as $detail_data)
1381  {
1382  $info .= '<tr>'.
1383  '<td class="std">'.$detail_data['count'].'</td>'.
1384  '<td class="std">'.$lng->txt("obj_".$detail_data["src_type"]).'</td>'.
1385  '<td class="std">'.ilFormat::formatSize($detail_data['filesize'], 'short').'</td>'.
1386  '</tr>'
1387  ;
1388  }
1389  $info .= '</table>';
1390  $disk_usage->setInfo($info);
1391 
1392  }
1393  $this->form_gui->addItem($disk_usage);
1394  }
1395 
1396  // personal data
1397  if(
1398  $this->isSettingChangeable('gender') or
1399  $this->isSettingChangeable('firstname') or
1400  $this->isSettingChangeable('lastname') or
1401  $this->isSettingChangeable('title') or
1402  $this->isSettingChangeable('personal_image') or
1403  $this->isSettingChangeable('birhtday')
1404  )
1405  {
1406  $sec_pd = new ilFormSectionHeaderGUI();
1407  $sec_pd->setTitle($this->lng->txt("personal_data"));
1408  $this->form_gui->addItem($sec_pd);
1409  }
1410 
1411  // gender
1412  if($this->isSettingChangeable('gender'))
1413  {
1414  $gndr = new ilRadioGroupInputGUI($lng->txt("gender"), "gender");
1415  $gndr->setRequired(isset($settings["require_gender"]) && $settings["require_gender"]);
1416  $female = new ilRadioOption($lng->txt("gender_f"), "f");
1417  $gndr->addOption($female);
1418  $male = new ilRadioOption($lng->txt("gender_m"), "m");
1419  $gndr->addOption($male);
1420  $this->form_gui->addItem($gndr);
1421  }
1422 
1423  // firstname, lastname, title
1424  $fields = array("firstname" => true, "lastname" => true,
1425  "title" => isset($settings["require_title"]) && $settings["require_title"]);
1426  foreach($fields as $field => $req)
1427  {
1428  if($this->isSettingChangeable($field))
1429  {
1430  $inp = new ilTextInputGUI($lng->txt($field), $field);
1431  $inp->setSize(32);
1432  $inp->setMaxLength(32);
1433  $inp->setRequired($req);
1434  $this->form_gui->addItem($inp);
1435  }
1436  }
1437 
1438  // personal image
1439  if($this->isSettingChangeable('upload'))
1440  {
1441  $pi = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
1442  if ($a_mode == "edit" || $a_mode == "upload")
1443  {
1444  $pi->setImage(ilObjUser::_getPersonalPicturePath($this->object->getId(), "small", true,
1445  true));
1446  }
1447  $this->form_gui->addItem($pi);
1448  }
1449 
1450  if($this->isSettingChangeable('birthday'))
1451  {
1452  $birthday = new ilBirthdayInputGUI($lng->txt('birthday'), 'birthday');
1453  $birthday->setRequired(isset($settings["require_birthday"]) && $settings["require_birthday"]);
1454  $birthday->setShowEmpty(true);
1455  $birthday->setStartYear(1900);
1456  $this->form_gui->addItem($birthday);
1457  }
1458 
1459 
1460  // institution, department, street, city, zip code, country, phone office
1461  // phone home, phone mobile, fax, e-mail
1462  $fields = array(
1463  array("institution", 40, 80),
1464  array("department", 40, 80),
1465  array("street", 40, 40),
1466  array("city", 40, 40),
1467  array("zipcode", 10, 10),
1468  array("country", 40, 40),
1469  array("sel_country"),
1470  array("phone_office", 30, 30),
1471  array("phone_home", 30, 30),
1472  array("phone_mobile", 30, 30),
1473  array("fax", 30, 30));
1474 
1475  $counter = 0;
1476  foreach ($fields as $field)
1477  {
1478  if(!$counter++ and $this->isSettingChangeable($field[0]))
1479  {
1480  // contact data
1481  $sec_cd = new ilFormSectionHeaderGUI();
1482  $sec_cd->setTitle($this->lng->txt("contact_data"));
1483  $this->form_gui->addItem($sec_cd);
1484  }
1485  if($this->isSettingChangeable($field[0]))
1486  {
1487  if ($field[0] != "sel_country")
1488  {
1489  $inp = new ilTextInputGUI($lng->txt($field[0]), $field[0]);
1490  $inp->setSize($field[1]);
1491  $inp->setMaxLength($field[2]);
1492  $inp->setRequired(isset($settings["require_".$field[0]]) &&
1493  $settings["require_".$field[0]]);
1494  $this->form_gui->addItem($inp);
1495  }
1496  else
1497  {
1498  // country selection
1499  include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
1500  $cs = new ilCountrySelectInputGUI($lng->txt($field[0]), $field[0]);
1501  $cs->setRequired(isset($settings["require_".$field[0]]) &&
1502  $settings["require_".$field[0]]);
1503  $this->form_gui->addItem($cs);
1504  }
1505  }
1506  }
1507 
1508  // email
1509  if($this->isSettingChangeable('email'))
1510  {
1511  $em = new ilEMailInputGUI($lng->txt("email"), "email");
1512  $em->setRequired(isset($settings["require_email"]) &&
1513  $settings["require_email"]);
1514  $this->form_gui->addItem($em);
1515  }
1516 
1517  // interests/hobbies
1518  if($this->isSettingChangeable('hobby'))
1519  {
1520  $hob = new ilTextAreaInputGUI($lng->txt("hobby"), "hobby");
1521  $hob->setRows(3);
1522  $hob->setCols(40);
1523  $hob->setRequired(isset($settings["require_hobby"]) &&
1524  $settings["require_hobby"]);
1525  $this->form_gui->addItem($hob);
1526  }
1527 
1528  // referral comment
1529  if($this->isSettingChangeable('referral_comment'))
1530  {
1531  $rc = new ilTextAreaInputGUI($lng->txt("referral_comment"), "referral_comment");
1532  $rc->setRows(3);
1533  $rc->setCols(40);
1534  $rc->setRequired(isset($settings["require_referral_comment"]) &&
1535  $settings["require_referral_comment"]);
1536  $this->form_gui->addItem($rc);
1537  }
1538 
1539 
1540  // interests
1541 
1542  $sh = new ilFormSectionHeaderGUI();
1543  $sh->setTitle($lng->txt("interests"));
1544  $this->form_gui->addItem($sh);
1545 
1546  $multi_fields = array("interests_general", "interests_help_offered", "interests_help_looking");
1547  foreach($multi_fields as $multi_field)
1548  {
1549  if($this->isSettingChangeable($multi_field))
1550  {
1551  // see ilUserProfile
1552  $ti = new ilTextInputGUI($lng->txt($multi_field), $multi_field);
1553  $ti->setMulti(true);
1554  $ti->setMaxLength(40);
1555  $ti->setSize(40);
1556  $ti->setRequired(isset($settings["require_".$multi_field]) &&
1557  $settings["require_".$multi_field]);
1558  $this->form_gui->addItem($ti);
1559  }
1560  }
1561 
1562 
1563  // instant messengers
1564  if($this->isSettingChangeable('instant_messengers'))
1565  {
1566  $sec_im = new ilFormSectionHeaderGUI();
1567  $sec_im->setTitle($this->lng->txt("instant_messengers"));
1568  $this->form_gui->addItem($sec_im);
1569  }
1570 
1571  // icq, yahoo, msn, aim, skype
1572  $fields = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
1573  foreach ($fields as $field)
1574  {
1575  if($this->isSettingChangeable('instant_messengers'))
1576  {
1577  $im = new ilTextInputGUI($lng->txt("im_".$field), "im_".$field);
1578  $im->setSize(40);
1579  $im->setMaxLength(40);
1580  $this->form_gui->addItem($im);
1581  }
1582  }
1583 
1584  // other information
1585  if($this->isSettingChangeable('user_profile_other'))
1586  {
1587  $sec_oi = new ilFormSectionHeaderGUI();
1588  $sec_oi->setTitle($this->lng->txt("user_profile_other"));
1589  $this->form_gui->addItem($sec_oi);
1590  }
1591 
1592  // matriculation number
1593  if($this->isSettingChangeable('matriculation'))
1594  {
1595  $mr = new ilTextInputGUI($lng->txt("matriculation"), "matriculation");
1596  $mr->setSize(40);
1597  $mr->setMaxLength(40);
1598  $mr->setRequired(isset($settings["require_matriculation"]) &&
1599  $settings["require_matriculation"]);
1600  $this->form_gui->addItem($mr);
1601  }
1602 
1603  // delicious
1604  if($this->isSettingChangeable('delicious'))
1605  {
1606  $mr = new ilTextInputGUI($lng->txt("delicious"), "delicious");
1607  $mr->setSize(40);
1608  $mr->setMaxLength(40);
1609  $mr->setRequired(isset($settings["require_delicious"]) &&
1610  $settings["require_delicious"]);
1611  $this->form_gui->addItem($mr);
1612  }
1613 
1614  // client IP
1615  $ip = new ilTextInputGUI($lng->txt("client_ip"), "client_ip");
1616  $ip->setSize(40);
1617  $ip->setMaxLength(255);
1618  $ip->setInfo($this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"]." <br />".
1619  '<span class="warning">'.$this->lng->txt("current_ip_alert")."</span>");
1620  $this->form_gui->addItem($ip);
1621 
1622  // additional user defined fields
1623  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1624  $user_defined_fields = ilUserDefinedFields::_getInstance();
1625 
1626  if($this->usrf_ref_id == USER_FOLDER_ID)
1627  {
1628  $all_defs = $user_defined_fields->getDefinitions();
1629  }
1630  else
1631  {
1632  $all_defs = $user_defined_fields->getChangeableLocalUserAdministrationDefinitions();
1633  }
1634 
1635  foreach($all_defs as $field_id => $definition)
1636  {
1637  if($definition['field_type'] == UDF_TYPE_TEXT) // text input
1638  {
1639  $udf = new ilTextInputGUI($definition['field_name'],
1640  "udf_".$definition['field_id']);
1641  $udf->setSize(40);
1642  $udf->setMaxLength(255);
1643  }
1644  else if($definition['field_type'] == UDF_TYPE_WYSIWYG) // text area input
1645  {
1646  $udf = new ilTextAreaInputGUI($definition['field_name'],
1647  "udf_".$definition['field_id']);
1648  $udf->setUseRte(true);
1649  }
1650  else // selection input
1651  {
1652  $udf = new ilSelectInputGUI($definition['field_name'],
1653  "udf_".$definition['field_id']);
1654  $udf->setOptions($user_defined_fields->fieldValuesToSelectArray(
1655  $definition['field_values']));
1656  }
1657  $udf->setRequired($definition['required']);
1658  $this->form_gui->addItem($udf);
1659  }
1660 
1661  // settings
1662  if(
1663  $a_mode == 'create' or
1664  $this->isSettingChangeable( 'language') or
1665  $this->isSettingChangeable( 'skin_style') or
1666  $this->isSettingChangeable( 'hits_per_page') or
1667  $this->isSettingChangeable( 'hide_own_online_status')
1668  )
1669  {
1670  $sec_st = new ilFormSectionHeaderGUI();
1671  $sec_st->setTitle($this->lng->txt("settings"));
1672  $this->form_gui->addItem($sec_st);
1673  }
1674 
1675  // role
1676  if ($a_mode == "create")
1677  {
1678  $role = new ilSelectInputGUI($lng->txt("default_role"),
1679  'default_role');
1680  $role->setRequired(true);
1681  $role->setValue($this->default_role);
1682  $role->setOptions($this->selectable_roles);
1683  $this->form_gui->addItem($role);
1684  }
1685 
1686  // language
1687  if($this->isSettingChangeable('language'))
1688  {
1689  $lang = new ilSelectInputGUI($lng->txt("language"),
1690  'language');
1691  $languages = $lng->getInstalledLanguages();
1692  $lng->loadLanguageModule("meta");
1693  $options = array();
1694  foreach($languages as $l)
1695  {
1696  $options[$l] = $lng->txt("meta_l_".$l);
1697  }
1698  $lang->setOptions($options);
1699  $lang->setValue($ilSetting->get("language"));
1700  $this->form_gui->addItem($lang);
1701  }
1702 
1703  // skin/style
1704  if($this->isSettingChangeable('skin_style'))
1705  {
1706  $sk = new ilSelectInputGUI($lng->txt("skin_style"),
1707  'skin_style');
1708  $templates = $styleDefinition->getAllTemplates();
1709 
1710  include_once("./Services/Style/classes/class.ilObjStyleSettings.php");
1711 
1712  $options = array();
1713  if (count($templates) > 0 && is_array ($templates))
1714  {
1715  foreach ($templates as $template)
1716  {
1717  $styleDef =& new ilStyleDefinition($template["id"]);
1718  $styleDef->startParsing();
1719  $styles = $styleDef->getStyles();
1720  foreach ($styles as $style)
1721  {
1722  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
1723  {
1724  continue;
1725  }
1726  $options[$template["id"].":".$style["id"]] =
1727  $styleDef->getTemplateName()." / ".$style["name"];
1728  }
1729  }
1730  }
1731  $sk->setOptions($options);
1732  $sk->setValue($ilClientIniFile->readVariable("layout","skin").
1733  ":".$ilClientIniFile->readVariable("layout","style"));
1734 
1735  $this->form_gui->addItem($sk);
1736  }
1737 
1738  // hits per page
1739  if($this->isSettingChangeable('hits_per_page'))
1740  {
1741  $hpp = new ilSelectInputGUI($lng->txt("hits_per_page"),
1742  'hits_per_page');
1743  $options = array(10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
1744  50 => 50, 100 => 100, 9999 => $this->lng->txt("no_limit"));
1745  $hpp->setOptions($options);
1746  $hpp->setValue($ilSetting->get("hits_per_page"));
1747  $this->form_gui->addItem($hpp);
1748 
1749  // users online
1750  $uo = new ilSelectInputGUI($lng->txt("users_online"),
1751  'show_users_online');
1752  $options = array(
1753  "y" => $lng->txt("users_online_show_y"),
1754  "associated" => $lng->txt("users_online_show_associated"),
1755  "n" => $lng->txt("users_online_show_n"));
1756  $uo->setOptions($options);
1757  $uo->setValue($ilSetting->get("show_users_online"));
1758  $this->form_gui->addItem($uo);
1759  }
1760 
1761  // hide online status
1762  if($this->isSettingChangeable('hide_own_online_status'))
1763  {
1764  $os = new ilCheckboxInputGUI($lng->txt("hide_own_online_status"), "hide_own_online_status");
1765  $this->form_gui->addItem($os);
1766  }
1767 
1768  if((int)$ilSetting->get('session_reminder_enabled'))
1769  {
1770  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
1771  $cb->setValue(1);
1772  $this->form_gui->addItem($cb);
1773  }
1774 
1775  // Options
1776  if($this->isSettingChangeable('send_mail'))
1777  {
1778  $sec_op = new ilFormSectionHeaderGUI();
1779  $sec_op->setTitle($this->lng->txt("options"));
1780  $this->form_gui->addItem($sec_op);
1781  }
1782 
1783  // send email
1784  $se = new ilCheckboxInputGUI($lng->txt('inform_user_mail'), 'send_mail');
1785  $se->setInfo($lng->txt('inform_user_mail_info'));
1786  $se->setValue('y');
1787  $se->setChecked(($ilUser->getPref('send_info_mails') == 'y'));
1788  $this->form_gui->addItem($se);
1789 
1790  // ignore required fields
1791  $irf = new ilCheckboxInputGUI($lng->txt('ignore_required_fields'), 'ignore_rf');
1792  $irf->setInfo($lng->txt('ignore_required_fields_info'));
1793  $irf->setValue(1);
1794  $this->form_gui->addItem($irf);
1795 
1796  // @todo: handle all required fields
1797 
1798  // command buttons
1799  if ($a_mode == "create" || $a_mode == "save")
1800  {
1801  $this->form_gui->addCommandButton("save", $lng->txt("save"));
1802  }
1803  if ($a_mode == "edit" || $a_mode == "update")
1804  {
1805  $this->form_gui->addCommandButton("update", $lng->txt("save"));
1806  }
1807  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
1808  }
1809 
1818  protected function isSettingChangeable($a_field)
1819  {
1820  // TODO: Allow mixed field parameter to support checks against an array of field names.
1821 
1822  global $ilSetting;
1823  static $settings = null;
1824 
1825 
1826 
1827  if($this->usrf_ref_id == USER_FOLDER_ID)
1828  {
1829  return true;
1830  }
1831 
1832  if($settings == NULL)
1833  {
1834  $settings = $ilSetting->getAll();
1835  }
1836  return (bool) $settings['usr_settings_changeable_lua_'.$a_field];
1837  }
1838 
1839 
1840 // BEGIN DiskQuota: Allow administrators to edit user picture
1847  {
1848  global $ilUser, $rbacsystem;
1849 
1850  // User folder
1851  if($this->usrf_ref_id == USER_FOLDER_ID and
1852  !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
1853  {
1854  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
1855  }
1856  // if called from local administration $this->usrf_ref_id is category id
1857  // Todo: this has to be fixed. Do not mix user folder id and category id
1858  if($this->usrf_ref_id != USER_FOLDER_ID)
1859  {
1860  // check if user is assigned to category
1861  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
1862  {
1863  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
1864  }
1865  }
1866 
1867  $userfile_input = $this->form_gui->getItemByPostVar("userfile");
1868 
1869  if ($_FILES["userfile"]["tmp_name"] == "")
1870  {
1871  if ($userfile_input->getDeletionFlag())
1872  {
1873  $this->object->removeUserPicture();
1874  }
1875  return;
1876  }
1877  if ($_FILES["userfile"]["size"] == 0)
1878  {
1879  ilUtil::sendFailure($this->lng->txt("msg_no_file"));
1880  }
1881  else
1882  {
1883  $webspace_dir = ilUtil::getWebspaceDir();
1884  $image_dir = $webspace_dir."/usr_images";
1885  $store_file = "usr_".$this->object->getId()."."."jpg";
1886 
1887  // store filename
1888  $this->object->setPref("profile_image", $store_file);
1889  $this->object->update();
1890 
1891  // move uploaded file
1892  $uploaded_file = $image_dir."/upload_".$this->object->getId()."pic";
1893  if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
1894  $uploaded_file, false))
1895  {
1896  ilUtil::sendFailure($this->lng->txt("upload_error", true));
1897  $this->ctrl->redirect($this, "showProfile");
1898  }
1899  chmod($uploaded_file, 0770);
1900 
1901  // take quality 100 to avoid jpeg artefacts when uploading jpeg files
1902  // taking only frame [0] to avoid problems with animated gifs
1903  $show_file = "$image_dir/usr_".$this->object->getId().".jpg";
1904  $thumb_file = "$image_dir/usr_".$this->object->getId()."_small.jpg";
1905  $xthumb_file = "$image_dir/usr_".$this->object->getId()."_xsmall.jpg";
1906  $xxthumb_file = "$image_dir/usr_".$this->object->getId()."_xxsmall.jpg";
1907  $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
1908  $show_file = ilUtil::escapeShellArg($show_file);
1909  $thumb_file = ilUtil::escapeShellArg($thumb_file);
1910  $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
1911  $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
1912 
1913  if(ilUtil::isConvertVersionAtLeast("6.3.8-3"))
1914  {
1915  ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200^ -gravity center -extent 200x200 -quality 100 JPEG:".$show_file);
1916  ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100^ -gravity center -extent 100x100 -quality 100 JPEG:".$thumb_file);
1917  ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75^ -gravity center -extent 75x75 -quality 100 JPEG:".$xthumb_file);
1918  ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30^ -gravity center -extent 30x30 -quality 100 JPEG:".$xxthumb_file);
1919  }
1920  else
1921  {
1922  ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200 -quality 100 JPEG:".$show_file);
1923  ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100 -quality 100 JPEG:".$thumb_file);
1924  ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75 -quality 100 JPEG:".$xthumb_file);
1925  ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30 -quality 100 JPEG:".$xxthumb_file);
1926  }
1927  }
1928  }
1929 
1934  {
1935  $webspace_dir = ilUtil::getWebspaceDir();
1936  $image_dir = $webspace_dir."/usr_images";
1937  $file = $image_dir."/usr_".$this->object->getID()."."."jpg";
1938  $thumb_file = $image_dir."/usr_".$this->object->getID()."_small.jpg";
1939  $xthumb_file = $image_dir."/usr_".$this->object->getID()."_xsmall.jpg";
1940  $xxthumb_file = $image_dir."/usr_".$this->object->getID()."_xxsmall.jpg";
1941  $upload_file = $image_dir."/upload_".$this->object->getID();
1942 
1943  // remove user pref file name
1944  $this->object->setPref("profile_image", "");
1945  $this->object->update();
1946  ilUtil::sendSuccess($this->lng->txt("user_image_removed"));
1947 
1948  if (@is_file($file))
1949  {
1950  unlink($file);
1951  }
1952  if (@is_file($thumb_file))
1953  {
1954  unlink($thumb_file);
1955  }
1956  if (@is_file($xthumb_file))
1957  {
1958  unlink($xthumb_file);
1959  }
1960  if (@is_file($xxthumb_file))
1961  {
1962  unlink($xxthumb_file);
1963  }
1964  if (@is_file($upload_file))
1965  {
1966  unlink($upload_file);
1967  }
1968 
1969  $this->editObject();
1970  }
1971 // END DiskQuota: Allow administrators to edit user picture
1972 
1977 /*
1978  function saveObjectOld()
1979  {
1980  global $ilias, $rbacsystem, $rbacadmin, $ilSetting;
1981 
1982  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1983 
1984  //load ILIAS settings
1985  $settings = $ilias->getAllSettings();
1986 
1987  // User folder
1988  if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
1989  !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
1990  {
1991  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
1992  }
1993 
1994  // check dynamically required fields
1995  foreach ($settings as $key => $val)
1996  {
1997  if (substr($key,0,8) == "require_")
1998  {
1999  $field = substr($key,8);
2000 
2001  switch($field)
2002  {
2003  case 'passwd':
2004  case 'passwd2':
2005  if(ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2006  {
2007  $require_keys[] = $field;
2008  }
2009  break;
2010  default:
2011  $require_keys[] = $field;
2012  break;
2013  }
2014  }
2015  }
2016 
2017  foreach ($require_keys as $key => $val)
2018  {
2019  if (isset($settings["require_" . $val]) && $settings["require_" . $val])
2020  {
2021  if (empty($_POST["Fobject"][$val]))
2022  {
2023  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2024  $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
2025  }
2026  }
2027  }
2028 
2029  if(!$this->__checkUserDefinedRequiredFields())
2030  {
2031  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
2032  }
2033 
2034  // validate login
2035  if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
2036  {
2037  $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
2038  }
2039 
2040  // check loginname
2041  if (ilObjUser::_loginExists($_POST["Fobject"]["login"]))
2042  {
2043  $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
2044  }
2045 
2046  // Do password checks only if auth mode allows password modifications
2047  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2048  if(ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2049  {
2050  // check passwords
2051  if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
2052  {
2053  $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
2054  }
2055 
2056  // validate password
2057  if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
2058  {
2059  $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
2060  }
2061  }
2062  if(ilAuthUtils::_needsExternalAccountByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2063  {
2064  if(!strlen($_POST['Fobject']['ext_account']))
2065  {
2066  $this->ilias->raiseError($this->lng->txt('ext_acccount_required'),$this->ilias->error_obj->MESSAGE);
2067  }
2068  }
2069 
2070  if($_POST['Fobject']['ext_account'] &&
2071  ($elogin = ilObjUser::_checkExternalAuthAccount($_POST['Fobject']['auth_mode'],$_POST['Fobject']['ext_account'])))
2072  {
2073  if($elogin != '')
2074  {
2075  $this->ilias->raiseError(
2076  sprintf($this->lng->txt("err_auth_ext_user_exists"),
2077  $_POST["Fobject"]["ext_account"],
2078  $_POST['Fobject']['auth_mode'],
2079  $elogin),
2080  $this->ilias->error_obj->MESSAGE);
2081  }
2082  }
2083 
2084 
2085  // The password type is not passed in the post data. Therefore we
2086  // append it here manually.
2087  include_once ('./Services/User/classes/class.ilObjUser.php');
2088  $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
2089 
2090  // validate email
2091  if (strlen($_POST['Fobject']['email']) and !ilUtil::is_email($_POST["Fobject"]["email"]))
2092  {
2093  $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
2094  }
2095 
2096  // validate time limit
2097  if ($_POST["time_limit"]["unlimited"] != 1 and
2098  ($this->__toUnix($_POST["time_limit"]["until"]) < $this->__toUnix($_POST["time_limit"]["from"])))
2099  {
2100  $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
2101  }
2102  if(!$this->ilias->account->getTimeLimitUnlimited())
2103  {
2104  if($this->__toUnix($_POST["time_limit"]["from"]) < $this->ilias->account->getTimeLimitFrom() or
2105  $this->__toUnix($_POST["time_limit"]["until"])> $this->ilias->account->getTimeLimitUntil() or
2106  $_POST['time_limit']['unlimited'])
2107  {
2108  $this->ilias->raiseError($this->lng->txt("time_limit_not_within_owners"),$this->ilias->error_obj->MESSAGE);
2109  }
2110  }
2111 
2112  // TODO: check if login or passwd already exists
2113  // TODO: check length of login and passwd
2114 
2115  // checks passed. save user
2116  $userObj = new ilObjUser();
2117  $userObj->assignData($_POST["Fobject"]);
2118  $userObj->setTitle($userObj->getFullname());
2119  $userObj->setDescription($userObj->getEmail());
2120 
2121  $userObj->setTimeLimitOwner($this->object->getRefId());
2122  $userObj->setTimeLimitUnlimited($_POST["time_limit"]["unlimited"]);
2123  $userObj->setTimeLimitFrom($this->__toUnix($_POST["time_limit"]["from"]));
2124  $userObj->setTimeLimitUntil($this->__toUnix($_POST["time_limit"]["until"]));
2125 
2126  $userObj->setUserDefinedData($_POST['udf']);
2127 
2128  $userObj->create();
2129 
2130  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2131  if(ilAuthUtils::_isExternalAccountEnabled())
2132  {
2133  $userObj->setExternalAccount($_POST["Fobject"]["ext_account"]);
2134  }
2135 
2136  //$user->setId($userObj->getId());
2137 
2138  //insert user data in table user_data
2139  $userObj->saveAsNew();
2140 
2141  // setup user preferences
2142  $userObj->setLanguage($_POST["Fobject"]["language"]);
2143 
2144  //set user skin and style
2145  $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
2146 
2147  if ($userObj->getPref("style") != $sknst[1] ||
2148  $userObj->getPref("skin") != $sknst[0])
2149  {
2150  $userObj->setPref("skin", $sknst[0]);
2151  $userObj->setPref("style", $sknst[1]);
2152  }
2153 
2154  // set hits per pages
2155  $userObj->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
2156  // set show users online
2157  $userObj->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
2158  // set hide_own_online_status
2159  $userObj->setPref("hide_own_online_status", $_POST["Fobject"]["hide_own_online_status"]);
2160 
2161  $userObj->writePrefs();
2162 
2163  //set role entries
2164  $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
2165 
2166  $msg = $this->lng->txt("user_added");
2167 
2168  // BEGIN DiskQuota: Remember the state of the "send info mail" checkbox
2169  global $ilUser;
2170  $ilUser->setPref('send_info_mails', ($_POST["send_mail"] != "") ? 'y' : 'n');
2171  $ilUser->writePrefs();
2172  // END DiskQuota: Remember the state of the "send info mail" checkbox
2173 
2174  // send new account mail
2175  if ($_POST["send_mail"] != "")
2176  {
2177  include_once("Services/Mail/classes/class.ilAccountMail.php");
2178  $acc_mail = new ilAccountMail();
2179  $acc_mail->setUserPassword($_POST["Fobject"]["passwd"]);
2180  $acc_mail->setUser($userObj);
2181 
2182  if ($acc_mail->send())
2183  {
2184  $msg = $msg."<br />".$this->lng->txt("mail_sent");
2185  }
2186  else
2187  {
2188  $msg = $msg."<br />".$this->lng->txt("mail_not_sent");
2189  }
2190  }
2191 
2192  ilUtil::sendInfo($msg, true);
2193 
2194  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
2195  {
2196  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
2197  }
2198  else
2199  {
2200  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2201  }
2202  }
2203 */
2208  function updateObjectOld()
2209  {
2210  global $ilias, $rbacsystem, $rbacadmin,$ilUser;
2211 
2212  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2213 
2214  //load ILIAS settings
2215  $settings = $ilias->getAllSettings();
2216 
2217  // User folder
2218  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write',$this->usrf_ref_id))
2219  {
2220  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2221  }
2222  // if called from local administration $this->usrf_ref_id is category id
2223  // Todo: this has to be fixed. Do not mix user folder id and category id
2224  if($this->usrf_ref_id != USER_FOLDER_ID)
2225  {
2226  // check if user is assigned to category
2227  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
2228  {
2229  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2230  }
2231  }
2232 
2233  foreach ($_POST["Fobject"] as $key => $val)
2234  {
2235  $_POST["Fobject"][$key] = ilUtil::stripSlashes($val);
2236  }
2237 
2238  // check dynamically required fields
2239  foreach ($settings as $key => $val)
2240  {
2241  $field = substr($key,8);
2242  switch($field)
2243  {
2244  case 'passwd':
2245  case 'passwd2':
2247  {
2248  $require_keys[] = $field;
2249  }
2250  break;
2251  default:
2252  $require_keys[] = $field;
2253  break;
2254 
2255  }
2256  }
2257 
2258  foreach ($require_keys as $key => $val)
2259  {
2260  // exclude required system and registration-only fields
2261  $system_fields = array("default_role");
2262  if (!in_array($val, $system_fields))
2263  {
2264  if (isset($settings["require_" . $val]) && $settings["require_" . $val])
2265  {
2266  if (empty($_POST["Fobject"][$val]))
2267  {
2268  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2269  $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
2270  }
2271  }
2272  }
2273  }
2274 
2275  if(!$this->__checkUserDefinedRequiredFields())
2276  {
2277  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
2278  }
2279  // validate login
2280  if ($this->object->getLogin() != $_POST["Fobject"]["login"] &&
2281  !ilUtil::isLogin($_POST["Fobject"]["login"]))
2282  {
2283  $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
2284  }
2285 
2286  // check loginname
2287  if (ilObjUser::_loginExists($_POST["Fobject"]["login"],$this->id))
2288  {
2289  $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
2290  }
2291 
2293  {
2294  if($_POST['Fobject']['passwd'] == "********" and
2295  !strlen($this->object->getPasswd()))
2296  {
2297  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2298  $this->lng->txt('password'),$this->ilias->error_obj->MESSAGE);
2299  }
2300  // check passwords
2301  if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
2302  {
2303  $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
2304  }
2305 
2306  // validate password
2307  if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
2308  {
2309  $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
2310  }
2311  }
2312  else
2313  {
2314  // Password will not be changed...
2315  $_POST['Fobject']['passwd'] = "********";
2316  }
2318  {
2319  if(!strlen($_POST['Fobject']['ext_account']))
2320  {
2321  $this->ilias->raiseError($this->lng->txt('ext_acccount_required'),$this->ilias->error_obj->MESSAGE);
2322  }
2323  }
2324  if($_POST['Fobject']['ext_account'] &&
2325  ($elogin = ilObjUser::_checkExternalAuthAccount($_POST['Fobject']['auth_mode'],$_POST['Fobject']['ext_account'])))
2326  {
2327  if($elogin != $this->object->getLogin())
2328  {
2329  $this->ilias->raiseError(
2330  sprintf($this->lng->txt("err_auth_ext_user_exists"),
2331  $_POST["Fobject"]["ext_account"],
2332  $_POST['Fobject']['auth_mode'],
2333  $elogin),
2334  $this->ilias->error_obj->MESSAGE);
2335  }
2336  }
2337 
2338  // The password type is not passed with the post data. Therefore we
2339  // append it here manually.
2340  include_once ('./Services/User/classes/class.ilObjUser.php');
2341  $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
2342 
2343  // validate email
2344  if (strlen($_POST['Fobject']['email']) and !ilUtil::is_email($_POST["Fobject"]["email"]))
2345  {
2346  $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
2347  }
2348 
2349  $start = $this->__toUnix($_POST["time_limit"]["from"]);
2350  $end = $this->__toUnix($_POST["time_limit"]["until"]);
2351 
2352  // validate time limit
2353  if (!$_POST["time_limit"]["unlimited"] and
2354  ( $start > $end))
2355  {
2356  $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
2357  }
2358 
2359  if(!$this->ilias->account->getTimeLimitUnlimited())
2360  {
2361  if($start < $this->ilias->account->getTimeLimitFrom() or
2362  $end > $this->ilias->account->getTimeLimitUntil() or
2363  $_POST['time_limit']['unlimited'])
2364  {
2365  $_SESSION['error_post_vars'] = $_POST;
2366 
2367  ilUtil::sendFailure($this->lng->txt('time_limit_not_within_owners'));
2368  $this->editObject();
2369 
2370  return false;
2371  }
2372  }
2373 
2374  // TODO: check length of login and passwd
2375 
2376  // checks passed. save user
2377  $_POST['Fobject']['time_limit_owner'] = $this->object->getTimeLimitOwner();
2378 
2379  $_POST['Fobject']['time_limit_unlimited'] = (int) $_POST['time_limit']['unlimited'];
2380  $_POST['Fobject']['time_limit_from'] = $this->__toUnix($_POST['time_limit']['from']);
2381  $_POST['Fobject']['time_limit_until'] = $this->__toUnix($_POST['time_limit']['until']);
2382 
2383  if($_POST['Fobject']['time_limit_unlimited'] != $this->object->getTimeLimitUnlimited() or
2384  $_POST['Fobject']['time_limit_from'] != $this->object->getTimeLimitFrom() or
2385  $_POST['Fobject']['time_limit_until'] != $this->object->getTimeLimitUntil())
2386  {
2387  $_POST['Fobject']['time_limit_message'] = 0;
2388  }
2389  else
2390  {
2391  $_POST['Fobject']['time_limit_message'] = $this->object->getTimeLimitMessage();
2392  }
2393 
2394  $this->object->assignData($_POST["Fobject"]);
2395  $this->object->setUserDefinedData($_POST['udf']);
2396 
2397  try
2398  {
2399  $this->object->updateLogin($_POST['Fobject']['login']);
2400  }
2401  catch (ilUserException $e)
2402  {
2403  ilUtil::sendFailure($e->getMessage());
2404  $this->form_gui->setValuesByPost();
2405  return $tpl->setContent($this->form_gui->getHtml());
2406  }
2407 
2408  $this->object->setTitle($this->object->getFullname());
2409  $this->object->setDescription($this->object->getEmail());
2410  $this->object->setLanguage($_POST["Fobject"]["language"]);
2411 
2412  //set user skin and style
2413  $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
2414 
2415  if ($this->object->getPref("style") != $sknst[1] ||
2416  $this->object->getPref("skin") != $sknst[0])
2417  {
2418  $this->object->setPref("skin", $sknst[0]);
2419  $this->object->setPref("style", $sknst[1]);
2420  }
2421 
2422  // set hits per pages
2423  $this->object->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
2424  // set show users online
2425  $this->object->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
2426  // set hide_own_online_status
2427  if ($_POST["Fobject"]["hide_own_online_status"]) {
2428  $this->object->setPref("hide_own_online_status", $_POST["Fobject"]["hide_own_online_status"]);
2429  }
2430  else {
2431  $this->object->setPref("hide_own_online_status", "n");
2432  }
2433 
2434  $this->update = $this->object->update();
2435  //$rbacadmin->updateDefaultRole($_POST["Fobject"]["default_role"], $this->object->getId());
2436 
2437  // BEGIN DiskQuota: Remember the state of the "send info mail" checkbox
2438  global $ilUser;
2439  $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
2440  $ilUser->writePrefs();
2441  // END DiskQuota: Remember the state of the "send info mail" checkbox
2442 
2443  $mail_message = $this->__sendProfileMail();
2444  $msg = $this->lng->txt('saved_successfully').$mail_message;
2445 
2446  // feedback
2447  ilUtil::sendSuccess($msg,true);
2448 
2449  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
2450  {
2451  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
2452  }
2453  else
2454  {
2455  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2456  }
2457  }
2458 
2459 
2460 
2466  function assignSaveObject()
2467  {
2468  global $rbacsystem, $rbacadmin, $rbacreview;
2469 
2470  if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
2471  {
2472  $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
2473  }
2474 
2475  $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
2476  $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
2477 
2478  // prevent unassignment of system role from system user
2479  if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles))
2480  {
2481  array_push($selected_roles,SYSTEM_ROLE_ID);
2482  }
2483 
2484  $global_roles_all = $rbacreview->getGlobalRoles();
2485  $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
2486  $assigned_roles = array_intersect($assigned_roles_all,$posted_roles);
2487  $assigned_global_roles_all = array_intersect($assigned_roles_all,$global_roles_all);
2488  $assigned_global_roles = array_intersect($assigned_global_roles_all,$posted_roles);
2489  $posted_global_roles = array_intersect($selected_roles,$global_roles_all);
2490 
2491  if ((empty($selected_roles) and count($assigned_roles_all) == count($assigned_roles))
2492  or (empty($posted_global_roles) and count($assigned_global_roles_all) == count($assigned_global_roles)))
2493  {
2494  //$this->ilias->raiseError($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
2495  // workaround. sometimes jumps back to wrong page
2496  ilUtil::sendFailure($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),true);
2497  $this->ctrl->redirect($this,'roleassignment');
2498  }
2499 
2500  foreach (array_diff($assigned_roles,$selected_roles) as $role)
2501  {
2502  $rbacadmin->deassignUser($role,$this->object->getId());
2503  }
2504 
2505  foreach (array_diff($selected_roles,$assigned_roles) as $role)
2506  {
2507  $rbacadmin->assignUser($role,$this->object->getId(),false);
2508  }
2509 
2510  include_once "./Services/AccessControl/classes/class.ilObjRole.php";
2511 
2512  // update object data entry (to update last modification date)
2513  $this->object->update();
2514 
2515  ilUtil::sendSuccess($this->lng->txt("msg_roleassignment_changed"),true);
2516 
2517  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
2518  {
2519  $this->ctrl->redirect($this,'roleassignment');
2520  }
2521  else
2522  {
2523  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2524  }
2525 
2526  }
2527 
2534  {
2535  global $rbacreview,$rbacsystem,$ilUser, $ilTabs;
2536 
2537  $ilTabs->activateTab("role_assignment");
2538 
2539  if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
2540  {
2541  $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
2542  }
2543 
2544  $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
2545 
2546  if ($_SESSION['filtered_roles'] > 5)
2547  {
2548  $_SESSION['filtered_roles'] = 0;
2549  }
2550 
2551  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html','Services/User');
2552 
2553  if(false)
2554  {
2555  $this->tpl->setCurrentBlock("filter");
2556  $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
2557  $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
2558  $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
2559  $this->tpl->setVariable("FILTER_NAME",'roleassignment');
2560  $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
2561  $this->tpl->parseCurrentBlock();
2562  }
2563 
2564  // init table
2565  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
2566  $tab = new ilRoleAssignmentTableGUI($this, "roleassignment");
2567 
2568  // now get roles depending on filter settings
2569  $role_list = $rbacreview->getRolesByFilter($tab->filter["role_filter"],$this->object->getId());
2570  $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
2571 
2572  $counter = 0;
2573 
2574  include_once ('./Services/AccessControl/classes/class.ilObjRole.php');
2575 
2576  $records = array();
2577  foreach ($role_list as $role)
2578  {
2579  // fetch context path of role
2580  $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
2581 
2582  // only list roles that are not set to status "deleted"
2583  if ($rbacreview->isDeleted($rolf[0]))
2584  {
2585  continue;
2586  }
2587 
2588  // build context path
2589  $path = "";
2590 
2591  if ($this->tree->isInTree($rolf[0]))
2592  {
2593  if ($rolf[0] == ROLE_FOLDER_ID)
2594  {
2595  $path = $this->lng->txt("global");
2596  }
2597  else
2598  {
2599  $tmpPath = $this->tree->getPathFull($rolf[0]);
2600 
2601  // count -1, to exclude the role folder itself
2602  /*for ($i = 1; $i < (count($tmpPath)-1); $i++)
2603  {
2604  if ($path != "")
2605  {
2606  $path .= " > ";
2607  }
2608 
2609  $path .= $tmpPath[$i]["title"];
2610  }*/
2611 
2612  $path = $tmpPath[count($tmpPath)-1]["title"];
2613  }
2614  }
2615  else
2616  {
2617  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role["obj_id"].")</b>";
2618  }
2619 
2620  $disabled = false;
2621 
2622  // disable checkbox for system role for the system user
2623  if (($this->object->getId() == SYSTEM_USER_ID and $role["obj_id"] == SYSTEM_ROLE_ID)
2624  or (!in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())) and $role["obj_id"] == SYSTEM_ROLE_ID))
2625  {
2626  $disabled = true;
2627  }
2628 
2629  // protected admin role
2630  if($role['obj_id'] == SYSTEM_ROLE_ID && !$rbacreview->isAssigned($ilUser->getId(),SYSTEM_ROLE_ID))
2631  {
2632  include_once './Services/PrivacySecurity/classes/class.ilSecuritySettings.php';
2633  if(ilSecuritySettings::_getInstance()->isAdminRoleProtected())
2634  {
2635  $disabled = true;
2636  }
2637  }
2638 
2639  if (substr($role["title"],0,3) == "il_")
2640  {
2641  if (!$assignable)
2642  {
2643  $rolf_arr = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
2644  $rolf2 = $rolf_arr[0];
2645  }
2646  else
2647  {
2648  $rolf2 = $rolf;
2649  }
2650 
2651  $parent_node = $this->tree->getNodeData($rolf2);
2652 
2653  $role["description"] = $this->lng->txt("obj_".$parent_node["type"])."&nbsp;(#".$parent_node["obj_id"].")";
2654  }
2655 
2656  $role_ids[$counter] = $role["obj_id"];
2657 
2658  $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"]."\"/>";
2659  $this->ctrl->setParameterByClass("ilobjrolegui", "ref_id", $rolf[0]);
2660  $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $role["obj_id"]);
2661  $result_set[$counter][] = $link = "<a href=\"".$this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm")."\">".ilObjRole::_getTranslation($role["title"])."</a>";
2662  $title = ilObjRole::_getTranslation($role["title"]);
2663  $result_set[$counter][] = $role["description"];
2664 
2665  // Add link to objector local Rores
2666  if ($role["role_type"] == "local") {
2667  // Get Object to the role
2668  $obj_id = ilRbacReview::getObjectOfRole($role["rol_id"]);
2669 
2670  $obj_type = ilObject::_lookupType($obj_id);
2671 
2673 
2674  foreach ($ref_ids as $ref_id) {}
2675 
2676  require_once("./Services/Link/classes/class.ilLink.php");
2677 
2678  $result_set[$counter][] = $context = "<a href='".ilLink::_getLink($ref_id, ilObject::_lookupType($obj_id))."' target='_top'>".$path."</a>";
2679  }
2680  else
2681  {
2682  $result_set[$counter][] = $path;
2683  $context = $path;
2684  }
2685 
2686  $records[] = array("path" => $path, "description" => $role["description"],
2687  "context" => $context, "checkbox" => $checkbox,
2688  "role" => $link, "title" => $title);
2689  ++$counter;
2690  }
2691 
2692  if (true)
2693  {
2694  $tab->setData($records);
2695  $this->tpl->setVariable("ROLES_TABLE",$tab->getHTML());
2696  return;
2697  }
2698  }
2699 
2704  {
2705  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
2706  $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
2707  $table_gui->writeFilterToSession(); // writes filter to session
2708  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2709  $this->roleassignmentObject();
2710  }
2711 
2716  {
2717  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
2718  $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
2719  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2720  $table_gui->resetFilter(); // clears filter
2721  $this->roleassignmentObject();
2722  }
2723 
2724  function __getDateSelect($a_type,$a_varname,$a_selected)
2725  {
2726  switch($a_type)
2727  {
2728  case "minute":
2729  for($i=0;$i<=60;$i++)
2730  {
2731  $days[$i] = $i < 10 ? "0".$i : $i;
2732  }
2733  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2734 
2735  case "hour":
2736  for($i=0;$i<24;$i++)
2737  {
2738  $days[$i] = $i < 10 ? "0".$i : $i;
2739  }
2740  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2741 
2742  case "day":
2743  for($i=1;$i<32;$i++)
2744  {
2745  $days[$i] = $i < 10 ? "0".$i : $i;
2746  }
2747  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
2748 
2749  case "month":
2750  for($i=1;$i<13;$i++)
2751  {
2752  $month[$i] = $i < 10 ? "0".$i : $i;
2753  }
2754  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
2755 
2756  case "year":
2757  if($a_selected < date('Y',time()))
2758  {
2759  $start = $a_selected;
2760  }
2761  else
2762  {
2763  $start = date('Y',time());
2764  }
2765 
2766  for($i = $start;$i < date("Y",time()) + 11;++$i)
2767  {
2768  $year[$i] = $i;
2769  }
2770  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
2771  }
2772  }
2773 
2774  function __toUnix($a_time_arr)
2775  {
2776  return mktime($a_time_arr["hour"],
2777  $a_time_arr["minute"],
2778  $a_time_arr["second"],
2779  $a_time_arr["month"],
2780  $a_time_arr["day"],
2781  $a_time_arr["year"]);
2782  }
2783 
2784 
2785 
2786 
2788  {
2789  unset($_SESSION["filtered_roles"]);
2790  }
2791 
2793  {
2794  $action[0] = $this->lng->txt('assigned_roles');
2795  $action[1] = $this->lng->txt('all_roles');
2796  $action[2] = $this->lng->txt('all_global_roles');
2797  $action[3] = $this->lng->txt('all_local_roles');
2798  $action[4] = $this->lng->txt('internal_local_roles_only');
2799  $action[5] = $this->lng->txt('non_internal_local_roles_only');
2800 
2801  return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
2802  }
2803 
2805  {
2807  $this->roleassignmentObject();
2808  }
2809 
2815  {
2816  global $ilLocator;
2817 
2818  $ilLocator->clearItems();
2819 
2820  if ($_GET["admin_mode"] == "settings") // system settings
2821  {
2822  $this->ctrl->setParameterByClass("ilobjsystemfoldergui",
2823  "ref_id", SYSTEM_FOLDER_ID);
2824  $ilLocator->addItem($this->lng->txt("administration"),
2825  $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjsystemfoldergui"), ""),
2826  ilFrameTargetInfo::_getFrame("MainContent"));
2827 
2828  if ($_GET['ref_id'] == USER_FOLDER_ID)
2829  {
2830  $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
2831  ilObject::_lookupObjId($_GET["ref_id"]))),
2832  $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
2833  }
2834  elseif ($_GET['ref_id'] == ROLE_FOLDER_ID)
2835  {
2836  $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
2837  ilObject::_lookupObjId($_GET["ref_id"]))),
2838  $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", "view"));
2839  }
2840 
2841  if ($_GET["obj_id"] > 0)
2842  {
2843  $ilLocator->addItem($this->object->getTitle(),
2844  $this->ctrl->getLinkTarget($this, "view"));
2845  }
2846  }
2847  else // repository administration
2848  {
2849  // ?
2850  }
2851  }
2852 
2853  function showUpperIcon()
2854  {
2855  }
2856 
2858  {
2859  global $ilUser,$ilias;
2860 
2861  if($_POST['send_mail'] != 'y')
2862  {
2863  return '';
2864  }
2865  if(!strlen($this->object->getEmail()))
2866  {
2867  return '';
2868  }
2869 
2870  // Choose language of user
2871  $usr_lang = new ilLanguage($this->object->getLanguage());
2872  $usr_lang->loadLanguageModule('crs');
2873  $usr_lang->loadLanguageModule('registration');
2874 
2875  include_once "Services/Mail/classes/class.ilMimeMail.php";
2876 
2877  $mmail = new ilMimeMail();
2878  $mmail->autoCheck(false);
2879  $mmail->From($ilUser->getEmail());
2880  $mmail->To($this->object->getEmail());
2881 
2882  // mail subject
2883  $subject = $usr_lang->txt("profile_changed");
2884 
2885 
2886  // mail body
2887  $body = ($usr_lang->txt("reg_mail_body_salutation")." ".$this->object->getFullname().",\n\n");
2888 
2889  $date = $this->object->getApproveDate();
2890  // Approve
2891  if((time() - strtotime($date)) < 10)
2892  {
2893  $body .= ($usr_lang->txt('reg_mail_body_approve')."\n\n");
2894  }
2895  else
2896  {
2897  $body .= ($usr_lang->txt('reg_mail_body_profile_changed')."\n\n");
2898  }
2899 
2900  // Append login info only if password has been chacnged
2901  if($_POST['passwd'] != '********')
2902  {
2903  $body .= $usr_lang->txt("reg_mail_body_text2")."\n".
2904  ILIAS_HTTP_PATH."/login.php?client_id=".$ilias->client_id."\n".
2905  $usr_lang->txt("login").": ".$this->object->getLogin()."\n".
2906  $usr_lang->txt("passwd").": ".$_POST['passwd']."\n\n";
2907  }
2908  $body .= ($usr_lang->txt("reg_mail_body_text3")."\n");
2909  $body .= $this->object->getProfileAsString($usr_lang);
2910 
2911  $mmail->Subject($subject);
2912  $mmail->Body($body);
2913  $mmail->Send();
2914 
2915 
2916  return "<br/>".$this->lng->txt("mail_sent");
2917  }
2918 
2922  public static function _goto($a_target)
2923  {
2924  global $ilUser, $ilCtrl;
2925 
2926  // #10888
2927  if($a_target == md5("usrdelown"))
2928  {
2929  if($ilUser->getId() != ANONYMOUS_USER_ID &&
2930  $ilUser->hasDeletionFlag())
2931  {
2932  $ilCtrl->setTargetScript("ilias.php");
2933  $ilCtrl->initBaseClass("ilpersonaldesktopgui");
2934  $ilCtrl->redirectByClass(array("ilpersonaldesktopgui", "ilpersonalsettingsgui"), "deleteOwnAccount3");
2935  }
2936  exit("This account is not flagged for deletion."); // #12160
2937  }
2938 
2939  if (substr($a_target, 0, 1) == "n")
2940  {
2941  $a_target = ilObjUser::_lookupId(ilUtil::stripSlashes(substr($a_target, 1)));
2942  }
2943 
2944  $_GET["cmd"] = "view";
2945  $_GET["user_id"] = (int) $a_target;
2946  $_GET["baseClass"] = "ilPublicUserProfileGUI";
2947  $_GET["cmdClass"] = "ilpublicuserprofilegui";
2948  include("ilias.php");
2949  exit;
2950  }
2951 
2960  protected function handleIgnoredRequiredFields()
2961  {
2962  $profileMaybeIncomplete = false;
2963 
2964  require_once 'Services/User/classes/class.ilUserProfile.php';
2965 
2966  foreach( ilUserProfile::getIgnorableRequiredSettings() as $fieldName )
2967  {
2968  $elm = $this->form_gui->getItemByPostVar($fieldName);
2969 
2970  if( !$elm ) continue;
2971 
2972  if( $elm->getRequired() )
2973  {
2974  $profileMaybeIncomplete = true;
2975 
2976  // Flag as optional
2977  $elm->setRequired( false );
2978  }
2979  }
2980 
2981  include_once 'Services/User/classes/class.ilUserDefinedFields.php';
2982  $user_defined_fields = ilUserDefinedFields::_getInstance();
2983  foreach($user_defined_fields->getDefinitions() as $field_id => $definition)
2984  {
2985  $elm = $this->form_gui->getItemByPostVar('udf_'.$definition['field_id']);
2986 
2987  if( !$elm ) continue;
2988 
2989  if( $elm->getRequired() && $definition['changeable'] && $definition['required'] && $definition['visible'] )
2990  {
2991  $profileMaybeIncomplete = true;
2992 
2993  // Flag as optional
2994  $elm->setRequired( false );
2995  }
2996  }
2997 
2998  return $profileMaybeIncomplete;
2999  }
3000 
3004  protected function showAcceptedTermsOfService()
3005  {
3009  $agree_date = $this->form_gui->getItemByPostVar('agree_date');
3010  if($agree_date && $agree_date->getValue())
3011  {
3012  $this->lng->loadLanguageModule('tos');
3013  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
3017  $entity = ilTermsOfServiceHelper::getCurrentAcceptanceForUser($this->object);
3018  if($entity->getId())
3019  {
3020  $show_agreement_text = new ilCheckboxInputGUI($this->lng->txt('tos_show_signed_text'), 'tos_show_signed_text');
3021 
3022  $agreement_lang = new ilNonEditableValueGUI($this->lng->txt('language'), '');
3023  $agreement_lang->setValue($this->lng->txt('meta_l_' . $entity->getIso2LanguageCode()));
3024  $show_agreement_text->addSubItem($agreement_lang);
3025 
3026  require_once 'Services/TermsOfService/classes/form/class.ilTermsOfServiceSignedDocumentFormElementGUI.php';
3027  $agreement_document = new ilTermsOfServiceSignedDocumentFormElementGUI($this->lng->txt('tos_agreement_document'), '', $entity);
3028  $show_agreement_text->addSubItem($agreement_document);
3029  $agree_date->addSubItem($show_agreement_text);
3030  }
3031  }
3032  else if($agree_date)
3033  {
3034  $agree_date->setValue($this->lng->txt('tos_not_accepted_yet'));
3035  }
3036  }
3037 } // END class.ilObjUserGUI
3038 ?>