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