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