ILIAS  eassessment Revision 61809
 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':
573  $user = $this->object;
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);
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/MediaCast/classes/class.ilObjMediaCastAccess.php";
969  $data["disk_space_used"] =
970  ilObjFileAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
971  ilObjFileBasedLMAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
972  ilObjSAHSLearningModuleAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
973  ilObjMailAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
974  ilObjMediaCastAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>';
975  */
976  // END DiskQuota, Show disk space used
977 
978  // personal data
979  $data["gender"] = $this->object->getGender();
980  $data["firstname"] = $this->object->getFirstname();
981  $data["lastname"] = $this->object->getLastname();
982  $data["title"] = $this->object->getUTitle();
983  $data['birthday'] = $this->object->getBirthday();
984  $data["institution"] = $this->object->getInstitution();
985  $data["department"] = $this->object->getDepartment();
986  $data["street"] = $this->object->getStreet();
987  $data["city"] = $this->object->getCity();
988  $data["zipcode"] = $this->object->getZipcode();
989  $data["country"] = $this->object->getCountry();
990  $data["sel_country"] = $this->object->getSelectedCountry();
991  $data["phone_office"] = $this->object->getPhoneOffice();
992  $data["phone_home"] = $this->object->getPhoneHome();
993  $data["phone_mobile"] = $this->object->getPhoneMobile();
994  $data["fax"] = $this->object->getFax();
995  $data["email"] = $this->object->getEmail();
996  $data["hobby"] = $this->object->getHobby();
997  $data["referral_comment"] = $this->object->getComment();
998 
999  // instant messengers
1000  $data["im_icq"] = $this->object->getInstantMessengerId('icq');
1001  $data["im_yahoo"] = $this->object->getInstantMessengerId('yahoo');
1002  $data["im_msn"] = $this->object->getInstantMessengerId('msn');
1003  $data["im_aim"] = $this->object->getInstantMessengerId('aim');
1004  $data["im_skype"] = $this->object->getInstantMessengerId('skype');
1005  $data["im_jabber"] = $this->object->getInstantMessengerId('jabber');
1006  $data["im_voip"] = $this->object->getInstantMessengerId('voip');
1007 
1008  // other data
1009  $data["matriculation"] = $this->object->getMatriculation();
1010  $data["delicious"] = $this->object->getDelicious();
1011  $data["client_ip"] = $this->object->getClientIP();
1012 
1013  // user defined fields
1014  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1015  $this->user_defined_fields = ilUserDefinedFields::_getInstance();
1016  $user_defined_data = $this->object->getUserDefinedData();
1017  foreach($this->user_defined_fields->getDefinitions() as $field_id => $definition)
1018  {
1019  $data["udf_".$field_id] = $user_defined_data["f_".$field_id];
1020  }
1021 
1022  // settings
1023  $data["language"] = $this->object->getLanguage();
1024  $data["skin_style"] = $this->object->skin.":".$this->object->prefs["style"];
1025  $data["hits_per_page"] = $this->object->prefs["hits_per_page"];
1026  $data["show_users_online"] = $this->object->prefs["show_users_online"];
1027  $data["hide_own_online_status"] = $this->object->prefs["hide_own_online_status"] == 'y';
1028  $data["session_reminder_enabled"] = (int)$this->object->prefs["session_reminder_enabled"];
1029 
1030  $this->form_gui->setValuesByArray($data);
1031  }
1032 
1036  function initForm($a_mode)
1037  {
1038  global $lng, $ilCtrl, $styleDefinition, $ilSetting, $ilClientIniFile, $ilUser;
1039 
1040  $settings = $ilSetting->getAll();
1041 
1042  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1043 
1044  $this->form_gui = new ilPropertyFormGUI();
1045  $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
1046  if ($a_mode == "create")
1047  {
1048  $this->form_gui->setTitle($lng->txt("usr_new"));
1049  }
1050  else
1051  {
1052  $this->form_gui->setTitle($lng->txt("usr_edit"));
1053  }
1054 
1055  // login data
1056  $sec_l = new ilFormSectionHeaderGUI();
1057  $sec_l->setTitle($lng->txt("login_data"));
1058  $this->form_gui->addItem($sec_l);
1059 
1060  // authentication mode
1061  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1062  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
1063  $am = new ilSelectInputGUI($lng->txt("auth_mode"), "auth_mode");
1064  $option = array();
1065  foreach ($active_auth_modes as $auth_name => $auth_key)
1066  {
1067  if ($auth_name == 'default')
1068  {
1069  $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
1070  }
1071  else
1072  {
1073  $name = $this->lng->txt('auth_'.$auth_name);
1074  }
1075  $option[$auth_name] = $name;
1076  }
1077  $am->setOptions($option);
1078  $this->form_gui->addItem($am);
1079 
1080  // login
1081  $lo = new ilUserLoginInputGUI($lng->txt("login"), "login");
1082  $lo->setRequired(true);
1083  if ($a_mode == "edit")
1084  {
1085  $lo->setCurrentUserId($this->object->getId());
1086  try
1087  {
1088  include_once 'Services/Calendar/classes/class.ilDate.php';
1089 
1090  $last_history_entry = ilObjUser::_getLastHistoryDataByUserId($this->object->getId());
1091  $lo->setInfo(
1092  sprintf(
1093  $this->lng->txt('usr_loginname_history_info'),
1094  ilDatePresentation::formatDate(new ilDateTime($last_history_entry[1], IL_CAL_UNIX)),
1095  $last_history_entry[0]
1096  )
1097  );
1098  }
1099  catch(ilUserException $e) { }
1100  }
1101 
1102  $this->form_gui->addItem($lo);
1103 
1104  // passwords
1105 // @todo: do not show passwords, if there is not a single auth, that
1106 // allows password setting
1107  {
1108  $pw = new ilPasswordInputGUI($lng->txt("passwd"), "passwd");
1109  $pw->setSize(32);
1110  $pw->setMaxLength(32);
1111  $pw->setValidateAuthPost("auth_mode");
1112  if ($a_mode == "create")
1113  {
1114  $pw->setRequiredOnAuth(true);
1115  }
1116  $pw->setInfo(ilUtil::getPasswordRequirementsInfo());
1117  $this->form_gui->addItem($pw);
1118  }
1119  // @todo: invisible/hidden passwords
1120 
1121  // external account
1122  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1124  {
1125  $ext = new ilTextInputGUI($lng->txt("user_ext_account"), "ext_account");
1126  $ext->setSize(40);
1127  $ext->setMaxLength(50);
1128  $ext->setInfo($lng->txt("user_ext_account_desc"));
1129  $this->form_gui->addItem($ext);
1130  }
1131 
1132  // login data
1133  $sec_si = new ilFormSectionHeaderGUI();
1134  $sec_si->setTitle($this->lng->txt("system_information"));
1135  $this->form_gui->addItem($sec_si);
1136 
1137  // create date, approve date, agreement date, last login
1138  if ($a_mode == "edit")
1139  {
1140  $sia = array("create_date", "approve_date", "agree_date", "last_login", "owner");
1141  foreach($sia as $a)
1142  {
1143  $siai = new ilNonEditableValueGUI($lng->txt($a), $a);
1144  $this->form_gui->addItem($siai);
1145  }
1146  }
1147 
1148  // active
1149  $ac = new ilCheckboxInputGUI($lng->txt("active"), "active");
1150  $ac->setChecked(true);
1151  $this->form_gui->addItem($ac);
1152 
1153  // access @todo: get fields right (names change)
1154  $lng->loadLanguageModule('crs');
1155 
1156  // access
1157  $radg = new ilRadioGroupInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1158  $radg->setValue(1);
1159  $op1 = new ilRadioOption($lng->txt("user_access_unlimited"), 1);
1160  $radg->addOption($op1);
1161  $op2 = new ilRadioOption($lng->txt("user_access_limited"), 0);
1162  $radg->addOption($op2);
1163 
1164 // $ac = new ilCheckboxInputGUI($lng->txt("time_limit"), "time_limit_unlimited");
1165 // $ac->setChecked(true);
1166 // $ac->setOptionTitle($lng->txt("crs_unlimited"));
1167 
1168  // access.from
1169  $acfrom = new ilDateTimeInputGUI($this->lng->txt("crs_from"), "time_limit_from");
1170  $acfrom->setShowTime(true);
1171 // $ac->addSubItem($acfrom);
1172  $op2->addSubItem($acfrom);
1173 
1174  // access.to
1175  $acto = new ilDateTimeInputGUI($this->lng->txt("crs_to"), "time_limit_until");
1176  $acto->setShowTime(true);
1177 // $ac->addSubItem($acto);
1178  $op2->addSubItem($acto);
1179 
1180 // $this->form_gui->addItem($ac);
1181  $this->form_gui->addItem($radg);
1182 
1183  require_once 'Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php';
1185  {
1186  // disk quota
1187  $disk_quota = new ilTextInputGUI($lng->txt("disk_quota"), "disk_quota");
1188  $disk_quota->setSize(10);
1189  $disk_quota->setMaxLength(11);
1190  $disk_quota->setInfo($this->lng->txt("enter_in_mb_desc"));
1191  $this->form_gui->addItem($disk_quota);
1192 
1193  if ($a_mode == "edit")
1194  {
1195  // show which disk quota is in effect, and explain why
1196  require_once 'Services/WebDAV/classes/class.ilDiskQuotaChecker.php';
1197  $dq_info = ilDiskQuotaChecker::_lookupDiskQuota($this->object->getId());
1198  if ($dq_info['user_disk_quota'] > $dq_info['role_disk_quota'])
1199  {
1200  $info_text = sprintf($lng->txt('disk_quota_is_1_instead_of_2_by_3'),
1201  ilFormat::formatSize($dq_info['user_disk_quota'],'short'),
1202  ilFormat::formatSize($dq_info['role_disk_quota'],'short'),
1203  $dq_info['role_title']);
1204  }
1205  else if (is_infinite($dq_info['role_disk_quota']))
1206  {
1207  $info_text = sprintf($lng->txt('disk_quota_is_unlimited_by_1'), $dq_info['role_title']);
1208  }
1209  else
1210  {
1211  $info_text = sprintf($lng->txt('disk_quota_is_1_by_2'),
1212  ilFormat::formatSize($dq_info['role_disk_quota'],'short'),
1213  $dq_info['role_title']);
1214  }
1215  $disk_quota->setInfo($this->lng->txt("enter_in_mb_desc").'<br>'.$info_text);
1216 
1217 
1218  // disk usage
1219  $du_info = ilDiskQuotaChecker::_lookupDiskUsage($this->object->getId());
1220  $disk_usage = new ilNonEditableValueGUI($lng->txt("disk_usage"), "disk_usage");
1221  if ($du_info['last_update'] === null)
1222  {
1223  $disk_usage->setValue($lng->txt('unknown'));
1224  }
1225  else
1226  {
1227  require_once 'classes/class.ilFormat.php';
1228  $disk_usage->setValue(ilFormat::formatSize($du_info['disk_usage'],'short'));
1229  $info = '<table>';
1230  // write the count and size of each object type
1231  foreach ($du_info['details'] as $detail_data)
1232  {
1233  $info .= '<tr>'.
1234  '<td>'.$detail_data['count'].'</td>'.
1235  '<td>'.$lng->txt($detail_data['type']).'</td>'.
1236  '<td>'.ilFormat::formatSize($detail_data['size'], 'short').'</td>'.
1237  '</tr>'
1238  ;
1239  }
1240  $info .= '</table>';
1241  $info .= '<br>'.$this->lng->txt('last_update').': '.
1242  ilDatePresentation::formatDate(new ilDateTime($du_info['last_update'], IL_CAL_DATETIME));
1243  $disk_usage->setInfo($info);
1244 
1245  }
1246  $this->form_gui->addItem($disk_usage);
1247 
1248  // date when the last disk quota reminder was sent to the user
1249  if (true || $dq_info['last_reminder'])
1250  {
1251  $reminder = new ilNonEditableValueGUI($lng->txt("disk_quota_last_reminder_sent"), "last_reminder");
1252  $reminder->setValue(
1253  ilDatePresentation::formatDate(new ilDateTime($dq_info['last_reminder'], IL_CAL_DATETIME))
1254  );
1255  $reminder->setInfo($this->lng->txt("disk_quota_last_reminder_sent_desc"));
1256  $this->form_gui->addItem($reminder);
1257  }
1258  }
1259  }
1260 
1261 
1262  // personal data
1263  if(
1264  $this->isSettingChangeable('gender') or
1265  $this->isSettingChangeable('firstname') or
1266  $this->isSettingChangeable('lastname') or
1267  $this->isSettingChangeable('title') or
1268  $this->isSettingChangeable('personal_image') or
1269  $this->isSettingChangeable('birhtday')
1270  )
1271  {
1272  $sec_pd = new ilFormSectionHeaderGUI();
1273  $sec_pd->setTitle($this->lng->txt("personal_data"));
1274  $this->form_gui->addItem($sec_pd);
1275  }
1276 
1277  // gender
1278  if($this->isSettingChangeable('gender'))
1279  {
1280  $gndr = new ilRadioGroupInputGUI($lng->txt("gender"), "gender");
1281  $gndr->setRequired(isset($settings["require_gender"]) && $settings["require_gender"]);
1282  $female = new ilRadioOption($lng->txt("gender_f"), "f");
1283  $gndr->addOption($female);
1284  $male = new ilRadioOption($lng->txt("gender_m"), "m");
1285  $gndr->addOption($male);
1286  $this->form_gui->addItem($gndr);
1287  }
1288 
1289  // firstname, lastname, title
1290  $fields = array("firstname" => true, "lastname" => true,
1291  "title" => isset($settings["require_title"]) && $settings["require_title"]);
1292  foreach($fields as $field => $req)
1293  {
1294  if($this->isSettingChangeable($field))
1295  {
1296  $inp = new ilTextInputGUI($lng->txt($field), $field);
1297  $inp->setSize(32);
1298  $inp->setMaxLength(32);
1299  $inp->setRequired($req);
1300  $this->form_gui->addItem($inp);
1301  }
1302  }
1303 
1304  // personal image
1305  if($this->isSettingChangeable('upload'))
1306  {
1307  $pi = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
1308  if ($a_mode == "edit" || $a_mode == "upload")
1309  {
1310  $pi->setImage(ilObjUser::_getPersonalPicturePath($this->object->getId(), "small", true,
1311  true));
1312  }
1313  $this->form_gui->addItem($pi);
1314  }
1315 
1316  if($this->isSettingChangeable('birthday'))
1317  {
1318  $birthday = new ilBirthdayInputGUI($lng->txt('birthday'), 'birthday');
1319  $birthday->setRequired(isset($settings["require_birthday"]) && $settings["require_birthday"]);
1320  $birthday->setShowEmpty(true);
1321  $birthday->setStartYear(1900);
1322  $this->form_gui->addItem($birthday);
1323  }
1324 
1325 
1326  // institution, department, street, city, zip code, country, phone office
1327  // phone home, phone mobile, fax, e-mail
1328  $fields = array(
1329  array("institution", 40, 80),
1330  array("department", 40, 80),
1331  array("street", 40, 40),
1332  array("city", 40, 40),
1333  array("zipcode", 10, 10),
1334  array("country", 40, 40),
1335  array("sel_country"),
1336  array("phone_office", 30, 30),
1337  array("phone_home", 30, 30),
1338  array("phone_mobile", 30, 30),
1339  array("fax", 30, 30));
1340 
1341  $counter = 0;
1342  foreach ($fields as $field)
1343  {
1344  if(!$counter++ and $this->isSettingChangeable($field[0]))
1345  {
1346  // contact data
1347  $sec_cd = new ilFormSectionHeaderGUI();
1348  $sec_cd->setTitle($this->lng->txt("contact_data"));
1349  $this->form_gui->addItem($sec_cd);
1350  }
1351  if($this->isSettingChangeable($field[0]))
1352  {
1353  if ($field[0] != "sel_country")
1354  {
1355  $inp = new ilTextInputGUI($lng->txt($field[0]), $field[0]);
1356  $inp->setSize($field[1]);
1357  $inp->setMaxLength($field[2]);
1358  $inp->setRequired(isset($settings["require_".$field[0]]) &&
1359  $settings["require_".$field[0]]);
1360  $this->form_gui->addItem($inp);
1361  }
1362  else
1363  {
1364  // country selection
1365  include_once("./Services/Form/classes/class.ilCountrySelectInputGUI.php");
1366  $cs = new ilCountrySelectInputGUI($lng->txt($field[0]), $field[0]);
1367  $cs->setRequired(isset($settings["require_".$field[0]]) &&
1368  $settings["require_".$field[0]]);
1369  $this->form_gui->addItem($cs);
1370  }
1371  }
1372  }
1373 
1374  // email
1375  if($this->isSettingChangeable('email'))
1376  {
1377  $em = new ilEMailInputGUI($lng->txt("email"), "email");
1378  $em->setRequired(isset($settings["require_email"]) &&
1379  $settings["require_email"]);
1380  $this->form_gui->addItem($em);
1381  }
1382 
1383  // interests/hobbies
1384  if($this->isSettingChangeable('hobby'))
1385  {
1386  $hob = new ilTextAreaInputGUI($lng->txt("hobby"), "hobby");
1387  $hob->setRows(3);
1388  $hob->setCols(40);
1389  $hob->setRequired(isset($settings["require_hobby"]) &&
1390  $settings["require_hobby"]);
1391  $this->form_gui->addItem($hob);
1392  }
1393 
1394  // referral comment
1395  if($this->isSettingChangeable('referral_comment'))
1396  {
1397  $rc = new ilTextAreaInputGUI($lng->txt("referral_comment"), "referral_comment");
1398  $rc->setRows(3);
1399  $rc->setCols(40);
1400  $rc->setRequired(isset($settings["require_referral_comment"]) &&
1401  $settings["require_referral_comment"]);
1402  $this->form_gui->addItem($rc);
1403  }
1404 
1405  // instant messengers
1406  if($this->isSettingChangeable('instant_messengers'))
1407  {
1408  $sec_im = new ilFormSectionHeaderGUI();
1409  $sec_im->setTitle($this->lng->txt("instant_messengers"));
1410  $this->form_gui->addItem($sec_im);
1411  }
1412 
1413  // icq, yahoo, msn, aim, skype
1414  $fields = array("icq", "yahoo", "msn", "aim", "skype", "jabber", "voip");
1415  foreach ($fields as $field)
1416  {
1417  if($this->isSettingChangeable('instant_messengers'))
1418  {
1419  $im = new ilTextInputGUI($lng->txt("im_".$field), "im_".$field);
1420  $im->setSize(40);
1421  $im->setMaxLength(40);
1422  $this->form_gui->addItem($im);
1423  }
1424  }
1425 
1426  // other information
1427  if($this->isSettingChangeable('user_profile_other'))
1428  {
1429  $sec_oi = new ilFormSectionHeaderGUI();
1430  $sec_oi->setTitle($this->lng->txt("user_profile_other"));
1431  $this->form_gui->addItem($sec_oi);
1432  }
1433 
1434  // matriculation number
1435  if($this->isSettingChangeable('matriculation'))
1436  {
1437  $mr = new ilTextInputGUI($lng->txt("matriculation"), "matriculation");
1438  $mr->setSize(40);
1439  $mr->setMaxLength(40);
1440  $mr->setRequired(isset($settings["require_matriculation"]) &&
1441  $settings["require_matriculation"]);
1442  $this->form_gui->addItem($mr);
1443  }
1444 
1445  // delicious
1446  if($this->isSettingChangeable('delicious'))
1447  {
1448  $mr = new ilTextInputGUI($lng->txt("delicious"), "delicious");
1449  $mr->setSize(40);
1450  $mr->setMaxLength(40);
1451  $mr->setRequired(isset($settings["require_delicious"]) &&
1452  $settings["require_delicious"]);
1453  $this->form_gui->addItem($mr);
1454  }
1455 
1456  // client IP
1457  $ip = new ilTextInputGUI($lng->txt("client_ip"), "client_ip");
1458  $ip->setSize(40);
1459  $ip->setMaxLength(255);
1460  $ip->setInfo($this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"]." <br />".
1461  '<small class="warning">'.$this->lng->txt("current_ip_alert")."</span>");
1462  $this->form_gui->addItem($ip);
1463 
1464  // additional user defined fields
1465  include_once './Services/User/classes/class.ilUserDefinedFields.php';
1466  $user_defined_fields = ilUserDefinedFields::_getInstance();
1467 
1468  if($this->usrf_ref_id == USER_FOLDER_ID)
1469  {
1470  $all_defs = $user_defined_fields->getDefinitions();
1471  }
1472  else
1473  {
1474  $all_defs = $user_defined_fields->getChangeableLocalUserAdministrationDefinitions();
1475  }
1476 
1477  foreach($all_defs as $field_id => $definition)
1478  {
1479  if($definition['field_type'] == UDF_TYPE_TEXT) // text input
1480  {
1481  $udf = new ilTextInputGUI($definition['field_name'],
1482  "udf_".$definition['field_id']);
1483  $udf->setSize(40);
1484  $udf->setMaxLength(255);
1485  }
1486  else if($definition['field_type'] == UDF_TYPE_WYSIWYG) // text area input
1487  {
1488  $udf = new ilTextAreaInputGUI($definition['field_name'],
1489  "udf_".$definition['field_id']);
1490  $udf->setUseRte(true);
1491  }
1492  else // selection input
1493  {
1494  $udf = new ilSelectInputGUI($definition['field_name'],
1495  "udf_".$definition['field_id']);
1496  $udf->setOptions($user_defined_fields->fieldValuesToSelectArray(
1497  $definition['field_values']));
1498  }
1499  $udf->setRequired($definition['required']);
1500  $this->form_gui->addItem($udf);
1501  }
1502 
1503  // settings
1504  if(
1505  $a_mode == 'create' or
1506  $this->isSettingChangeable( 'language') or
1507  $this->isSettingChangeable( 'skin_style') or
1508  $this->isSettingChangeable( 'hits_per_page') or
1509  $this->isSettingChangeable( 'hide_own_online_status')
1510  )
1511  {
1512  $sec_st = new ilFormSectionHeaderGUI();
1513  $sec_st->setTitle($this->lng->txt("settings"));
1514  $this->form_gui->addItem($sec_st);
1515  }
1516 
1517  // role
1518  if ($a_mode == "create")
1519  {
1520  $role = new ilSelectInputGUI($lng->txt("default_role"),
1521  'default_role');
1522  $role->setRequired(true);
1523  $role->setValue($this->default_role);
1524  $role->setOptions($this->selectable_roles);
1525  $this->form_gui->addItem($role);
1526  }
1527 
1528  // language
1529  if($this->isSettingChangeable('language'))
1530  {
1531  $lang = new ilSelectInputGUI($lng->txt("language"),
1532  'language');
1533  $languages = $this->lng->getInstalledLanguages();
1534  $options = array();
1535  foreach($languages as $l)
1536  {
1537  $options[$l] = $lng->txt("lang_".$l);
1538  }
1539  $lang->setOptions($options);
1540  $lang->setValue($ilSetting->get("language"));
1541  $this->form_gui->addItem($lang);
1542  }
1543 
1544  // skin/style
1545  if($this->isSettingChangeable('skin_style'))
1546  {
1547  $sk = new ilSelectInputGUI($lng->txt("skin_style"),
1548  'skin_style');
1549  $templates = $styleDefinition->getAllTemplates();
1550  include("./Services/Style/classes/class.ilObjStyleSettings.php");
1551  $options = array();
1552  if (count($templates) > 0 && is_array ($templates))
1553  {
1554  foreach ($templates as $template)
1555  {
1556  $styleDef =& new ilStyleDefinition($template["id"]);
1557  $styleDef->startParsing();
1558  $styles = $styleDef->getStyles();
1559  foreach ($styles as $style)
1560  {
1561  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
1562  {
1563  continue;
1564  }
1565  $options[$template["id"].":".$style["id"]] =
1566  $styleDef->getTemplateName()." / ".$style["name"];
1567  }
1568  }
1569  }
1570  $sk->setOptions($options);
1571  $sk->setValue($ilClientIniFile->readVariable("layout","skin").
1572  ":".$ilClientIniFile->readVariable("layout","style"));
1573 
1574  $this->form_gui->addItem($sk);
1575  }
1576 
1577  // hits per page
1578  if($this->isSettingChangeable('hits_per_page'))
1579  {
1580  $hpp = new ilSelectInputGUI($lng->txt("hits_per_page"),
1581  'hits_per_page');
1582  $options = array(10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40,
1583  50 => 50, 100 => 100, 9999 => $this->lng->txt("no_limit"));
1584  $hpp->setOptions($options);
1585  $hpp->setValue($ilSetting->get("hits_per_page"));
1586  $this->form_gui->addItem($hpp);
1587 
1588  // users online
1589  $uo = new ilSelectInputGUI($lng->txt("users_online"),
1590  'show_users_online');
1591  $options = array(
1592  "y" => $lng->txt("users_online_show_y"),
1593  "associated" => $lng->txt("users_online_show_associated"),
1594  "n" => $lng->txt("users_online_show_n"));
1595  $uo->setOptions($options);
1596  $uo->setValue($ilSetting->get("show_users_online"));
1597  $this->form_gui->addItem($uo);
1598  }
1599 
1600  // hide online status
1601  if($this->isSettingChangeable('hide_own_online_status'))
1602  {
1603  $os = new ilCheckboxInputGUI($lng->txt("hide_own_online_status"), "hide_own_online_status");
1604  $this->form_gui->addItem($os);
1605  }
1606 
1607  // Options
1608  if($this->isSettingChangeable('send_mail'))
1609  {
1610  $sec_op = new ilFormSectionHeaderGUI();
1611  $sec_op->setTitle($this->lng->txt("options"));
1612  $this->form_gui->addItem($sec_op);
1613  }
1614 
1615  // send email
1616  $se = new ilCheckboxInputGUI($lng->txt('inform_user_mail'), 'send_mail');
1617  $se->setValue('y');
1618  $se->setChecked(($ilUser->getPref('send_info_mails') == 'y'));
1619  $this->form_gui->addItem($se);
1620 
1621  if((int)$ilSetting->get('session_reminder_enabled'))
1622  {
1623  $cb = new ilCheckboxInputGUI($this->lng->txt('session_reminder'), 'session_reminder_enabled');
1624  $cb->setValue(1);
1625  $this->form_gui->addItem($cb);
1626  }
1627 
1628  // @todo: handle all required fields
1629 
1630  // command buttons
1631  if ($a_mode == "create" || $a_mode == "save")
1632  {
1633  $this->form_gui->addCommandButton("save", $lng->txt("save"));
1634  }
1635  if ($a_mode == "edit" || $a_mode == "update")
1636  {
1637  $this->form_gui->addCommandButton("update", $lng->txt("save"));
1638  }
1639  $this->form_gui->addCommandButton("cancel", $lng->txt("cancel"));
1640  }
1641 
1650  protected function isSettingChangeable($a_field)
1651  {
1652  // TODO: Allow mixed field parameter to support checks against an array of field names.
1653 
1654  global $ilSetting;
1655  static $settings = null;
1656 
1657 
1658 
1659  if($this->usrf_ref_id == USER_FOLDER_ID)
1660  {
1661  return true;
1662  }
1663 
1664  if($settings == NULL)
1665  {
1666  $settings = $ilSetting->getAll();
1667  }
1668  return (bool) $settings['usr_settings_changeable_lua_'.$a_field];
1669  }
1670 
1676  function editOldObject()
1677  {
1678  global $ilias, $rbacsystem, $rbacreview, $rbacadmin, $styleDefinition, $ilUser
1679  ,$ilSetting;
1680 
1681  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
1682 
1683 
1684  //load ILIAS settings
1685  $settings = $ilias->getAllSettings();
1686 
1687  // User folder
1688  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
1689  {
1690  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
1691  }
1692  // if called from local administration $this->usrf_ref_id is category id
1693  // Todo: this has to be fixed. Do not mix user folder id and category id
1694  if($this->usrf_ref_id != USER_FOLDER_ID)
1695  {
1696  // check if user is assigned to category
1697  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
1698  {
1699  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
1700  }
1701  }
1702 
1703  if($this->usrf_ref_id != USER_FOLDER_ID)
1704  {
1705  $this->tabs_gui->clearTargets();
1706  }
1707 
1708  $data = array();
1709  $data["fields"] = array();
1710  $data["fields"]["login"] = $this->object->getLogin();
1711  $data["fields"]["passwd"] = "********"; // will not be saved
1712  #$data["fields"]["passwd2"] = "********"; // will not be saved
1713  $data["fields"]["ext_account"] = $this->object->getExternalAccount();
1714  $data["fields"]["title"] = $this->object->getUTitle();
1715  $data["fields"]["gender"] = $this->object->getGender();
1716  $data["fields"]["firstname"] = $this->object->getFirstname();
1717  $data["fields"]["lastname"] = $this->object->getLastname();
1718  $data["fields"]["institution"] = $this->object->getInstitution();
1719  $data["fields"]["department"] = $this->object->getDepartment();
1720  $data["fields"]["street"] = $this->object->getStreet();
1721  $data["fields"]["city"] = $this->object->getCity();
1722  $data["fields"]["zipcode"] = $this->object->getZipcode();
1723  $data["fields"]["country"] = $this->object->getCountry();
1724  $data["fields"]["sel_country"] = $this->object->getSelectedCountry();
1725  $data["fields"]["phone_office"] = $this->object->getPhoneOffice();
1726  $data["fields"]["phone_home"] = $this->object->getPhoneHome();
1727  $data["fields"]["phone_mobile"] = $this->object->getPhoneMobile();
1728  $data["fields"]["fax"] = $this->object->getFax();
1729  $data["fields"]["email"] = $this->object->getEmail();
1730  $data["fields"]["hobby"] = $this->object->getHobby();
1731  $data["fields"]["im_icq"] = $this->object->getInstantMessengerId('icq');
1732  $data["fields"]["im_yahoo"] = $this->object->getInstantMessengerId('yahoo');
1733  $data["fields"]["im_msn"] = $this->object->getInstantMessengerId('msn');
1734  $data["fields"]["im_aim"] = $this->object->getInstantMessengerId('aim');
1735  $data["fields"]["im_skype"] = $this->object->getInstantMessengerId('skype');
1736  $data["fields"]["im_jabber"] = $this->object->getInstantMessengerId('jabber');
1737  $data["fields"]["im_voip"] = $this->object->getInstantMessengerId('voip');
1738  $data["fields"]["matriculation"] = $this->object->getMatriculation();
1739  $data["fields"]["client_ip"] = $this->object->getClientIP();
1740  $data["fields"]["referral_comment"] = $this->object->getComment();
1741  $data["fields"]["owner"] = ilObjUser::_lookupLogin($this->object->getOwner());
1742  $data["fields"]["create_date"] = $this->object->getCreateDate();
1743  $data["fields"]["approve_date"] = $this->object->getApproveDate();
1744  $data["fields"]["agree_date"] = $this->object->getAgreeDate();
1745  $data["fields"]["last_login"] = $this->object->getLastLogin();
1746  $data["fields"]["active"] = $this->object->getActive();
1747  $data["fields"]["auth_mode"] = $this->object->getAuthMode();
1748  $data["fields"]["ext_account"] = $this->object->getExternalAccount();
1749 
1750  // BEGIN DiskQuota Get Picture, Owner, Last login, Approve Date and AgreeDate
1751  $this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("personal_picture"));
1752  $webspace_dir = ilUtil::getWebspaceDir("output");
1753  $full_img = $this->object->getPref("profile_image");
1754  $last_dot = strrpos($full_img, ".");
1755  $small_img = substr($full_img, 0, $last_dot).
1756  "_small".substr($full_img, $last_dot, strlen($full_img) - $last_dot);
1757  $image_file = $webspace_dir."/usr_images/".$small_img;
1758  if (@is_file($image_file))
1759  {
1760  $this->tpl->setVariable("IMG_PERSONAL", $image_file."?dummy=".rand(1,99999));
1761  $this->tpl->setVariable("ALT_IMG_PERSONAL",$this->lng->txt("personal_picture"));
1762  $this->tpl->setVariable("TXT_REMOVE_PIC", $this->lng->txt("remove_personal_picture"));
1763  }
1764 
1765  $this->tpl->setVariable("UPLOAD", $this->lng->txt("upload"));
1766  $this->tpl->setVariable("TXT_FILE", $this->lng->txt("userfile"));
1767  $this->tpl->setVariable("USER_FILE", $this->lng->txt("user_file"));
1768  // END DiskQuota Get Picture, Owner, Last login, Approve Date and AgreeDate
1769 
1770  // BEGIN DiskQuota, Show disk space used
1771  // W. Randelshofer 2008-07-07: Deactivated display of disk space usage,
1772  // because determining the disk space usage may take several minutes.
1773  /*
1774  require_once "Modules/File/classes/class.ilObjFileAccess.php";
1775  require_once "Modules/HTMLLearningModule/classes/class.ilObjFileBasedLMAccess.php";
1776  require_once "Modules/ScormAicc/classes/class.ilObjSAHSLearningModuleAccess.php";
1777  require_once "Services/Mail/classes/class.ilObjMailAccess.php";
1778  $this->tpl->setVariable('TXT_DISK_SPACE_USED',$this->lng->txt('disk_space_used'));
1779  $this->tpl->setVariable('DISK_SPACE_USED',
1780  ilObjFileAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1781  ilObjFileBasedLMAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1782  ilObjSAHSLearningModuleAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1783  ilObjMailAccess::_getDiskSpaceUsedBy($this->object->getId(), true).'<br>'.
1784  );
1785  */
1786  // END DiskQuota, Show disk space used
1787 
1788  if (!count($user_online = ilUtil::getUsersOnline($this->object->getId())) == 1)
1789  {
1790  $user_is_online = false;
1791  }
1792  else
1793  {
1794  $user_is_online = true;
1795 
1796  // extract serialized role Ids from session data
1797  preg_match("/RoleId.*?;\}/",$user_online[$this->object->getId()]["data"],$matches);
1798 
1799  $active_roles = unserialize(substr($matches[0],7));
1800 
1801  // gather data for active roles
1802  $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
1803 
1804  foreach ($assigned_roles as $key => $role)
1805  {
1806  $roleObj = $this->ilias->obj_factory->getInstanceByObjId($role);
1807 
1808  // fetch context path of role
1809  $rolf = $rbacreview->getFoldersAssignedToRole($role,true);
1810 
1811  // only list roles that are not set to status "deleted"
1812  if (count($rolf) > 0)
1813  {
1814  if (!$rbacreview->isDeleted($rolf[0]))
1815  {
1816  $path = "";
1817 
1818  if ($this->tree->isInTree($rolf[0]))
1819  {
1820  $tmpPath = $this->tree->getPathFull($rolf[0]);
1821 
1822  // count -1, to exclude the role folder itself
1823  for ($i = 0; $i < (count($tmpPath)-1); $i++)
1824  {
1825  if ($path != "")
1826  {
1827  $path .= " > ";
1828  }
1829 
1830  $path .= $tmpPath[$i]["title"];
1831  }
1832  }
1833  else
1834  {
1835  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role.")</b>";
1836  }
1837  $active_roles = $active_roles ? $active_roles : array();
1838  if (in_array($role,$active_roles))
1839  {
1840  $data["active_role"][$role]["active"] = true;
1841  }
1842 
1843  $data["active_role"][$role]["title"] = $roleObj->getTitle();
1844  $data["active_role"][$role]["context"] = $path;
1845 
1846  unset($roleObj);
1847  }
1848  }
1849  else
1850  {
1851  $path = "<b>No role folder found for role ".$role."!</b>";
1852  }
1853  }
1854  }
1855 
1856  $this->getTemplateFile("edit","usr");
1857 
1858  // FILL SAVED VALUES IN CASE OF ERROR
1859  if (isset($_SESSION["error_post_vars"]["Fobject"]))
1860  {
1861  if (!isset($_SESSION["error_post_vars"]["Fobject"]["active"]))
1862  {
1863  $_SESSION["error_post_vars"]["Fobject"]["active"] = 0;
1864  }
1865 
1866  foreach ($_SESSION["error_post_vars"]["Fobject"] as $key => $val)
1867  {
1868  $str = $this->lng->txt($key);
1869  if ($key == "title")
1870  {
1871  $str = $this->lng->txt("person_title");
1872  }
1873  if($key == 'passwd2')
1874  {
1875  continue;
1876  }
1877  if($key == 'passwd')
1878  {
1880  ilAuthUtils::_getAuthMode($_SESSION['error_post_vars']['Fobject']['auth_mode'])))
1881  {
1882  $this->tpl->setCurrentBlock('passwords_visible');
1883  $this->tpl->setVariable('VISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
1884  $this->tpl->setVariable('VISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
1885  $this->tpl->setVariable('VISIBLE_PASSWD',$_SESSION['error_post_vars']['Fobject']['passwd']);
1886  $this->tpl->setVariable('VISIBLE_PASSWD2',$_SESSION['error_post_vars']['Fobject']['passwd2']);
1887  $this->tpl->parseCurrentBlock();
1888  }
1889  else
1890  {
1891  $this->tpl->setCurrentBlock('passwords_invisible');
1892  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
1893  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
1894  $this->tpl->setVariable('INVISIBLE_PASSWD',strlen($this->object->getPasswd()) ?
1895  "********" :
1896  "");
1897  $this->tpl->setVariable('INVISIBLE_PASSWD2',strlen($this->object->getPasswd()) ?
1898  "********" :
1899  "");
1900  $this->tpl->setVariable('INVISIBLE_PASSWD_HIDDEN',"********");
1901  $this->tpl->parseCurrentBlock();
1902 
1903  }
1904  continue;
1905  }
1906 
1907  // check to see if dynamically required
1908  if (isset($settings["require_" . $key]) && $settings["require_" . $key])
1909  {
1910  $str = $str . '<span class="asterisk">*</span>';
1911  }
1912 
1913  $this->tpl->setVariable("TXT_".strtoupper($key), $str);
1914 
1915  if ($key != "default_role" and $key != "language"
1916  and $key != "skin_style" and $key != "hits_per_page"
1917  and $key != "show_users_online")
1918  {
1919  $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val,true));
1920  }
1921  }
1922 
1923  // gender selection
1924  $gender = strtoupper($_SESSION["error_post_vars"]["Fobject"]["gender"]);
1925 
1926 
1927  if (!empty($gender))
1928  {
1929  $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
1930  }
1931 
1932  $active = $_SESSION["error_post_vars"]["Fobject"]["active"];
1933  if ($active)
1934  {
1935  $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
1936  }
1937  }
1938  else
1939  {
1940  if (!isset($data["fields"]["active"]))
1941  {
1942  $data["fields"]["active"] = 0;
1943  }
1944 
1945  foreach ($data["fields"] as $key => $val)
1946  {
1947  $str = $this->lng->txt($key);
1948  if ($key == "title")
1949  {
1950  $str = $this->lng->txt("person_title");
1951  }
1952  if ($key == "ext_account")
1953  {
1954  continue;
1955  }
1956  if($key == 'passwd')
1957  {
1958  $auth_mode = $this->object->getAuthMode(true);
1960  {
1961  $this->tpl->setCurrentBlock('passwords_visible');
1962  $this->tpl->setVariable('VISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
1963  $this->tpl->setVariable('VISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
1964  $this->tpl->setVariable('VISIBLE_PASSWD',"********");
1965  $this->tpl->setVariable('VISIBLE_PASSWD2',"********");
1966  $this->tpl->parseCurrentBlock();
1967  }
1968  else
1969  {
1970  $this->tpl->setCurrentBlock('passwords_invisible');
1971  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD',$this->lng->txt('passwd'));
1972  $this->tpl->setVariable('INVISIBLE_TXT_PASSWD2',$this->lng->txt('retype_password'));
1973  $this->tpl->setVariable('INVISIBLE_PASSWD',strlen($this->object->getPasswd()) ?
1974  "********" :
1975  "");
1976  $this->tpl->setVariable('INVISIBLE_PASSWD2',strlen($this->object->getPasswd()) ?
1977  "********" :
1978  "");
1979  $this->tpl->setVariable('INVISIBLE_PASSWD_HIDDEN',"********");
1980  $this->tpl->parseCurrentBlock();
1981  }
1982  continue;
1983  }
1984 
1985  // check to see if dynamically required
1986  if (isset($settings["require_" . $key]) && $settings["require_" . $key])
1987  {
1988  $str = $str . '<span class="asterisk">*</span>';
1989  }
1990 
1991  $this->tpl->setVariable("TXT_".strtoupper($key), $str);
1992 
1993  $this->tpl->setVariable(strtoupper($key), ilUtil::prepareFormOutput($val));
1994  #$this->tpl->parseCurrentBlock();
1995  }
1996 
1997  // gender selection
1998  $gender = strtoupper($data["fields"]["gender"]);
1999 
2000  if (!empty($gender))
2001  {
2002  $this->tpl->setVariable("BTN_GENDER_".$gender,"checked=\"checked\"");
2003  }
2004 
2005  $active = $data["fields"]["active"];
2006  if ($active)
2007  {
2008  $this->tpl->setVariable("ACTIVE", "checked=\"checked\"");
2009  }
2010  }
2011 
2012  // external account
2013  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2015  {
2016  $this->tpl->setCurrentBlock("ext_account");
2017  $this->tpl->setVariable("TXT_EXT_ACCOUNT",$this->lng->txt("user_ext_account"));
2018  $this->tpl->setVariable("TXT_EXT_ACCOUNT_DESC",$this->lng->txt("user_ext_account_desc"));
2019  if (isset($_SESSION["error_post_vars"]["Fobject"]["ext_account"]))
2020  {
2021  $this->tpl->setVariable("EXT_ACCOUNT_VAL",
2022  $_SESSION["error_post_vars"]["Fobject"]["ext_account"]);
2023  }
2024  else
2025  {
2026  $this->tpl->setVariable("EXT_ACCOUNT_VAL",
2027  $data["fields"]["ext_account"]);
2028  }
2029  /* Disabled: external account names should be changeable by admins
2030  if ($this->object->getAuthMode(true) != AUTH_LOCAL &&
2031  $this->object->getAuthMode(true) != AUTH_CAS &&
2032  $this->object->getAuthMode(true) != AUTH_SHIBBOLETH &&
2033  $this->object->getAuthMode(true) != AUTH_SOAP)
2034  {
2035  $this->tpl->setVariable("OPTION_DISABLED_EXT", "\"disabled=disabled\"");
2036  }
2037  */
2038  $this->tpl->parseCurrentBlock();
2039  }
2040  $auth_mode = $_SESSION['error_post_vars']['Fobject']['auth_mode'] ?
2041  ilAuthUtils::_getAuthMode($_SESSION['error_post_vars']['Fobject']['auth_mode']) :
2042  $this->object->getAuthMode(true);
2044  {
2045  $this->tpl->setVariable("OPTION_DISABLED", "\"disabled=disabled\"");
2046  }
2047  $obj_str = ($this->call_by_reference) ? "" : "&obj_id=".$this->obj_id;
2048 
2049  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
2050  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($this->object->getType()."_edit"));
2051  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2052  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
2053  $this->tpl->setVariable("CMD_SUBMIT", "update");
2054  $this->tpl->setVariable("TARGET", $this->getTargetFrame("update"));
2055  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
2056 
2057  $this->tpl->setVariable("TXT_LOGIN_DATA", $this->lng->txt("login_data"));
2058  $this->tpl->setVariable("TXT_SYSTEM_INFO", $this->lng->txt("system_information"));
2059  $this->tpl->setVariable("TXT_PERSONAL_DATA", $this->lng->txt("personal_data"));
2060  $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
2061  $this->tpl->setVariable("TXT_SETTINGS", $this->lng->txt("settings"));
2062  $this->tpl->setVariable("TXT_LANGUAGE",$this->lng->txt("language"));
2063  $this->tpl->setVariable("TXT_SKIN_STYLE",$this->lng->txt("usr_skin_style"));
2064  $this->tpl->setVariable("TXT_HITS_PER_PAGE",$this->lng->txt("hits_per_page"));
2065  $this->tpl->setVariable("TXT_SHOW_USERS_ONLINE",$this->lng->txt("show_users_online"));
2066  $this->tpl->setVariable("TXT_GENDER_F",$this->lng->txt("gender_f"));
2067  $this->tpl->setVariable("TXT_GENDER_M",$this->lng->txt("gender_m"));
2068  $this->tpl->setVariable("TXT_INSTANT_MESSENGERS",$this->lng->txt("user_profile_instant_messengers"));
2069  $this->tpl->setVariable("TXT_OTHER",$this->lng->txt("user_profile_other"));
2070  if ($this->object->getId() == $ilUser->getId())
2071  {
2072  $this->tpl->setVariable("TXT_CURRENT_IP","(".$this->lng->txt("current_ip")." ".$_SERVER["REMOTE_ADDR"].")");
2073  }
2074  $this->tpl->setVariable("TXT_CURRENT_IP_ALERT",$this->lng->txt("current_ip_alert"));
2075 
2076  // auth mode selection
2077  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2078  $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
2079 //var_dump($active_auth_modes);
2080  // preselect previous chosen auth mode otherwise default auth mode
2081  $selected_auth_mode = (isset($_SESSION["error_post_vars"]["Fobject"]["auth_mode"])) ? $_SESSION["error_post_vars"]["Fobject"]["auth_mode"] : $this->object->getAuthMode();
2082 
2083  foreach ($active_auth_modes as $auth_name => $auth_key)
2084  {
2085  $this->tpl->setCurrentBlock("auth_mode_selection");
2086 
2087  if ($auth_name == 'default')
2088  {
2089  $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
2090  }
2091  else
2092  {
2093  $name = $this->lng->txt('auth_'.$auth_name);
2094  }
2095 
2096  $this->tpl->setVariable("AUTH_MODE_NAME", $name);
2097 
2098  $this->tpl->setVariable("AUTH_MODE", $auth_name);
2099 
2100  if ($selected_auth_mode == $auth_name)
2101  {
2102  $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
2103  }
2104 
2105  $this->tpl->parseCurrentBlock();
2106  } // END auth_mode selection
2107 
2108 
2109  // language selection
2110  $languages = $this->lng->getInstalledLanguages();
2111 
2112  // preselect previous chosen language otherwise default language
2113  $selected_lang = (isset($_SESSION["error_post_vars"]["Fobject"]["language"])) ? $_SESSION["error_post_vars"]["Fobject"]["language"] : $this->object->getLanguage();
2114 
2115  foreach ($languages as $lang_key)
2116  {
2117  $this->tpl->setCurrentBlock("language_selection");
2118  $this->tpl->setVariable("LANG", $this->lng->txt("lang_".$lang_key));
2119  $this->tpl->setVariable("LANGSHORT", $lang_key);
2120 
2121  if ($selected_lang == $lang_key)
2122  {
2123  $this->tpl->setVariable("SELECTED_LANG", "selected=\"selected\"");
2124  }
2125 
2126  $this->tpl->parseCurrentBlock();
2127  } // END language selection
2128 
2129  // BEGIN skin & style selection
2130  //$this->ilias->getSkins();
2131  $templates = $styleDefinition->getAllTemplates();
2132 
2133  // preselect previous chosen skin/style otherwise default skin/style
2134  if (isset($_SESSION["error_post_vars"]["Fobject"]["skin_style"]))
2135  {
2136  $sknst = explode(":", $_SESSION["error_post_vars"]["Fobject"]["skin_style"]);
2137 
2138  $selected_style = $sknst[1];
2139  $selected_skin = $sknst[0];
2140  }
2141  else
2142  {
2143  $selected_style = $this->object->prefs["style"];
2144  $selected_skin = $this->object->skin;
2145  }
2146 
2147  include("./Services/Style/classes/class.ilObjStyleSettings.php");
2148  if (count($templates) > 0 && is_array ($templates))
2149  {
2150  foreach ($templates as $template)
2151  {
2152  // get styles for skin
2153  //$this->ilias->getStyles($skin["name"]);
2154  $styleDef =& new ilStyleDefinition($template["id"]);
2155  $styleDef->startParsing();
2156  $styles = $styleDef->getStyles();
2157  foreach ($styles as $style)
2158  {
2159  if (!ilObjStyleSettings::_lookupActivatedStyle($template["id"],$style["id"]))
2160  {
2161  continue;
2162  }
2163 
2164  $this->tpl->setCurrentBlock("selectskin");
2165 
2166  if ($selected_skin == $template["id"] &&
2167  $selected_style == $style["id"])
2168  {
2169  $this->tpl->setVariable("SKINSELECTED", "selected=\"selected\"");
2170  }
2171 
2172  $this->tpl->setVariable("SKINVALUE", $template["id"].":".$style["id"]);
2173  $this->tpl->setVariable("SKINOPTION", $styleDef->getTemplateName()." / ".$style["name"]);
2174  $this->tpl->parseCurrentBlock();
2175  }
2176  } // END skin & style selection
2177  }
2178  // BEGIN hits per page
2179  $hits_options = array(2,10,15,20,30,40,50,100,9999);
2180  // preselect previous chosen option otherwise default option
2181  if (isset($_SESSION["error_post_vars"]["Fobject"]["hits_per_page"]))
2182  {
2183  $selected_option = $_SESSION["error_post_vars"]["Fobject"]["hits_per_page"];
2184  }
2185  else
2186  {
2187  $selected_option = $this->object->prefs["hits_per_page"];
2188  }
2189  foreach($hits_options as $hits_option)
2190  {
2191  $this->tpl->setCurrentBlock("selecthits");
2192 
2193  if ($selected_option == $hits_option)
2194  {
2195  $this->tpl->setVariable("HITSSELECTED", "selected=\"selected\"");
2196  }
2197 
2198  $this->tpl->setVariable("HITSVALUE", $hits_option);
2199 
2200  if ($hits_option == 9999)
2201  {
2202  $hits_option = $this->lng->txt("no_limit");
2203  }
2204 
2205  $this->tpl->setVariable("HITSOPTION", $hits_option);
2206  $this->tpl->parseCurrentBlock();
2207  }
2208  // END hits per page
2209 
2210  // BEGIN show users online
2211  $users_online_options = array("y","associated","n");
2212  // preselect previous chosen option otherwise default option
2213  if (isset($_SESSION["error_post_vars"]["Fobject"]["show_users_online"]))
2214  {
2215  $selected_option = $_SESSION["error_post_vars"]["Fobject"]["show_users_online"];
2216  }
2217  else
2218  {
2219  $selected_option = $this->object->prefs["show_users_online"];
2220  }
2221  foreach($users_online_options as $an_option)
2222  {
2223  $this->tpl->setCurrentBlock("show_users_online");
2224 
2225  if ($selected_option == $an_option)
2226  {
2227  $this->tpl->setVariable("USERS_ONLINE_SELECTED", "selected=\"selected\"");
2228  }
2229 
2230  $this->tpl->setVariable("USERS_ONLINE_VALUE", $an_option);
2231 
2232  $this->tpl->setVariable("USERS_ONLINE_OPTION", $this->lng->txt("users_online_show_".$an_option));
2233  $this->tpl->parseCurrentBlock();
2234  }
2235  // END show users online
2236 
2237  // BEGIN hide_own_online_status
2238  if (isset($_SESSION["error_post_vars"]["Fobject"]["hide_own_online_status"]))
2239  {
2240  $hide_own_online_status = $_SESSION["error_post_vars"]["Fobject"]["hide_own_online_status"];
2241  }
2242  else
2243  {
2244  $hide_own_online_status = ($this->object->prefs["hide_own_online_status"] != '') ? $this->object->prefs["hide_own_online_status"] : "n";
2245  }
2246  $this->tpl->setCurrentBlock("hide_own_online_status");
2247  $this->tpl->setVariable("TXT_HIDE_OWN_ONLINE_STATUS", $this->lng->txt("hide_own_online_status"));
2248  if ($hide_own_online_status == "y") {
2249  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "checked=\"checked\"");
2250  }
2251  else {
2252  $this->tpl->setVariable("CHK_HIDE_OWN_ONLINE_STATUS", "");
2253  }
2254  $this->tpl->parseCurrentBlock();
2255  //END hide_own_online_status
2256 
2257  // inform user about changes option
2258  $this->tpl->setCurrentBlock("inform_user");
2259 
2260  // BEGIN DiskQuota Remember the state of the "send info mail" checkbox
2261  $sendInfoMail = $ilUser->getPref('send_info_mails') == 'y';
2262  if ($sendInfoMail)
2263  // END DiskQuota Remember the state of the "send info mail" checkbox
2264  {
2265  $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
2266  }
2267 
2268  $this->tpl->setVariable("TXT_INFORM_USER_MAIL", $this->lng->txt("inform_user_mail"));
2269  $this->tpl->parseCurrentBlock();
2270 
2271  $this->lng->loadLanguageModule('crs');
2272 
2273  $time_limit_unlimited = $_SESSION["error_post_vars"]["time_limit"]["unlimited"] ?
2274  $_SESSION["error_post_vars"]["time_limit"]["unlimited"] :
2275  $this->object->getTimeLimitUnlimited();
2276  $time_limit_from = $_SESSION["error_post_vars"]["time_limit"]["from"] ?
2277  $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["from"]) :
2278  $this->object->getTimeLimitFrom();
2279 
2280  $time_limit_until = $_SESSION["error_post_vars"]["time_limit"]["until"] ?
2281  $this->__toUnix($_SESSION["error_post_vars"]["time_limit"]["until"]) :
2282  $this->object->getTimeLimitUntil();
2283 
2284  $this->tpl->setCurrentBlock("time_limit");
2285  $this->tpl->setVariable("TXT_TIME_LIMIT", $this->lng->txt("time_limit"));
2286  $this->tpl->setVariable("TXT_TIME_LIMIT_UNLIMITED", $this->lng->txt("crs_unlimited"));
2287  $this->tpl->setVariable("TXT_TIME_LIMIT_FROM", $this->lng->txt("crs_from"));
2288  $this->tpl->setVariable("TXT_TIME_LIMIT_UNTIL", $this->lng->txt("crs_to"));
2289 
2290  $this->tpl->setVariable("TIME_LIMIT_UNLIMITED",ilUtil::formCheckbox($time_limit_unlimited,"time_limit[unlimited]",1));
2291  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MINUTE",$this->__getDateSelect("minute","time_limit[from][minute]",
2292  date("i",$time_limit_from)));
2293  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_HOUR",$this->__getDateSelect("hour","time_limit[from][hour]",
2294  date("G",$time_limit_from)));
2295  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_DAY",$this->__getDateSelect("day","time_limit[from][day]",
2296  date("d",$time_limit_from)));
2297  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_MONTH",$this->__getDateSelect("month","time_limit[from][month]",
2298  date("m",$time_limit_from)));
2299  $this->tpl->setVariable("SELECT_TIME_LIMIT_FROM_YEAR",$this->__getDateSelect("year","time_limit[from][year]",
2300  date("Y",$time_limit_from)));
2301  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MINUTE",$this->__getDateSelect("minute","time_limit[until][minute]",
2302  date("i",$time_limit_until)));
2303  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_HOUR",$this->__getDateSelect("hour","time_limit[until][hour]",
2304  date("G",$time_limit_until)));
2305  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_DAY",$this->__getDateSelect("day","time_limit[until][day]",
2306  date("d",$time_limit_until)));
2307  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_MONTH",$this->__getDateSelect("month","time_limit[until][month]",
2308  date("m",$time_limit_until)));
2309  $this->tpl->setVariable("SELECT_TIME_LIMIT_UNTIL_YEAR",$this->__getDateSelect("year","time_limit[until][year]",
2310  date("Y",$time_limit_until)));
2311  $this->tpl->parseCurrentBlock();
2312 
2313  $this->__showUserDefinedFields();
2314  }
2315 
2316 // BEGIN DiskQuota: Allow administrators to edit user picture
2323  {
2324  global $ilUser, $rbacsystem;
2325 
2326  // User folder
2327  if($this->usrf_ref_id == USER_FOLDER_ID and
2328  !$rbacsystem->checkAccess('visible,read',$this->usrf_ref_id))
2329  {
2330  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2331  }
2332  // if called from local administration $this->usrf_ref_id is category id
2333  // Todo: this has to be fixed. Do not mix user folder id and category id
2334  if($this->usrf_ref_id != USER_FOLDER_ID)
2335  {
2336  // check if user is assigned to category
2337  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
2338  {
2339  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2340  }
2341  }
2342 
2343  $userfile_input = $this->form_gui->getItemByPostVar("userfile");
2344 
2345  if ($_FILES["userfile"]["tmp_name"] == "")
2346  {
2347  if ($userfile_input->getDeletionFlag())
2348  {
2349  $this->object->removeUserPicture();
2350  }
2351  return;
2352  }
2353  if ($_FILES["userfile"]["size"] == 0)
2354  {
2355  ilUtil::sendFailure($this->lng->txt("msg_no_file"));
2356  }
2357  else
2358  {
2359  $webspace_dir = ilUtil::getWebspaceDir();
2360  $image_dir = $webspace_dir."/usr_images";
2361  $store_file = "usr_".$this->object->getId()."."."jpg";
2362 
2363  // store filename
2364  $this->object->setPref("profile_image", $store_file);
2365  $this->object->update();
2366 
2367  // move uploaded file
2368  $uploaded_file = $image_dir."/upload_".$this->object->getId()."pic";
2369  if (!ilUtil::moveUploadedFile($_FILES["userfile"]["tmp_name"], $_FILES["userfile"]["name"],
2370  $uploaded_file, false))
2371  {
2372  ilUtil::sendFailure($this->lng->txt("upload_error", true));
2373  $this->ctrl->redirect($this, "showProfile");
2374  }
2375  chmod($uploaded_file, 0770);
2376 
2377  // take quality 100 to avoid jpeg artefacts when uploading jpeg files
2378  // taking only frame [0] to avoid problems with animated gifs
2379  $show_file = "$image_dir/usr_".$this->object->getId().".jpg";
2380  $thumb_file = "$image_dir/usr_".$this->object->getId()."_small.jpg";
2381  $xthumb_file = "$image_dir/usr_".$this->object->getId()."_xsmall.jpg";
2382  $xxthumb_file = "$image_dir/usr_".$this->object->getId()."_xxsmall.jpg";
2383  $uploaded_file = ilUtil::escapeShellArg($uploaded_file);
2384  $show_file = ilUtil::escapeShellArg($show_file);
2385  $thumb_file = ilUtil::escapeShellArg($thumb_file);
2386  $xthumb_file = ilUtil::escapeShellArg($xthumb_file);
2387  $xxthumb_file = ilUtil::escapeShellArg($xxthumb_file);
2388  ilUtil::execConvert($uploaded_file . "[0] -geometry 200x200 -quality 100 JPEG:".$show_file);
2389  ilUtil::execConvert($uploaded_file . "[0] -geometry 100x100 -quality 100 JPEG:".$thumb_file);
2390  ilUtil::execConvert($uploaded_file . "[0] -geometry 75x75 -quality 100 JPEG:".$xthumb_file);
2391  ilUtil::execConvert($uploaded_file . "[0] -geometry 30x30 -quality 100 JPEG:".$xxthumb_file);
2392  }
2393  }
2394 
2399  {
2400  $webspace_dir = ilUtil::getWebspaceDir();
2401  $image_dir = $webspace_dir."/usr_images";
2402  $file = $image_dir."/usr_".$this->object->getID()."."."jpg";
2403  $thumb_file = $image_dir."/usr_".$this->object->getID()."_small.jpg";
2404  $xthumb_file = $image_dir."/usr_".$this->object->getID()."_xsmall.jpg";
2405  $xxthumb_file = $image_dir."/usr_".$this->object->getID()."_xxsmall.jpg";
2406  $upload_file = $image_dir."/upload_".$this->object->getID();
2407 
2408  // remove user pref file name
2409  $this->object->setPref("profile_image", "");
2410  $this->object->update();
2411  ilUtil::sendSuccess($this->lng->txt("user_image_removed"));
2412 
2413  if (@is_file($file))
2414  {
2415  unlink($file);
2416  }
2417  if (@is_file($thumb_file))
2418  {
2419  unlink($thumb_file);
2420  }
2421  if (@is_file($xthumb_file))
2422  {
2423  unlink($xthumb_file);
2424  }
2425  if (@is_file($xxthumb_file))
2426  {
2427  unlink($xxthumb_file);
2428  }
2429  if (@is_file($upload_file))
2430  {
2431  unlink($upload_file);
2432  }
2433 
2434  $this->editObject();
2435  }
2436 // END DiskQuota: Allow administrators to edit user picture
2437 
2442 /*
2443  function saveObjectOld()
2444  {
2445  global $ilias, $rbacsystem, $rbacadmin, $ilSetting;
2446 
2447  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2448 
2449  //load ILIAS settings
2450  $settings = $ilias->getAllSettings();
2451 
2452  // User folder
2453  if (!$rbacsystem->checkAccess('create_user', $this->usrf_ref_id) and
2454  !$rbacsystem->checkAccess('cat_administrate_users',$this->usrf_ref_id))
2455  {
2456  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
2457  }
2458 
2459  // check dynamically required fields
2460  foreach ($settings as $key => $val)
2461  {
2462  if (substr($key,0,8) == "require_")
2463  {
2464  $field = substr($key,8);
2465 
2466  switch($field)
2467  {
2468  case 'passwd':
2469  case 'passwd2':
2470  if(ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2471  {
2472  $require_keys[] = $field;
2473  }
2474  break;
2475  default:
2476  $require_keys[] = $field;
2477  break;
2478  }
2479  }
2480  }
2481 
2482  foreach ($require_keys as $key => $val)
2483  {
2484  if (isset($settings["require_" . $val]) && $settings["require_" . $val])
2485  {
2486  if (empty($_POST["Fobject"][$val]))
2487  {
2488  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2489  $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
2490  }
2491  }
2492  }
2493 
2494  if(!$this->__checkUserDefinedRequiredFields())
2495  {
2496  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
2497  }
2498 
2499  // validate login
2500  if (!ilUtil::isLogin($_POST["Fobject"]["login"]))
2501  {
2502  $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
2503  }
2504 
2505  // check loginname
2506  if (ilObjUser::_loginExists($_POST["Fobject"]["login"]))
2507  {
2508  $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
2509  }
2510 
2511  // Do password checks only if auth mode allows password modifications
2512  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2513  if(ilAuthUtils::_allowPasswordModificationByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2514  {
2515  // check passwords
2516  if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
2517  {
2518  $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
2519  }
2520 
2521  // validate password
2522  if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
2523  {
2524  $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
2525  }
2526  }
2527  if(ilAuthUtils::_needsExternalAccountByAuthMode(ilAuthUtils::_getAuthMode($_POST['Fobject']['auth_mode'])))
2528  {
2529  if(!strlen($_POST['Fobject']['ext_account']))
2530  {
2531  $this->ilias->raiseError($this->lng->txt('ext_acccount_required'),$this->ilias->error_obj->MESSAGE);
2532  }
2533  }
2534 
2535  if($_POST['Fobject']['ext_account'] &&
2536  ($elogin = ilObjUser::_checkExternalAuthAccount($_POST['Fobject']['auth_mode'],$_POST['Fobject']['ext_account'])))
2537  {
2538  if($elogin != '')
2539  {
2540  $this->ilias->raiseError(
2541  sprintf($this->lng->txt("err_auth_ext_user_exists"),
2542  $_POST["Fobject"]["ext_account"],
2543  $_POST['Fobject']['auth_mode'],
2544  $elogin),
2545  $this->ilias->error_obj->MESSAGE);
2546  }
2547  }
2548 
2549 
2550  // The password type is not passed in the post data. Therefore we
2551  // append it here manually.
2552  include_once ('./Services/User/classes/class.ilObjUser.php');
2553  $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
2554 
2555  // validate email
2556  if (strlen($_POST['Fobject']['email']) and !ilUtil::is_email($_POST["Fobject"]["email"]))
2557  {
2558  $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
2559  }
2560 
2561  // validate time limit
2562  if ($_POST["time_limit"]["unlimited"] != 1 and
2563  ($this->__toUnix($_POST["time_limit"]["until"]) < $this->__toUnix($_POST["time_limit"]["from"])))
2564  {
2565  $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
2566  }
2567  if(!$this->ilias->account->getTimeLimitUnlimited())
2568  {
2569  if($this->__toUnix($_POST["time_limit"]["from"]) < $this->ilias->account->getTimeLimitFrom() or
2570  $this->__toUnix($_POST["time_limit"]["until"])> $this->ilias->account->getTimeLimitUntil() or
2571  $_POST['time_limit']['unlimited'])
2572  {
2573  $this->ilias->raiseError($this->lng->txt("time_limit_not_within_owners"),$this->ilias->error_obj->MESSAGE);
2574  }
2575  }
2576 
2577  // TODO: check if login or passwd already exists
2578  // TODO: check length of login and passwd
2579 
2580  // checks passed. save user
2581  $userObj = new ilObjUser();
2582  $userObj->assignData($_POST["Fobject"]);
2583  $userObj->setTitle($userObj->getFullname());
2584  $userObj->setDescription($userObj->getEmail());
2585 
2586  $userObj->setTimeLimitOwner($this->object->getRefId());
2587  $userObj->setTimeLimitUnlimited($_POST["time_limit"]["unlimited"]);
2588  $userObj->setTimeLimitFrom($this->__toUnix($_POST["time_limit"]["from"]));
2589  $userObj->setTimeLimitUntil($this->__toUnix($_POST["time_limit"]["until"]));
2590 
2591  $userObj->setUserDefinedData($_POST['udf']);
2592 
2593  $userObj->create();
2594 
2595  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2596  if(ilAuthUtils::_isExternalAccountEnabled())
2597  {
2598  $userObj->setExternalAccount($_POST["Fobject"]["ext_account"]);
2599  }
2600 
2601  //$user->setId($userObj->getId());
2602 
2603  //insert user data in table user_data
2604  $userObj->saveAsNew();
2605 
2606  // setup user preferences
2607  $userObj->setLanguage($_POST["Fobject"]["language"]);
2608 
2609  //set user skin and style
2610  $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
2611 
2612  if ($userObj->getPref("style") != $sknst[1] ||
2613  $userObj->getPref("skin") != $sknst[0])
2614  {
2615  $userObj->setPref("skin", $sknst[0]);
2616  $userObj->setPref("style", $sknst[1]);
2617  }
2618 
2619  // set hits per pages
2620  $userObj->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
2621  // set show users online
2622  $userObj->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
2623  // set hide_own_online_status
2624  $userObj->setPref("hide_own_online_status", $_POST["Fobject"]["hide_own_online_status"]);
2625 
2626  $userObj->writePrefs();
2627 
2628  //set role entries
2629  $rbacadmin->assignUser($_POST["Fobject"]["default_role"],$userObj->getId(),true);
2630 
2631  $msg = $this->lng->txt("user_added");
2632 
2633  // BEGIN DiskQuota: Remember the state of the "send info mail" checkbox
2634  global $ilUser;
2635  $ilUser->setPref('send_info_mails', ($_POST["send_mail"] != "") ? 'y' : 'n');
2636  $ilUser->writePrefs();
2637  // END DiskQuota: Remember the state of the "send info mail" checkbox
2638 
2639  // send new account mail
2640  if ($_POST["send_mail"] != "")
2641  {
2642  include_once("Services/Mail/classes/class.ilAccountMail.php");
2643  $acc_mail = new ilAccountMail();
2644  $acc_mail->setUserPassword($_POST["Fobject"]["passwd"]);
2645  $acc_mail->setUser($userObj);
2646 
2647  if ($acc_mail->send())
2648  {
2649  $msg = $msg."<br />".$this->lng->txt("mail_sent");
2650  }
2651  else
2652  {
2653  $msg = $msg."<br />".$this->lng->txt("mail_not_sent");
2654  }
2655  }
2656 
2657  ilUtil::sendInfo($msg, true);
2658 
2659  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
2660  {
2661  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
2662  }
2663  else
2664  {
2665  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2666  }
2667  }
2668 */
2673  function updateObjectOld()
2674  {
2675  global $ilias, $rbacsystem, $rbacadmin,$ilUser;
2676 
2677  include_once('./Services/Authentication/classes/class.ilAuthUtils.php');
2678 
2679  //load ILIAS settings
2680  $settings = $ilias->getAllSettings();
2681 
2682  // User folder
2683  if($this->usrf_ref_id == USER_FOLDER_ID and !$rbacsystem->checkAccess('visible,read,write',$this->usrf_ref_id))
2684  {
2685  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2686  }
2687  // if called from local administration $this->usrf_ref_id is category id
2688  // Todo: this has to be fixed. Do not mix user folder id and category id
2689  if($this->usrf_ref_id != USER_FOLDER_ID)
2690  {
2691  // check if user is assigned to category
2692  if(!$rbacsystem->checkAccess('cat_administrate_users',$this->object->getTimeLimitOwner()))
2693  {
2694  $this->ilias->raiseError($this->lng->txt("msg_no_perm_modify_user"),$this->ilias->error_obj->MESSAGE);
2695  }
2696  }
2697 
2698  foreach ($_POST["Fobject"] as $key => $val)
2699  {
2700  $_POST["Fobject"][$key] = ilUtil::stripSlashes($val);
2701  }
2702 
2703  // check dynamically required fields
2704  foreach ($settings as $key => $val)
2705  {
2706  $field = substr($key,8);
2707  switch($field)
2708  {
2709  case 'passwd':
2710  case 'passwd2':
2712  {
2713  $require_keys[] = $field;
2714  }
2715  break;
2716  default:
2717  $require_keys[] = $field;
2718  break;
2719 
2720  }
2721  }
2722 
2723  foreach ($require_keys as $key => $val)
2724  {
2725  // exclude required system and registration-only fields
2726  $system_fields = array("default_role");
2727  if (!in_array($val, $system_fields))
2728  {
2729  if (isset($settings["require_" . $val]) && $settings["require_" . $val])
2730  {
2731  if (empty($_POST["Fobject"][$val]))
2732  {
2733  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2734  $this->lng->txt($val),$this->ilias->error_obj->MESSAGE);
2735  }
2736  }
2737  }
2738  }
2739 
2740  if(!$this->__checkUserDefinedRequiredFields())
2741  {
2742  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
2743  }
2744  // validate login
2745  if ($this->object->getLogin() != $_POST["Fobject"]["login"] &&
2746  !ilUtil::isLogin($_POST["Fobject"]["login"]))
2747  {
2748  $this->ilias->raiseError($this->lng->txt("login_invalid"),$this->ilias->error_obj->MESSAGE);
2749  }
2750 
2751  // check loginname
2752  if (ilObjUser::_loginExists($_POST["Fobject"]["login"],$this->id))
2753  {
2754  $this->ilias->raiseError($this->lng->txt("login_exists"),$this->ilias->error_obj->MESSAGE);
2755  }
2756 
2758  {
2759  if($_POST['Fobject']['passwd'] == "********" and
2760  !strlen($this->object->getPasswd()))
2761  {
2762  $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields") . ": " .
2763  $this->lng->txt('password'),$this->ilias->error_obj->MESSAGE);
2764  }
2765  // check passwords
2766  if ($_POST["Fobject"]["passwd"] != $_POST["Fobject"]["passwd2"])
2767  {
2768  $this->ilias->raiseError($this->lng->txt("passwd_not_match"),$this->ilias->error_obj->MESSAGE);
2769  }
2770 
2771  // validate password
2772  if (!ilUtil::isPassword($_POST["Fobject"]["passwd"]))
2773  {
2774  $this->ilias->raiseError($this->lng->txt("passwd_invalid"),$this->ilias->error_obj->MESSAGE);
2775  }
2776  }
2777  else
2778  {
2779  // Password will not be changed...
2780  $_POST['Fobject']['passwd'] = "********";
2781  }
2783  {
2784  if(!strlen($_POST['Fobject']['ext_account']))
2785  {
2786  $this->ilias->raiseError($this->lng->txt('ext_acccount_required'),$this->ilias->error_obj->MESSAGE);
2787  }
2788  }
2789  if($_POST['Fobject']['ext_account'] &&
2790  ($elogin = ilObjUser::_checkExternalAuthAccount($_POST['Fobject']['auth_mode'],$_POST['Fobject']['ext_account'])))
2791  {
2792  if($elogin != $this->object->getLogin())
2793  {
2794  $this->ilias->raiseError(
2795  sprintf($this->lng->txt("err_auth_ext_user_exists"),
2796  $_POST["Fobject"]["ext_account"],
2797  $_POST['Fobject']['auth_mode'],
2798  $elogin),
2799  $this->ilias->error_obj->MESSAGE);
2800  }
2801  }
2802 
2803  // The password type is not passed with the post data. Therefore we
2804  // append it here manually.
2805  include_once ('./Services/User/classes/class.ilObjUser.php');
2806  $_POST["Fobject"]["passwd_type"] = IL_PASSWD_PLAIN;
2807 
2808  // validate email
2809  if (strlen($_POST['Fobject']['email']) and !ilUtil::is_email($_POST["Fobject"]["email"]))
2810  {
2811  $this->ilias->raiseError($this->lng->txt("email_not_valid"),$this->ilias->error_obj->MESSAGE);
2812  }
2813 
2814  $start = $this->__toUnix($_POST["time_limit"]["from"]);
2815  $end = $this->__toUnix($_POST["time_limit"]["until"]);
2816 
2817  // validate time limit
2818  if (!$_POST["time_limit"]["unlimited"] and
2819  ( $start > $end))
2820  {
2821  $this->ilias->raiseError($this->lng->txt("time_limit_not_valid"),$this->ilias->error_obj->MESSAGE);
2822  }
2823 
2824  if(!$this->ilias->account->getTimeLimitUnlimited())
2825  {
2826  if($start < $this->ilias->account->getTimeLimitFrom() or
2827  $end > $this->ilias->account->getTimeLimitUntil() or
2828  $_POST['time_limit']['unlimited'])
2829  {
2830  $_SESSION['error_post_vars'] = $_POST;
2831 
2832  ilUtil::sendFailure($this->lng->txt('time_limit_not_within_owners'));
2833  $this->editObject();
2834 
2835  return false;
2836  }
2837  }
2838 
2839  // TODO: check length of login and passwd
2840 
2841  // checks passed. save user
2842  $_POST['Fobject']['time_limit_owner'] = $this->object->getTimeLimitOwner();
2843 
2844  $_POST['Fobject']['time_limit_unlimited'] = (int) $_POST['time_limit']['unlimited'];
2845  $_POST['Fobject']['time_limit_from'] = $this->__toUnix($_POST['time_limit']['from']);
2846  $_POST['Fobject']['time_limit_until'] = $this->__toUnix($_POST['time_limit']['until']);
2847 
2848  if($_POST['Fobject']['time_limit_unlimited'] != $this->object->getTimeLimitUnlimited() or
2849  $_POST['Fobject']['time_limit_from'] != $this->object->getTimeLimitFrom() or
2850  $_POST['Fobject']['time_limit_until'] != $this->object->getTimeLimitUntil())
2851  {
2852  $_POST['Fobject']['time_limit_message'] = 0;
2853  }
2854  else
2855  {
2856  $_POST['Fobject']['time_limit_message'] = $this->object->getTimeLimitMessage();
2857  }
2858 
2859  $this->object->assignData($_POST["Fobject"]);
2860  $this->object->setUserDefinedData($_POST['udf']);
2861 
2862  try
2863  {
2864  $this->object->updateLogin($_POST['Fobject']['login']);
2865  }
2866  catch (ilUserException $e)
2867  {
2868  ilUtil::sendFailure($e->getMessage());
2869  $this->form_gui->setValuesByPost();
2870  return $tpl->setContent($this->form_gui->getHtml());
2871  }
2872 
2873  $this->object->setTitle($this->object->getFullname());
2874  $this->object->setDescription($this->object->getEmail());
2875  $this->object->setLanguage($_POST["Fobject"]["language"]);
2876 
2877  //set user skin and style
2878  $sknst = explode(":", $_POST["Fobject"]["skin_style"]);
2879 
2880  if ($this->object->getPref("style") != $sknst[1] ||
2881  $this->object->getPref("skin") != $sknst[0])
2882  {
2883  $this->object->setPref("skin", $sknst[0]);
2884  $this->object->setPref("style", $sknst[1]);
2885  }
2886 
2887  // set hits per pages
2888  $this->object->setPref("hits_per_page", $_POST["Fobject"]["hits_per_page"]);
2889  // set show users online
2890  $this->object->setPref("show_users_online", $_POST["Fobject"]["show_users_online"]);
2891  // set hide_own_online_status
2892  if ($_POST["Fobject"]["hide_own_online_status"]) {
2893  $this->object->setPref("hide_own_online_status", $_POST["Fobject"]["hide_own_online_status"]);
2894  }
2895  else {
2896  $this->object->setPref("hide_own_online_status", "n");
2897  }
2898 
2899  $this->update = $this->object->update();
2900  //$rbacadmin->updateDefaultRole($_POST["Fobject"]["default_role"], $this->object->getId());
2901 
2902  // BEGIN DiskQuota: Remember the state of the "send info mail" checkbox
2903  global $ilUser;
2904  $ilUser->setPref('send_info_mails', ($_POST['send_mail'] == 'y') ? 'y' : 'n');
2905  $ilUser->writePrefs();
2906  // END DiskQuota: Remember the state of the "send info mail" checkbox
2907 
2908  $mail_message = $this->__sendProfileMail();
2909  $msg = $this->lng->txt('saved_successfully').$mail_message;
2910 
2911  // feedback
2912  ilUtil::sendSuccess($msg,true);
2913 
2914  if (strtolower($_GET["baseClass"]) == 'iladministrationgui')
2915  {
2916  $this->ctrl->redirectByClass("ilobjuserfoldergui", "view");
2917  }
2918  else
2919  {
2920  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2921  }
2922  }
2923 
2924 
2925 
2931  function assignSaveObject()
2932  {
2933  global $rbacsystem, $rbacadmin, $rbacreview;
2934 
2935  if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
2936  {
2937  $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
2938  }
2939 
2940  $selected_roles = $_POST["role_id"] ? $_POST["role_id"] : array();
2941  $posted_roles = $_POST["role_id_ctrl"] ? $_POST["role_id_ctrl"] : array();
2942 
2943  // prevent unassignment of system role from system user
2944  if ($this->object->getId() == SYSTEM_USER_ID and in_array(SYSTEM_ROLE_ID, $posted_roles))
2945  {
2946  array_push($selected_roles,SYSTEM_ROLE_ID);
2947  }
2948 
2949  $global_roles_all = $rbacreview->getGlobalRoles();
2950  $assigned_roles_all = $rbacreview->assignedRoles($this->object->getId());
2951  $assigned_roles = array_intersect($assigned_roles_all,$posted_roles);
2952  $assigned_global_roles_all = array_intersect($assigned_roles_all,$global_roles_all);
2953  $assigned_global_roles = array_intersect($assigned_global_roles_all,$posted_roles);
2954  $posted_global_roles = array_intersect($selected_roles,$global_roles_all);
2955 
2956  if ((empty($selected_roles) and count($assigned_roles_all) == count($assigned_roles))
2957  or (empty($posted_global_roles) and count($assigned_global_roles_all) == count($assigned_global_roles)))
2958  {
2959  //$this->ilias->raiseError($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),$this->ilias->error_obj->MESSAGE);
2960  // workaround. sometimes jumps back to wrong page
2961  ilUtil::sendFailure($this->lng->txt("msg_min_one_role")."<br/>".$this->lng->txt("action_aborted"),true);
2962  $this->ctrl->redirect($this,'roleassignment');
2963  }
2964 
2965  foreach (array_diff($assigned_roles,$selected_roles) as $role)
2966  {
2967  $rbacadmin->deassignUser($role,$this->object->getId());
2968  }
2969 
2970  foreach (array_diff($selected_roles,$assigned_roles) as $role)
2971  {
2972  $rbacadmin->assignUser($role,$this->object->getId(),false);
2973  }
2974 
2975  include_once "./Services/AccessControl/classes/class.ilObjRole.php";
2976 
2977  // update object data entry (to update last modification date)
2978  $this->object->update();
2979 
2980  ilUtil::sendSuccess($this->lng->txt("msg_roleassignment_changed"),true);
2981 
2982  if(strtolower($_GET["baseClass"]) == 'iladministrationgui')
2983  {
2984  $this->ctrl->redirect($this,'roleassignment');
2985  }
2986  else
2987  {
2988  $this->ctrl->redirectByClass('ilobjcategorygui','listUsers');
2989  }
2990 
2991  }
2992 
2999  {
3000  global $rbacreview,$rbacsystem,$ilUser, $ilTabs;
3001 
3002  $ilTabs->activateTab("role_assignment");
3003 
3004  if (!$rbacsystem->checkAccess("edit_roleassignment", $this->usrf_ref_id))
3005  {
3006  $this->ilias->raiseError($this->lng->txt("msg_no_perm_assign_role_to_user"),$this->ilias->error_obj->MESSAGE);
3007  }
3008 
3009  $_SESSION['filtered_roles'] = isset($_POST['filter']) ? $_POST['filter'] : $_SESSION['filtered_roles'];
3010 
3011  if ($_SESSION['filtered_roles'] > 5)
3012  {
3013  $_SESSION['filtered_roles'] = 0;
3014  }
3015 
3016  $this->tpl->addBlockfile('ADM_CONTENT','adm_content','tpl.usr_role_assignment.html');
3017 
3018  if(false)
3019  {
3020  $this->tpl->setCurrentBlock("filter");
3021  $this->tpl->setVariable("FILTER_TXT_FILTER",$this->lng->txt('filter'));
3022  $this->tpl->setVariable("SELECT_FILTER",$this->__buildFilterSelect());
3023  $this->tpl->setVariable("FILTER_ACTION",$this->ctrl->getFormAction($this));
3024  $this->tpl->setVariable("FILTER_NAME",'roleassignment');
3025  $this->tpl->setVariable("FILTER_VALUE",$this->lng->txt('apply_filter'));
3026  $this->tpl->parseCurrentBlock();
3027  }
3028 
3029  // init table
3030  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
3031  $tab = new ilRoleAssignmentTableGUI($this, "roleassignment");
3032 
3033  // now get roles depending on filter settings
3034  $role_list = $rbacreview->getRolesByFilter($tab->filter["role_filter"],$this->object->getId());
3035  $assigned_roles = $rbacreview->assignedRoles($this->object->getId());
3036 
3037  $counter = 0;
3038 
3039  include_once ('./Services/AccessControl/classes/class.ilObjRole.php');
3040 
3041  $records = array();
3042  foreach ($role_list as $role)
3043  {
3044  // fetch context path of role
3045  $rolf = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
3046 
3047  // only list roles that are not set to status "deleted"
3048  if ($rbacreview->isDeleted($rolf[0]))
3049  {
3050  continue;
3051  }
3052 
3053  // build context path
3054  $path = "";
3055 
3056  if ($this->tree->isInTree($rolf[0]))
3057  {
3058  if ($rolf[0] == ROLE_FOLDER_ID)
3059  {
3060  $path = $this->lng->txt("global");
3061  }
3062  else
3063  {
3064  $tmpPath = $this->tree->getPathFull($rolf[0]);
3065 
3066  // count -1, to exclude the role folder itself
3067  /*for ($i = 1; $i < (count($tmpPath)-1); $i++)
3068  {
3069  if ($path != "")
3070  {
3071  $path .= " > ";
3072  }
3073 
3074  $path .= $tmpPath[$i]["title"];
3075  }*/
3076 
3077  $path = $tmpPath[count($tmpPath)-2]["title"];
3078  }
3079  }
3080  else
3081  {
3082  $path = "<b>Rolefolder ".$rolf[0]." not found in tree! (Role ".$role["obj_id"].")</b>";
3083  }
3084 
3085  $disabled = false;
3086 
3087  // disable checkbox for system role for the system user
3088  if (($this->object->getId() == SYSTEM_USER_ID and $role["obj_id"] == SYSTEM_ROLE_ID)
3089  or (!in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())) and $role["obj_id"] == SYSTEM_ROLE_ID))
3090  {
3091  $disabled = true;
3092  }
3093 
3094  if (substr($role["title"],0,3) == "il_")
3095  {
3096  if (!$assignable)
3097  {
3098  $rolf_arr = $rbacreview->getFoldersAssignedToRole($role["obj_id"],true);
3099  $rolf2 = $rolf_arr[0];
3100  }
3101  else
3102  {
3103  $rolf2 = $rolf;
3104  }
3105 
3106  $parent_node = $this->tree->getParentNodeData($rolf2);
3107 
3108  $role["description"] = $this->lng->txt("obj_".$parent_node["type"])."&nbsp;(#".$parent_node["obj_id"].")";
3109  }
3110 
3111  $role_ids[$counter] = $role["obj_id"];
3112 
3113  $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"]."\"/>";
3114  $this->ctrl->setParameterByClass("ilobjrolegui", "ref_id", $rolf[0]);
3115  $this->ctrl->setParameterByClass("ilobjrolegui", "obj_id", $role["obj_id"]);
3116  $result_set[$counter][] = $link = "<a href=\"".$this->ctrl->getLinkTargetByClass("ilobjrolegui", "perm")."\">".ilObjRole::_getTranslation($role["title"])."</a>";
3117  $title = ilObjRole::_getTranslation($role["title"]);
3118  $result_set[$counter][] = $role["description"];
3119 
3120  // Add link to objector local Rores
3121  if ($role["role_type"] == "local") {
3122  // Get Object to the role
3123  $obj_id = ilRbacReview::getObjectOfRole($role["rol_id"]);
3124 
3125  $obj_type = ilObject::_lookupType($obj_id);
3126 
3128 
3129  foreach ($ref_ids as $ref_id) {}
3130 
3131  require_once("./classes/class.ilLink.php");
3132 
3133  $result_set[$counter][] = $context = "<a href='".ilLink::_getLink($ref_id, ilObject::_lookupType($obj_id))."' target='_top'>".$path."</a>";
3134  }
3135  else
3136  {
3137  $result_set[$counter][] = $path;
3138  $context = $path;
3139  }
3140 
3141  $records[] = array("path" => $path, "description" => $role["description"],
3142  "context" => $context, "checkbox" => $checkbox,
3143  "role" => $link, "title" => $title);
3144  ++$counter;
3145  }
3146 
3147  if (true)
3148  {
3149  $tab->setData($records);
3150  $this->tpl->setVariable("ROLES_TABLE",$tab->getHTML());
3151  return;
3152  }
3153 
3154  return $this->__showRolesTable($result_set,$role_ids);
3155  }
3156 
3161  {
3162  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
3163  $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
3164  $table_gui->writeFilterToSession(); // writes filter to session
3165  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3166  $this->roleassignmentObject();
3167  }
3168 
3173  {
3174  include_once("./Services/User/classes/class.ilRoleAssignmentTableGUI.php");
3175  $table_gui = new ilRoleAssignmentTableGUI($this, "roleassignment");
3176  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3177  $table_gui->resetFilter(); // clears filter
3178  $this->roleassignmentObject();
3179  }
3180 
3181  function __getDateSelect($a_type,$a_varname,$a_selected)
3182  {
3183  switch($a_type)
3184  {
3185  case "minute":
3186  for($i=0;$i<=60;$i++)
3187  {
3188  $days[$i] = $i < 10 ? "0".$i : $i;
3189  }
3190  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
3191 
3192  case "hour":
3193  for($i=0;$i<24;$i++)
3194  {
3195  $days[$i] = $i < 10 ? "0".$i : $i;
3196  }
3197  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
3198 
3199  case "day":
3200  for($i=1;$i<32;$i++)
3201  {
3202  $days[$i] = $i < 10 ? "0".$i : $i;
3203  }
3204  return ilUtil::formSelect($a_selected,$a_varname,$days,false,true);
3205 
3206  case "month":
3207  for($i=1;$i<13;$i++)
3208  {
3209  $month[$i] = $i < 10 ? "0".$i : $i;
3210  }
3211  return ilUtil::formSelect($a_selected,$a_varname,$month,false,true);
3212 
3213  case "year":
3214  if($a_selected < date('Y',time()))
3215  {
3216  $start = $a_selected;
3217  }
3218  else
3219  {
3220  $start = date('Y',time());
3221  }
3222 
3223  for($i = $start;$i < date("Y",time()) + 11;++$i)
3224  {
3225  $year[$i] = $i;
3226  }
3227  return ilUtil::formSelect($a_selected,$a_varname,$year,false,true);
3228  }
3229  }
3230 
3231  function __toUnix($a_time_arr)
3232  {
3233  return mktime($a_time_arr["hour"],
3234  $a_time_arr["minute"],
3235  $a_time_arr["second"],
3236  $a_time_arr["month"],
3237  $a_time_arr["day"],
3238  $a_time_arr["year"]);
3239  }
3240 
3241  function __showRolesTable($a_result_set,$a_role_ids = NULL)
3242  {
3243  global $rbacsystem;
3244 
3245  $actions = array("assignSave" => $this->lng->txt("change_assignment"));
3246 
3247  $tbl =& $this->__initTableGUI();
3248  $tpl =& $tbl->getTemplateObject();
3249 
3250  $tpl->setCurrentBlock("tbl_form_header");
3251  $tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
3252  $tpl->parseCurrentBlock();
3253 
3254  $tpl->setCurrentBlock("tbl_action_row");
3255 
3256  $tpl->setVariable("COLUMN_COUNTS",4);
3257  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
3258 
3259  foreach ($actions as $name => $value)
3260  {
3261  $tpl->setCurrentBlock("tbl_action_btn");
3262  $tpl->setVariable("BTN_NAME",$name);
3263  $tpl->setVariable("BTN_VALUE",$value);
3264  $tpl->parseCurrentBlock();
3265  }
3266 
3267  if (!empty($a_role_ids))
3268  {
3269  // set checkbox toggles
3270  $tpl->setCurrentBlock("tbl_action_toggle_checkboxes");
3271  $tpl->setVariable("JS_VARNAME","role_id");
3272  $tpl->setVariable("JS_ONCLICK",ilUtil::array_php2js($a_role_ids));
3273  $tpl->setVariable("TXT_CHECKALL", $this->lng->txt("check_all"));
3274  $tpl->setVariable("TXT_UNCHECKALL", $this->lng->txt("uncheck_all"));
3275  $tpl->parseCurrentBlock();
3276  }
3277 
3278  $tpl->setVariable("TPLPATH",$this->tpl->tplPath);
3279 
3280 
3281  $this->ctrl->setParameter($this,"cmd","roleassignment");
3282 
3283  // title & header columns
3284  $tbl->setTitle($this->lng->txt("edit_roleassignment"),"icon_role.gif",$this->lng->txt("roles"));
3285 
3286  //user must be administrator
3287  $tbl->setHeaderNames(array("",$this->lng->txt("role"),$this->lng->txt("description"),$this->lng->txt("context")));
3288  $tbl->setHeaderVars(array("","title","description","context"),$this->ctrl->getParameterArray($this,"",false));
3289  $tbl->setColumnWidth(array("","30%","40%","30%"));
3290 
3291  $this->__setTableGUIBasicData($tbl,$a_result_set,"roleassignment");
3292  $tbl->render();
3293  $this->tpl->setVariable("ROLES_TABLE",$tbl->tpl->get());
3294 
3295  return true;
3296  }
3297 
3298  function &__initTableGUI()
3299  {
3300  include_once "./Services/Table/classes/class.ilTableGUI.php";
3301 
3302  return new ilTableGUI(0,false);
3303  }
3304 
3305  function __setTableGUIBasicData(&$tbl,&$result_set,$from = "")
3306  {
3307  switch($from)
3308  {
3309  default:
3310  $order = $_GET["sort_by"] ? $_GET["sort_by"] : "title";
3311  break;
3312  }
3313 
3314  //$tbl->enable("hits");
3315  $tbl->setOrderColumn($order);
3316  $tbl->setOrderDirection($_GET["sort_order"]);
3317  $tbl->setOffset($_GET["offset"]);
3318  $tbl->setLimit($_GET["limit"]);
3319  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
3320  $tbl->setData($result_set);
3321  }
3322 
3324  {
3325  unset($_SESSION["filtered_roles"]);
3326  }
3327 
3329  {
3330  $action[0] = $this->lng->txt('assigned_roles');
3331  $action[1] = $this->lng->txt('all_roles');
3332  $action[2] = $this->lng->txt('all_global_roles');
3333  $action[3] = $this->lng->txt('all_local_roles');
3334  $action[4] = $this->lng->txt('internal_local_roles_only');
3335  $action[5] = $this->lng->txt('non_internal_local_roles_only');
3336 
3337  return ilUtil::formSelect($_SESSION['filtered_roles'],"filter",$action,false,true);
3338  }
3339 
3341  {
3343  $this->roleassignmentObject();
3344  }
3345 
3351  {
3352  global $ilLocator;
3353 
3354  $ilLocator->clearItems();
3355 
3356  if ($_GET["admin_mode"] == "settings") // system settings
3357  {
3358  $ilLocator->addItem($this->lng->txt("administration"),
3359  $this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
3360  ilFrameTargetInfo::_getFrame("MainContent"));
3361 
3362  if ($_GET['ref_id'] == USER_FOLDER_ID)
3363  {
3364  $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
3365  ilObject::_lookupObjId($_GET["ref_id"]))),
3366  $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
3367  }
3368  elseif ($_GET['ref_id'] == ROLE_FOLDER_ID)
3369  {
3370  $ilLocator->addItem($this->lng->txt("obj_".ilObject::_lookupType(
3371  ilObject::_lookupObjId($_GET["ref_id"]))),
3372  $this->ctrl->getLinkTargetByClass("ilobjrolefoldergui", "view"));
3373  }
3374 
3375  if ($_GET["obj_id"] > 0)
3376  {
3377  $ilLocator->addItem($this->object->getTitle(),
3378  $this->ctrl->getLinkTarget($this, "view"));
3379  }
3380  }
3381  else // repository administration
3382  {
3383  // ?
3384  }
3385  }
3386 
3387  function showUpperIcon()
3388  {
3389  global $tree, $tpl, $objDefinition;
3390 
3391  if (strtolower($_GET["baseClass"]) == "iladministrationgui")
3392  {
3393  $tpl->setUpperIcon(
3394  $this->ctrl->getLinkTargetByClass("ilobjuserfoldergui", "view"));
3395  }
3396  else
3397  {
3398  if ($this->object->getRefId() != ROOT_FOLDER_ID &&
3399  $this->object->getRefId() != SYSTEM_FOLDER_ID)
3400  {
3401  $par_id = $tree->getParentId($this->usrf_ref_id);
3402  $tpl->setUpperIcon("repository.php?ref_id=".$par_id);
3403  }
3404  }
3405  }
3406 
3408  {
3409  global $ilUser,$ilias;
3410 
3411  if($_POST['send_mail'] != 'y')
3412  {
3413  return '';
3414  }
3415  if(!strlen($this->object->getEmail()))
3416  {
3417  return '';
3418  }
3419 
3420  // Choose language of user
3421  $usr_lang = new ilLanguage($this->object->getLanguage());
3422  $usr_lang->loadLanguageModule('crs');
3423  $usr_lang->loadLanguageModule('registration');
3424 
3425  include_once "Services/Mail/classes/class.ilMimeMail.php";
3426 
3427  $mmail = new ilMimeMail();
3428  $mmail->autoCheck(false);
3429  $mmail->From($ilUser->getEmail());
3430  $mmail->To($this->object->getEmail());
3431 
3432  // mail subject
3433  $subject = $usr_lang->txt("profile_changed");
3434 
3435 
3436  // mail body
3437  $body = ($usr_lang->txt("reg_mail_body_salutation")." ".$this->object->getFullname().",\n\n");
3438 
3439  $date = $this->object->getApproveDate();
3440  // Approve
3441  if((time() - strtotime($date)) < 10)
3442  {
3443  $body .= ($usr_lang->txt('reg_mail_body_approve')."\n\n");
3444  }
3445  else
3446  {
3447  $body .= ($usr_lang->txt('reg_mail_body_profile_changed')."\n\n");
3448  }
3449 
3450  // Append login info only if password has been changed
3451  if($_POST['passwd'] != '********')
3452  {
3453  $body .= $usr_lang->txt("reg_mail_body_text2")."\n".
3454  ILIAS_HTTP_PATH."/login.php?client_id=".$ilias->client_id."\n".
3455  $usr_lang->txt("login").": ".$this->object->getLogin()."\n".
3456  $usr_lang->txt("passwd").": ".$_POST['passwd']."\n\n";
3457  }
3458  $body .= ($usr_lang->txt("reg_mail_body_text3")."\n");
3459  $body .= $this->object->getProfileAsString($usr_lang);
3460 
3461  $mmail->Subject($subject);
3462  $mmail->Body($body);
3463  $mmail->Send();
3464 
3465 
3466  return "<br/>".$this->lng->txt("mail_sent");
3467  }
3468 
3472  function _goto($a_target)
3473  {
3474  global $ilAccess, $ilErr, $lng, $ilNavigationHistory;
3475 
3476  if (substr($a_target, 0, 1) == "n")
3477  {
3478  $a_target = ilObjUser::_lookupId(ilUtil::stripSlashes(substr($a_target, 1)));
3479  }
3480 
3481  $_GET["cmd"] = "view";
3482  $_GET["user_id"] = (int) $a_target;
3483  $_GET["baseClass"] = "ilPublicUserProfileGUI";
3484  $_GET["cmdClass"] = "ilpublicuserprofilegui";
3485  include("ilias.php");
3486  exit;
3487  }
3488 
3489 } // END class.ilObjUserGUI
3490 ?>