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