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