ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjUserFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./Services/Object/classes/class.ilObjectGUI.php";
5 
21 {
22  public $ctrl;
23 
24  protected $log;
25 
30  public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
31  {
32  global $ilCtrl;
33 
34  // TODO: move this to class.ilias.php
35  define('USER_FOLDER_ID', 7);
36 
37  $this->type = "usrf";
38  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
39 
40  $this->lng->loadLanguageModule('search');
41  $this->lng->loadLanguageModule("user");
42 
43  $ilCtrl->saveParameter($this, "letter");
44 
45  $this->log = ilLoggerFactory::getLogger("user");
46  }
47 
48  public function setUserOwnerId($a_id)
49  {
50  $this->user_owner_id = $a_id;
51  }
52  public function getUserOwnerId()
53  {
54  return $this->user_owner_id ? $this->user_owner_id : USER_FOLDER_ID;
55  }
56 
57  public function executeCommand()
58  {
59  global $ilTabs;
60 
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63  $this->prepareOutput();
64 
65  switch ($next_class) {
66  case 'ilusertablegui':
67  include_once("./Services/User/classes/class.ilUserTableGUI.php");
68  $u_table = new ilUserTableGUI($this, "view");
69  $u_table->initFilter();
70  $this->ctrl->setReturn($this, 'view');
71  $this->ctrl->forwardCommand($u_table);
72  break;
73 
74  case 'ilpermissiongui':
75  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
76  $perm_gui = new ilPermissionGUI($this);
77  $ret =&$this->ctrl->forwardCommand($perm_gui);
78  break;
79 
80  case 'ilrepositorysearchgui':
81  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
82  $user_search = new ilRepositorySearchGUI();
83  $user_search->setTitle($this->lng->txt("search_user_extended")); // #17502
84  $user_search->enableSearchableCheck(false);
85  $user_search->setUserLimitations(false);
86  $user_search->setCallback(
87  $this,
88  'searchResultHandler',
89  $this->getUserMultiCommands(true)
90  );
91  $this->tabs_gui->setTabActive('search_user_extended');
92  $this->ctrl->setReturn($this, 'view');
93  $ret =&$this->ctrl->forwardCommand($user_search);
94  break;
95 
96  case 'ilaccountcodesgui':
97  $this->tabs_gui->setTabActive('settings');
98  $this->setSubTabs("settings");
99  $ilTabs->activateSubTab("account_codes");
100  include_once("./Services/User/classes/class.ilAccountCodesGUI.php");
101  $acc = new ilAccountCodesGUI($this->ref_id);
102  $this->ctrl->forwardCommand($acc);
103  break;
104 
105  case 'ilcustomuserfieldsgui':
106  $this->tabs_gui->setTabActive('settings');
107  $this->setSubTabs("settings");
108  $ilTabs->activateSubTab("user_defined_fields");
109  include_once("./Services/User/classes/class.ilCustomUserFieldsGUI.php");
110  $cf = new ilCustomUserFieldsGUI();
111  $this->ctrl->forwardCommand($cf);
112  break;
113 
114  case 'iluserstartingpointgui':
115  $this->tabs_gui->setTabActive('settings');
116  $this->setSubTabs("settings");
117  $ilTabs->activateSubTab("starting_points");
118  include_once("./Services/User/classes/class.ilUserStartingPointGUI.php");
119  $cf = new ilUserStartingPointGUI($this->ref_id);
120  $this->ctrl->forwardCommand($cf);
121  break;
122 
123  case 'iluserprofileinfosettingsgui':
124  $this->tabs_gui->setTabActive('settings');
125  $this->setSubTabs("settings");
126  $ilTabs->activateSubTab("user_profile_settings");
127  include_once("./Services/User/classes/class.ilUserProfileInfoSettingsGUI.php");
128  $ps = new ilUserProfileInfoSettingsGUI();
129  $this->ctrl->forwardCommand($ps);
130  break;
131 
132  default:
133  if (!$cmd) {
134  $cmd = "view";
135  }
136  $cmd .= "Object";
137  $this->$cmd();
138 
139  break;
140  }
141  return true;
142  }
143 
144  public function learningProgressObject()
145  {
146  global $rbacsystem, $tpl;
147 
148  // deprecated JF 27 May 2013
149  exit();
150 
151  if (!$rbacsystem->checkAccess("read", $this->object->getRefId()) ||
154  $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
155  }
156 
157  include_once "Services/User/classes/class.ilUserLPTableGUI.php";
158  $tbl = new ilUserLPTableGUI($this, "learningProgress", $this->object->getRefId());
159 
160  $tpl->setContent($tbl->getHTML());
161  }
162 
167  public function resetFilterObject()
168  {
169  include_once("./Services/User/classes/class.ilUserTableGUI.php");
170  $utab = new ilUserTableGUI($this, "view");
171  $utab->resetOffset();
172  $utab->resetFilter();
173 
174  // from "old" implementation
175  $this->viewObject(true);
176  }
177 
181  public function addUserObject()
182  {
183  global $ilCtrl;
184 
185  $ilCtrl->setParameterByClass("ilobjusergui", "new_type", "usr");
186  $ilCtrl->redirectByClass(array("iladministrationgui", "ilobjusergui"), "create");
187  }
188 
189 
193  public function applyFilterObject()
194  {
195  global $ilTabs;
196 
197  include_once("./Services/User/classes/class.ilUserTableGUI.php");
198  $utab = new ilUserTableGUI($this, "view");
199  $utab->resetOffset();
200  $utab->writeFilterToSession();
201  $this->viewObject();
202  $ilTabs->activateTab("usrf");
203  }
204 
210  public function viewObject($reset_filter = false)
211  {
212  global $rbacsystem, $ilUser, $ilToolbar, $tpl, $ilSetting, $lng;
213 
214  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
215 
216  if ($rbacsystem->checkAccess('create_usr', $this->object->getRefId()) ||
217  $rbacsystem->checkAccess('cat_administrate_users', $this->object->getRefId())) {
218  $button = ilLinkButton::getInstance();
219  $button->setCaption("usr_add");
220  $button->setUrl($this->ctrl->getLinkTarget($this, "addUser"));
221  $ilToolbar->addButtonInstance($button);
222 
223  $button = ilLinkButton::getInstance();
224  $button->setCaption("import_users");
225  $button->setUrl($this->ctrl->getLinkTarget($this, "importUserForm"));
226  $ilToolbar->addButtonInstance($button);
227  }
228 
229  // alphabetical navigation
230  include_once './Services/User/classes/class.ilUserAccountSettings.php';
232  if ((int) $ilSetting->get('user_adm_alpha_nav')) {
233  $ilToolbar->addSeparator();
234 
235  // alphabetical navigation
236  include_once("./Services/Form/classes/class.ilAlphabetInputGUI.php");
237  $ai = new ilAlphabetInputGUI("", "first");
238  include_once("./Services/User/classes/class.ilObjUser.php");
239  $ai->setLetters(ilObjUser::getFirstLettersOfLastnames());
240  /*$ai->setLetters(array("A","B","C","D","E","F","G","H","I","J",
241  "K","L","M","N","O","P","Q","R","S","T",
242  "U","V","W","X","Y","Z","1","2","3","4","_",
243  "Ä","Ü","Ö",":",";","+","*","#","§","%","&"));*/
244  $ai->setParentCommand($this, "chooseLetter");
245  $ai->setHighlighted($_GET["letter"]);
246  $ilToolbar->addInputItem($ai, true);
247  }
248 
249  include_once("./Services/User/classes/class.ilUserTableGUI.php");
250  $utab = new ilUserTableGUI($this, "view");
251  $tpl->setContent($utab->getHTML());
252  }
253 
257  protected function addUserAutoCompleteObject()
258  {
259  include_once './Services/User/classes/class.ilUserAutoComplete.php';
260  $auto = new ilUserAutoComplete();
261  $auto->setSearchFields(array('login','firstname','lastname','email', 'second_email'));
262  $auto->enableFieldSearchableCheck(false);
263  $auto->setMoreLinkAvailable(true);
264 
265  if (($_REQUEST['fetchall'])) {
266  $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
267  }
268 
269  echo $auto->getList($_REQUEST['term']);
270  exit();
271  }
272 
279  public function chooseLetterObject()
280  {
281  global $ilCtrl;
282 
283  $ilCtrl->redirect($this, "view");
284  }
285 
286 
293  public function showActions($with_subobjects = false)
294  {
295  global $rbacsystem;
296 
297  $operations = array();
298  //var_dump($this->actions);
299  if ($this->actions == "") {
300  $d = array(
301  "delete" => array("name" => "delete", "lng" => "delete"),
302  "activate" => array("name" => "activate", "lng" => "activate"),
303  "deactivate" => array("name" => "deactivate", "lng" => "deactivate"),
304  "accessRestrict" => array("name" => "accessRestrict", "lng" => "accessRestrict"),
305  "accessFree" => array("name" => "accessFree", "lng" => "accessFree"),
306  "export" => array("name" => "export", "lng" => "export")
307  );
308  } else {
309  $d = $this->actions;
310  }
311  foreach ($d as $row) {
312  if ($rbacsystem->checkAccess($row["name"], $this->object->getRefId())) {
313  $operations[] = $row;
314  }
315  }
316 
317  if (count($operations) > 0) {
318  $select = "<select name=\"selectedAction\">\n";
319  foreach ($operations as $val) {
320  $select .= "<option value=\"" . $val["name"] . "\"";
321  if (strcmp($_POST["selectedAction"], $val["name"]) == 0) {
322  $select .= " selected=\"selected\"";
323  }
324  $select .= ">";
325  $select .= $this->lng->txt($val["lng"]);
326  $select .= "</option>";
327  }
328  $select .= "</select>";
329  $this->tpl->setCurrentBlock("tbl_action_select");
330  $this->tpl->setVariable("SELECT_ACTION", $select);
331  $this->tpl->setVariable("BTN_NAME", "userAction");
332  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("submit"));
333  $this->tpl->parseCurrentBlock();
334  }
335 
336  if ($with_subobjects === true) {
337  $subobjs = $this->showPossibleSubObjects();
338  }
339 
340  if ((count($operations) > 0) or $subobjs === true) {
341  $this->tpl->setCurrentBlock("tbl_action_row");
342  $this->tpl->setVariable("COLUMN_COUNTS", count($this->data["cols"]));
343  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
344  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
345  $this->tpl->parseCurrentBlock();
346  }
347  }
348 
355  public function showPossibleSubObjects()
356  {
357  global $rbacsystem;
358 
359  $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
360 
361  if (!$rbacsystem->checkAccess('create_usr', $this->object->getRefId())) {
362  unset($d["usr"]);
363  }
364 
365  if (count($d) > 0) {
366  foreach ($d as $row) {
367  $count = 0;
368  if ($row["max"] > 0) {
369  //how many elements are present?
370  for ($i=0; $i<count($this->data["ctrl"]); $i++) {
371  if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
372  $count++;
373  }
374  }
375  }
376  if ($row["max"] == "" || $count < $row["max"]) {
377  $subobj[] = $row["name"];
378  }
379  }
380  }
381 
382  if (is_array($subobj)) {
383  //build form
384  $opts = ilUtil::formSelect(12, "new_type", $subobj);
385  $this->tpl->setCurrentBlock("add_object");
386  $this->tpl->setVariable("SELECT_OBJTYPE", $opts);
387  $this->tpl->setVariable("BTN_NAME", "create");
388  $this->tpl->setVariable("TXT_ADD", $this->lng->txt("add"));
389  $this->tpl->parseCurrentBlock();
390 
391  return true;
392  }
393 
394  return false;
395  }
396 
398  {
399  $this->ctrl->redirect($this, 'view');
400  }
401 
402  public function cancelSearchActionObject()
403  {
404  $this->ctrl->redirectByClass('ilrepositorysearchgui', 'showSearchResults');
405  }
406 
412  public function confirmactivateObject()
413  {
414  global $rbacsystem, $ilUser;
415 
416  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
417  if (!$rbacsystem->checkAccess('write', $this->object->getRefId())) {
418  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->WARNING);
419  }
420 
421  // FOR ALL SELECTED OBJECTS
422  foreach ($_POST["id"] as $id) {
423  // instatiate correct object class (usr)
424  $obj =&$this->ilias->obj_factory->getInstanceByObjId($id);
425  $obj->setActive(true, $ilUser->getId());
426  $obj->update();
427  }
428 
429  ilUtil::sendSuccess($this->lng->txt("user_activated"), true);
430 
431  if ($_POST["frsrch"]) {
432  $this->ctrl->redirectByClass('ilRepositorySearchGUI', 'show');
433  } else {
434  $this->ctrl->redirect($this, "view");
435  }
436  }
437 
443  public function confirmdeactivateObject()
444  {
445  global $rbacsystem, $ilUser;
446 
447  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
448  if (!$rbacsystem->checkAccess('write', $this->object->getRefId())) {
449  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->WARNING);
450  }
451 
452  // FOR ALL SELECTED OBJECTS
453  foreach ($_POST["id"] as $id) {
454  // instatiate correct object class (usr)
455  $obj =&$this->ilias->obj_factory->getInstanceByObjId($id);
456  $obj->setActive(false, $ilUser->getId());
457  $obj->update();
458  }
459 
460  // Feedback
461  ilUtil::sendSuccess($this->lng->txt("user_deactivated"), true);
462 
463  if ($_POST["frsrch"]) {
464  $this->ctrl->redirectByClass('ilRepositorySearchGUI', 'show');
465  } else {
466  $this->ctrl->redirect($this, "view");
467  }
468  }
469 
470  public function confirmaccessFreeObject()
471  {
472  global $rbacsystem, $ilUser;
473 
474  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
475  if (!$rbacsystem->checkAccess('write', $this->object->getRefId())) {
476  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->WARNING);
477  }
478 
479  // FOR ALL SELECTED OBJECTS
480  foreach ($_POST["id"] as $id) {
481  // instatiate correct object class (usr)
482  $obj = $this->ilias->obj_factory->getInstanceByObjId($id);
483  $obj->setTimeLimitUnlimited(1);
484  $obj->setTimeLimitFrom("");
485  $obj->setTimeLimitUntil("");
486  $obj->setTimeLimitMessage(0);
487  $obj->update();
488  }
489 
490  // Feedback
491  ilUtil::sendSuccess($this->lng->txt("access_free_granted"), true);
492 
493  if ($_POST["frsrch"]) {
494  $this->ctrl->redirectByClass('ilRepositorySearchGUI', 'show');
495  } else {
496  $this->ctrl->redirect($this, "view");
497  }
498  }
499 
500  public function setAccessRestrictionObject($a_form = null, $a_from_search = false)
501  {
502  if (!$a_form) {
503  $a_form = $this->initAccessRestrictionForm($a_from_search);
504  }
505  $this->tpl->setContent($a_form->getHTML());
506 
507  // #10963
508  return true;
509  }
510 
511  protected function initAccessRestrictionForm($a_from_search = false)
512  {
513  $user_ids = $this->getActionUserIds();
514  if (!$user_ids) {
515  ilUtil::sendFailure($this->lng->txt('select_one'));
516  return $this->viewObject();
517  }
518 
519  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
520  $form = new ilPropertyFormGUI();
521  $form->setTitle($this->lng->txt("time_limit_add_time_limit_for_selected"));
522  $form->setFormAction($this->ctrl->getFormAction($this, "confirmaccessRestrict"));
523 
524  $from = new ilDateTimeInputGUI($this->lng->txt("access_from"), "from");
525  $from->setShowTime(true);
526  $from->setRequired(true);
527  $form->addItem($from);
528 
529  $to = new ilDateTimeInputGUI($this->lng->txt("access_until"), "to");
530  $to->setRequired(true);
531  $to->setShowTime(true);
532  $form->addItem($to);
533 
534  $form->addCommandButton("confirmaccessRestrict", $this->lng->txt("confirm"));
535  $form->addCommandButton("view", $this->lng->txt("cancel"));
536 
537  foreach ($user_ids as $user_id) {
538  $ufield = new ilHiddenInputGUI("id[]");
539  $ufield->setValue($user_id);
540  $form->addItem($ufield);
541  }
542 
543  // return to search?
544  if ($a_from_search || $_POST["frsrch"]) {
545  $field = new ilHiddenInputGUI("frsrch");
546  $field->setValue(1);
547  $form->addItem($field);
548  }
549 
550  return $form;
551  }
552 
553  public function confirmaccessRestrictObject()
554  {
555  $form = $this->initAccessRestrictionForm();
556  if (!$form->checkInput()) {
557  return $this->setAccessRestrictionObject($form);
558  }
559 
560  $timefrom = $form->getItemByPostVar("from")->getDate()->get(IL_CAL_UNIX);
561  $timeuntil = $form->getItemByPostVar("to")->getDate()->get(IL_CAL_UNIX);
562  if ($timeuntil <= $timefrom) {
563  ilUtil::sendFailure($this->lng->txt("time_limit_not_valid"));
564  return $this->setAccessRestrictionObject($form);
565  }
566 
567  global $rbacsystem, $ilUser;
568 
569  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
570  if (!$rbacsystem->checkAccess('write', $this->object->getRefId())) {
571  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->WARNING);
572  }
573 
574  // FOR ALL SELECTED OBJECTS
575  foreach ($_POST["id"] as $id) {
576  // instatiate correct object class (usr)
577  $obj = $this->ilias->obj_factory->getInstanceByObjId($id);
578  $obj->setTimeLimitUnlimited(0);
579  $obj->setTimeLimitFrom($timefrom);
580  $obj->setTimeLimitUntil($timeuntil);
581  $obj->setTimeLimitMessage(0);
582  $obj->update();
583  }
584 
585  // Feedback
586  ilUtil::sendSuccess($this->lng->txt("access_restricted"), true);
587 
588  if ($_POST["frsrch"]) {
589  $this->ctrl->redirectByClass('ilRepositorySearchGUI', 'show');
590  } else {
591  $this->ctrl->redirect($this, "view");
592  }
593  }
594 
600  public function confirmdeleteObject()
601  {
602  global $rbacsystem, $ilCtrl, $ilUser;
603 
604  // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
605  if (!$rbacsystem->checkAccess('delete', $this->object->getRefId())) {
606  ilUtil::sendFailure($this->lng->txt("msg_no_perm_delete"), true);
607  $ilCtrl->redirect($this, "view");
608  }
609 
610  if (in_array($ilUser->getId(), $_POST["id"])) {
611  $this->ilias->raiseError($this->lng->txt("msg_no_delete_yourself"), $this->ilias->error_obj->WARNING);
612  }
613 
614  // FOR ALL SELECTED OBJECTS
615  foreach ($_POST["id"] as $id) {
616  // instatiate correct object class (usr)
617  $obj =&$this->ilias->obj_factory->getInstanceByObjId($id);
618  $obj->delete();
619  }
620 
621  // Feedback
622  ilUtil::sendSuccess($this->lng->txt("user_deleted"), true);
623 
624  if ($_POST["frsrch"]) {
625  $this->ctrl->redirectByClass('ilRepositorySearchGUI', 'show');
626  } else {
627  $this->ctrl->redirect($this, "view");
628  }
629  }
630 
636  protected function getActionUserIds()
637  {
638  if ($_POST["select_cmd_all"]) {
639  include_once("./Services/User/classes/class.ilUserTableGUI.php");
640  $utab = new ilUserTableGUI($this, "view", ilUserTableGUI::MODE_USER_FOLDER, false);
641  return $utab->getUserIdsForFilter();
642  } else {
643  return $_POST["id"];
644  }
645  }
646 
650  public function showActionConfirmation($action, $a_from_search = false)
651  {
652  global $ilTabs;
653 
654  $user_ids = $this->getActionUserIds();
655  if (!$user_ids) {
656  $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
657  }
658 
659  if (!$a_from_search) {
660  $ilTabs->activateTab("obj_usrf");
661  } else {
662  $ilTabs->activateTab("search_user_extended");
663  }
664 
665  if (strcmp($action, "accessRestrict") == 0) {
666  return $this->setAccessRestrictionObject(null, $a_from_search);
667  }
668  if (strcmp($action, "mail") == 0) {
669  return $this->mailObject();
670  }
671 
672  unset($this->data);
673 
674  if (!$a_from_search) {
675  $cancel = "cancelUserFolderAction";
676  } else {
677  $cancel = "cancelSearchAction";
678  }
679 
680  // display confirmation message
681  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
682  $cgui = new ilConfirmationGUI();
683  $cgui->setFormAction($this->ctrl->getFormAction($this));
684  $cgui->setHeaderText($this->lng->txt("info_" . $action . "_sure"));
685  $cgui->setCancel($this->lng->txt("cancel"), $cancel);
686  $cgui->setConfirm($this->lng->txt("confirm"), "confirm" . $action);
687 
688  if ($a_from_search) {
689  $cgui->addHiddenItem("frsrch", 1);
690  }
691 
692  foreach ($user_ids as $id) {
693  $user = new ilObjUser($id);
694 
695  $login = $user->getLastLogin();
696  if (!$login) {
697  $login = $this->lng->txt("never");
698  } else {
700  }
701 
702  $caption = $user->getFullname() . " (" . $user->getLogin() . ")" . ", " .
703  $user->getEmail() . " - " . $this->lng->txt("last_login") . ": " . $login;
704 
705  $cgui->addItem("id[]", $id, $caption);
706  }
707 
708  $this->tpl->setContent($cgui->getHTML());
709 
710  return true;
711  }
712 
716  public function deleteUsersObject()
717  {
718  $_POST["selectedAction"] = "delete";
719  $this->showActionConfirmation($_POST["selectedAction"]);
720  }
721 
725  public function activateUsersObject()
726  {
727  $_POST["selectedAction"] = "activate";
728  $this->showActionConfirmation($_POST["selectedAction"]);
729  }
730 
734  public function deactivateUsersObject()
735  {
736  $_POST["selectedAction"] = "deactivate";
737  $this->showActionConfirmation($_POST["selectedAction"]);
738  }
739 
743  public function restrictAccessObject()
744  {
745  $_POST["selectedAction"] = "accessRestrict";
746  $this->showActionConfirmation($_POST["selectedAction"]);
747  }
748 
752  public function freeAccessObject()
753  {
754  $_POST["selectedAction"] = "accessFree";
755  $this->showActionConfirmation($_POST["selectedAction"]);
756  }
757 
758  public function userActionObject()
759  {
760  $this->showActionConfirmation($_POST["selectedAction"]);
761  }
762 
766  public function importUserFormObject()
767  {
768  global $tpl, $rbacsystem;
769 
770  // Blind out tabs for local user import
771  if ($_GET["baseClass"] == 'ilRepositoryGUI') {
772  $this->tabs_gui->clearTargets();
773  }
774 
775  if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
776  $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
777  }
778 
779  $this->initUserImportForm();
780  $tpl->setContent($this->form->getHTML());
781  }
782 
788  public function initUserImportForm()
789  {
790  global $lng, $ilCtrl;
791 
792  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
793  $this->form = new ilPropertyFormGUI();
794 
795  // Import File
796  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
797  $fi = new ilFileInputGUI($lng->txt("import_file"), "importFile");
798  $fi->setSuffixes(array("xml", "zip"));
799  //$fi->enableFileNameSelection();
800  //$fi->setInfo($lng->txt(""));
801  $this->form->addItem($fi);
802 
803  $this->form->addCommandButton("importUserRoleAssignment", $lng->txt("import"));
804  $this->form->addCommandButton("importCancelled", $lng->txt("cancel"));
805 
806  $this->form->setTitle($lng->txt("import_users"));
807  $this->form->setFormAction($ilCtrl->getFormAction($this));
808  }
809 
815  public function importCancelledObject()
816  {
817  // purge user import directory
818  $import_dir = $this->getImportDir();
819  if (@is_dir($import_dir)) {
820  ilUtil::delDir($import_dir);
821  }
822 
823  if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
824  $this->ctrl->redirect($this, "view");
825  //ilUtil::redirect($this->ctrl->getLinkTarget($this,$return_location));
826  } else {
827  $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
828  }
829  }
830 
834  public function getImportDir()
835  {
836  // For each user session a different directory must be used to prevent
837  // that one user session overwrites the import data that another session
838  // is currently importing.
839  global $ilUser;
840  $importDir = ilUtil::getDataDir() . '/user_import/usr_' . $ilUser->getId() . '_' . session_id();
841  ilUtil::makeDirParents($importDir);
842  return $importDir;
843  }
844 
849  {
850  global $ilUser, $tpl, $lng, $ilCtrl;
851  ;
852 
853  // Blind out tabs for local user import
854  if ($_GET["baseClass"] == 'ilRepositoryGUI') {
855  $this->tabs_gui->clearTargets();
856  }
857 
858  $this->initUserImportForm();
859  if ($this->form->checkInput()) {
860  include_once './Services/AccessControl/classes/class.ilObjRole.php';
861  include_once './Services/User/classes/class.ilUserImportParser.php';
862 
863  global $rbacreview, $rbacsystem, $tree, $lng;
864 
865 
866  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.usr_import_roles.html", "Services/User");
867 
868  $import_dir = $this->getImportDir();
869 
870  // recreate user import directory
871  if (@is_dir($import_dir)) {
872  ilUtil::delDir($import_dir);
873  }
874  ilUtil::makeDir($import_dir);
875 
876  // move uploaded file to user import directory
877  $file_name = $_FILES["importFile"]["name"];
878  $parts = pathinfo($file_name);
879  $full_path = $import_dir . "/" . $file_name;
880 
881  // check if import file exists
882  if (!is_file($_FILES["importFile"]["tmp_name"])) {
883  ilUtil::delDir($import_dir);
884  $this->ilias->raiseError($this->lng->txt("no_import_file_found"), $this->ilias->error_obj->MESSAGE);
885  }
886  ilUtil::moveUploadedFile(
887  $_FILES["importFile"]["tmp_name"],
888  $_FILES["importFile"]["name"],
889  $full_path
890  );
891 
892  // handle zip file
893  if (strtolower($parts["extension"]) == "zip") {
894  // unzip file
895  ilUtil::unzip($full_path);
896 
897  $xml_file = null;
898  $file_list = ilUtil::getDir($import_dir);
899  foreach ($file_list as $a_file) {
900  if (substr($a_file['entry'], -4) == '.xml') {
901  $xml_file = $import_dir . "/" . $a_file['entry'];
902  break;
903  }
904  }
905  if (is_null($xml_file)) {
906  $subdir = basename($parts["basename"], "." . $parts["extension"]);
907  $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
908  }
909  }
910  // handle xml file
911  else {
912  $xml_file = $full_path;
913  }
914 
915  // check xml file
916  if (!is_file($xml_file)) {
917  ilUtil::delDir($import_dir);
918  $this->ilias->raiseError($this->lng->txt("no_xml_file_found_in_zip")
919  . " " . $subdir . "/" . $subdir . ".xml", $this->ilias->error_obj->MESSAGE);
920  }
921 
922  require_once("./Services/User/classes/class.ilUserImportParser.php");
923 
924  // Verify the data
925  // ---------------
926  $importParser = new ilUserImportParser($xml_file, IL_VERIFY);
927  $importParser->startParsing();
928  switch ($importParser->getErrorLevel()) {
929  case IL_IMPORT_SUCCESS:
930  break;
931  case IL_IMPORT_WARNING:
932  $this->tpl->setVariable("IMPORT_LOG", $importParser->getProtocolAsHTML($lng->txt("verification_warning_log")));
933  break;
934  case IL_IMPORT_FAILURE:
935  ilUtil::delDir($import_dir);
936  $this->ilias->raiseError(
937  $lng->txt("verification_failed") . $importParser->getProtocolAsHTML($lng->txt("verification_failure_log")),
938  $this->ilias->error_obj->MESSAGE
939  );
940  return;
941  }
942 
943  // Create the role selection form
944  // ------------------------------
945  $this->tpl->setCurrentBlock("role_selection_form");
946  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
947  $this->tpl->setVariable("TXT_IMPORT_USERS", $this->lng->txt("import_users"));
948  $this->tpl->setVariable("TXT_IMPORT_FILE", $this->lng->txt("import_file"));
949  $this->tpl->setVariable("IMPORT_FILE", $file_name);
950  $this->tpl->setVariable("TXT_USER_ELEMENT_COUNT", $this->lng->txt("num_users"));
951  $this->tpl->setVariable("USER_ELEMENT_COUNT", $importParser->getUserCount());
952  $this->tpl->setVariable("TXT_ROLE_ASSIGNMENT", $this->lng->txt("role_assignment"));
953  $this->tpl->setVariable("BTN_IMPORT", $this->lng->txt("import"));
954  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
955  $this->tpl->setVariable("XML_FILE_NAME", $xml_file);
956 
957  // Extract the roles
958  $importParser = new ilUserImportParser($xml_file, IL_EXTRACT_ROLES);
959  $importParser->startParsing();
960  $roles = $importParser->getCollectedRoles();
961 
962  // get global roles
963  $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
964  $gl_roles = array();
965  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
966  foreach ($all_gl_roles as $obj_data) {
967  // check assignment permission if called from local admin
968  if ($this->object->getRefId() != USER_FOLDER_ID) {
969  if (!in_array(SYSTEM_ROLE_ID, $roles_of_user) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
970  continue;
971  }
972  }
973  // exclude anonymous role from list
974  if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID) {
975  // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
976  if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(SYSTEM_ROLE_ID, $roles_of_user)) {
977  $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
978  }
979  }
980  }
981 
982  // global roles
983  $got_globals = false;
984  foreach ($roles as $role_id => $role) {
985  if ($role["type"] == "Global") {
986  if (!$got_globals) {
987  $got_globals = true;
988 
989  $this->tpl->setCurrentBlock("global_role_section");
990  $this->tpl->setVariable("TXT_GLOBAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_global"));
991  $this->tpl->setVariable("TXT_GLOBAL_ROLES", $this->lng->txt("assign_global_role"));
992  }
993 
994  // pre selection for role
995  $pre_select = array_search($role["name"], $gl_roles);
996  if (!$pre_select) {
997  switch ($role["name"]) {
998  case "Administrator": // ILIAS 2/3 Administrator
999  $pre_select = array_search("Administrator", $gl_roles);
1000  break;
1001 
1002  case "Autor": // ILIAS 2 Author
1003  $pre_select = array_search("User", $gl_roles);
1004  break;
1005 
1006  case "Lerner": // ILIAS 2 Learner
1007  $pre_select = array_search("User", $gl_roles);
1008  break;
1009 
1010  case "Gast": // ILIAS 2 Guest
1011  $pre_select = array_search("Guest", $gl_roles);
1012  break;
1013 
1014  default:
1015  $pre_select = array_search("User", $gl_roles);
1016  break;
1017  }
1018  }
1019  $this->tpl->setCurrentBlock("global_role");
1020  $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $gl_roles, false, true);
1021  $this->tpl->setVariable("TXT_IMPORT_GLOBAL_ROLE", $role["name"] . " [" . $role_id . "]");
1022  $this->tpl->setVariable("SELECT_GLOBAL_ROLE", $role_select);
1023  $this->tpl->parseCurrentBlock();
1024  }
1025  }
1026 
1027  // Check if local roles need to be assigned
1028  $got_locals = false;
1029  foreach ($roles as $role_id => $role) {
1030  if ($role["type"] == "Local") {
1031  $got_locals = true;
1032  break;
1033  }
1034  }
1035 
1036  if ($got_locals) {
1037  $this->tpl->setCurrentBlock("local_role_section");
1038  $this->tpl->setVariable("TXT_LOCAL_ROLES_IMPORT", $this->lng->txt("roles_of_import_local"));
1039  $this->tpl->setVariable("TXT_LOCAL_ROLES", $this->lng->txt("assign_local_role"));
1040 
1041 
1042  // get local roles
1043  if ($this->object->getRefId() == USER_FOLDER_ID) {
1044  // The import function has been invoked from the user folder
1045  // object. In this case, we show only matching roles,
1046  // because the user folder object is considered the parent of all
1047  // local roles and may contains thousands of roles on large ILIAS
1048  // installations.
1049  $loc_roles = array();
1050  require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
1051  foreach ($roles as $role_id => $role) {
1052  if ($role["type"] == "Local") {
1053  $searchName = (substr($role['name'], 0, 1) == '#') ? $role['name'] : '#' . $role['name'];
1054  $matching_role_ids = ilMailRoleAddressType::searchRolesByMailboxAddressList($searchName);
1055  foreach ($matching_role_ids as $mid) {
1056  if (!in_array($mid, $loc_roles)) {
1057  $loc_roles[] = $mid;
1058  }
1059  }
1060  }
1061  }
1062  } else {
1063  // The import function has been invoked from a locally
1064  // administrated category. In this case, we show all roles
1065  // contained in the subtree of the category.
1066  $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId());
1067  }
1068  $l_roles = array();
1069 
1070  // create a search array with .
1071  $l_roles_mailbox_searcharray = array();
1072  require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
1073  foreach ($loc_roles as $key => $loc_role) {
1074  // fetch context path of role
1075  $rolf = $rbacreview->getFoldersAssignedToRole($loc_role, true);
1076 
1077  // only process role folders that are not set to status "deleted"
1078  // and for which the user has write permissions.
1079  // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
1080  // (The ROLE_FOLDER_ID folder contains the global roles).
1081  if (
1082  !$rbacreview->isDeleted($rolf[0]) &&
1083  $rbacsystem->checkAccess('write', $rolf[0]) &&
1084  $rolf[0] != ROLE_FOLDER_ID
1085  ) {
1086  // A local role is only displayed, if it is contained in the subtree of
1087  // the localy administrated category. If the import function has been
1088  // invoked from the user folder object, we show all local roles, because
1089  // the user folder object is considered the parent of all local roles.
1090  // Thus, if we start from the user folder object, we initialize the
1091  // isInSubtree variable with true. In all other cases it is initialized
1092  // with false, and only set to true if we find the object id of the
1093  // locally administrated category in the tree path to the local role.
1094  $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
1095 
1096  $path_array = array();
1097  if ($this->tree->isInTree($rolf[0])) {
1098  // Create path. Paths which have more than 4 segments
1099  // are truncated in the middle.
1100  $tmpPath = $this->tree->getPathFull($rolf[0]);
1101  $tmpPath[] = $rolf[0];//adds target item to list
1102 
1103  for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++) {
1104  if ($i < 3 || $i > $n - 3) {
1105  $path_array[] = $tmpPath[$i]['title'];
1106  } elseif ($i == 3 || $i == $n - 3) {
1107  $path_array[] = '...';
1108  }
1109 
1110  $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
1111  }
1112  //revert this path for a better readability in dropdowns #18306
1113  $path = implode(" < ", array_reverse($path_array));
1114  } else {
1115  $path = "<b>Rolefolder " . $rolf[0] . " not found in tree! (Role " . $loc_role . ")</b>";
1116  }
1117  $roleMailboxAddress = ilMailRoleAddressType::getRoleMailboxAddress($loc_role);
1118  $l_roles[$loc_role] = $roleMailboxAddress . ', ' . $path;
1119  }
1120  } //foreach role
1121 
1122  $l_roles[""] = "";
1123  natcasesort($l_roles);
1124  $l_roles[""] = $this->lng->txt("usrimport_ignore_role");
1125  require_once 'Services/Mail/classes/Address/Type/class.ilMailRoleAddressType.php';
1126  foreach ($roles as $role_id => $role) {
1127  if ($role["type"] == "Local") {
1128  $this->tpl->setCurrentBlock("local_role");
1129  $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]);
1130  $searchName = (substr($role['name'], 0, 1) == '#') ? $role['name'] : '#' . $role['name'];
1131  $matching_role_ids = ilMailRoleAddressType::searchRolesByMailboxAddressList($searchName);
1132  $pre_select = count($matching_role_ids) == 1 ? $matching_role_ids[0] : "";
1133  if ($this->object->getRefId() == USER_FOLDER_ID) {
1134  // There are too many roles in a large ILIAS installation
1135  // that's why whe show only a choice with the the option "ignore",
1136  // and the matching roles.
1137  $selectable_roles = array();
1138  $selectable_roles[""] = $this->lng->txt("usrimport_ignore_role");
1139  foreach ($matching_role_ids as $id) {
1140  $selectable_roles[$id] = $l_roles[$id];
1141  }
1142  $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $selectable_roles, false, true);
1143  } else {
1144  $role_select = ilUtil::formSelect($pre_select, "role_assign[" . $role_id . "]", $l_roles, false, true);
1145  }
1146  $this->tpl->setVariable("SELECT_LOCAL_ROLE", $role_select);
1147  $this->tpl->parseCurrentBlock();
1148  }
1149  }
1150  }
1151  //
1152 
1153  $this->tpl->setVariable("TXT_CONFLICT_HANDLING", $lng->txt("conflict_handling"));
1154  $handlers = array(
1155  IL_IGNORE_ON_CONFLICT => "ignore_on_conflict",
1156  IL_UPDATE_ON_CONFLICT => "update_on_conflict"
1157  );
1158  $this->tpl->setVariable("TXT_CONFLICT_HANDLING_INFO", str_replace('\n', '<br>', $this->lng->txt("usrimport_conflict_handling_info")));
1159  $this->tpl->setVariable("TXT_CONFLICT_CHOICE", $lng->txt("conflict_handling"));
1160  $this->tpl->setVariable("SELECT_CONFLICT", ilUtil::formSelect(IL_IGNORE_ON_CONFLICT, "conflict_handling_choice", $handlers, false, false));
1161 
1162  // new account mail
1163  $this->lng->loadLanguageModule("mail");
1164  include_once './Services/User/classes/class.ilObjUserFolder.php';
1165  $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
1166  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
1167  $this->tpl->setCurrentBlock("inform_user");
1168  $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $lng->txt("mail_account_mail"));
1169  if (true) {
1170  $this->tpl->setVariable("SEND_MAIL", " checked=\"checked\"");
1171  }
1172  $this->tpl->setVariable(
1173  "TXT_INFORM_USER_MAIL",
1174  $this->lng->txt("user_send_new_account_mail")
1175  );
1176  $this->tpl->parseCurrentBlock();
1177  }
1178  } else {
1179  $this->form->setValuesByPost();
1180  $tpl->setContent($this->form->getHtml());
1181  }
1182  }
1183 
1187  public function importUsersObject()
1188  {
1189  global $rbacreview,$ilUser;
1190 
1191  // Blind out tabs for local user import
1192  if ($_GET["baseClass"] == 'ilRepositoryGUI') {
1193  $this->tabs_gui->clearTargets();
1194  }
1195 
1196  include_once './Services/AccessControl/classes/class.ilObjRole.php';
1197  include_once './Services/User/classes/class.ilUserImportParser.php';
1198 
1199  global $rbacreview, $rbacsystem, $tree, $lng;
1200 
1201  switch ($_POST["conflict_handling_choice"]) {
1202  case "update_on_conflict":
1204  break;
1205  case "ignore_on_conflict":
1206  default:
1208  break;
1209  }
1210  $importParser = new ilUserImportParser($_POST["xml_file"], IL_USER_IMPORT, $rule);
1211  $importParser->setFolderId($this->getUserOwnerId());
1212  $import_dir = $this->getImportDir();
1213 
1214  // Catch hack attempts
1215  // We check here again, if the role folders are in the tree, and if the
1216  // user has permission on the roles.
1217  if ($_POST["role_assign"]) {
1218  $global_roles = $rbacreview->getGlobalRoles();
1219  $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1220  foreach ($_POST["role_assign"] as $role_id) {
1221  if ($role_id != "") {
1222  if (in_array($role_id, $global_roles)) {
1223  if (!in_array(SYSTEM_ROLE_ID, $roles_of_user)) {
1224  if ($role_id == SYSTEM_ROLE_ID && !in_array(SYSTEM_ROLE_ID, $roles_of_user)
1225  || ($this->object->getRefId() != USER_FOLDER_ID
1226  && !ilObjRole::_getAssignUsersStatus($role_id))
1227  ) {
1228  ilUtil::delDir($import_dir);
1229  $this->ilias->raiseError(
1230  $this->lng->txt("usrimport_with_specified_role_not_permitted"),
1231  $this->ilias->error_obj->MESSAGE
1232  );
1233  }
1234  }
1235  } else {
1236  $rolf = $rbacreview->getFoldersAssignedToRole($role_id, true);
1237  if ($rbacreview->isDeleted($rolf[0])
1238  || !$rbacsystem->checkAccess('write', $rolf[0])) {
1239  ilUtil::delDir($import_dir);
1240  $this->ilias->raiseError(
1241  $this->lng->txt("usrimport_with_specified_role_not_permitted"),
1242  $this->ilias->error_obj->MESSAGE
1243  );
1244  return;
1245  }
1246  }
1247  }
1248  }
1249  }
1250 
1251  $importParser->setRoleAssignment($_POST["role_assign"]);
1252  $importParser->startParsing();
1253 
1254  // purge user import directory
1255  ilUtil::delDir($import_dir);
1256 
1257  switch ($importParser->getErrorLevel()) {
1258  case IL_IMPORT_SUCCESS:
1259  ilUtil::sendSuccess($this->lng->txt("user_imported"), true);
1260  break;
1261  case IL_IMPORT_WARNING:
1262  ilUtil::sendInfo($this->lng->txt("user_imported_with_warnings") . $importParser->getProtocolAsHTML($lng->txt("import_warning_log")), true);
1263  break;
1264  case IL_IMPORT_FAILURE:
1265  $this->ilias->raiseError(
1266  $this->lng->txt("user_import_failed")
1267  . $importParser->getProtocolAsHTML($lng->txt("import_failure_log")),
1268  $this->ilias->error_obj->MESSAGE
1269  );
1270  break;
1271  }
1272 
1273  if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
1274  $this->ctrl->redirect($this, "view");
1275  //ilUtil::redirect($this->ctrl->getLinkTarget($this));
1276  } else {
1277  $this->ctrl->redirectByClass('ilobjcategorygui', 'listUsers');
1278  }
1279  }
1280 
1281  public function hitsperpageObject()
1282  {
1283  parent::hitsperpageObject();
1284  $this->viewObject();
1285  }
1286 
1291  protected function generalSettingsObject()
1292  {
1293  global $ilSetting;
1294 
1295  $this->initFormGeneralSettings();
1296 
1297  include_once './Services/User/classes/class.ilUserAccountSettings.php';
1299 
1300  $show_blocking_time_in_days = $ilSetting->get('loginname_change_blocking_time') / 86400;
1301  $show_blocking_time_in_days = (float) $show_blocking_time_in_days;
1302 
1303  include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1304  $security = ilSecuritySettings::_getInstance();
1305 
1306  $this->form->setValuesByArray(
1307  array(
1308  'lua' => $aset->isLocalUserAdministrationEnabled(),
1309  'lrua' => $aset->isUserAccessRestricted(),
1310  'allow_change_loginname' => (bool) $ilSetting->get('allow_change_loginname'),
1311  'create_history_loginname' => (bool) $ilSetting->get('create_history_loginname'),
1312  'reuse_of_loginnames' => (bool) $ilSetting->get('reuse_of_loginnames'),
1313  'loginname_change_blocking_time' => (float) $show_blocking_time_in_days,
1314  'user_adm_alpha_nav' => (int) $ilSetting->get('user_adm_alpha_nav'),
1315  // 'user_ext_profiles' => (int)$ilSetting->get('user_ext_profiles')
1316  'user_reactivate_code' => (int) $ilSetting->get('user_reactivate_code'),
1317  'user_own_account' => (int) $ilSetting->get('user_delete_own_account'),
1318  'user_own_account_email' => $ilSetting->get('user_delete_own_account_email'),
1319 
1320  'session_handling_type' => $ilSetting->get('session_handling_type', ilSession::SESSION_HANDLING_FIXED),
1321  'session_reminder_enabled' => $ilSetting->get('session_reminder_enabled'),
1322  'session_max_count' => $ilSetting->get('session_max_count', ilSessionControl::DEFAULT_MAX_COUNT),
1323  'session_min_idle' => $ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE),
1324  'session_max_idle' => $ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE),
1325  'session_max_idle_after_first_request' => $ilSetting->get('session_max_idle_after_first_request', ilSessionControl::DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST),
1326 
1327  'password_change_on_first_login_enabled' => $security->isPasswordChangeOnFirstLoginEnabled() ? 1 : 0,
1328  'password_must_not_contain_loginame' => $security->getPasswordMustNotContainLoginnameStatus() ? 1 : 0,
1329  'password_chars_and_numbers_enabled' => $security->isPasswordCharsAndNumbersEnabled() ? 1 : 0,
1330  'password_special_chars_enabled' => $security->isPasswordSpecialCharsEnabled() ? 1 : 0 ,
1331  'password_min_length' => $security->getPasswordMinLength(),
1332  'password_max_length' => $security->getPasswordMaxLength(),
1333  'password_ucase_chars_num' => $security->getPasswordNumberOfUppercaseChars(),
1334  'password_lowercase_chars_num' => $security->getPasswordNumberOfLowercaseChars(),
1335  'password_max_age' => $security->getPasswordMaxAge(),
1336 
1337  'login_max_attempts' => $security->getLoginMaxAttempts(),
1338  'ps_prevent_simultaneous_logins' => (int) $security->isPreventionOfSimultaneousLoginsEnabled(),
1339  'password_assistance' => (bool) $ilSetting->get("password_assistance")
1340  ,'letter_avatars' => (int) $ilSetting->get('letter_avatars')
1341  )
1342  );
1343 
1344  $this->tpl->setContent($this->form->getHTML());
1345  }
1346 
1347 
1352  public function saveGeneralSettingsObject()
1353  {
1354  global $ilUser, $ilSetting;
1355 
1356  $this->initFormGeneralSettings();
1357  if ($this->form->checkInput()) {
1358  $valid = true;
1359 
1360  if (!strlen($this->form->getInput('loginname_change_blocking_time'))) {
1361  $valid = false;
1362  $this->form->getItemByPostVar('loginname_change_blocking_time')
1363  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
1364  }
1365 
1366  include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1367  $security = ilSecuritySettings::_getInstance();
1368 
1369  // account security settings
1370  $security->setPasswordCharsAndNumbersEnabled((bool) $_POST["password_chars_and_numbers_enabled"]);
1371  $security->setPasswordSpecialCharsEnabled((bool) $_POST["password_special_chars_enabled"]);
1372  $security->setPasswordMinLength((int) $_POST["password_min_length"]);
1373  $security->setPasswordMaxLength((int) $_POST["password_max_length"]);
1374  $security->setPasswordNumberOfUppercaseChars((int) $_POST['password_ucase_chars_num']);
1375  $security->setPasswordNumberOfLowercaseChars((int) $_POST['password_lowercase_chars_num']);
1376  $security->setPasswordMaxAge((int) $_POST["password_max_age"]);
1377  $security->setLoginMaxAttempts((int) $_POST["login_max_attempts"]);
1378  $security->setPreventionOfSimultaneousLogins((bool) $_POST['ps_prevent_simultaneous_logins']);
1379  $security->setPasswordChangeOnFirstLoginEnabled((bool) $_POST['password_change_on_first_login_enabled']);
1380  $security->setPasswordMustNotContainLoginnameStatus((int) $_POST['password_must_not_contain_loginame']);
1381 
1382  if (!$security->validate($this->form)) {
1383  $valid = false;
1384  }
1385 
1386  if ($valid) {
1387  $security->save();
1388 
1389  include_once './Services/User/classes/class.ilUserAccountSettings.php';
1390  ilUserAccountSettings::getInstance()->enableLocalUserAdministration($this->form->getInput('lua'));
1391  ilUserAccountSettings::getInstance()->restrictUserAccess($this->form->getInput('lrua'));
1393 
1394  $ilSetting->set('allow_change_loginname', (int) $this->form->getInput('allow_change_loginname'));
1395  $ilSetting->set('create_history_loginname', (int) $this->form->getInput('create_history_loginname'));
1396  $ilSetting->set('reuse_of_loginnames', (int) $this->form->getInput('reuse_of_loginnames'));
1397  $save_blocking_time_in_seconds = (int) ($this->form->getInput('loginname_change_blocking_time') * 86400);
1398  $ilSetting->set('loginname_change_blocking_time', (int) $save_blocking_time_in_seconds);
1399  $ilSetting->set('user_adm_alpha_nav', (int) $this->form->getInput('user_adm_alpha_nav'));
1400  $ilSetting->set('user_reactivate_code', (int) $this->form->getInput('user_reactivate_code'));
1401 
1402  $ilSetting->set('user_delete_own_account', (int) $this->form->getInput('user_own_account'));
1403  $ilSetting->set('user_delete_own_account_email', $this->form->getInput('user_own_account_email'));
1404 
1405  $ilSetting->set("password_assistance", $this->form->getInput("password_assistance"));
1406 
1407  // BEGIN SESSION SETTINGS
1408  $ilSetting->set(
1409  'session_handling_type',
1410  (int) $this->form->getInput('session_handling_type')
1411  );
1412 
1413  if ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_FIXED) {
1414  $ilSetting->set(
1415  'session_reminder_enabled',
1416  $this->form->getInput('session_reminder_enabled')
1417  );
1418  } elseif ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_LOAD_DEPENDENT) {
1419  require_once 'Services/Authentication/classes/class.ilSessionControl.php';
1420  if (
1421  $ilSetting->get(
1422  'session_allow_client_maintenance',
1424  )
1425  ) {
1426  // has to be done BEFORE updating the setting!
1427  include_once "Services/Authentication/classes/class.ilSessionStatistics.php";
1428  ilSessionStatistics::updateLimitLog((int) $this->form->getInput('session_max_count'));
1429 
1430  $ilSetting->set(
1431  'session_max_count',
1432  (int) $this->form->getInput('session_max_count')
1433  );
1434  $ilSetting->set(
1435  'session_min_idle',
1436  (int) $this->form->getInput('session_min_idle')
1437  );
1438  $ilSetting->set(
1439  'session_max_idle',
1440  (int) $this->form->getInput('session_max_idle')
1441  );
1442  $ilSetting->set(
1443  'session_max_idle_after_first_request',
1444  (int) $this->form->getInput('session_max_idle_after_first_request')
1445  );
1446  }
1447  }
1448  // END SESSION SETTINGS
1449  $ilSetting->set('letter_avatars', (int) $this->form->getInput('letter_avatars'));
1450  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
1451  } else {
1452  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
1453  }
1454  } else {
1455  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
1456  }
1457  $this->form->setValuesByPost();
1458  $this->tpl->setContent($this->form->getHTML());
1459  }
1460 
1461 
1466  protected function initFormGeneralSettings()
1467  {
1468  global $ilSetting;
1469 
1470  $this->setSubTabs('settings');
1471  $this->tabs_gui->setTabActive('settings');
1472  $this->tabs_gui->setSubTabActive('general_settings');
1473 
1474  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1475  $this->form = new ilPropertyFormGUI();
1476  $this->form->setFormAction($this->ctrl->getFormAction($this, 'saveGeneralSettings'));
1477 
1478  $this->form->setTitle($this->lng->txt('general_settings'));
1479 
1480  $lua = new ilCheckboxInputGUI($this->lng->txt('enable_local_user_administration'), 'lua');
1481  $lua->setInfo($this->lng->txt('enable_local_user_administration_info'));
1482  $lua->setValue(1);
1483  $this->form->addItem($lua);
1484 
1485  $lrua = new ilCheckboxInputGUI($this->lng->txt('restrict_user_access'), 'lrua');
1486  $lrua->setInfo($this->lng->txt('restrict_user_access_info'));
1487  $lrua->setValue(1);
1488  $this->form->addItem($lrua);
1489 
1490  // enable alphabetical navigation in user administration
1491  $alph = new ilCheckboxInputGUI($this->lng->txt('user_adm_enable_alpha_nav'), 'user_adm_alpha_nav');
1492  //$alph->setInfo($this->lng->txt('restrict_user_access_info'));
1493  $alph->setValue(1);
1494  $this->form->addItem($alph);
1495 
1496  // account codes
1497  $code = new ilCheckboxInputGUI($this->lng->txt("user_account_code_setting"), "user_reactivate_code");
1498  $code->setInfo($this->lng->txt('user_account_code_setting_info'));
1499  $this->form->addItem($code);
1500 
1501  // delete own account
1502  $own = new ilCheckboxInputGUI($this->lng->txt("user_allow_delete_own_account"), "user_own_account");
1503  $this->form->addItem($own);
1504  $own_email = new ilEMailInputGUI($this->lng->txt("user_delete_own_account_notification_email"), "user_own_account_email");
1505  $own->addSubItem($own_email);
1506 
1507 
1508  // BEGIN SESSION SETTINGS
1509 
1510  // create session handling radio group
1511  $ssettings = new ilRadioGroupInputGUI($this->lng->txt('sess_mode'), 'session_handling_type');
1512 
1513  // first option, fixed session duration
1514  $fixed = new ilRadioOption($this->lng->txt('sess_fixed_duration'), ilSession::SESSION_HANDLING_FIXED);
1515 
1516  // create session reminder subform
1517  $cb = new ilCheckboxInputGUI($this->lng->txt("session_reminder"), "session_reminder_enabled");
1518  $expires = ilSession::getSessionExpireValue();
1519  $time = ilDatePresentation::secondsToString($expires, true);
1520  $cb->setInfo($this->lng->txt("session_reminder_info") . "<br />" .
1521  sprintf($this->lng->txt('session_reminder_session_duration'), $time));
1522  $fixed->addSubItem($cb);
1523 
1524  // add session handling to radio group
1525  $ssettings->addOption($fixed);
1526 
1527  // second option, session control
1528  $ldsh = new ilRadioOption($this->lng->txt('sess_load_dependent_session_handling'), ilSession::SESSION_HANDLING_LOAD_DEPENDENT);
1529 
1530  // add session control subform
1531  require_once('Services/Authentication/classes/class.ilSessionControl.php');
1532 
1533  // this is the max count of active sessions
1534  // that are getting started simlutanously
1535  $sub_ti = new ilTextInputGUI($this->lng->txt('session_max_count'), 'session_max_count');
1536  $sub_ti->setMaxLength(5);
1537  $sub_ti->setSize(5);
1538  $sub_ti->setInfo($this->lng->txt('session_max_count_info'));
1539  if (!$ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
1540  $sub_ti->setDisabled(true);
1541  }
1542  $ldsh->addSubItem($sub_ti);
1543 
1544  // after this (min) idle time the session can be deleted,
1545  // if there are further requests for new sessions,
1546  // but max session count is reached yet
1547  $sub_ti = new ilTextInputGUI($this->lng->txt('session_min_idle'), 'session_min_idle');
1548  $sub_ti->setMaxLength(5);
1549  $sub_ti->setSize(5);
1550  $sub_ti->setInfo($this->lng->txt('session_min_idle_info'));
1551  if (!$ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
1552  $sub_ti->setDisabled(true);
1553  }
1554  $ldsh->addSubItem($sub_ti);
1555 
1556  // after this (max) idle timeout the session expires
1557  // and become invalid, so it is not considered anymore
1558  // when calculating current count of active sessions
1559  $sub_ti = new ilTextInputGUI($this->lng->txt('session_max_idle'), 'session_max_idle');
1560  $sub_ti->setMaxLength(5);
1561  $sub_ti->setSize(5);
1562  $sub_ti->setInfo($this->lng->txt('session_max_idle_info'));
1563  if (!$ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
1564  $sub_ti->setDisabled(true);
1565  }
1566  $ldsh->addSubItem($sub_ti);
1567 
1568  // this is the max duration that can elapse between the first and the secnd
1569  // request to the system before the session is immidietly deleted
1570  $sub_ti = new ilTextInputGUI(
1571  $this->lng->txt('session_max_idle_after_first_request'),
1572  'session_max_idle_after_first_request'
1573  );
1574  $sub_ti->setMaxLength(5);
1575  $sub_ti->setSize(5);
1576  $sub_ti->setInfo($this->lng->txt('session_max_idle_after_first_request_info'));
1577  if (!$ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
1578  $sub_ti->setDisabled(true);
1579  }
1580  $ldsh->addSubItem($sub_ti);
1581 
1582  // add session control to radio group
1583  $ssettings->addOption($ldsh);
1584 
1585  // add radio group to form
1586  if ($ilSetting->get('session_allow_client_maintenance', ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE)) {
1587  // just shows the status wether the session
1588  //setting maintenance is allowed by setup
1589  $this->form->addItem($ssettings);
1590  } else {
1591  // just shows the status wether the session
1592  //setting maintenance is allowed by setup
1593  $ti = new ilNonEditableValueGUI($this->lng->txt('session_config'), "session_config");
1594  $ti->setValue($this->lng->txt('session_config_maintenance_disabled'));
1595  $ssettings->setDisabled(true);
1596  $ti->addSubItem($ssettings);
1597  $this->form->addItem($ti);
1598  }
1599 
1600  // END SESSION SETTINGS
1601 
1602 
1603  $this->lng->loadLanguageModule('ps');
1604 
1605  $pass = new ilFormSectionHeaderGUI();
1606  $pass->setTitle($this->lng->txt('ps_password_settings'));
1607  $this->form->addItem($pass);
1608 
1609  $check = new ilCheckboxInputGUI($this->lng->txt('ps_password_change_on_first_login_enabled'), 'password_change_on_first_login_enabled');
1610  $check->setInfo($this->lng->txt('ps_password_change_on_first_login_enabled_info'));
1611  $this->form->addItem($check);
1612 
1613  include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
1614 
1615  $check = new ilCheckboxInputGUI($this->lng->txt('ps_password_must_not_contain_loginame'), 'password_must_not_contain_loginame');
1616  $check->setInfo($this->lng->txt('ps_password_must_not_contain_loginame_info'));
1617  $this->form->addItem($check);
1618 
1619  $check = new ilCheckboxInputGUI($this->lng->txt('ps_password_chars_and_numbers_enabled'), 'password_chars_and_numbers_enabled');
1620  //$check->setOptionTitle($this->lng->txt('ps_password_chars_and_numbers_enabled'));
1621  $check->setInfo($this->lng->txt('ps_password_chars_and_numbers_enabled_info'));
1622  $this->form->addItem($check);
1623 
1624  $check = new ilCheckboxInputGUI($this->lng->txt('ps_password_special_chars_enabled'), 'password_special_chars_enabled');
1625  //$check->setOptionTitle($this->lng->txt('ps_password_special_chars_enabled'));
1626  $check->setInfo($this->lng->txt('ps_password_special_chars_enabled_info'));
1627  $this->form->addItem($check);
1628 
1629  $text = new ilNumberInputGUI($this->lng->txt('ps_password_min_length'), 'password_min_length');
1630  $text->setInfo($this->lng->txt('ps_password_min_length_info'));
1631  $text->setSize(1);
1632  $text->setMaxLength(2);
1633  $this->form->addItem($text);
1634 
1635  $text = new ilNumberInputGUI($this->lng->txt('ps_password_max_length'), 'password_max_length');
1636  $text->setInfo($this->lng->txt('ps_password_max_length_info'));
1637  $text->setSize(2);
1638  $text->setMaxLength(3);
1639  $this->form->addItem($text);
1640 
1641  $text = new ilNumberInputGUI($this->lng->txt('ps_password_uppercase_chars_num'), 'password_ucase_chars_num');
1642  $text->setInfo($this->lng->txt('ps_password_uppercase_chars_num_info'));
1643  $text->setMinValue(0);
1644  $text->setSize(2);
1645  $text->setMaxLength(3);
1646  $this->form->addItem($text);
1647 
1648  $text = new ilNumberInputGUI($this->lng->txt('ps_password_lowercase_chars_num'), 'password_lowercase_chars_num');
1649  $text->setInfo($this->lng->txt('ps_password_lowercase_chars_num_info'));
1650  $text->setMinValue(0);
1651  $text->setSize(2);
1652  $text->setMaxLength(3);
1653  $this->form->addItem($text);
1654 
1655  $text = new ilNumberInputGUI($this->lng->txt('ps_password_max_age'), 'password_max_age');
1656  $text->setInfo($this->lng->txt('ps_password_max_age_info'));
1657  $text->setSize(2);
1658  $text->setMaxLength(3);
1659  $this->form->addItem($text);
1660 
1661  // password assistance
1662  $cb = new ilCheckboxInputGUI($this->lng->txt("enable_password_assistance"), "password_assistance");
1663  $cb->setInfo($this->lng->txt("password_assistance_info"));
1664  $this->form->addItem($cb);
1665 
1666  $pass = new ilFormSectionHeaderGUI();
1667  $pass->setTitle($this->lng->txt('ps_security_protection'));
1668  $this->form->addItem($pass);
1669 
1670  $text = new ilNumberInputGUI($this->lng->txt('ps_login_max_attempts'), 'login_max_attempts');
1671  $text->setInfo($this->lng->txt('ps_login_max_attempts_info'));
1672  $text->setSize(1);
1673  $text->setMaxLength(2);
1674  $this->form->addItem($text);
1675 
1676  // prevent login from multiple pcs at the same time
1677  $objCb = new ilCheckboxInputGUI($this->lng->txt('ps_prevent_simultaneous_logins'), 'ps_prevent_simultaneous_logins');
1678  $objCb->setValue(1);
1679  $objCb->setInfo($this->lng->txt('ps_prevent_simultaneous_logins_info'));
1680  $this->form->addItem($objCb);
1681 
1682 
1683 
1684 
1685  $log = new ilFormSectionHeaderGUI();
1686  $log->setTitle($this->lng->txt('loginname_settings'));
1687  $this->form->addItem($log);
1688 
1689  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
1690  $chbChangeLogin->setValue(1);
1691  $this->form->addItem($chbChangeLogin);
1692  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
1693  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
1694  $chbCreateHistory->setValue(1);
1695 
1696  $chbChangeLogin->addSubItem($chbCreateHistory);
1697  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'reuse_of_loginnames');
1698  $chbReuseLoginnames->setValue(1);
1699  $chbReuseLoginnames->setInfo($this->lng->txt('reuse_of_loginnames_contained_in_history_info'));
1700 
1701  $chbChangeLogin->addSubItem($chbReuseLoginnames);
1702  $chbChangeBlockingTime = new ilNumberInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
1703  $chbChangeBlockingTime->allowDecimals(true);
1704  $chbChangeBlockingTime->setSuffix($this->lng->txt('days'));
1705  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
1706  $chbChangeBlockingTime->setSize(10);
1707  $chbChangeBlockingTime->setMaxLength(10);
1708  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
1709 
1710  $la = new ilCheckboxInputGUI($this->lng->txt('usr_letter_avatars'), 'letter_avatars');
1711  $la->setValue(1);
1712  $la->setInfo($this->lng->txt('usr_letter_avatars_info'));
1713  $this->form->addItem($la);
1714 
1715  $this->form->addCommandButton('saveGeneralSettings', $this->lng->txt('save'));
1716  }
1717 
1718 
1719 
1720 
1731  public function settingsObject()
1732  {
1733  global $tpl, $lng, $ilias, $ilTabs;
1734 
1735  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
1736  $lng->loadLanguageModule("administration");
1737  $lng->loadLanguageModule("mail");
1738  $lng->loadLanguageModule("chatroom");
1739  $this->setSubTabs('settings');
1740  $ilTabs->activateTab('settings');
1741  $ilTabs->activateSubTab('standard_fields');
1742 
1743  include_once("./Services/User/classes/class.ilUserFieldSettingsTableGUI.php");
1744  $tab = new ilUserFieldSettingsTableGUI($this, "settings");
1745  if ($this->confirm_change) {
1746  $tab->setConfirmChange();
1747  }
1748  $tpl->setContent($tab->getHTML());
1749  }
1750 
1751  public function confirmSavedObject()
1752  {
1753  $this->saveGlobalUserSettingsObject("save");
1754  }
1755 
1757  {
1758  include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
1759  include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
1760 
1761  global $ilias,$ilSetting;
1762 
1763  // see ilUserFieldSettingsTableGUI
1764  include_once("./Services/User/classes/class.ilUserProfile.php");
1765  $up = new ilUserProfile();
1766  $up->skipField("username");
1767  $field_properties = $up->getStandardFields();
1768  $profile_fields = array_keys($field_properties);
1769 
1770  $valid = true;
1771  foreach ($profile_fields as $field) {
1772  if ($_POST["chb"]["required_" . $field] &&
1773  !(int) $_POST['chb']['visib_reg_' . $field]
1774  ) {
1775  $valid = false;
1776  break;
1777  }
1778  }
1779 
1780  if (!$valid) {
1781  global $lng;
1782  ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
1783  $this->confirm_change = 1;
1784  $this->settingsObject();
1785  return;
1786  }
1787 
1788  // For the following fields, the required state can not be changed
1789  $fixed_required_fields = array(
1790  "firstname" => 1,
1791  "lastname" => 1,
1792  "upload" => 0,
1793  "password" => 0,
1794  "language" => 0,
1795  "skin_style" => 0,
1796  "hits_per_page" => 0,
1797  /*"show_users_online" => 0,*/
1798  "hide_own_online_status" => 0
1799  );
1800 
1801  // check if a course export state of any field has been added
1802  $privacy = ilPrivacySettings::_getInstance();
1803  if ($privacy->enabledCourseExport() == true &&
1804  $privacy->courseConfirmationRequired() == true &&
1805  $action != "save") {
1806  foreach ($profile_fields as $field) {
1807  if (!$ilias->getSetting("usr_settings_course_export_" . $field) && $_POST["chb"]["course_export_" . $field] == "1") {
1808  #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export'));
1809  #$this->confirm_change = 1;
1810  #$this->settingsObject();
1811  #return;
1812  }
1813  }
1814  }
1815  // Reset user confirmation
1816  if ($action == 'save') {
1817  include_once('Services/Membership/classes/class.ilMemberAgreement.php');
1819  }
1820 
1821  foreach ($profile_fields as $field) {
1822  // Enable disable searchable
1823  if (ilUserSearchOptions::_isSearchable($field)) {
1824  ilUserSearchOptions::_saveStatus($field, (bool) $_POST['chb']['searchable_' . $field]);
1825  }
1826 
1827  if (!$_POST["chb"]["visible_" . $field] && !$field_properties[$field]["visible_hide"]) {
1828  $ilias->setSetting("usr_settings_hide_" . $field, "1");
1829  } else {
1830  $ilias->deleteSetting("usr_settings_hide_" . $field);
1831  }
1832 
1833  if (!$_POST["chb"]["changeable_" . $field] && !$field_properties[$field]["changeable_hide"]) {
1834  $ilias->setSetting("usr_settings_disable_" . $field, "1");
1835  } else {
1836  $ilias->deleteSetting("usr_settings_disable_" . $field);
1837  }
1838 
1839  // registration visible
1840  if ((int) $_POST['chb']['visib_reg_' . $field] && !$field_properties[$field]["visib_reg_hide"]) {
1841  $ilSetting->set('usr_settings_visib_reg_' . $field, '1');
1842  } else {
1843  $ilSetting->set('usr_settings_visib_reg_' . $field, '0');
1844  }
1845 
1846  if ((int) $_POST['chb']['visib_lua_' . $field]) {
1847  $ilSetting->set('usr_settings_visib_lua_' . $field, '1');
1848  } else {
1849  $ilSetting->set('usr_settings_visib_lua_' . $field, '0');
1850  }
1851 
1852  if ((int) $_POST['chb']['changeable_lua_' . $field]) {
1853  $ilSetting->set('usr_settings_changeable_lua_' . $field, '1');
1854  } else {
1855  $ilSetting->set('usr_settings_changeable_lua_' . $field, '0');
1856  }
1857 
1858  if ($_POST["chb"]["export_" . $field] && !$field_properties[$field]["export_hide"]) {
1859  $ilias->setSetting("usr_settings_export_" . $field, "1");
1860  } else {
1861  $ilias->deleteSetting("usr_settings_export_" . $field);
1862  }
1863 
1864  // Course export/visibility
1865  if ($_POST["chb"]["course_export_" . $field] && !$field_properties[$field]["course_export_hide"]) {
1866  $ilias->setSetting("usr_settings_course_export_" . $field, "1");
1867  } else {
1868  $ilias->deleteSetting("usr_settings_course_export_" . $field);
1869  }
1870 
1871  // Group export/visibility
1872  if ($_POST["chb"]["group_export_" . $field] && !$field_properties[$field]["group_export_hide"]) {
1873  $ilias->setSetting("usr_settings_group_export_" . $field, "1");
1874  } else {
1875  $ilias->deleteSetting("usr_settings_group_export_" . $field);
1876  }
1877 
1878  $is_fixed = array_key_exists($field, $fixed_required_fields);
1879  if ($is_fixed && $fixed_required_fields[$field] || !$is_fixed && $_POST["chb"]["required_" . $field]) {
1880  $ilias->setSetting("require_" . $field, "1");
1881  } else {
1882  $ilias->deleteSetting("require_" . $field);
1883  }
1884  }
1885 
1886  if ($_POST["select"]["default_hits_per_page"]) {
1887  $ilias->setSetting("hits_per_page", $_POST["select"]["default_hits_per_page"]);
1888  }
1889 
1890  /*if ($_POST["select"]["default_show_users_online"])
1891  {
1892  $ilias->setSetting("show_users_online",$_POST["select"]["default_show_users_online"]);
1893  }*/
1894 
1895  if ($_POST["chb"]["export_preferences"]) {
1896  $ilias->setSetting("usr_settings_export_preferences", $_POST["chb"]["export_preferences"]);
1897  } else {
1898  $ilias->deleteSetting("usr_settings_export_preferences");
1899  }
1900 
1901  $ilias->setSetting('mail_incoming_mail', (int) $_POST['select']['default_mail_incoming_mail']);
1902  $ilias->setSetting('chat_osc_accept_msg', ilUtil::stripSlashes($_POST['select']['default_chat_osc_accept_msg']));
1903  $ilias->setSetting('bs_allow_to_contact_me', ilUtil::stripSlashes($_POST['select']['default_bs_allow_to_contact_me']));
1904  $ilias->setSetting('hide_own_online_status', ilUtil::stripSlashes($_POST['select']['default_hide_own_online_status']));
1905 
1906  ilUtil::sendSuccess($this->lng->txt("usr_settings_saved"));
1907  $this->settingsObject();
1908  }
1909 
1910 
1914  public function __buildUserFilterSelect()
1915  {
1916  $action[-1] = $this->lng->txt('all_users');
1917  $action[1] = $this->lng->txt('usr_active_only');
1918  $action[0] = $this->lng->txt('usr_inactive_only');
1919  $action[2] = $this->lng->txt('usr_limited_access_only');
1920  $action[3] = $this->lng->txt('usr_without_courses');
1921  $action[4] = $this->lng->txt('usr_filter_lastlogin');
1922  $action[5] = $this->lng->txt("usr_filter_coursemember");
1923  $action[6] = $this->lng->txt("usr_filter_groupmember");
1924  $action[7] = $this->lng->txt("usr_filter_role");
1925 
1926  return ilUtil::formSelect($_SESSION['user_filter'], "user_filter", $action, false, true);
1927  }
1928 
1935  public function downloadExportFileObject()
1936  {
1937  if (!isset($_POST["file"])) {
1938  $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
1939  }
1940 
1941  if (count($_POST["file"]) > 1) {
1942  $this->ilias->raiseError($this->lng->txt("select_max_one_item"), $this->ilias->error_obj->MESSAGE);
1943  }
1944 
1945  $file = basename($_POST["file"][0]);
1946 
1947  $export_dir = $this->object->getExportDirectory();
1948  ilUtil::deliverFile($export_dir . "/" . $file, $file);
1949  }
1950 
1955  {
1956  if (!isset($_POST["file"])) {
1957  $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
1958  }
1959 
1960  // display confirmation message
1961  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1962  $cgui = new ilConfirmationGUI();
1963  $cgui->setFormAction($this->ctrl->getFormAction($this));
1964  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1965  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteExportFile");
1966  $cgui->setConfirm($this->lng->txt("confirm"), "deleteExportFile");
1967 
1968  // BEGIN TABLE DATA
1969  foreach ($_POST["file"] as $file) {
1970  $cgui->addItem("file[]", $file, $file, ilObject::_getIcon($this->object->getId()), $this->lng->txt("obj_usrf"));
1971  }
1972 
1973  $this->tpl->setContent($cgui->getHTML());
1974  }
1975 
1976 
1981  {
1982  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
1983  }
1984 
1985 
1989  public function deleteExportFileObject()
1990  {
1991  $export_dir = $this->object->getExportDirectory();
1992  foreach ($_POST["file"] as $file) {
1993  $file = basename($file);
1994 
1995  $exp_file = $export_dir . "/" . $file;
1996  if (@is_file($exp_file)) {
1997  unlink($exp_file);
1998  }
1999  }
2000  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2001  }
2002 
2013  public function exportObject()
2014  {
2015  global $ilias, $ilCtrl;
2016 
2017  if ($_POST["cmd"]["export"]) {
2018  $this->object->buildExportFile($_POST["export_type"]);
2019  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2020  exit;
2021  }
2022 
2023  $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.usr_export.html', 'Services/User');
2024 
2025  $export_types = array(
2026  "userfolder_export_excel_x86",
2027  "userfolder_export_csv",
2028  "userfolder_export_xml"
2029  );
2030 
2031  // create table
2032  include_once("./Services/Table/classes/class.ilTableGUI.php");
2033  $tbl = new ilTableGUI();
2034 
2035  // load files templates
2036  $this->tpl->addBlockfile("EXPORT_FILES", "export_files", "tpl.table.html");
2037 
2038  // load template for table content data
2039  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.usr_export_file_row.html", "Services/User");
2040 
2041  $num = 0;
2042 
2043  $tbl->setTitle($this->lng->txt("userfolder_export_files"));
2044 
2045  $tbl->setHeaderNames(array("", $this->lng->txt("userfolder_export_file"),
2046  $this->lng->txt("userfolder_export_file_size"), $this->lng->txt("date") ));
2047  $tbl->setHeaderVars(array(), $ilCtrl->getParameterArray($this, "export"));
2048 
2049  $tbl->enabled["sort"] = false;
2050  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
2051 
2052  // control
2053  $tbl->setOrderColumn($_GET["sort_by"]);
2054  $tbl->setOrderDirection($_GET["sort_order"]);
2055  $tbl->setLimit($_GET["limit"]);
2056  $tbl->setOffset($_GET["offset"]);
2057  $tbl->setMaxCount($this->maxcount); // ???
2058 
2059 
2060  $this->tpl->setVariable("COLUMN_COUNTS", 4);
2061 
2062  // delete button
2063  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
2064  $this->tpl->setVariable("ALT_ARROW", $this->lng->txt("actions"));
2065  $this->tpl->setCurrentBlock("tbl_action_btn");
2066  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
2067  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
2068  $this->tpl->parseCurrentBlock();
2069 
2070  $this->tpl->setCurrentBlock("tbl_action_btn");
2071  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
2072  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
2073  $this->tpl->parseCurrentBlock();
2074 
2075  // footer
2076  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
2077  //$tbl->disable("footer");
2078 
2079  $export_files = $this->object->getExportFiles();
2080 
2081  $tbl->setMaxCount(count($export_files));
2082  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
2083 
2084  $tbl->render();
2085 
2086  if (count($export_files) > 0) {
2087  $i=0;
2088  foreach ($export_files as $exp_file) {
2089  $this->tpl->setCurrentBlock("tbl_content");
2090  $this->tpl->setVariable("TXT_FILENAME", $exp_file["filename"]);
2091 
2092  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
2093  $this->tpl->setVariable("CSS_ROW", $css_row);
2094 
2095  $this->tpl->setVariable("TXT_SIZE", $exp_file["filesize"]);
2096  $this->tpl->setVariable("CHECKBOX_ID", $exp_file["filename"]);
2097 
2098  $file_arr = explode("__", $exp_file["filename"]);
2099  $this->tpl->setVariable('TXT_DATE', ilDatePresentation::formatDate(new ilDateTime($file_arr[0], IL_CAL_UNIX)));
2100 
2101  $this->tpl->parseCurrentBlock();
2102  }
2103 
2104  $this->tpl->setCurrentBlock("selectall");
2105  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2106  $this->tpl->setVariable("CSS_ROW", $css_row);
2107  $this->tpl->parseCurrentBlock();
2108  } //if is_array
2109  /*
2110  else
2111 
2112  {
2113  $this->tpl->setCurrentBlock("notfound");
2114  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
2115  $this->tpl->setVariable("NUM_COLS", 3);
2116  $this->tpl->parseCurrentBlock();
2117  }
2118  */
2119 
2120  $this->tpl->parseCurrentBlock();
2121 
2122 
2123  foreach ($export_types as $export_type) {
2124  $this->tpl->setCurrentBlock("option");
2125  $this->tpl->setVariable("OPTION_VALUE", $export_type);
2126  $this->tpl->setVariable("OPTION_TEXT", $this->lng->txt($export_type));
2127  $this->tpl->parseCurrentBlock();
2128  }
2129 
2130  $this->tpl->setVariable("EXPORT_BUTTON", $this->lng->txt("create_export_file"));
2131  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2132  }
2133 
2134  protected function initNewAccountMailForm()
2135  {
2136  global $lng, $ilCtrl;
2137 
2138  $lng->loadLanguageModule("meta");
2139  $lng->loadLanguageModule("mail");
2140 
2141  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2142  $form = new ilPropertyFormGUI();
2143  $form->setFormAction($ilCtrl->getFormAction($this));
2144 
2145  $form->setTitleIcon(ilUtil::getImagePath("icon_mail.svg"));
2146  $form->setTitle($lng->txt("user_new_account_mail"));
2147  $form->setDescription($lng->txt("user_new_account_mail_desc"));
2148 
2149  $langs = $lng->getInstalledLanguages();
2150  foreach ($langs as $lang_key) {
2151  $amail = $this->object->_lookupNewAccountMail($lang_key);
2152 
2153  $title = $lng->txt("meta_l_" . $lang_key);
2154  if ($lang_key == $lng->getDefaultLanguage()) {
2155  $title .= " (" . $lng->txt("default") . ")";
2156  }
2157 
2159  $header->setTitle($title);
2160  $form->addItem($header);
2161 
2162  $subj = new ilTextInputGUI($lng->txt("subject"), "subject_" . $lang_key);
2163  // $subj->setRequired(true);
2164  $subj->setValue($amail["subject"]);
2165  $form->addItem($subj);
2166 
2167  $salg = new ilTextInputGUI($lng->txt("mail_salutation_general"), "sal_g_" . $lang_key);
2168  // $salg->setRequired(true);
2169  $salg->setValue($amail["sal_g"]);
2170  $form->addItem($salg);
2171 
2172  $salf = new ilTextInputGUI($lng->txt("mail_salutation_female"), "sal_f_" . $lang_key);
2173  // $salf->setRequired(true);
2174  $salf->setValue($amail["sal_f"]);
2175  $form->addItem($salf);
2176 
2177  $salm = new ilTextInputGUI($lng->txt("mail_salutation_male"), "sal_m_" . $lang_key);
2178  // $salm->setRequired(true);
2179  $salm->setValue($amail["sal_m"]);
2180  $form->addItem($salm);
2181 
2182  $body = new ilTextAreaInputGUI($lng->txt("message_content"), "body_" . $lang_key);
2183  // $body->setRequired(true);
2184  $body->setValue($amail["body"]);
2185  $body->setRows(10);
2186  $body->setCols(100);
2187  $form->addItem($body);
2188 
2189  $att = new ilFileInputGUI($lng->txt("attachment"), "att_" . $lang_key);
2190  $att->setAllowDeletion(true);
2191  if ($amail["att_file"]) {
2192  $att->setValue($amail["att_file"]);
2193  }
2194  $form->addItem($att);
2195  }
2196 
2197  $form->addCommandButton("saveNewAccountMail", $lng->txt("save"));
2198  $form->addCommandButton("cancelNewAccountMail", $lng->txt("cancel"));
2199 
2200  return $form;
2201  }
2202 
2206  public function newAccountMailObject()
2207  {
2208  global $lng;
2209 
2210  $this->setSubTabs('settings');
2211  $this->tabs_gui->setTabActive('settings');
2212  $this->tabs_gui->setSubTabActive('user_new_account_mail');
2213 
2214  $form = $this->initNewAccountMailForm();
2215 
2216  $ftpl = new ilTemplate('tpl.usrf_new_account_mail.html', true, true, 'Services/User');
2217  $ftpl->setVariable("FORM", $form->getHTML());
2218  unset($form);
2219 
2220  // placeholder help text
2221  $ftpl->setVariable("TXT_USE_PLACEHOLDERS", $lng->txt("mail_nacc_use_placeholder"));
2222  $ftpl->setVariable("TXT_MAIL_SALUTATION", $lng->txt("mail_nacc_salutation"));
2223  $ftpl->setVariable("TXT_FIRST_NAME", $lng->txt("firstname"));
2224  $ftpl->setVariable("TXT_LAST_NAME", $lng->txt("lastname"));
2225  $ftpl->setVariable("TXT_EMAIL", $lng->txt("email"));
2226  $ftpl->setVariable("TXT_LOGIN", $lng->txt("mail_nacc_login"));
2227  $ftpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
2228  $ftpl->setVariable("TXT_PASSWORD_BLOCK", $lng->txt("mail_nacc_pw_block"));
2229  $ftpl->setVariable("TXT_NOPASSWORD_BLOCK", $lng->txt("mail_nacc_no_pw_block"));
2230  $ftpl->setVariable("TXT_ADMIN_MAIL", $lng->txt("mail_nacc_admin_mail"));
2231  $ftpl->setVariable("TXT_ILIAS_URL", $lng->txt("mail_nacc_ilias_url"));
2232  $ftpl->setVariable("TXT_CLIENT_NAME", $lng->txt("mail_nacc_client_name"));
2233  $ftpl->setVariable("TXT_TARGET", $lng->txt("mail_nacc_target"));
2234  $ftpl->setVariable("TXT_TARGET_TITLE", $lng->txt("mail_nacc_target_title"));
2235  $ftpl->setVariable("TXT_TARGET_TYPE", $lng->txt("mail_nacc_target_type"));
2236  $ftpl->setVariable("TXT_TARGET_BLOCK", $lng->txt("mail_nacc_target_block"));
2237  $ftpl->setVariable("TXT_IF_TIMELIMIT", $lng->txt("mail_nacc_if_timelimit"));
2238  $ftpl->setVariable("TXT_TIMELIMIT", $lng->txt("mail_nacc_timelimit"));
2239 
2240  $this->tpl->setContent($ftpl->get());
2241  }
2242 
2243  public function cancelNewAccountMailObject()
2244  {
2245  $this->ctrl->redirect($this, "settings");
2246  }
2247 
2248  public function saveNewAccountMailObject()
2249  {
2250  global $lng;
2251 
2252  $langs = $lng->getInstalledLanguages();
2253  foreach ($langs as $lang_key) {
2254  $this->object->_writeNewAccountMail(
2255  $lang_key,
2256  ilUtil::stripSlashes($_POST["subject_" . $lang_key]),
2257  ilUtil::stripSlashes($_POST["sal_g_" . $lang_key]),
2258  ilUtil::stripSlashes($_POST["sal_f_" . $lang_key]),
2259  ilUtil::stripSlashes($_POST["sal_m_" . $lang_key]),
2260  ilUtil::stripSlashes($_POST["body_" . $lang_key])
2261  );
2262 
2263  if ($_FILES["att_" . $lang_key]["tmp_name"]) {
2264  $this->object->_updateAccountMailAttachment(
2265  $lang_key,
2266  $_FILES["att_" . $lang_key]["tmp_name"],
2267  $_FILES["att_" . $lang_key]["name"]
2268  );
2269  }
2270 
2271  if ($_POST["att_" . $lang_key . "_delete"]) {
2272  $this->object->_deleteAccountMailAttachment($lang_key);
2273  }
2274  }
2275 
2276  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2277  $this->ctrl->redirect($this, "newAccountMail");
2278  }
2279 
2280  public function getAdminTabs()
2281  {
2282  $this->getTabs();
2283  }
2284 
2290  public function getTabs()
2291  {
2292  include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
2293 
2294  global $rbacsystem;
2295 
2296  if ($rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
2297  $this->tabs_gui->addTarget(
2298  "usrf",
2299  $this->ctrl->getLinkTarget($this, "view"),
2300  array("view","delete","resetFilter", "userAction", ""),
2301  "",
2302  ""
2303  );
2304 
2305  $this->tabs_gui->addTarget(
2306  "search_user_extended",
2307  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', ''),
2308  array(),
2309  "ilrepositorysearchgui",
2310  ""
2311  );
2312  }
2313 
2314  if ($rbacsystem->checkAccess("write", $this->object->getRefId())) {
2315  $this->tabs_gui->addTarget(
2316  "settings",
2317  $this->ctrl->getLinkTarget($this, "generalSettings"),
2318  array('settings','generalSettings','listUserDefinedField','newAccountMail')
2319  );
2320 
2321  $this->tabs_gui->addTarget(
2322  "export",
2323  $this->ctrl->getLinkTarget($this, "export"),
2324  "export",
2325  "",
2326  ""
2327  );
2328 
2329  /* deprecated, JF 27 May 2013
2330  if(ilObjUserTracking::_enabledLearningProgress() &&
2331  ilObjUserTracking::_enabledUserRelatedData())
2332  {
2333  $tabs_gui->addTarget("learning_progress",
2334  $this->ctrl->getLinkTarget($this, "learningProgress"), "learningProgress", "", "");
2335  }
2336  */
2337  }
2338 
2339  if ($rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
2340  $this->tabs_gui->addTarget(
2341  "perm_settings",
2342  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
2343  array("perm","info","owner"),
2344  'ilpermissiongui'
2345  );
2346  }
2347  }
2348 
2349 
2353  public function setSubTabs($a_tab)
2354  {
2355  global $rbacsystem,$ilUser;
2356 
2357  switch ($a_tab) {
2358  case "settings":
2359  $this->tabs_gui->addSubTabTarget(
2360  'general_settings',
2361  $this->ctrl->getLinkTarget($this, 'generalSettings'),
2362  'generalSettings',
2363  get_class($this)
2364  );
2365  $this->tabs_gui->addSubTabTarget(
2366  "standard_fields",
2367  $this->ctrl->getLinkTarget($this, 'settings'),
2368  array("settings", "saveGlobalUserSettings"),
2369  get_class($this)
2370  );
2371  $this->tabs_gui->addSubTabTarget(
2372  "user_defined_fields",
2373  $this->ctrl->getLinkTargetByClass("ilcustomuserfieldsgui", "listUserDefinedFields"),
2374  "listUserDefinedFields",
2375  get_class($this)
2376  );
2377  $this->tabs_gui->addSubTabTarget(
2378  "user_new_account_mail",
2379  $this->ctrl->getLinkTarget($this, 'newAccountMail'),
2380  "newAccountMail",
2381  get_class($this)
2382  );
2383 
2384  $this->tabs_gui->addSubTabTarget(
2385  "starting_points",
2386  $this->ctrl->getLinkTargetByClass("iluserstartingpointgui", "startingPoints"),
2387  "startingPoints",
2388  get_class($this)
2389  );
2390 
2391 
2392  $this->tabs_gui->addSubTabTarget(
2393  "user_profile_info",
2394  $this->ctrl->getLinkTargetByClass("ilUserProfileInfoSettingsGUI", ''),
2395  "",
2396  "ilUserProfileInfoSettingsGUI"
2397  );
2398 
2399  #$this->tabs_gui->addSubTab("account_codes", $this->lng->txt("user_account_codes"),
2400  # $this->ctrl->getLinkTargetByClass("ilaccountcodesgui"));
2401  break;
2402  }
2403  }
2404 
2406  {
2407  global $ilSetting;
2408 
2409  $show_blocking_time_in_days = (int) $ilSetting->get('loginname_change_blocking_time') / 86400;
2410 
2411  $this->initLoginSettingsForm();
2412  $this->loginSettingsForm->setValuesByArray(array(
2413  'allow_change_loginname' => (bool) $ilSetting->get('allow_change_loginname'),
2414  'create_history_loginname' => (bool) $ilSetting->get('create_history_loginname'),
2415  'reuse_of_loginnames' => (bool) $ilSetting->get('reuse_of_loginnames'),
2416  'loginname_change_blocking_time' => (float) $show_blocking_time_in_days
2417  ));
2418 
2419  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
2420  }
2421 
2422  private function initLoginSettingsForm()
2423  {
2424  $this->setSubTabs('settings');
2425  $this->tabs_gui->setTabActive('settings');
2426  $this->tabs_gui->setSubTabActive('loginname_settings');
2427 
2428  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2429  $this->loginSettingsForm = new ilPropertyFormGUI;
2430  $this->loginSettingsForm->setFormAction($this->ctrl->getFormAction($this, 'saveLoginnameSettings'));
2431  $this->loginSettingsForm->setTitle($this->lng->txt('loginname_settings'));
2432 
2433  $chbChangeLogin = new ilCheckboxInputGUI($this->lng->txt('allow_change_loginname'), 'allow_change_loginname');
2434  $chbChangeLogin->setValue(1);
2435  $this->loginSettingsForm->addItem($chbChangeLogin);
2436  $chbCreateHistory = new ilCheckboxInputGUI($this->lng->txt('history_loginname'), 'create_history_loginname');
2437  $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
2438  $chbCreateHistory->setValue(1);
2439  $chbChangeLogin->addSubItem($chbCreateHistory);
2440  $chbReuseLoginnames = new ilCheckboxInputGUI($this->lng->txt('reuse_of_loginnames_contained_in_history'), 'reuse_of_loginnames');
2441  $chbReuseLoginnames->setValue(1);
2442  $chbReuseLoginnames->setInfo($this->lng->txt('reuse_of_loginnames_contained_in_history_info'));
2443  $chbChangeLogin->addSubItem($chbReuseLoginnames);
2444  $chbChangeBlockingTime = new ilNumberInputGUI($this->lng->txt('loginname_change_blocking_time'), 'loginname_change_blocking_time');
2445  $chbChangeBlockingTime->allowDecimals(true);
2446  $chbChangeBlockingTime->setSuffix($this->lng->txt('days'));
2447  $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
2448  $chbChangeBlockingTime->setSize(10);
2449  $chbChangeBlockingTime->setMaxLength(10);
2450  $chbChangeLogin->addSubItem($chbChangeBlockingTime);
2451 
2452  $this->loginSettingsForm->addCommandButton('saveLoginnameSettings', $this->lng->txt('save'));
2453  }
2454 
2456  {
2457  global $ilUser, $ilSetting;
2458 
2459  $this->initLoginSettingsForm();
2460  if ($this->loginSettingsForm->checkInput()) {
2461  $valid = true;
2462 
2463  if (!strlen($this->loginSettingsForm->getInput('loginname_change_blocking_time'))) {
2464  $valid = false;
2465  $this->loginSettingsForm->getItemByPostVar('loginname_change_blocking_time')
2466  ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
2467  }
2468 
2469  if ($valid) {
2470  $save_blocking_time_in_seconds = (int) $this->loginSettingsForm->getInput('loginname_change_blocking_time') * 86400;
2471 
2472  $ilSetting->set('allow_change_loginname', (int) $this->loginSettingsForm->getInput('allow_change_loginname'));
2473  $ilSetting->set('create_history_loginname', (int) $this->loginSettingsForm->getInput('create_history_loginname'));
2474  $ilSetting->set('reuse_of_loginnames', (int) $this->loginSettingsForm->getInput('reuse_of_loginnames'));
2475  $ilSetting->set('loginname_change_blocking_time', (int) $save_blocking_time_in_seconds);
2476 
2477  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
2478  } else {
2479  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2480  }
2481  } else {
2482  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2483  }
2484  $this->loginSettingsForm->setValuesByPost();
2485 
2486  $this->tpl->setVariable('ADM_CONTENT', $this->loginSettingsForm->getHTML());
2487  }
2488 
2492  public static function _goto($a_user)
2493  {
2494  global $ilAccess, $ilErr, $lng;
2495 
2496  $a_target = USER_FOLDER_ID;
2497 
2498  if ($ilAccess->checkAccess("read", "", $a_target)) {
2499  ilUtil::redirect("ilias.php?baseClass=ilAdministrationGUI&ref_id=" . $a_target . "&jmpToUser=" . $a_user);
2500  exit;
2501  } else {
2502  if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
2503  ilUtil::sendFailure(sprintf(
2504  $lng->txt("msg_no_perm_read_item"),
2506  ), true);
2508  }
2509  }
2510  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
2511  }
2512 
2516  public function jumpToUserObject()
2517  {
2518  global $ilCtrl;
2519 
2520  if (((int) $_GET["jmpToUser"]) > 0 && ilObject::_lookupType((int) $_GET["jmpToUser"]) == "usr") {
2521  $ilCtrl->setParameterByClass("ilobjusergui", "obj_id", (int) $_GET["jmpToUser"]);
2522  $ilCtrl->redirectByClass("ilobjusergui", "view");
2523  }
2524  }
2525 
2529  public function searchResultHandler($a_usr_ids, $a_cmd)
2530  {
2531  if (!count((array) $a_usr_ids)) {
2532  ilUtil::sendFailure($this->lng->txt('select_one'));
2533  return false;
2534  }
2535 
2536  $_POST['id'] = $a_usr_ids;
2537 
2538  // no real confirmation here
2539  if (stristr($a_cmd, "export")) {
2540  $cmd = $a_cmd . "Object";
2541  return $this->$cmd();
2542  }
2543 
2544  $_POST['selectedAction'] = $a_cmd;
2545  return $this->showActionConfirmation($a_cmd, true);
2546  }
2547 
2548  public function getUserMultiCommands($a_search_form = false)
2549  {
2550  global $rbacsystem, $ilUser;
2551 
2552  // see searchResultHandler()
2553  if ($a_search_form) {
2554  $cmds = array(
2555  'activate' => $this->lng->txt('activate'),
2556  'deactivate' => $this->lng->txt('deactivate'),
2557  'accessRestrict' => $this->lng->txt('accessRestrict'),
2558  'accessFree' => $this->lng->txt('accessFree')
2559  );
2560 
2561  if ($rbacsystem->checkAccess('delete', $this->object->getRefId())) {
2562  $cmds["delete"] = $this->lng->txt("delete");
2563  }
2564  }
2565  // show confirmation
2566  else {
2567  $cmds = array(
2568  'activateUsers' => $this->lng->txt('activate'),
2569  'deactivateUsers' => $this->lng->txt('deactivate'),
2570  'restrictAccess' => $this->lng->txt('accessRestrict'),
2571  'freeAccess' => $this->lng->txt('accessFree')
2572  );
2573 
2574  if ($rbacsystem->checkAccess('delete', $this->object->getRefId())) {
2575  $cmds["deleteUsers"] = $this->lng->txt("delete");
2576  }
2577  }
2578 
2579  // no confirmation needed
2580  $export_types = array("userfolder_export_excel_x86", "userfolder_export_csv", "userfolder_export_xml");
2581  foreach ($export_types as $type) {
2582  $cmd = explode("_", $type);
2583  $cmd = array_pop($cmd);
2584  $cmds['usrExport' . ucfirst($cmd)] = $this->lng->txt('export') . ' - ' .
2585  $this->lng->txt($type);
2586  }
2587 
2588  // check if current user may send mails
2589  include_once "Services/Mail/classes/class.ilMail.php";
2590  $mail = new ilMail($ilUser->getId());
2591  if ($rbacsystem->checkAccess('internal_mail', $mail->getMailObjectReferenceId())) {
2592  $cmds["mail"] = $this->lng->txt("send_mail");
2593  }
2594 
2595  $cmds['addToClipboard'] = $this->lng->txt('clipboard_add_btn');
2596 
2597  return $cmds;
2598  }
2599 
2600  public function usrExportX86Object()
2601  {
2602  $user_ids = $this->getActionUserIds();
2603  if (!$user_ids) {
2604  ilUtil::sendFailure($this->lng->txt('select_one'));
2605  return $this->viewObject();
2606  }
2607  $this->object->buildExportFile("userfolder_export_excel_x86", $user_ids);
2608  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2609  }
2610 
2611  public function usrExportCsvObject()
2612  {
2613  $user_ids = $this->getActionUserIds();
2614  if (!$user_ids) {
2615  ilUtil::sendFailure($this->lng->txt('select_one'));
2616  return $this->viewObject();
2617  }
2618  $this->object->buildExportFile("userfolder_export_csv", $user_ids);
2619  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2620  }
2621 
2622  public function usrExportXmlObject()
2623  {
2624  $user_ids = $this->getActionUserIds();
2625  if (!$user_ids) {
2626  ilUtil::sendFailure($this->lng->txt('select_one'));
2627  return $this->viewObject();
2628  }
2629  $this->object->buildExportFile("userfolder_export_xml", $user_ids);
2630  $this->ctrl->redirectByClass("ilobjuserfoldergui", "export");
2631  }
2632 
2633  public function mailObject()
2634  {
2635  global $ilUser;
2636 
2637  $user_ids = $this->getActionUserIds();
2638  if (!$user_ids) {
2639  ilUtil::sendFailure($this->lng->txt('select_one'));
2640  return $this->viewObject();
2641  }
2642 
2643  // remove existing (temporary) lists
2644  include_once "Services/Contact/classes/class.ilMailingLists.php";
2645  $list = new ilMailingLists($ilUser);
2646  $list->deleteTemporaryLists();
2647 
2648  // create (temporary) mailing list
2649  include_once "Services/Contact/classes/class.ilMailingList.php";
2650  $list = new ilMailingList($ilUser);
2652  $list->setTitle("-TEMPORARY SYSTEM LIST-");
2653  $list->setDescription("-USER ACCOUNTS MAIL-");
2654  $list->setCreateDate(date("Y-m-d H:i:s"));
2655  $list->insert();
2656  $list_id = $list->getId();
2657 
2658  // after list has been saved...
2659  foreach ($user_ids as $user_id) {
2660  $list->assignUser($user_id);
2661  }
2662 
2663  include_once "Services/Mail/classes/class.ilFormatMail.php";
2664  $umail = new ilFormatMail($ilUser->getId());
2665  $mail_data = $umail->getSavedData();
2666 
2667  if (!is_array($mail_data)) {
2668  $mail_data = array("user_id" => $ilUser->getId());
2669  }
2670 
2671  // ???
2672  // $mail_data = $umail->appendSearchResult(array('#il_ml_'.$list_id), 'to');
2673 
2674  $umail->savePostData(
2675  $mail_data['user_id'],
2676  $mail_data['attachments'],
2677  '#il_ml_' . $list_id, // $mail_data['rcp_to'],
2678  $mail_data['rcp_cc'],
2679  $mail_data['rcp_bcc'],
2680  $mail_data['m_type'],
2681  $mail_data['m_email'],
2682  $mail_data['m_subject'],
2683  $mail_data['m_message'],
2684  $mail_data['use_placeholders'],
2685  $mail_data['tpl_ctx_id'],
2686  $mail_data['tpl_ctx_params']
2687  );
2688 
2689  require_once 'Services/Mail/classes/class.ilMailFormCall.php';
2692  $this,
2693  '',
2694  array(),
2695  array(
2696  'type' => 'search_res'
2697  )
2698  )
2699  );
2700  }
2701 
2702  public function addToExternalSettingsForm($a_form_id)
2703  {
2704  switch ($a_form_id) {
2706 
2707  include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2708  $security = ilSecuritySettings::_getInstance();
2709 
2710  $fields = array();
2711 
2712  $subitems = array(
2713  'ps_password_change_on_first_login_enabled' => array($security->isPasswordChangeOnFirstLoginEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
2714  'ps_password_must_not_contain_loginame' => array((bool) $security->getPasswordMustNotContainLoginnameStatus(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
2715  'ps_password_chars_and_numbers_enabled' => array($security->isPasswordCharsAndNumbersEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
2716  'ps_password_special_chars_enabled' => array($security->isPasswordSpecialCharsEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL),
2717  'ps_password_min_length' => (int) $security->getPasswordMinLength(),
2718  'ps_password_max_length' => (int) $security->getPasswordMaxLength(),
2719  'ps_password_uppercase_chars_num' => (int) $security->getPasswordNumberOfUppercaseChars(),
2720  'ps_password_lowercase_chars_num' => (int) $security->getPasswordNumberOfLowercaseChars(),
2721  'ps_password_max_age' => (int) $security->getPasswordMaxAge()
2722  );
2723  $fields['ps_password_settings'] = array(null, null, $subitems);
2724 
2725  $subitems = array(
2726  'ps_login_max_attempts' => (int) $security->getLoginMaxAttempts(),
2727  'ps_prevent_simultaneous_logins' => array($security->isPreventionOfSimultaneousLoginsEnabled(), ilAdministrationSettingsFormHandler::VALUE_BOOL)
2728  );
2729  $fields['ps_security_protection'] = array(null, null, $subitems);
2730 
2731  return array(array("generalSettings", $fields));
2732  }
2733  }
2734 
2735  protected function addToClipboardObject()
2736  {
2737  $users = (array) $_POST['id'];
2738  if (!count($users)) {
2739  ilUtil::sendFailure($this->lng->txt('select_one'), true);
2740  $this->ctrl->redirect($this, 'view');
2741  }
2742  include_once './Services/User/classes/class.ilUserClipboard.php';
2743  $clip = ilUserClipboard::getInstance($GLOBALS['ilUser']->getId());
2744  $clip->add($users);
2745  $clip->save();
2746 
2747  ilUtil::sendSuccess($this->lng->txt('clipboard_user_added'), true);
2748  $this->ctrl->redirect($this, 'view');
2749  }
2750 } // END class.ilObjUserFolderGUI
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet ...
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
setSubTabs($a_tab)
set sub tabs
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Add some data
This class represents an option in a radio group.
GUI class for account codes.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
__buildUserFilterSelect()
build select form to distinguish between active and non-active users
showActionConfirmation($action, $a_from_search=false)
display activation confirmation screen
const IL_CAL_DATETIME
static getInstance($a_usr_id)
Get singelton instance.
$_SESSION["AccountId"]
getImportDir()
get user import directory name
This class represents a property form user interface.
$action
$type
$_GET["client_id"]
$tbl
Definition: example_048.php:81
const IL_USER_IMPORT
static searchRolesByMailboxAddressList( $a_address_list, ilMailRfc822AddressParserFactory $parserFactory=null, ilMailRfc822AddressParser $parser=null)
Finds all role ids that match the specified user friendly role mailbox address list.
static _goto($a_user)
goto target group
This class represents a section header in a property form.
This class represents a file property in a property form.
confirmdeleteObject()
confirm delete Object
$code
Definition: example_050.php:99
const IL_IMPORT_FAILURE
This class represents a text property in a property form.
importUserRoleAssignmentObject()
display form for user import
$valid
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(!array_key_exists('StateId', $_REQUEST)) $id
setValue($a_value)
Set Value.
activateUsersObject()
Activate users.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
initFormGeneralSettings()
init general settings form
Class ilUserProfile.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
chooseLetterObject()
Choose first letter.
settingsObject()
Global user settings.
Learning progress account list for user administration.
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
This class represents a checkbox property in a property form.
static getRoleMailboxAddress( $a_role_id, $is_localize=true, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
Returns the mailbox address of a role.
setFormAction($a_formaction)
Set FormAction.
const IL_EXTRACT_ROLES
static _lookupTitle($a_id)
lookup object title
$from
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor public.
const IL_IMPORT_WARNING
viewObject()
list childs of current object
Class ilTableGUI.
exportObject()
Global user settings.
This class represents a email property in a property form.
const SESSION_HANDLING_FIXED
const IL_CAL_UNIX
setInfo($a_info)
Set Info.
static _reset()
Reset all.
importCancelledObject()
import cancelled
static _getAssignUsersStatus($a_role_id)
importUserFormObject()
display form for user import
generalSettingsObject()
Show user account general settings.
Auto completion class for user lists.
restrictAccessObject()
Restrict access.
This class represents a date/time property in a property form.
User profile info settings UI class.
global $ilCtrl
Definition: ilias.php:18
allowDecimals($a_value)
Toggle Decimals.
getActionUserIds()
Get selected items for table action.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
setValue($a_value)
Set Value.
$time
Definition: cron.php:21
const IL_IMPORT_SUCCESS
resetFilterObject()
Reset filter (note: this function existed before data table filter has been introduced.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
TableGUI class for user administration.
static updateLimitLog($a_new_value)
Log max session setting.
This class represents a hidden form property in a property form.
prepareOutput($a_show_subobjects=true)
prepare output
static _enabledLearningProgress()
check wether learing progress is enabled or not
Class ilCustomUserFieldsGUI.
This class represents a property in a property form.
deactivateUsersObject()
Deactivate users.
Class UserMail this class handles user mails.
static _saveStatus($a_key, $a_enabled)
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
saveGeneralSettingsObject()
Save user account settings.
if(isset($_POST['submit'])) $form
$rule
Definition: showstats.php:43
static _lookupNewAccountMail($a_lang)
Class ilUserStartingPointGUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
confirmDeleteExportFileObject()
confirmation screen for export file deletion
This class handles base functions for mail handling.
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
cancelDeleteExportFileObject()
cancel deletion of export files
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
deleteExportFileObject()
delete export files
setValue($a_value)
Set Value.
getUserMultiCommands($a_search_form=false)
special template class to simplify handling of ITX/PEAR
$text
Definition: errorreport.php:18
This class represents a text property in a property form.
showActions($with_subobjects=false)
show possible action (form buttons)
Date and time handling
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
newAccountMailObject()
new account mail administration
setMaxLength($a_maxlength)
Set Max Length.
$n
Definition: RandomTest.php:85
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
confirmdeactivateObject()
Set the selected users inactive.
jumpToUserObject()
Jump to edit screen for user.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
$users
Definition: authpage.php:44
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
downloadExportFileObject()
Download selected export files.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
showPossibleSubObjects()
show possible subobjects (pulldown menu) overwritten to prevent displaying of role templates in local...
initAccessRestrictionForm($a_from_search=false)
const IL_VERIFY
static getDataDir()
get data directory (outside webspace)
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
This class represents a non editable value in a property form.
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
static getInstance()
Singelton get instance.
This class represents a text area property in a property form.
static getFirstLettersOfLastnames()
Get first letters of all lastnames.
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
searchResultHandler($a_usr_ids, $a_cmd)
Handles multi command from repository search gui.
$ret
Definition: parser.php:6
Class ilObjUserFolderGUI.
$i
Definition: disco.tpl.php:19
const USER_FOLDER_ID
Class ilObjUserFolder.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
static getLogger($a_component_id)
Get component logger.
const SESSION_HANDLING_LOAD_DEPENDENT
static _getInstance()
Get instance of ilPrivacySettings.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
setValue($a_value)
Set Value.
static redirect($a_script)
static getSessionExpireValue()
Returns the session expiration value.
initUserImportForm()
Init user import form.
confirmactivateObject()
Set the selected users active.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static _getInstance()
Get instance of ilSecuritySettings.
$key
Definition: croninfo.php:18
setSuffixes($a_suffixes)
Set Accepted Suffixes.
$_POST["username"]
viewObject($reset_filter=false)
list users
const IL_UPDATE_ON_CONFLICT
setRequired($a_required)
Set Required.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
const IL_IGNORE_ON_CONFLICT
setAccessRestrictionObject($a_form=null, $a_from_search=false)
Confirmation screen class.
addUserAutoCompleteObject()
Show auto complete results.