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