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