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