ILIAS  release_7 Revision v7.30-3-g800a261c036
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
18{
19 public $ctrl;
20
21 protected $log;
22
24 public $object;
25
30
35 public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output = true)
36 {
37 global $DIC;
38
39 $ilCtrl = $DIC['ilCtrl'];
40 // TODO: move this to class.ilias.php
41 define(
42 'USER_FOLDER_ID',
43 7
44 );
45 $this->type = "usrf";
47 $a_data,
48 $a_id,
49 $a_call_by_reference,
50 false
51 );
52
53 $this->lng->loadLanguageModule('search');
54 $this->lng->loadLanguageModule("user");
55 $this->lng->loadLanguageModule('tos');
56 $ilCtrl->saveParameter(
57 $this,
58 "letter"
59 );
60
61 $this->user_settings_config = new ilUserSettingsConfig();
62
63 $this->log = ilLoggerFactory::getLogger("user");
64 }
65
66 public function setUserOwnerId($a_id)
67 {
68 $this->user_owner_id = $a_id;
69 }
70
71 public function getUserOwnerId()
72 {
73 return $this->user_owner_id ? $this->user_owner_id : USER_FOLDER_ID;
74 }
75
76 public function executeCommand()
77 {
78 global $DIC;
79
80 $ilTabs = $DIC['ilTabs'];
81 $access = $DIC->access();
82
83 $next_class = $this->ctrl->getNextClass($this);
84 $cmd = $this->ctrl->getCmd();
85 $this->prepareOutput();
86
87 switch ($next_class) {
88 case 'ilusertablegui':
89 include_once("./Services/User/classes/class.ilUserTableGUI.php");
90 $u_table = new ilUserTableGUI(
91 $this,
92 "view"
93 );
94 $u_table->initFilter();
95 $this->ctrl->setReturn(
96 $this,
97 'view'
98 );
99 $this->ctrl->forwardCommand($u_table);
100 break;
101
102 case 'ilpermissiongui':
103 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
104 $perm_gui = new ilPermissionGUI($this);
105 $ret = &$this->ctrl->forwardCommand($perm_gui);
106 break;
107
108 case 'ilrepositorysearchgui':
109
110 if (!$access->checkRbacOrPositionPermissionAccess(
111 "read_users",
114 )) {
115 $this->ilias->raiseError(
116 $this->lng->txt("permission_denied"),
117 $this->ilias->error_obj->MESSAGE
118 );
119 }
120
121 include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
122 $user_search = new ilRepositorySearchGUI();
123 $user_search->setTitle($this->lng->txt("search_user_extended")); // #17502
124 $user_search->enableSearchableCheck(false);
125 $user_search->setUserLimitations(false);
126 $user_search->setCallback(
127 $this,
128 'searchResultHandler',
129 $this->getUserMultiCommands(true)
130 );
131 $user_search->addUserAccessFilterCallable(array($this, "searchUserAccessFilterCallable"));
132 $this->tabs_gui->setTabActive('search_user_extended');
133 $this->ctrl->setReturn(
134 $this,
135 'view'
136 );
137 $ret = &$this->ctrl->forwardCommand($user_search);
138 break;
139
140 case 'ilaccountcodesgui':
141 $this->tabs_gui->setTabActive('settings');
142 $this->setSubTabs("settings");
143 $ilTabs->activateSubTab("account_codes");
144 include_once("./Services/User/classes/class.ilAccountCodesGUI.php");
145 $acc = new ilAccountCodesGUI($this->ref_id);
146 $this->ctrl->forwardCommand($acc);
147 break;
148
149 case 'ilcustomuserfieldsgui':
150 $this->tabs_gui->setTabActive('settings');
151 $this->setSubTabs("settings");
152 $ilTabs->activateSubTab("user_defined_fields");
153 include_once("./Services/User/classes/class.ilCustomUserFieldsGUI.php");
154 $cf = new ilCustomUserFieldsGUI();
155 $this->ctrl->forwardCommand($cf);
156 break;
157
158 case 'iluserstartingpointgui':
159 $this->tabs_gui->setTabActive('settings');
160 $this->setSubTabs("settings");
161 $ilTabs->activateSubTab("starting_points");
162 include_once("./Services/User/classes/class.ilUserStartingPointGUI.php");
163 $cf = new ilUserStartingPointGUI($this->ref_id);
164 $this->ctrl->forwardCommand($cf);
165 break;
166
167 case 'iluserprofileinfosettingsgui':
168 $this->tabs_gui->setTabActive('settings');
169 $this->setSubTabs("settings");
170 $ilTabs->activateSubTab("user_profile_info");
172 $this->ctrl->forwardCommand($ps);
173 break;
174
175 default:
176 if (!$cmd) {
177 $cmd = "view";
178 }
179 $cmd .= "Object";
180 $this->$cmd();
181
182 break;
183 }
184 return true;
185 }
186
187 public function learningProgressObject()
188 {
189 global $DIC;
190
191 $rbacsystem = $DIC['rbacsystem'];
192 $tpl = $DIC['tpl'];
193
194 // deprecated JF 27 May 2013
195 exit();
196
197 if (!$rbacsystem->checkAccess(
198 "read",
199 $this->object->getRefId()
200 ) ||
203 $this->ilias->raiseError(
204 $this->lng->txt("permission_denied"),
205 $this->ilias->error_obj->MESSAGE
206 );
207 }
208
209 include_once "Services/User/classes/class.ilUserLPTableGUI.php";
210 $tbl = new ilUserLPTableGUI(
211 $this,
212 "learningProgress",
213 $this->object->getRefId()
214 );
215
216 $tpl->setContent($tbl->getHTML());
217 }
218
223 public function resetFilterObject()
224 {
225 include_once("./Services/User/classes/class.ilUserTableGUI.php");
226 $utab = new ilUserTableGUI(
227 $this,
228 "view"
229 );
230 $utab->resetOffset();
231 $utab->resetFilter();
232
233 // from "old" implementation
234 $this->viewObject(true);
235 }
236
240 public function addUserObject()
241 {
242 global $DIC;
243
244 $ilCtrl = $DIC['ilCtrl'];
245
246 $ilCtrl->setParameterByClass(
247 "ilobjusergui",
248 "new_type",
249 "usr"
250 );
251 $ilCtrl->redirectByClass(
252 array("iladministrationgui", "ilobjusergui"),
253 "create"
254 );
255 }
256
260 public function applyFilterObject()
261 {
262 global $DIC;
263
264 $ilTabs = $DIC['ilTabs'];
265
266 include_once("./Services/User/classes/class.ilUserTableGUI.php");
267 $utab = new ilUserTableGUI(
268 $this,
269 "view"
270 );
271 $utab->resetOffset();
272 $utab->writeFilterToSession();
273 $this->viewObject();
274 $ilTabs->activateTab("usrf");
275 }
276
281 public function viewObject($reset_filter = false)
282 {
283 global $DIC;
284
285 $rbacsystem = $DIC['rbacsystem'];
286 $ilToolbar = $DIC->toolbar();
287 $tpl = $DIC['tpl'];
288 $ilSetting = $DIC['ilSetting'];
289 $access = $DIC->access();
290 $user_filter = null;
291
292 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
293
294 if ($rbacsystem->checkAccess('create_usr', $this->object->getRefId())
295 || $rbacsystem->checkAccess('cat_administrate_users', $this->object->getRefId())) {
296 $button = ilLinkButton::getInstance();
297 $button->setCaption("usr_add");
298 $button->setUrl(
299 $this->ctrl->getLinkTarget(
300 $this,
301 "addUser"
302 )
303 );
304 $ilToolbar->addButtonInstance($button);
305
306 $button = ilLinkButton::getInstance();
307 $button->setCaption("import_users");
308 $button->setUrl(
309 $this->ctrl->getLinkTarget(
310 $this,
311 "importUserForm"
312 )
313 );
314 $ilToolbar->addButtonInstance($button);
315 }
316
317 if (
318 !$access->checkAccess(
319 'read_users',
320 '',
322 ) &&
323 $access->checkRbacOrPositionPermissionAccess(
324 'read_users',
327 )) {
329 $user_filter = $access->filterUserIdsByRbacOrPositionOfCurrentUser(
330 'read_users',
333 $users
334 );
335 }
336
337 // alphabetical navigation
338 if ((int) $ilSetting->get('user_adm_alpha_nav')) {
339 if (count($ilToolbar->getItems()) > 0) {
340 $ilToolbar->addSeparator();
341 }
342
343 // alphabetical navigation
344 include_once("./Services/Form/classes/class.ilAlphabetInputGUI.php");
345 $ai = new ilAlphabetInputGUI(
346 "",
347 "first"
348 );
349 include_once("./Services/User/classes/class.ilObjUser.php");
350 $ai->setLetters(ilObjUser::getFirstLettersOfLastnames($user_filter));
351 $ai->setParentCommand(
352 $this,
353 "chooseLetter"
354 );
355 $ai->setHighlighted($_GET["letter"]);
356 $ilToolbar->addInputItem(
357 $ai,
358 true
359 );
360 }
361
362 include_once("./Services/User/classes/class.ilUserTableGUI.php");
363 $utab = new ilUserTableGUI(
364 $this,
365 "view",
367 false
368 );
369 $utab->addFilterItemValue(
370 'user_ids',
371 $user_filter
372 );
373 $utab->getItems();
374
375 $tpl->setContent($utab->getHTML());
376 }
377
381 protected function addUserAutoCompleteObject()
382 {
383 include_once './Services/User/classes/class.ilUserAutoComplete.php';
384 $auto = new ilUserAutoComplete();
385 $auto->addUserAccessFilterCallable([$this, 'filterUserIdsByRbacOrPositionOfCurrentUser']);
386 $auto->setSearchFields(array('login', 'firstname', 'lastname', 'email', 'second_email'));
387 $auto->enableFieldSearchableCheck(false);
388 $auto->setMoreLinkAvailable(true);
389
390 if (($_REQUEST['fetchall'])) {
391 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
392 }
393
394 echo $auto->getList($_REQUEST['term']);
395 exit();
396 }
397
401 public function filterUserIdsByRbacOrPositionOfCurrentUser(array $user_ids)
402 {
403 global $DIC;
404
405 $access = $DIC->access();
406 return $access->filterUserIdsByRbacOrPositionOfCurrentUser(
407 'read_users',
410 $user_ids
411 );
412 }
413
419 public function chooseLetterObject()
420 {
421 global $DIC;
422
423 $ilCtrl = $DIC['ilCtrl'];
424
425 $ilCtrl->redirect(
426 $this,
427 "view"
428 );
429 }
430
436 public function showActions($with_subobjects = false)
437 {
438 global $DIC;
439
440 $rbacsystem = $DIC['rbacsystem'];
441
442 $operations = array();
443 //var_dump($this->actions);
444 if ($this->actions == "") {
445 $d = array(
446 "delete" => array("name" => "delete", "lng" => "delete"),
447 "activate" => array("name" => "activate", "lng" => "activate"),
448 "deactivate" => array("name" => "deactivate", "lng" => "deactivate"),
449 "accessRestrict" => array("name" => "accessRestrict", "lng" => "accessRestrict"),
450 "accessFree" => array("name" => "accessFree", "lng" => "accessFree"),
451 "export" => array("name" => "export", "lng" => "export")
452 );
453 } else {
455 }
456 foreach ($d as $row) {
457 if ($rbacsystem->checkAccess(
458 $row["name"],
459 $this->object->getRefId()
460 )) {
461 $operations[] = $row;
462 }
463 }
464
465 if (count($operations) > 0) {
466 $select = "<select name=\"selectedAction\">\n";
467 foreach ($operations as $val) {
468 $select .= "<option value=\"" . $val["name"] . "\"";
469 if (strcmp(
470 $_POST["selectedAction"],
471 $val["name"]
472 ) == 0) {
473 $select .= " selected=\"selected\"";
474 }
475 $select .= ">";
476 $select .= $this->lng->txt($val["lng"]);
477 $select .= "</option>";
478 }
479 $select .= "</select>";
480 $this->tpl->setCurrentBlock("tbl_action_select");
481 $this->tpl->setVariable(
482 "SELECT_ACTION",
483 $select
484 );
485 $this->tpl->setVariable(
486 "BTN_NAME",
487 "userAction"
488 );
489 $this->tpl->setVariable(
490 "BTN_VALUE",
491 $this->lng->txt("submit")
492 );
493 $this->tpl->parseCurrentBlock();
494 }
495
496 if ($with_subobjects === true) {
497 $subobjs = $this->showPossibleSubObjects();
498 }
499
500 if ((count($operations) > 0) or $subobjs === true) {
501 $this->tpl->setCurrentBlock("tbl_action_row");
502 $this->tpl->setVariable(
503 "COLUMN_COUNTS",
504 count($this->data["cols"])
505 );
506 $this->tpl->setVariable(
507 "IMG_ARROW",
508 ilUtil::getImagePath("arrow_downright.svg")
509 );
510 $this->tpl->setVariable(
511 "ALT_ARROW",
512 $this->lng->txt("actions")
513 );
514 $this->tpl->parseCurrentBlock();
515 }
516 }
517
523 public function showPossibleSubObjects()
524 {
525 global $DIC;
526
527 $rbacsystem = $DIC['rbacsystem'];
528
529 $d = $this->objDefinition->getCreatableSubObjects($this->object->getType());
530
531 if (!$rbacsystem->checkAccess(
532 'create_usr',
533 $this->object->getRefId()
534 )) {
535 unset($d["usr"]);
536 }
537
538 if (count($d) > 0) {
539 foreach ($d as $row) {
540 $count = 0;
541 if ($row["max"] > 0) {
542 //how many elements are present?
543 for ($i = 0; $i < count($this->data["ctrl"]); $i++) {
544 if ($this->data["ctrl"][$i]["type"] == $row["name"]) {
545 $count++;
546 }
547 }
548 }
549 if ($row["max"] == "" || $count < $row["max"]) {
550 $subobj[] = $row["name"];
551 }
552 }
553 }
554
555 if (is_array($subobj)) {
556 //build form
557 $opts = ilUtil::formSelect(
558 12,
559 "new_type",
560 $subobj
561 );
562 $this->tpl->setCurrentBlock("add_object");
563 $this->tpl->setVariable(
564 "SELECT_OBJTYPE",
565 $opts
566 );
567 $this->tpl->setVariable(
568 "BTN_NAME",
569 "create"
570 );
571 $this->tpl->setVariable(
572 "TXT_ADD",
573 $this->lng->txt("add")
574 );
575 $this->tpl->parseCurrentBlock();
576
577 return true;
578 }
579
580 return false;
581 }
582
584 {
585 $this->ctrl->redirect(
586 $this,
587 'view'
588 );
589 }
590
591 public function cancelSearchActionObject()
592 {
593 $this->ctrl->redirectByClass(
594 'ilrepositorysearchgui',
595 'showSearchResults'
596 );
597 }
598
603 public function confirmactivateObject()
604 {
605 global $DIC;
606
607 $ilUser = $DIC['ilUser'];
608
609 if (!$this->checkUserManipulationAccessBool()) {
610 $this->ilias->raiseError(
611 $this->lng->txt("msg_no_perm_write"),
612 $this->ilias->error_obj->WARNING
613 );
614 }
615
616 // FOR ALL SELECTED OBJECTS
617 foreach ($this->getActionUserIds() as $id) {
619 $id,
620 false
621 );
622 if ($obj instanceof \ilObjUser) {
623 $obj->setActive(
624 true,
625 $ilUser->getId()
626 );
627 $obj->update();
628 }
629 }
630
631 ilUtil::sendSuccess(
632 $this->lng->txt("user_activated"),
633 true
634 );
635
636 if ($_POST["frsrch"]) {
637 $this->ctrl->redirectByClass(
638 'ilRepositorySearchGUI',
639 'show'
640 );
641 } else {
642 $this->ctrl->redirect(
643 $this,
644 "view"
645 );
646 }
647 }
648
653 public function confirmdeactivateObject()
654 {
655 global $DIC;
656
657 $ilUser = $DIC['ilUser'];
658
659 if (!$this->checkUserManipulationAccessBool()) {
660 $this->ilias->raiseError(
661 $this->lng->txt("msg_no_perm_write"),
662 $this->ilias->error_obj->WARNING
663 );
664 }
665 // FOR ALL SELECTED OBJECTS
666 foreach ($this->getActionUserIds() as $id) {
668 $id,
669 false
670 );
671 if ($obj instanceof \ilObjUser) {
672 $obj->setActive(
673 false,
674 $ilUser->getId()
675 );
676 $obj->update();
677 }
678 }
679
680 // Feedback
681 ilUtil::sendSuccess(
682 $this->lng->txt("user_deactivated"),
683 true
684 );
685
686 if ($_POST["frsrch"]) {
687 $this->ctrl->redirectByClass(
688 'ilRepositorySearchGUI',
689 'show'
690 );
691 } else {
692 $this->ctrl->redirect(
693 $this,
694 "view"
695 );
696 }
697 }
698
702 protected function confirmaccessFreeObject()
703 {
704 global $DIC;
705
706 $rbacsystem = $DIC['rbacsystem'];
707 $ilUser = $DIC['ilUser'];
708
709 if (!$this->checkUserManipulationAccessBool()) {
710 $this->ilias->raiseError(
711 $this->lng->txt("msg_no_perm_write"),
712 $this->ilias->error_obj->WARNING
713 );
714 }
715
716 foreach ($this->getActionUserIds() as $id) {
718 $id,
719 false
720 );
721 if ($obj instanceof \ilObjUser) {
722 $obj->setTimeLimitUnlimited(1);
723 $obj->setTimeLimitFrom("");
724 $obj->setTimeLimitUntil("");
725 $obj->setTimeLimitMessage(0);
726 $obj->update();
727 }
728 }
729
730 // Feedback
731 ilUtil::sendSuccess(
732 $this->lng->txt("access_free_granted"),
733 true
734 );
735
736 if ($_POST["frsrch"]) {
737 $this->ctrl->redirectByClass(
738 'ilRepositorySearchGUI',
739 'show'
740 );
741 } else {
742 $this->ctrl->redirect(
743 $this,
744 "view"
745 );
746 }
747 }
748
749 public function setAccessRestrictionObject($a_form = null, $a_from_search = false)
750 {
751 if (!$a_form) {
752 $a_form = $this->initAccessRestrictionForm($a_from_search);
753 }
754 $this->tpl->setContent($a_form->getHTML());
755
756 // #10963
757 return true;
758 }
759
764 protected function initAccessRestrictionForm($a_from_search = false)
765 {
766 $user_ids = $this->getActionUserIds();
767 if (!$user_ids) {
768 ilUtil::sendFailure($this->lng->txt('select_one'));
769 return $this->viewObject();
770 }
771
772 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
773 $form = new ilPropertyFormGUI();
774 $form->setTitle($this->lng->txt("time_limit_add_time_limit_for_selected"));
775 $form->setFormAction(
776 $this->ctrl->getFormAction(
777 $this,
778 "confirmaccessRestrict"
779 )
780 );
781
782 $from = new ilDateTimeInputGUI(
783 $this->lng->txt("access_from"),
784 "from"
785 );
786 $from->setShowTime(true);
787 $from->setRequired(true);
788 $form->addItem($from);
789
790 $to = new ilDateTimeInputGUI(
791 $this->lng->txt("access_until"),
792 "to"
793 );
794 $to->setRequired(true);
795 $to->setShowTime(true);
796 $form->addItem($to);
797
798 $form->addCommandButton(
799 "confirmaccessRestrict",
800 $this->lng->txt("confirm")
801 );
802 $form->addCommandButton(
803 "view",
804 $this->lng->txt("cancel")
805 );
806
807 foreach ($user_ids as $user_id) {
808 $ufield = new ilHiddenInputGUI("id[]");
809 $ufield->setValue($user_id);
810 $form->addItem($ufield);
811 }
812
813 // return to search?
814 if ($a_from_search || $_POST["frsrch"]) {
815 $field = new ilHiddenInputGUI("frsrch");
816 $field->setValue(1);
817 $form->addItem($field);
818 }
819
820 return $form;
821 }
822
828 protected function confirmaccessRestrictObject()
829 {
830 global $DIC;
831
832 $ilUser = $DIC->user();
833
834 $form = $this->initAccessRestrictionForm();
835 if (!$form->checkInput()) {
836 return $this->setAccessRestrictionObject($form);
837 }
838
839 $timefrom = $form->getItemByPostVar("from")->getDate()->get(IL_CAL_UNIX);
840 $timeuntil = $form->getItemByPostVar("to")->getDate()->get(IL_CAL_UNIX);
841 if ($timeuntil <= $timefrom) {
842 ilUtil::sendFailure($this->lng->txt("time_limit_not_valid"));
843 return $this->setAccessRestrictionObject($form);
844 }
845
846 if (!$this->checkUserManipulationAccessBool()) {
847 $this->ilias->raiseError(
848 $this->lng->txt("msg_no_perm_write"),
849 $this->ilias->error_obj->WARNING
850 );
851 }
852 foreach ($this->getActionUserIds() as $id) {
854 $id,
855 false
856 );
857 if ($obj instanceof \ilObjUser) {
858 $obj->setTimeLimitUnlimited(0);
859 $obj->setTimeLimitFrom($timefrom);
860 $obj->setTimeLimitUntil($timeuntil);
861 $obj->setTimeLimitMessage(0);
862 $obj->update();
863 }
864 }
865 ilUtil::sendSuccess(
866 $this->lng->txt("access_restricted"),
867 true
868 );
869
870 if ($_POST["frsrch"]) {
871 $this->ctrl->redirectByClass(
872 'ilRepositorySearchGUI',
873 'show'
874 );
875 } else {
876 $this->ctrl->redirect(
877 $this,
878 "view"
879 );
880 }
881 }
882
887 public function confirmdeleteObject()
888 {
889 global $DIC;
890
891 $rbacsystem = $DIC['rbacsystem'];
892 $ilCtrl = $DIC['ilCtrl'];
893 $ilUser = $DIC['ilUser'];
894
895 // FOR NON_REF_OBJECTS WE CHECK ACCESS ONLY OF PARENT OBJECT ONCE
896 if (!$rbacsystem->checkAccess(
897 'delete',
898 $this->object->getRefId()
899 )) {
901 $this->lng->txt("msg_no_perm_delete"),
902 true
903 );
904 $ilCtrl->redirect(
905 $this,
906 "view"
907 );
908 }
909
910 if (in_array(
911 $ilUser->getId(),
912 $_POST["id"]
913 )) {
914 $this->ilias->raiseError(
915 $this->lng->txt("msg_no_delete_yourself"),
916 $this->ilias->error_obj->WARNING
917 );
918 }
919
920 // FOR ALL SELECTED OBJECTS
921 foreach ($_POST["id"] as $id) {
922 // instatiate correct object class (usr)
923 $obj = &$this->ilias->obj_factory->getInstanceByObjId($id);
924 $obj->delete();
925 }
926
927 // Feedback
928 ilUtil::sendSuccess(
929 $this->lng->txt("user_deleted"),
930 true
931 );
932
933 if ($_POST["frsrch"]) {
934 $this->ctrl->redirectByClass(
935 'ilRepositorySearchGUI',
936 'show'
937 );
938 } else {
939 $this->ctrl->redirect(
940 $this,
941 "view"
942 );
943 }
944 }
945
950 protected function getActionUserIds()
951 {
952 global $DIC;
953 $access = $DIC->access();
954
955 if ($_POST["select_cmd_all"]) {
956 include_once("./Services/User/classes/class.ilUserTableGUI.php");
957 $utab = new ilUserTableGUI(
958 $this,
959 "view",
961 false
962 );
963
964 if (!$access->checkAccess(
965 'read_users',
966 '',
968 ) &&
969 $access->checkRbacOrPositionPermissionAccess(
970 'read_users',
973 )) {
975 $filtered_users = $access->filterUserIdsByRbacOrPositionOfCurrentUser(
976 'read_users',
979 $users
980 );
981
982 $utab->addFilterItemValue(
983 "user_ids",
984 $filtered_users
985 );
986 }
987
988 return $utab->getUserIdsForFilter();
989 } else {
990 return $access->filterUserIdsByRbacOrPositionOfCurrentUser(
991 'read_users',
994 (array) $_POST['id']
995 );
996 }
997 }
998
1004 {
1005 global $DIC;
1006
1007 $access = $DIC->access();
1008 return $access->checkRbacOrPositionPermissionAccess(
1009 'write',
1012 );
1013 }
1014
1018 public function showActionConfirmation($action, $a_from_search = false)
1019 {
1020 global $DIC;
1021
1022 $ilTabs = $DIC['ilTabs'];
1023
1024 $user_ids = $this->getActionUserIds();
1025 if (!$user_ids) {
1026 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_checkbox'));
1027 $this->viewObject();
1028 return;
1029 }
1030
1031 if (!$a_from_search) {
1032 $ilTabs->activateTab("obj_usrf");
1033 } else {
1034 $ilTabs->activateTab("search_user_extended");
1035 }
1036
1037 if (strcmp(
1038 $action,
1039 "accessRestrict"
1040 ) == 0) {
1041 return $this->setAccessRestrictionObject(
1042 null,
1043 $a_from_search
1044 );
1045 }
1046 if (strcmp(
1047 $action,
1048 "mail"
1049 ) == 0) {
1050 return $this->mailObject();
1051 }
1052
1053 unset($this->data);
1054
1055 if (!$a_from_search) {
1056 $cancel = "cancelUserFolderAction";
1057 } else {
1058 $cancel = "cancelSearchAction";
1059 }
1060
1061 // display confirmation message
1062 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1063 $cgui = new ilConfirmationGUI();
1064 $cgui->setFormAction($this->ctrl->getFormAction($this));
1065 $cgui->setHeaderText($this->lng->txt("info_" . $action . "_sure"));
1066 $cgui->setCancel(
1067 $this->lng->txt("cancel"),
1068 $cancel
1069 );
1070 $cgui->setConfirm(
1071 $this->lng->txt("confirm"),
1072 "confirm" . $action
1073 );
1074
1075 if ($a_from_search) {
1076 $cgui->addHiddenItem(
1077 "frsrch",
1078 1
1079 );
1080 }
1081
1082 foreach ($user_ids as $id) {
1083 $user = new ilObjUser($id);
1084
1085 $login = $user->getLastLogin();
1086 if (!$login) {
1087 $login = $this->lng->txt("never");
1088 } else {
1090 new ilDateTime(
1091 $login,
1093 )
1094 );
1095 }
1096
1097 $caption = $user->getFullname() . " (" . $user->getLogin() . ")" . ", " .
1098 $user->getEmail() . " - " . $this->lng->txt("last_login") . ": " . $login;
1099
1100 $cgui->addItem(
1101 "id[]",
1102 $id,
1103 $caption
1104 );
1105 }
1106
1107 $this->tpl->setContent($cgui->getHTML());
1108
1109 return true;
1110 }
1111
1115 public function deleteUsersObject()
1116 {
1117 $_POST["selectedAction"] = "delete";
1118 if (in_array($this->user->getId(), $this->getActionUserIds())) {
1119 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_no_delete_yourself'));
1120 $this->viewObject();
1121 return;
1122 }
1123 $this->showActionConfirmation($_POST["selectedAction"]);
1124 }
1125
1129 public function activateUsersObject()
1130 {
1131 $_POST["selectedAction"] = "activate";
1132 $this->showActionConfirmation($_POST["selectedAction"]);
1133 }
1134
1138 public function deactivateUsersObject()
1139 {
1140 $_POST["selectedAction"] = "deactivate";
1141 if (in_array($this->user->getId(), $this->getActionUserIds())) {
1142 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_deactivate_yourself'));
1143 $this->viewObject();
1144 return;
1145 }
1146 $this->showActionConfirmation($_POST["selectedAction"]);
1147 }
1148
1152 public function restrictAccessObject()
1153 {
1154 $_POST["selectedAction"] = "accessRestrict";
1155 $this->showActionConfirmation($_POST["selectedAction"]);
1156 }
1157
1161 public function freeAccessObject()
1162 {
1163 $_POST["selectedAction"] = "accessFree";
1164 $this->showActionConfirmation($_POST["selectedAction"]);
1165 }
1166
1167 public function userActionObject()
1168 {
1169 $this->showActionConfirmation($_POST["selectedAction"]);
1170 }
1171
1175 public function importUserFormObject()
1176 {
1177 global $DIC;
1178
1179 $tpl = $DIC['tpl'];
1180 $rbacsystem = $DIC['rbacsystem'];
1181 $ilCtrl = $DIC->ctrl();
1182 $access = $DIC->access();
1183
1184 $this->tabs_gui->clearTargets();
1185 $this->tabs_gui->setBackTarget(
1186 $this->lng->txt('usrf'),
1187 $ilCtrl->getLinkTarget(
1188 $this,
1189 'view'
1190 )
1191 );
1192 if (
1193 !$rbacsystem->checkAccess('create_usr', $this->object->getRefId())
1194 && !$access->checkAccess('cat_administrate_users', '', $this->object->getRefId())
1195 ) {
1196 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"));
1197 return;
1198 }
1199 $this->initUserImportForm();
1200 $tpl->setContent($this->form->getHTML());
1201 }
1202
1207 public function initUserImportForm()
1208 {
1209 global $DIC;
1210
1211 $lng = $DIC['lng'];
1212 $ilCtrl = $DIC['ilCtrl'];
1213
1214 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1215 $this->form = new ilPropertyFormGUI();
1216
1217 // Import File
1218 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
1219 $fi = new ilFileInputGUI(
1220 $lng->txt('import_file'),
1221 'importFile'
1222 );
1223 $fi->setSuffixes(['xml']);
1224 $fi->setRequired(true);
1225 $this->form->addItem($fi);
1226
1227 $this->form->addCommandButton(
1228 'importUserRoleAssignment',
1229 $lng->txt('import')
1230 );
1231 $this->form->addCommandButton(
1232 'importCancelled',
1233 $lng->txt('cancel')
1234 );
1235
1236 $this->form->setTitle($lng->txt('import_users'));
1237 $this->form->setFormAction($ilCtrl->getFormAction($this));
1238 }
1239
1244 public function importCancelledObject()
1245 {
1246 global $DIC;
1247 $filesystem = $DIC->filesystem()->storage();
1248
1249 // purge user import directory
1250 $import_dir = $this->getImportDir();
1251 if ($filesystem->hasDir($import_dir)) {
1252 $filesystem->deleteDir($import_dir);
1253 }
1254
1255 if (strtolower($_GET["baseClass"]) == 'iladministrationgui') {
1256 $this->ctrl->redirect(
1257 $this,
1258 "view"
1259 );
1260 } else {
1261 $this->ctrl->redirectByClass(
1262 'ilobjcategorygui',
1263 'listUsers'
1264 );
1265 }
1266 }
1267
1271 public function getImportDir()
1272 {
1273 // For each user session a different directory must be used to prevent
1274 // that one user session overwrites the import data that another session
1275 // is currently importing.
1276 global $DIC;
1277
1278 $ilUser = $DIC->user();
1279
1280 $importDir = 'user_import/usr_' . $ilUser->getId() . '_' . mb_substr(session_id(), 0, 8);
1281
1282 return $importDir;
1283 }
1284
1289 {
1290 global $DIC;
1291
1292 $tpl = $DIC->ui()->mainTemplate();
1293 $ilCtrl = $DIC->ctrl();
1294 $renderer = $DIC->ui()->renderer();
1295
1296 $this->tabs_gui->clearTargets();
1297 $this->tabs_gui->setBackTarget(
1298 $this->lng->txt('usrf'),
1299 $ilCtrl->getLinkTarget(
1300 $this,
1301 'view'
1302 )
1303 );
1304
1305 $this->initUserImportForm();
1306 if ($this->form->checkInput()) {
1307 $xml_file = $this->handleUploadedFiles();
1308 //importParser needs the full path to xml file
1309 $xml_file_full_path = ilUtil::getDataDir() . '/' . $xml_file;
1310
1311 list($form, $message) = $this->initUserRoleAssignmentForm($xml_file_full_path);
1312
1313 $tpl->setContent($message . $renderer->render($form));
1314 } else {
1315 $this->form->setValuesByPost();
1316 $tpl->setContent($this->form->getHtml());
1317 }
1318 }
1319
1320 private function initUserRoleAssignmentForm($xml_file_full_path) : array
1321 {
1322 global $DIC;
1323
1324 $ilUser = $DIC->user();
1325 $rbacreview = $DIC->rbac()->review();
1326 $rbacsystem = $DIC->rbac()->system();
1327 $ui = $DIC->ui()->factory();
1328
1329 $importParser = new ilUserImportParser(
1330 $xml_file_full_path,
1331 IL_VERIFY
1332 );
1333 $importParser->startParsing();
1334
1335 $message = $this->verifyXmlData($importParser);
1336
1337 $xml_file_name = explode(
1338 "/",
1339 $xml_file_full_path
1340 );
1341 $roles_import_filename = $ui->input()->field()->text($this->lng->txt("import_file"))
1342 ->withDisabled(true)
1343 ->withValue(end($xml_file_name));
1344
1345 $roles_import_count = $ui->input()->field()->numeric($this->lng->txt("num_users"))
1346 ->withDisabled(true)
1347 ->withValue($importParser->getUserCount());
1348
1349 $importParser = new ilUserImportParser(
1350 $xml_file_full_path,
1352 );
1353 $importParser->startParsing();
1354 // Extract the roles
1355 $roles = $importParser->getCollectedRoles();
1356
1357 // get global roles
1358 $all_gl_roles = $rbacreview->getRoleListByObject(ROLE_FOLDER_ID);
1359 $gl_roles = [];
1360 $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1361 foreach ($all_gl_roles as $obj_data) {
1362 // check assignment permission if called from local admin
1363 if ($this->object->getRefId() != USER_FOLDER_ID) {
1364 if (!in_array(
1366 $roles_of_user
1367 ) && !ilObjRole::_getAssignUsersStatus($obj_data['obj_id'])) {
1368 continue;
1369 }
1370 }
1371 // exclude anonymous role from list
1372 if ($obj_data["obj_id"] != ANONYMOUS_ROLE_ID) {
1373 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
1374 if ($obj_data["obj_id"] != SYSTEM_ROLE_ID or in_array(
1376 $roles_of_user
1377 )) {
1378 $gl_roles[$obj_data["obj_id"]] = $obj_data["title"];
1379 }
1380 }
1381 }
1382
1383 // global roles
1384 $got_globals = false;
1385 $global_selects = [];
1386 foreach ($roles as $role_id => $role) {
1387 if ($role["type"] == "Global") {
1388 if (!$got_globals) {
1389 $got_globals = true;
1390
1391 $global_roles_assignment_info = $ui->input()->field()->text(
1392 $this->lng->txt("roles_of_import_global")
1393 )
1394 ->withDisabled(true)
1395 ->withValue($this->lng->txt("assign_global_role"));
1396 }
1397
1398 //select options for new form input to still have both ids
1399 $select_options = [];
1400 foreach ($gl_roles as $key => $value) {
1401 $select_options[$role_id . "-" . $key] = $value;
1402 }
1403
1404 // pre selection for role
1405 $pre_select = array_search(
1406 $role["name"],
1407 $select_options
1408 );
1409 if (!$pre_select) {
1410 switch ($role["name"]) {
1411 case "Administrator": // ILIAS 2/3 Administrator
1412 $pre_select = array_search(
1413 "Administrator",
1414 $select_options
1415 );
1416 break;
1417
1418 case "Autor": // ILIAS 2 Author
1419 $pre_select = array_search(
1420 "User",
1421 $select_options
1422 );
1423 break;
1424
1425 case "Lerner": // ILIAS 2 Learner
1426 $pre_select = array_search(
1427 "User",
1428 $select_options
1429 );
1430 break;
1431
1432 case "Gast": // ILIAS 2 Guest
1433 $pre_select = array_search(
1434 "Guest",
1435 $select_options
1436 );
1437 break;
1438
1439 default:
1440 $pre_select = array_search(
1441 "User",
1442 $select_options
1443 );
1444 break;
1445 }
1446 }
1447
1448 $select = $ui->input()->field()->select(
1449 $role["name"],
1450 $select_options
1451 )
1452 ->withValue($pre_select)
1453 ->withRequired(true);
1454 array_push(
1455 $global_selects,
1456 $select
1457 );
1458 }
1459 }
1460
1461 // Check if local roles need to be assigned
1462 $got_locals = false;
1463 foreach ($roles as $role_id => $role) {
1464 if ($role["type"] == "Local") {
1465 $got_locals = true;
1466 break;
1467 }
1468 }
1469
1470 if ($got_locals) {
1471 $local_roles_assignment_info = $ui->input()->field()->text($this->lng->txt("roles_of_import_local"))
1472 ->withDisabled(true)
1473 ->withValue($this->lng->txt("assign_local_role"));
1474
1475 // get local roles
1476 if ($this->object->getRefId() == USER_FOLDER_ID) {
1477 // The import function has been invoked from the user folder
1478 // object. In this case, we show only matching roles,
1479 // because the user folder object is considered the parent of all
1480 // local roles and may contains thousands of roles on large ILIAS
1481 // installations.
1482 $loc_roles = [];
1483
1484 $roleMailboxSearch = new \ilRoleMailboxSearch(new \ilMailRfc822AddressParserFactory());
1485 foreach ($roles as $role_id => $role) {
1486 if ($role["type"] == "Local") {
1487 $searchName = (substr(
1488 $role['name'],
1489 0,
1490 1
1491 ) == '#') ? $role['name'] : '#' . $role['name'];
1492 $matching_role_ids = $roleMailboxSearch->searchRoleIdsByAddressString($searchName);
1493 foreach ($matching_role_ids as $mid) {
1494 if (!in_array(
1495 $mid,
1496 $loc_roles
1497 )) {
1498 $loc_roles[] = $mid;
1499 }
1500 }
1501 }
1502 }
1503 } else {
1504 // The import function has been invoked from a locally
1505 // administrated category. In this case, we show all roles
1506 // contained in the subtree of the category.
1507 $loc_roles = $rbacreview->getAssignableRolesInSubtree($this->object->getRefId());
1508 }
1509 $l_roles = [];
1510
1511 // create a search array with .
1512 $l_roles_mailbox_searcharray = array();
1513 foreach ($loc_roles as $key => $loc_role) {
1514 // fetch context path of role
1515 $rolf = $rbacreview->getFoldersAssignedToRole(
1516 $loc_role,
1517 true
1518 );
1519
1520 // only process role folders that are not set to status "deleted"
1521 // and for which the user has write permissions.
1522 // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
1523 // (The ROLE_FOLDER_ID folder contains the global roles).
1524 if (
1525 !$rbacreview->isDeleted($rolf[0]) &&
1526 $rbacsystem->checkAccess(
1527 'write',
1528 $rolf[0]
1529 ) &&
1530 $rolf[0] != ROLE_FOLDER_ID
1531 ) {
1532 // A local role is only displayed, if it is contained in the subtree of
1533 // the localy administrated category. If the import function has been
1534 // invoked from the user folder object, we show all local roles, because
1535 // the user folder object is considered the parent of all local roles.
1536 // Thus, if we start from the user folder object, we initialize the
1537 // isInSubtree variable with true. In all other cases it is initialized
1538 // with false, and only set to true if we find the object id of the
1539 // locally administrated category in the tree path to the local role.
1540 $isInSubtree = $this->object->getRefId() == USER_FOLDER_ID;
1541
1542 $path_array = [];
1543 if ($this->tree->isInTree($rolf[0])) {
1544 // Create path. Paths which have more than 4 segments
1545 // are truncated in the middle.
1546 $tmpPath = $this->tree->getPathFull($rolf[0]);
1547 $tmpPath[] = $rolf[0];//adds target item to list
1548
1549 for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++) {
1550 if ($i < 3 || $i > $n - 3) {
1551 $path_array[] = $tmpPath[$i]['title'];
1552 } elseif ($i == 3 || $i == $n - 3) {
1553 $path_array[] = '...';
1554 }
1555
1556 $isInSubtree |= $tmpPath[$i]['obj_id'] == $this->object->getId();
1557 }
1558 //revert this path for a better readability in dropdowns #18306
1559 $path = implode(
1560 " < ",
1561 array_reverse($path_array)
1562 );
1563 } else {
1564 $path = "<b>Rolefolder " . $rolf[0] . " not found in tree! (Role " . $loc_role . ")</b>";
1565 }
1566 $roleMailboxAddress = (new \ilRoleMailboxAddress($loc_role))->value();
1567 $l_roles[$loc_role] = $roleMailboxAddress . ', ' . $path;
1568 }
1569 } //foreach role
1570
1571 natcasesort($l_roles);
1572 $l_roles["ignore"] = $this->lng->txt("usrimport_ignore_role");
1573
1574 $roleMailboxSearch = new \ilRoleMailboxSearch(new \ilMailRfc822AddressParserFactory());
1575 $local_selects = [];
1576 foreach ($roles as $role_id => $role) {
1577 if ($role["type"] == "Local") {
1578 /*$this->tpl->setCurrentBlock("local_role");
1579 $this->tpl->setVariable("TXT_IMPORT_LOCAL_ROLE", $role["name"]);*/
1580 $searchName = (substr(
1581 $role['name'],
1582 0,
1583 1
1584 ) == '#') ? $role['name'] : '#' . $role['name'];
1585 $matching_role_ids = $roleMailboxSearch->searchRoleIdsByAddressString($searchName);
1586 $pre_select = count($matching_role_ids) == 1 ? $role_id . "-" . $matching_role_ids[0] : "ignore";
1587
1588 $selectable_roles = [];
1589 if ($this->object->getRefId() == USER_FOLDER_ID) {
1590 // There are too many roles in a large ILIAS installation
1591 // that's why whe show only a choice with the the option "ignore",
1592 // and the matching roles.
1593 $selectable_roles["ignore"] = $this->lng->txt("usrimport_ignore_role");
1594 foreach ($matching_role_ids as $id) {
1595 $selectable_roles[$role_id . "-" . $id] = $l_roles[$id];
1596 }
1597 } else {
1598 foreach ($l_roles as $local_role_id => $value) {
1599 if ($local_role_id !== "ignore") {
1600 $selectable_roles[$role_id . "-" . $local_role_id] = $value;
1601 }
1602 }
1603 }
1604
1605 if (count($selectable_roles) > 0) {
1606 $select = $ui->input()->field()
1607 ->select($role["name"], $selectable_roles)
1608 ->withRequired(true);
1609 if (array_key_exists($pre_select, $selectable_roles)) {
1610 $select = $select->withValue($pre_select);
1611 }
1612 $local_selects[] = $select;
1613 }
1614 }
1615 }
1616 }
1617
1618 $handlers = array(
1619 IL_IGNORE_ON_CONFLICT => $this->lng->txt("ignore_on_conflict"),
1620 IL_UPDATE_ON_CONFLICT => $this->lng->txt("update_on_conflict")
1621 );
1622
1623 $conflict_action_select = $ui->input()->field()->select(
1624 $this->lng->txt("conflict_handling"),
1625 $handlers,
1626 str_replace(
1627 '\n',
1628 '<br>',
1629 $this->lng->txt("usrimport_conflict_handling_info")
1630 )
1631 )
1632 ->withValue(IL_IGNORE_ON_CONFLICT)
1633 ->withRequired(true);
1634
1635 // new account mail
1636 $this->lng->loadLanguageModule("mail");
1637 $amail = ilObjUserFolder::_lookupNewAccountMail($this->lng->getDefaultLanguage());
1638 if (trim($amail["body"]) != "" && trim($amail["subject"]) != "") {
1639 $send_checkbox = $ui->input()->field()->checkbox($this->lng->txt("user_send_new_account_mail"))
1640 ->withValue(true);
1641
1642 $mail_section = $ui->input()->field()->section(
1643 [$send_checkbox],
1644 $this->lng->txt("mail_account_mail")
1645 );
1646 }
1647
1648 $file_info_section = $ui->input()->field()->section(
1649 [
1650 "filename" => $roles_import_filename,
1651 "import_count" => $roles_import_count,
1652 ],
1653 $this->lng->txt("file_info")
1654 );
1655
1656 $form_action = $DIC->ctrl()->getFormActionByClass('ilObjUserFolderGui', 'importUsers');
1657
1658 $form_elements = [
1659 "file_info" => $file_info_section
1660 ];
1661
1662 if (!empty($global_selects)) {
1663 $global_role_info_section = $ui->input()
1664 ->field()
1665 ->section([$global_roles_assignment_info], $this->lng->txt("global_role_assignment"));
1666 $global_role_selection_section = $ui->input()->field()->section($global_selects, "");
1667 $form_elements["global_role_info"] = $global_role_info_section;
1668 $form_elements["global_role_selection"] = $global_role_selection_section;
1669 }
1670
1671 if (!empty($local_selects)) {
1672 $local_role_info_section = $ui->input()->field()->section(
1673 [$local_roles_assignment_info],
1674 $this->lng->txt("local_role_assignment")
1675 );
1676 $local_role_selection_section = $ui->input()->field()->section(
1677 $local_selects,
1678 ""
1679 );
1680
1681 $form_elements["local_role_info"] = $local_role_info_section;
1682 $form_elements["local_role_selection"] = $local_role_selection_section;
1683 }
1684
1685 $form_elements["conflict_action"] = $ui->input()->field()->section([$conflict_action_select], "");
1686
1687 if (!empty($mail_section)) {
1688 $form_elements["send_mail"] = $mail_section;
1689 }
1690
1691 return [$ui->input()->container()->form()->standard(
1692 $form_action,
1693 $form_elements
1694 ), $message];
1695 }
1696
1700 private function handleUploadedFiles() : string
1701 {
1702 global $DIC;
1703
1704 $ilUser = $DIC->user();
1705
1706 $upload = $DIC->upload();
1707
1708 $filesystem = $DIC->filesystem()->storage();
1709 $import_dir = $this->getImportDir();
1710
1711 if (!$upload->hasBeenProcessed()) {
1712 $upload->process();
1713 }
1714
1715 // recreate user import directory
1716 if ($filesystem->hasDir($import_dir)) {
1717 $filesystem->deleteDir($import_dir);
1718 }
1719 $filesystem->createDir($import_dir);
1720
1721 foreach ($upload->getResults() as $single_file_upload) {
1722 $file_name = $single_file_upload->getName();
1723 $parts = pathinfo($file_name);
1724
1725 //check if upload status is ok
1726 if ($single_file_upload->getStatus() != \ILIAS\FileUpload\DTO\ProcessingStatus::OK) {
1727 $filesystem->deleteDir($import_dir);
1728 $this->ilias->raiseError(
1729 $this->lng->txt("no_import_file_found"),
1730 $this->ilias->error_obj->MESSAGE
1731 );
1732 }
1733
1734 // move uploaded file to user import directory
1735 $upload->moveFilesTo(
1736 $import_dir,
1737 \ILIAS\FileUpload\Location::STORAGE
1738 );
1739
1740 // handle zip file
1741 if ($single_file_upload->getMimeType() == "application/zip") {
1742 // Workaround: unzip function needs full path to file. Should be replaced once Filesystem has own unzip implementation
1743 $full_path = ilUtil::getDataDir() . '/user_import/usr_' . $ilUser->getId() . '_' . session_id(
1744 ) . "/" . $file_name;
1745 ilUtil::unzip($full_path);
1746
1747 $xml_file = null;
1748 $file_list = $filesystem->listContents($import_dir);
1749
1750 foreach ($file_list as $key => $a_file) {
1751 if (substr(
1752 $a_file->getPath(),
1753 -4
1754 ) == '.xml') {
1755 unset($file_list[$key]);
1756 $xml_file = $a_file->getPath();
1757 break;
1758 }
1759 }
1760
1761 //Removing all files except the one to be imported, to make sure to get the right one in import-function
1762 foreach ($file_list as $a_file) {
1763 $filesystem->delete($a_file->getPath());
1764 }
1765
1766 if (is_null($xml_file)) {
1767 $subdir = basename(
1768 $parts["basename"],
1769 "." . $parts["extension"]
1770 );
1771 $xml_file = $import_dir . "/" . $subdir . "/" . $subdir . ".xml";
1772 }
1773 } // handle xml file
1774 else {
1775 $a = $filesystem->listContents($import_dir);
1776 $file = end($a);
1777 $xml_file = $file->getPath();
1778 }
1779
1780 // check xml file
1781 if (!$filesystem->has($xml_file)) {
1782 $filesystem->deleteDir($import_dir);
1783 $this->ilias->raiseError(
1784 $this->lng->txt("no_xml_file_found_in_zip")
1785 . " " . $subdir . "/" . $subdir . ".xml",
1786 $this->ilias->error_obj->MESSAGE
1787 );
1788 }
1789 }
1790
1791 return $xml_file;
1792 }
1793
1794 public function verifyXmlData($importParser) : string
1795 {
1796 global $DIC;
1797
1798 $filesystem = $DIC->filesystem()->storage();
1799
1800 $import_dir = $this->getImportDir();
1801 switch ($importParser->getErrorLevel()) {
1802 case IL_IMPORT_SUCCESS:
1803 return '';
1804 case IL_IMPORT_WARNING:
1805 return $importParser->getProtocolAsHTML($this->lng->txt("verification_warning_log"));
1806 case IL_IMPORT_FAILURE:
1807 $filesystem->deleteDir($import_dir);
1808 $this->ilias->raiseError(
1809 $this->lng->txt("verification_failed") . $importParser->getProtocolAsHTML(
1810 $this->lng->txt("verification_failure_log")
1811 ),
1812 $this->ilias->error_obj->MESSAGE
1813 );
1814 return '';
1815 }
1816 }
1817
1821 public function importUsersObject()
1822 {
1823 global $DIC;
1824
1825 $ilUser = $DIC->user();
1826 $request = $DIC->http()->request();
1827 $rbacreview = $DIC->rbac()->review();
1828 $rbacsystem = $DIC->rbac()->system();
1829 $filesystem = $DIC->filesystem()->storage();
1830 $import_dir = $this->getImportDir();
1831
1832 $file_list = $filesystem->listContents($import_dir);
1833
1834 //Make sure there's only one file in the import directory at this point
1835 if (count($file_list) > 1) {
1836 $filesystem->deleteDir($import_dir);
1837 $this->ilias->raiseError(
1838 $this->lng->txt("usrimport_wrong_file_count"),
1839 $this->ilias->error_obj->MESSAGE
1840 );
1841 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
1842 $this->ctrl->redirect(
1843 $this,
1844 "view"
1845 );
1846 } else {
1847 $this->ctrl->redirectByClass(
1848 'ilobjcategorygui',
1849 'listUsers'
1850 );
1851 }
1852 } else {
1853 $xml_file = $file_list[0]->getPath();
1854 }
1855
1856 //Need full path to xml file to initialise form
1857 $xml_path = ilUtil::getDataDir() . '/' . $xml_file;
1858
1859 if ($request->getMethod() == "POST") {
1860 $form = $this->initUserRoleAssignmentForm($xml_path)[0]->withRequest($request);
1861 $result = $form->getData();
1862 } else {
1863 $this->ilias->raiseError(
1864 $this->lng->txt("usrimport_form_not_evaluabe"),
1865 $this->ilias->error_obj->MESSAGE
1866 );
1867 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
1868 $this->ctrl->redirect(
1869 $this,
1870 "view"
1871 );
1872 } else {
1873 $this->ctrl->redirectByClass(
1874 'ilobjcategorygui',
1875 'listUsers'
1876 );
1877 }
1878 }
1879
1880 $rule = $result["conflict_action"][0];
1881
1882 //If local roles exist, merge the roles that are to be assigned, otherwise just take the array that has global roles
1883 $local_role_selection = (array) ($result['local_role_selection'] ?? []);
1884 $global_role_selection = (array) ($result['global_role_selection'] ?? []);
1885 $roles = array_merge(
1886 $local_role_selection,
1887 $global_role_selection
1888 );
1889
1890 $role_assignment = [];
1891 foreach ($roles as $value) {
1892 $keys = explode(
1893 "-",
1894 $value
1895 );
1896 $role_assignment[$keys[0]] = $keys[1];
1897 }
1898
1899 $importParser = new ilUserImportParser(
1900 $xml_path,
1902 $rule
1903 );
1904 $importParser->setFolderId($this->getUserOwnerId());
1905
1906 // Catch hack attempts
1907 // We check here again, if the role folders are in the tree, and if the
1908 // user has permission on the roles.
1909 if (!empty($role_assignment)) {
1910 $global_roles = $rbacreview->getGlobalRoles();
1911 $roles_of_user = $rbacreview->assignedRoles($ilUser->getId());
1912 foreach ($role_assignment as $role_id) {
1913 if ($role_id != "") {
1914 if (in_array(
1915 $role_id,
1916 $global_roles
1917 )) {
1918 if (!in_array(
1920 $roles_of_user
1921 )) {
1922 if ($role_id == SYSTEM_ROLE_ID && !in_array(
1924 $roles_of_user
1925 )
1926 || ($this->object->getRefId() != USER_FOLDER_ID
1928 ) {
1929 $filesystem->deleteDir($import_dir);
1930 $this->ilias->raiseError(
1931 $this->lng->txt("usrimport_with_specified_role_not_permitted"),
1932 $this->ilias->error_obj->MESSAGE
1933 );
1934 }
1935 }
1936 } else {
1937 $rolf = $rbacreview->getFoldersAssignedToRole(
1938 $role_id,
1939 true
1940 );
1941 if ($rbacreview->isDeleted($rolf[0])
1942 || !$rbacsystem->checkAccess(
1943 'write',
1944 $rolf[0]
1945 )) {
1946 $filesystem->deleteDir($import_dir);
1947 $this->ilias->raiseError(
1948 $this->lng->txt("usrimport_with_specified_role_not_permitted"),
1949 $this->ilias->error_obj->MESSAGE
1950 );
1951 return;
1952 }
1953 }
1954 }
1955 }
1956 }
1957
1958 if (isset($result['send_mail'])) {
1959 $importParser->setSendMail($result['send_mail'][0]);
1960 }
1961
1962 $importParser->setRoleAssignment($role_assignment);
1963 $importParser->startParsing();
1964
1965 // purge user import directory
1966 $filesystem->deleteDir($import_dir);
1967
1968 switch ($importParser->getErrorLevel()) {
1969 case IL_IMPORT_SUCCESS:
1970 ilUtil::sendSuccess(
1971 $this->lng->txt("user_imported"),
1972 true
1973 );
1974 break;
1975 case IL_IMPORT_WARNING:
1976 ilUtil::sendSuccess(
1977 $this->lng->txt("user_imported_with_warnings") . $importParser->getProtocolAsHTML(
1978 $this->lng->txt("import_warning_log")
1979 ),
1980 true
1981 );
1982 break;
1983 case IL_IMPORT_FAILURE:
1984 $this->ilias->raiseError(
1985 $this->lng->txt("user_import_failed")
1986 . $importParser->getProtocolAsHTML($this->lng->txt("import_failure_log")),
1987 $this->ilias->error_obj->MESSAGE
1988 );
1989 break;
1990 }
1991
1992 if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
1993 $this->ctrl->redirect(
1994 $this,
1995 "view"
1996 );
1997 } else {
1998 $this->ctrl->redirectByClass(
1999 'ilobjcategorygui',
2000 'listUsers'
2001 );
2002 }
2003 }
2004
2005 public function hitsperpageObject()
2006 {
2007 parent::hitsperpageObject();
2008 $this->viewObject();
2009 }
2010
2015 protected function generalSettingsObject()
2016 {
2017 global $DIC;
2018
2019 $ilSetting = $DIC['ilSetting'];
2020
2021 $this->initFormGeneralSettings();
2022
2023 include_once './Services/User/classes/class.ilUserAccountSettings.php';
2025
2026 $show_blocking_time_in_days = $ilSetting->get('loginname_change_blocking_time') / 86400;
2027 $show_blocking_time_in_days = (float) $show_blocking_time_in_days;
2028
2029 include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2031
2032 $settings = [
2033 'lua' => $aset->isLocalUserAdministrationEnabled(),
2034 'lrua' => $aset->isUserAccessRestricted(),
2035 'allow_change_loginname' => (bool) $ilSetting->get('allow_change_loginname'),
2036 'create_history_loginname' => (bool) $ilSetting->get('create_history_loginname'),
2037 'reuse_of_loginnames' => (bool) $ilSetting->get('reuse_of_loginnames'),
2038 'loginname_change_blocking_time' => (float) $show_blocking_time_in_days,
2039 'user_adm_alpha_nav' => (int) $ilSetting->get('user_adm_alpha_nav'),
2040 // 'user_ext_profiles' => (int)$ilSetting->get('user_ext_profiles')
2041 'user_reactivate_code' => (int) $ilSetting->get('user_reactivate_code'),
2042 'user_own_account' => (int) $ilSetting->get('user_delete_own_account'),
2043 'user_own_account_email' => $ilSetting->get('user_delete_own_account_email'),
2044 'tos_withdrawal_usr_deletion' => (bool) $ilSetting->get('tos_withdrawal_usr_deletion'),
2045
2046 'session_handling_type' => $ilSetting->get(
2047 'session_handling_type',
2049 ),
2050 'session_reminder_enabled' => $ilSetting->get('session_reminder_enabled'),
2051 'session_max_count' => $ilSetting->get(
2052 'session_max_count',
2054 ),
2055 'session_min_idle' => $ilSetting->get(
2056 'session_min_idle',
2058 ),
2059 'session_max_idle' => $ilSetting->get(
2060 'session_max_idle',
2062 ),
2063 'session_max_idle_after_first_request' => $ilSetting->get(
2064 'session_max_idle_after_first_request',
2066 ),
2067
2068 'login_max_attempts' => $security->getLoginMaxAttempts(),
2069 'ps_prevent_simultaneous_logins' => (int) $security->isPreventionOfSimultaneousLoginsEnabled(),
2070 'password_assistance' => (bool) $ilSetting->get("password_assistance"),
2071 'letter_avatars' => (int) $ilSetting->get('letter_avatars'),
2072 'password_change_on_first_login_enabled' => $security->isPasswordChangeOnFirstLoginEnabled() ? 1 : 0,
2073 'password_max_age' => $security->getPasswordMaxAge()
2074 ];
2075
2076 $passwordPolicySettings = $this->getPasswordPolicySettingsMap($security);
2077 $this->form->setValuesByArray(
2078 array_merge(
2079 $settings,
2080 $passwordPolicySettings,
2081 ['pw_policy_hash' => md5(
2082 implode(
2083 '',
2084 $passwordPolicySettings
2085 )
2086 )
2087 ]
2088 )
2089 );
2090
2091 $this->tpl->setContent($this->form->getHTML());
2092 }
2093
2098 private function getPasswordPolicySettingsMap(\ilSecuritySettings $security) : array
2099 {
2100 return [
2101 'password_must_not_contain_loginame' => $security->getPasswordMustNotContainLoginnameStatus() ? 1 : 0,
2102 'password_chars_and_numbers_enabled' => $security->isPasswordCharsAndNumbersEnabled() ? 1 : 0,
2103 'password_special_chars_enabled' => $security->isPasswordSpecialCharsEnabled() ? 1 : 0,
2104 'password_min_length' => $security->getPasswordMinLength(),
2105 'password_max_length' => $security->getPasswordMaxLength(),
2106 'password_ucase_chars_num' => $security->getPasswordNumberOfUppercaseChars(),
2107 'password_lowercase_chars_num' => $security->getPasswordNumberOfLowercaseChars(),
2108 ];
2109 }
2110
2116 {
2117 global $DIC;
2118
2119 $ilUser = $DIC['ilUser'];
2120 $ilSetting = $DIC['ilSetting'];
2121
2122 $this->initFormGeneralSettings();
2123 if ($this->form->checkInput()) {
2124 $valid = true;
2125
2126 if (!strlen($this->form->getInput('loginname_change_blocking_time'))) {
2127 $valid = false;
2128 $this->form->getItemByPostVar('loginname_change_blocking_time')
2129 ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
2130 }
2131
2132 include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2134
2135 // account security settings
2136 $security->setPasswordCharsAndNumbersEnabled((bool) $_POST["password_chars_and_numbers_enabled"]);
2137 $security->setPasswordSpecialCharsEnabled((bool) $_POST["password_special_chars_enabled"]);
2138 $security->setPasswordMinLength((int) $_POST["password_min_length"]);
2139 $security->setPasswordMaxLength((int) $_POST["password_max_length"]);
2140 $security->setPasswordNumberOfUppercaseChars((int) $_POST['password_ucase_chars_num']);
2141 $security->setPasswordNumberOfLowercaseChars((int) $_POST['password_lowercase_chars_num']);
2142 $security->setPasswordMaxAge((int) $_POST["password_max_age"]);
2143 $security->setLoginMaxAttempts((int) $_POST["login_max_attempts"]);
2144 $security->setPreventionOfSimultaneousLogins((bool) $_POST['ps_prevent_simultaneous_logins']);
2145 $security->setPasswordChangeOnFirstLoginEnabled((bool) $_POST['password_change_on_first_login_enabled']);
2146 $security->setPasswordMustNotContainLoginnameStatus((int) $_POST['password_must_not_contain_loginame']);
2147
2148 if (!$security->validate($this->form)) {
2149 $valid = false;
2150 }
2151
2152 if ($valid) {
2153 $security->save();
2154
2155 include_once './Services/User/classes/class.ilUserAccountSettings.php';
2156 ilUserAccountSettings::getInstance()->enableLocalUserAdministration($this->form->getInput('lua'));
2157 ilUserAccountSettings::getInstance()->restrictUserAccess($this->form->getInput('lrua'));
2159
2160 $ilSetting->set(
2161 'allow_change_loginname',
2162 (int) $this->form->getInput('allow_change_loginname')
2163 );
2164 $ilSetting->set(
2165 'create_history_loginname',
2166 (int) $this->form->getInput('create_history_loginname')
2167 );
2168 $ilSetting->set(
2169 'reuse_of_loginnames',
2170 (int) $this->form->getInput('reuse_of_loginnames')
2171 );
2172 $save_blocking_time_in_seconds = (int) ($this->form->getInput(
2173 'loginname_change_blocking_time'
2174 ) * 86400);
2175 $ilSetting->set(
2176 'loginname_change_blocking_time',
2177 (int) $save_blocking_time_in_seconds
2178 );
2179 $ilSetting->set(
2180 'user_adm_alpha_nav',
2181 (int) $this->form->getInput('user_adm_alpha_nav')
2182 );
2183 $ilSetting->set(
2184 'user_reactivate_code',
2185 (int) $this->form->getInput('user_reactivate_code')
2186 );
2187
2188 $ilSetting->set(
2189 'user_delete_own_account',
2190 (int) $this->form->getInput('user_own_account')
2191 );
2192 $ilSetting->set(
2193 'user_delete_own_account_email',
2194 $this->form->getInput('user_own_account_email')
2195 );
2196 $ilSetting->set(
2197 'tos_withdrawal_usr_deletion',
2198 (string) ((int) $this->form->getInput('tos_withdrawal_usr_deletion'))
2199 );
2200
2201 $ilSetting->set(
2202 "password_assistance",
2203 $this->form->getInput("password_assistance")
2204 );
2205
2206 // BEGIN SESSION SETTINGS
2207 $ilSetting->set(
2208 'session_handling_type',
2209 (int) $this->form->getInput('session_handling_type')
2210 );
2211
2212 if ($this->form->getInput('session_handling_type') == ilSession::SESSION_HANDLING_FIXED) {
2213 $ilSetting->set(
2214 'session_reminder_enabled',
2215 $this->form->getInput('session_reminder_enabled')
2216 );
2217 } elseif ($this->form->getInput(
2218 'session_handling_type'
2220 require_once 'Services/Authentication/classes/class.ilSessionControl.php';
2221 if (
2222 $ilSetting->get(
2223 'session_allow_client_maintenance',
2225 )
2226 ) {
2227 // has to be done BEFORE updating the setting!
2228 include_once "Services/Authentication/classes/class.ilSessionStatistics.php";
2229 ilSessionStatistics::updateLimitLog((int) $this->form->getInput('session_max_count'));
2230
2231 $ilSetting->set(
2232 'session_max_count',
2233 (int) $this->form->getInput('session_max_count')
2234 );
2235 $ilSetting->set(
2236 'session_min_idle',
2237 (int) $this->form->getInput('session_min_idle')
2238 );
2239 $ilSetting->set(
2240 'session_max_idle',
2241 (int) $this->form->getInput('session_max_idle')
2242 );
2243 $ilSetting->set(
2244 'session_max_idle_after_first_request',
2245 (int) $this->form->getInput('session_max_idle_after_first_request')
2246 );
2247 }
2248 }
2249 // END SESSION SETTINGS
2250 $ilSetting->set(
2251 'letter_avatars',
2252 (int) $this->form->getInput('letter_avatars')
2253 );
2254
2255 $requestPasswordReset = false;
2256 if ($this->form->getInput('pw_policy_hash')) {
2257 $oldSettingsHash = $this->form->getInput('pw_policy_hash');
2258 $currentSettingsHash = md5(
2259 implode(
2260 '',
2261 $this->getPasswordPolicySettingsMap($security)
2262 )
2263 );
2264 $requestPasswordReset = ($oldSettingsHash !== $currentSettingsHash);
2265 }
2266
2267 if ($requestPasswordReset) {
2268 $this->ctrl->redirect(
2269 $this,
2270 'askForUserPasswordReset'
2271 );
2272 } else {
2273 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
2274 }
2275 } else {
2276 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2277 }
2278 } else {
2279 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2280 }
2281 $this->form->setValuesByPost();
2282 $this->tpl->setContent($this->form->getHTML());
2283 }
2284
2288 protected function forceUserPasswordResetObject()
2289 {
2290 \ilUserPasswordManager::getInstance()->resetLastPasswordChangeForLocalUsers();
2291 $this->lng->loadLanguageModule('ps');
2292
2293 \ilUtil::sendSuccess(
2294 $this->lng->txt('ps_passwd_policy_change_force_user_reset_succ'),
2295 true
2296 );
2297 $this->ctrl->redirect(
2298 $this,
2299 'generalSettings'
2300 );
2301 }
2302
2307 {
2308 $this->lng->loadLanguageModule('ps');
2309
2310 $confirmation = new \ilConfirmationGUI();
2311 $confirmation->setFormAction(
2312 $this->ctrl->getFormAction(
2313 $this,
2314 'askForUserPasswordReset'
2315 )
2316 );
2317 $confirmation->setHeaderText($this->lng->txt('ps_passwd_policy_changed_force_user_reset'));
2318 $confirmation->setConfirm(
2319 $this->lng->txt('yes'),
2320 'forceUserPasswordReset'
2321 );
2322 $confirmation->setCancel(
2323 $this->lng->txt('no'),
2324 'generalSettings'
2325 );
2326
2327 $this->tpl->setContent($confirmation->getHTML());
2328 }
2329
2334 protected function initFormGeneralSettings()
2335 {
2336 global $DIC;
2337
2338 $ilSetting = $DIC['ilSetting'];
2339
2340 $this->setSubTabs('settings');
2341 $this->tabs_gui->setTabActive('settings');
2342 $this->tabs_gui->setSubTabActive('general_settings');
2343
2344 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2345 $this->form = new ilPropertyFormGUI();
2346 $this->form->setFormAction(
2347 $this->ctrl->getFormAction(
2348 $this,
2349 'saveGeneralSettings'
2350 )
2351 );
2352
2353 $this->form->setTitle($this->lng->txt('general_settings'));
2354
2355 $lua = new ilCheckboxInputGUI(
2356 $this->lng->txt('enable_local_user_administration'),
2357 'lua'
2358 );
2359 $lua->setInfo($this->lng->txt('enable_local_user_administration_info'));
2360 $lua->setValue(1);
2361 $this->form->addItem($lua);
2362
2363 $lrua = new ilCheckboxInputGUI(
2364 $this->lng->txt('restrict_user_access'),
2365 'lrua'
2366 );
2367 $lrua->setInfo($this->lng->txt('restrict_user_access_info'));
2368 $lrua->setValue(1);
2369 $this->form->addItem($lrua);
2370
2371 // enable alphabetical navigation in user administration
2372 $alph = new ilCheckboxInputGUI(
2373 $this->lng->txt('user_adm_enable_alpha_nav'),
2374 'user_adm_alpha_nav'
2375 );
2376 //$alph->setInfo($this->lng->txt('restrict_user_access_info'));
2377 $alph->setValue(1);
2378 $this->form->addItem($alph);
2379
2380 // account codes
2381 $code = new ilCheckboxInputGUI(
2382 $this->lng->txt("user_account_code_setting"),
2383 "user_reactivate_code"
2384 );
2385 $code->setInfo($this->lng->txt('user_account_code_setting_info'));
2386 $this->form->addItem($code);
2387
2388 // delete own account
2389 $own = new ilCheckboxInputGUI(
2390 $this->lng->txt("user_allow_delete_own_account"),
2391 "user_own_account"
2392 );
2393 $this->form->addItem($own);
2394 $own_email = new ilEMailInputGUI(
2395 $this->lng->txt("user_delete_own_account_notification_email"),
2396 "user_own_account_email"
2397 );
2398 $own->addSubItem($own_email);
2399
2400 $withdrawalProvokesDeletion = new ilCheckboxInputGUI(
2401 $this->lng->txt('tos_withdrawal_usr_deletion'),
2402 'tos_withdrawal_usr_deletion'
2403 );
2404 $withdrawalProvokesDeletion->setInfo($this->lng->txt('tos_withdrawal_usr_deletion_info'));
2405 $withdrawalProvokesDeletion->setValue('1');
2406 $this->form->addItem($withdrawalProvokesDeletion);
2407
2408 // BEGIN SESSION SETTINGS
2409
2410 // create session handling radio group
2411 $ssettings = new ilRadioGroupInputGUI(
2412 $this->lng->txt('sess_mode'),
2413 'session_handling_type'
2414 );
2415
2416 // first option, fixed session duration
2417 $fixed = new ilRadioOption(
2418 $this->lng->txt('sess_fixed_duration'),
2420 );
2421
2422 // create session reminder subform
2423 $cb = new ilCheckboxInputGUI(
2424 $this->lng->txt("session_reminder"),
2425 "session_reminder_enabled"
2426 );
2429 $expires,
2430 true
2431 );
2432 $cb->setInfo(
2433 $this->lng->txt("session_reminder_info") . "<br />" .
2434 sprintf(
2435 $this->lng->txt('session_reminder_session_duration'),
2436 $time
2437 )
2438 );
2439 $fixed->addSubItem($cb);
2440
2441 // add session handling to radio group
2442 $ssettings->addOption($fixed);
2443
2444 // second option, session control
2445 $ldsh = new ilRadioOption(
2446 $this->lng->txt('sess_load_dependent_session_handling'),
2448 );
2449
2450 // add session control subform
2451 require_once('Services/Authentication/classes/class.ilSessionControl.php');
2452
2453 // this is the max count of active sessions
2454 // that are getting started simlutanously
2455 $sub_ti = new ilTextInputGUI(
2456 $this->lng->txt('session_max_count'),
2457 'session_max_count'
2458 );
2459 $sub_ti->setMaxLength(5);
2460 $sub_ti->setSize(5);
2461 $sub_ti->setInfo($this->lng->txt('session_max_count_info'));
2462 if (!$ilSetting->get(
2463 'session_allow_client_maintenance',
2465 )) {
2466 $sub_ti->setDisabled(true);
2467 }
2468 $ldsh->addSubItem($sub_ti);
2469
2470 // after this (min) idle time the session can be deleted,
2471 // if there are further requests for new sessions,
2472 // but max session count is reached yet
2473 $sub_ti = new ilTextInputGUI(
2474 $this->lng->txt('session_min_idle'),
2475 'session_min_idle'
2476 );
2477 $sub_ti->setMaxLength(5);
2478 $sub_ti->setSize(5);
2479 $sub_ti->setInfo($this->lng->txt('session_min_idle_info'));
2480 if (!$ilSetting->get(
2481 'session_allow_client_maintenance',
2483 )) {
2484 $sub_ti->setDisabled(true);
2485 }
2486 $ldsh->addSubItem($sub_ti);
2487
2488 // after this (max) idle timeout the session expires
2489 // and become invalid, so it is not considered anymore
2490 // when calculating current count of active sessions
2491 $sub_ti = new ilTextInputGUI(
2492 $this->lng->txt('session_max_idle'),
2493 'session_max_idle'
2494 );
2495 $sub_ti->setMaxLength(5);
2496 $sub_ti->setSize(5);
2497 $sub_ti->setInfo($this->lng->txt('session_max_idle_info'));
2498 if (!$ilSetting->get(
2499 'session_allow_client_maintenance',
2501 )) {
2502 $sub_ti->setDisabled(true);
2503 }
2504 $ldsh->addSubItem($sub_ti);
2505
2506 // this is the max duration that can elapse between the first and the secnd
2507 // request to the system before the session is immidietly deleted
2508 $sub_ti = new ilTextInputGUI(
2509 $this->lng->txt('session_max_idle_after_first_request'),
2510 'session_max_idle_after_first_request'
2511 );
2512 $sub_ti->setMaxLength(5);
2513 $sub_ti->setSize(5);
2514 $sub_ti->setInfo($this->lng->txt('session_max_idle_after_first_request_info'));
2515 if (!$ilSetting->get(
2516 'session_allow_client_maintenance',
2518 )) {
2519 $sub_ti->setDisabled(true);
2520 }
2521 $ldsh->addSubItem($sub_ti);
2522
2523 // add session control to radio group
2524 $ssettings->addOption($ldsh);
2525
2526 // add radio group to form
2527 if ($ilSetting->get(
2528 'session_allow_client_maintenance',
2530 )) {
2531 // just shows the status wether the session
2532 //setting maintenance is allowed by setup
2533 $this->form->addItem($ssettings);
2534 } else {
2535 // just shows the status wether the session
2536 //setting maintenance is allowed by setup
2537 $ti = new ilNonEditableValueGUI(
2538 $this->lng->txt('session_config'),
2539 "session_config"
2540 );
2541 $ti->setValue($this->lng->txt('session_config_maintenance_disabled'));
2542 $ssettings->setDisabled(true);
2543 $ti->addSubItem($ssettings);
2544 $this->form->addItem($ti);
2545 }
2546
2547 // END SESSION SETTINGS
2548
2549 $this->lng->loadLanguageModule('ps');
2550
2552 $pass->setTitle($this->lng->txt('ps_password_settings'));
2553 $this->form->addItem($pass);
2554
2555 $check = new ilCheckboxInputGUI(
2556 $this->lng->txt('ps_password_change_on_first_login_enabled'),
2557 'password_change_on_first_login_enabled'
2558 );
2559 $check->setInfo($this->lng->txt('ps_password_change_on_first_login_enabled_info'));
2560 $this->form->addItem($check);
2561
2562 include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
2563
2564 $check = new ilCheckboxInputGUI(
2565 $this->lng->txt('ps_password_must_not_contain_loginame'),
2566 'password_must_not_contain_loginame'
2567 );
2568 $check->setInfo($this->lng->txt('ps_password_must_not_contain_loginame_info'));
2569 $this->form->addItem($check);
2570
2571 $check = new ilCheckboxInputGUI(
2572 $this->lng->txt('ps_password_chars_and_numbers_enabled'),
2573 'password_chars_and_numbers_enabled'
2574 );
2575 //$check->setOptionTitle($this->lng->txt('ps_password_chars_and_numbers_enabled'));
2576 $check->setInfo($this->lng->txt('ps_password_chars_and_numbers_enabled_info'));
2577 $this->form->addItem($check);
2578
2579 $check = new ilCheckboxInputGUI(
2580 $this->lng->txt('ps_password_special_chars_enabled'),
2581 'password_special_chars_enabled'
2582 );
2583 //$check->setOptionTitle($this->lng->txt('ps_password_special_chars_enabled'));
2584 $check->setInfo($this->lng->txt('ps_password_special_chars_enabled_info'));
2585 $this->form->addItem($check);
2586
2587 $text = new ilNumberInputGUI(
2588 $this->lng->txt('ps_password_min_length'),
2589 'password_min_length'
2590 );
2591 $text->setInfo($this->lng->txt('ps_password_min_length_info'));
2592 $text->setSize(1);
2593 $text->setMaxLength(2);
2594 $this->form->addItem($text);
2595
2596 $text = new ilNumberInputGUI(
2597 $this->lng->txt('ps_password_max_length'),
2598 'password_max_length'
2599 );
2600 $text->setInfo($this->lng->txt('ps_password_max_length_info'));
2601 $text->setSize(2);
2602 $text->setMaxLength(3);
2603 $this->form->addItem($text);
2604
2605 $text = new ilNumberInputGUI(
2606 $this->lng->txt('ps_password_uppercase_chars_num'),
2607 'password_ucase_chars_num'
2608 );
2609 $text->setInfo($this->lng->txt('ps_password_uppercase_chars_num_info'));
2610 $text->setMinValue(0);
2611 $text->setSize(2);
2612 $text->setMaxLength(3);
2613 $this->form->addItem($text);
2614
2615 $text = new ilNumberInputGUI(
2616 $this->lng->txt('ps_password_lowercase_chars_num'),
2617 'password_lowercase_chars_num'
2618 );
2619 $text->setInfo($this->lng->txt('ps_password_lowercase_chars_num_info'));
2620 $text->setMinValue(0);
2621 $text->setSize(2);
2622 $text->setMaxLength(3);
2623 $this->form->addItem($text);
2624
2625 $text = new ilNumberInputGUI(
2626 $this->lng->txt('ps_password_max_age'),
2627 'password_max_age'
2628 );
2629 $text->setInfo($this->lng->txt('ps_password_max_age_info'));
2630 $text->setSize(2);
2631 $text->setMaxLength(3);
2632 $this->form->addItem($text);
2633
2634 // password assistance
2635 $cb = new ilCheckboxInputGUI(
2636 $this->lng->txt("enable_password_assistance"),
2637 "password_assistance"
2638 );
2639 $cb->setInfo($this->lng->txt("password_assistance_info"));
2640 $this->form->addItem($cb);
2641
2643 $pass->setTitle($this->lng->txt('ps_security_protection'));
2644 $this->form->addItem($pass);
2645
2646 $text = new ilNumberInputGUI(
2647 $this->lng->txt('ps_login_max_attempts'),
2648 'login_max_attempts'
2649 );
2650 $text->setInfo($this->lng->txt('ps_login_max_attempts_info'));
2651 $text->setSize(1);
2652 $text->setMaxLength(2);
2653 $this->form->addItem($text);
2654
2655 // prevent login from multiple pcs at the same time
2656 $objCb = new ilCheckboxInputGUI(
2657 $this->lng->txt('ps_prevent_simultaneous_logins'),
2658 'ps_prevent_simultaneous_logins'
2659 );
2660 $objCb->setValue(1);
2661 $objCb->setInfo($this->lng->txt('ps_prevent_simultaneous_logins_info'));
2662 $this->form->addItem($objCb);
2663
2665 $log->setTitle($this->lng->txt('loginname_settings'));
2666 $this->form->addItem($log);
2667
2668 $chbChangeLogin = new ilCheckboxInputGUI(
2669 $this->lng->txt('allow_change_loginname'),
2670 'allow_change_loginname'
2671 );
2672 $chbChangeLogin->setValue(1);
2673 $this->form->addItem($chbChangeLogin);
2674 $chbCreateHistory = new ilCheckboxInputGUI(
2675 $this->lng->txt('history_loginname'),
2676 'create_history_loginname'
2677 );
2678 $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
2679 $chbCreateHistory->setValue(1);
2680
2681 $chbChangeLogin->addSubItem($chbCreateHistory);
2682 $chbReuseLoginnames = new ilCheckboxInputGUI(
2683 $this->lng->txt('reuse_of_loginnames_contained_in_history'),
2684 'reuse_of_loginnames'
2685 );
2686 $chbReuseLoginnames->setValue(1);
2687 $chbReuseLoginnames->setInfo($this->lng->txt('reuse_of_loginnames_contained_in_history_info'));
2688
2689 $chbChangeLogin->addSubItem($chbReuseLoginnames);
2690 $chbChangeBlockingTime = new ilNumberInputGUI(
2691 $this->lng->txt('loginname_change_blocking_time'),
2692 'loginname_change_blocking_time'
2693 );
2694 $chbChangeBlockingTime->allowDecimals(true);
2695 $chbChangeBlockingTime->setSuffix($this->lng->txt('days'));
2696 $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
2697 $chbChangeBlockingTime->setSize(10);
2698 $chbChangeBlockingTime->setMaxLength(10);
2699 $chbChangeLogin->addSubItem($chbChangeBlockingTime);
2700
2701 $la = new ilCheckboxInputGUI(
2702 $this->lng->txt('usr_letter_avatars'),
2703 'letter_avatars'
2704 );
2705 $la->setValue(1);
2706 $la->setInfo($this->lng->txt('usr_letter_avatars_info'));
2707 $this->form->addItem($la);
2708
2709 $passwordPolicySettingsHash = new \ilHiddenInputGUI('pw_policy_hash');
2710 $this->form->addItem($passwordPolicySettingsHash);
2711
2712 $this->form->addCommandButton(
2713 'saveGeneralSettings',
2714 $this->lng->txt('save')
2715 );
2716 }
2717
2726 public function settingsObject()
2727 {
2728 global $DIC;
2729
2730 $tpl = $DIC['tpl'];
2731 $lng = $DIC['lng'];
2732 $ilias = $DIC['ilias'];
2733 $ilTabs = $DIC['ilTabs'];
2734
2735 include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
2736 $lng->loadLanguageModule("administration");
2737 $lng->loadLanguageModule("mail");
2738 $lng->loadLanguageModule("chatroom");
2739 $this->setSubTabs('settings');
2740 $ilTabs->activateTab('settings');
2741 $ilTabs->activateSubTab('standard_fields');
2742
2743 include_once("./Services/User/classes/class.ilUserFieldSettingsTableGUI.php");
2744 $tab = new ilUserFieldSettingsTableGUI(
2745 $this,
2746 "settings"
2747 );
2748 if ($this->confirm_change) {
2749 $tab->setConfirmChange();
2750 }
2751 $tpl->setContent($tab->getHTML());
2752 }
2753
2754 public function confirmSavedObject()
2755 {
2756 $this->saveGlobalUserSettingsObject("save");
2757 }
2758
2759 public function saveGlobalUserSettingsObject($action = "")
2760 {
2761 include_once 'Services/Search/classes/class.ilUserSearchOptions.php';
2762 include_once 'Services/PrivacySecurity/classes/class.ilPrivacySettings.php';
2763
2764 global $DIC;
2765
2766 $ilias = $DIC['ilias'];
2767 $ilSetting = $DIC['ilSetting'];
2768
2770
2771 // see ilUserFieldSettingsTableGUI
2772 include_once("./Services/User/classes/class.ilUserProfile.php");
2773 $up = new ilUserProfile();
2774 $up->skipField("username");
2775 $field_properties = $up->getStandardFields();
2776 $profile_fields = array_keys($field_properties);
2777
2778 $valid = true;
2779 foreach ($profile_fields as $field) {
2780 if ($_POST["chb"]["required_" . $field] &&
2781 !(int) $_POST['chb']['visib_reg_' . $field]
2782 ) {
2783 $valid = false;
2784 break;
2785 }
2786 }
2787
2788 if (!$valid) {
2789 global $DIC;
2790
2791 $lng = $DIC['lng'];
2792 ilUtil::sendFailure($lng->txt('invalid_visible_required_options_selected'));
2793 $this->confirm_change = 1;
2794 $this->settingsObject();
2795 return;
2796 }
2797
2798 // For the following fields, the required state can not be changed
2799 $fixed_required_fields = array(
2800 "firstname" => 1,
2801 "lastname" => 1,
2802 "upload" => 0,
2803 "password" => 0,
2804 "language" => 0,
2805 "skin_style" => 0,
2806 "hits_per_page" => 0,
2807 /*"show_users_online" => 0,*/
2808 "hide_own_online_status" => 0
2809 );
2810
2811 // check if a course export state of any field has been added
2813 if ($privacy->enabledCourseExport() == true &&
2814 $privacy->courseConfirmationRequired() == true &&
2815 $action != "save") {
2816 foreach ($profile_fields as $field) {
2817 if (!$ilias->getSetting(
2818 "usr_settings_course_export_" . $field
2819 ) && $_POST["chb"]["course_export_" . $field] == "1") {
2820 #ilUtil::sendQuestion($this->lng->txt('confirm_message_course_export'));
2821 #$this->confirm_change = 1;
2822 #$this->settingsObject();
2823 #return;
2824 }
2825 }
2826 }
2827 // Reset user confirmation
2828 if ($action == 'save') {
2829 include_once('Services/Membership/classes/class.ilMemberAgreement.php');
2831 }
2832
2833 foreach ($profile_fields as $field) {
2834 // Enable disable searchable
2837 $field,
2838 (bool) $_POST['chb']['searchable_' . $field]
2839 );
2840 }
2841
2842 if (!$_POST["chb"]["visible_" . $field] && !$field_properties[$field]["visible_hide"]) {
2843 $user_settings_config->setVisible(
2844 $field,
2845 false
2846 );
2847 } else {
2848 $user_settings_config->setVisible(
2849 $field,
2850 true
2851 );
2852 }
2853
2854 if (!$_POST["chb"]["changeable_" . $field] && !$field_properties[$field]["changeable_hide"]) {
2855 $user_settings_config->setChangeable(
2856 $field,
2857 false
2858 );
2859 } else {
2860 $user_settings_config->setChangeable(
2861 $field,
2862 true
2863 );
2864 }
2865
2866 // registration visible
2867 if ((int) $_POST['chb']['visib_reg_' . $field] && !$field_properties[$field]["visib_reg_hide"]) {
2868 $ilSetting->set(
2869 'usr_settings_visib_reg_' . $field,
2870 '1'
2871 );
2872 } else {
2873 $ilSetting->set(
2874 'usr_settings_visib_reg_' . $field,
2875 '0'
2876 );
2877 }
2878
2879 if ((int) $_POST['chb']['visib_lua_' . $field]) {
2880 $ilSetting->set(
2881 'usr_settings_visib_lua_' . $field,
2882 '1'
2883 );
2884 } else {
2885 $ilSetting->set(
2886 'usr_settings_visib_lua_' . $field,
2887 '0'
2888 );
2889 }
2890
2891 if ((int) $_POST['chb']['changeable_lua_' . $field]) {
2892 $ilSetting->set(
2893 'usr_settings_changeable_lua_' . $field,
2894 '1'
2895 );
2896 } else {
2897 $ilSetting->set(
2898 'usr_settings_changeable_lua_' . $field,
2899 '0'
2900 );
2901 }
2902
2903 if ($_POST["chb"]["export_" . $field] && !$field_properties[$field]["export_hide"]) {
2904 $ilias->setSetting(
2905 "usr_settings_export_" . $field,
2906 "1"
2907 );
2908 } else {
2909 $ilias->deleteSetting("usr_settings_export_" . $field);
2910 }
2911
2912 // Course export/visibility
2913 if ($_POST["chb"]["course_export_" . $field] && !$field_properties[$field]["course_export_hide"]) {
2914 $ilias->setSetting(
2915 "usr_settings_course_export_" . $field,
2916 "1"
2917 );
2918 } else {
2919 $ilias->deleteSetting("usr_settings_course_export_" . $field);
2920 }
2921
2922 // Group export/visibility
2923 if ($_POST["chb"]["group_export_" . $field] && !$field_properties[$field]["group_export_hide"]) {
2924 $ilias->setSetting(
2925 "usr_settings_group_export_" . $field,
2926 "1"
2927 );
2928 } else {
2929 $ilias->deleteSetting("usr_settings_group_export_" . $field);
2930 }
2931
2932 $is_fixed = array_key_exists(
2933 $field,
2934 $fixed_required_fields
2935 );
2936 if ($is_fixed && $fixed_required_fields[$field] || !$is_fixed && $_POST["chb"]["required_" . $field]) {
2937 $ilias->setSetting(
2938 "require_" . $field,
2939 "1"
2940 );
2941 } else {
2942 $ilias->deleteSetting("require_" . $field);
2943 }
2944 }
2945
2946 if ($_POST["select"]["default_hits_per_page"]) {
2947 $ilias->setSetting(
2948 "hits_per_page",
2949 $_POST["select"]["default_hits_per_page"]
2950 );
2951 }
2952
2953 /*if ($_POST["select"]["default_show_users_online"])
2954 {
2955 $ilias->setSetting("show_users_online",$_POST["select"]["default_show_users_online"]);
2956 }*/
2957
2958 if ($_POST["chb"]["export_preferences"]) {
2959 $ilias->setSetting(
2960 "usr_settings_export_preferences",
2961 $_POST["chb"]["export_preferences"]
2962 );
2963 } else {
2964 $ilias->deleteSetting("usr_settings_export_preferences");
2965 }
2966
2967 $ilias->setSetting(
2968 'mail_incoming_mail',
2969 (int) $_POST['select']['default_mail_incoming_mail']
2970 );
2971 $ilias->setSetting(
2972 'chat_osc_accept_msg',
2973 ilUtil::stripSlashes($_POST['select']['default_chat_osc_accept_msg'])
2974 );
2975 $ilias->setSetting(
2976 'bs_allow_to_contact_me',
2977 ilUtil::stripSlashes($_POST['select']['default_bs_allow_to_contact_me'])
2978 );
2979 $ilias->setSetting(
2980 'hide_own_online_status',
2981 ilUtil::stripSlashes($_POST['select']['default_hide_own_online_status'])
2982 );
2983
2984 ilUtil::sendSuccess($this->lng->txt("usr_settings_saved"));
2985 $this->settingsObject();
2986 }
2987
2991 public function __buildUserFilterSelect()
2992 {
2993 $action[-1] = $this->lng->txt('all_users');
2994 $action[1] = $this->lng->txt('usr_active_only');
2995 $action[0] = $this->lng->txt('usr_inactive_only');
2996 $action[2] = $this->lng->txt('usr_limited_access_only');
2997 $action[3] = $this->lng->txt('usr_without_courses');
2998 $action[4] = $this->lng->txt('usr_filter_lastlogin');
2999 $action[5] = $this->lng->txt("usr_filter_coursemember");
3000 $action[6] = $this->lng->txt("usr_filter_groupmember");
3001 $action[7] = $this->lng->txt("usr_filter_role");
3002
3003 return ilUtil::formSelect(
3004 $_SESSION['user_filter'],
3005 "user_filter",
3006 $action,
3007 false,
3008 true
3009 );
3010 }
3011
3017 {
3018 if (!isset($_POST["file"])) {
3019 $this->ilias->raiseError(
3020 $this->lng->txt("no_checkbox"),
3021 $this->ilias->error_obj->MESSAGE
3022 );
3023 }
3024
3025 if (count($_POST["file"]) > 1) {
3026 $this->ilias->raiseError(
3027 $this->lng->txt("select_max_one_item"),
3028 $this->ilias->error_obj->MESSAGE
3029 );
3030 }
3031
3032 $file = basename($_POST["file"][0]);
3033
3034 $export_dir = $this->object->getExportDirectory();
3036 $export_dir . "/" . $file,
3037 $file
3038 );
3039 }
3040
3045 {
3046 if (!isset($_POST["file"])) {
3047 $this->ilias->raiseError(
3048 $this->lng->txt("no_checkbox"),
3049 $this->ilias->error_obj->MESSAGE
3050 );
3051 }
3052
3053 // display confirmation message
3054 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3055 $cgui = new ilConfirmationGUI();
3056 $cgui->setFormAction($this->ctrl->getFormAction($this));
3057 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
3058 $cgui->setCancel(
3059 $this->lng->txt("cancel"),
3060 "cancelDeleteExportFile"
3061 );
3062 $cgui->setConfirm(
3063 $this->lng->txt("confirm"),
3064 "deleteExportFile"
3065 );
3066
3067 // BEGIN TABLE DATA
3068 foreach ($_POST["file"] as $file) {
3069 $cgui->addItem(
3070 "file[]",
3071 $file,
3072 $file,
3073 ilObject::_getIcon($this->object->getId()),
3074 $this->lng->txt("obj_usrf")
3075 );
3076 }
3077
3078 $this->tpl->setContent($cgui->getHTML());
3079 }
3080
3085 {
3086 $this->ctrl->redirectByClass(
3087 "ilobjuserfoldergui",
3088 "export"
3089 );
3090 }
3091
3095 public function deleteExportFileObject()
3096 {
3097 $export_dir = $this->object->getExportDirectory();
3098 foreach ($_POST["file"] as $file) {
3099 $file = basename($file);
3100
3101 $exp_file = $export_dir . "/" . $file;
3102 if (@is_file($exp_file)) {
3103 unlink($exp_file);
3104 }
3105 }
3106 $this->ctrl->redirectByClass(
3107 "ilobjuserfoldergui",
3108 "export"
3109 );
3110 }
3111
3115 protected function performExportObject()
3116 {
3117 $this->checkPermission("write,read_users");
3118
3119 $this->object->buildExportFile($_POST["export_type"]);
3120 $this->ctrl->redirect(
3121 $this,
3122 'export'
3123 );
3124 }
3125
3129 public function exportObject()
3130 {
3131 global $DIC;
3132
3133 $this->checkPermission("write,read_users");
3134
3135 $button = ilSubmitButton::getInstance();
3136 $button->setCaption('create_export_file');
3137 $button->setCommand('performExport');
3138 $toolbar = $DIC->toolbar();
3139 $toolbar->setFormAction($this->ctrl->getFormAction($this));
3140
3141 $export_types = array(
3142 "userfolder_export_excel_x86",
3143 "userfolder_export_csv",
3144 "userfolder_export_xml"
3145 );
3146 $options = [];
3147 foreach ($export_types as $type) {
3148 $options[$type] = $this->lng->txt($type);
3149 }
3150 $type_selection = new \ilSelectInputGUI(
3151 '',
3152 'export_type'
3153 );
3154 $type_selection->setOptions($options);
3155
3156 $toolbar->addInputItem(
3157 $type_selection,
3158 true
3159 );
3160 $toolbar->addButtonInstance($button);
3161
3162 $table = new \ilUserExportFileTableGUI(
3163 $this,
3164 'export'
3165 );
3166 $table->init();
3167 $table->parse($this->object->getExportFiles());
3168
3169 $this->tpl->setContent($table->getHTML());
3170 }
3171
3172 protected function initNewAccountMailForm()
3173 {
3174 global $DIC;
3175
3176 $lng = $DIC['lng'];
3177 $ilCtrl = $DIC['ilCtrl'];
3178
3179 $lng->loadLanguageModule("meta");
3180 $lng->loadLanguageModule("mail");
3181
3182 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3183 $form = new ilPropertyFormGUI();
3184 $form->setFormAction($ilCtrl->getFormAction($this));
3185
3186 $form->setTitleIcon(ilUtil::getImagePath("icon_mail.svg"));
3187 $form->setTitle($lng->txt("user_new_account_mail"));
3188 $form->setDescription($lng->txt("user_new_account_mail_desc"));
3189
3190 $langs = $lng->getInstalledLanguages();
3191 foreach ($langs as $lang_key) {
3192 $amail = $this->object->_lookupNewAccountMail($lang_key);
3193
3194 $title = $lng->txt("meta_l_" . $lang_key);
3195 if ($lang_key == $lng->getDefaultLanguage()) {
3196 $title .= " (" . $lng->txt("default") . ")";
3197 }
3198
3199 $header = new ilFormSectionHeaderGUI();
3200 $header->setTitle($title);
3201 $form->addItem($header);
3202
3203 $subj = new ilTextInputGUI(
3204 $lng->txt("subject"),
3205 "subject_" . $lang_key
3206 );
3207 // $subj->setRequired(true);
3208 $subj->setValue($amail["subject"]);
3209 $form->addItem($subj);
3210
3211 $salg = new ilTextInputGUI(
3212 $lng->txt("mail_salutation_general"),
3213 "sal_g_" . $lang_key
3214 );
3215 // $salg->setRequired(true);
3216 $salg->setValue($amail["sal_g"]);
3217 $form->addItem($salg);
3218
3219 $salf = new ilTextInputGUI(
3220 $lng->txt("mail_salutation_female"),
3221 "sal_f_" . $lang_key
3222 );
3223 // $salf->setRequired(true);
3224 $salf->setValue($amail["sal_f"]);
3225 $form->addItem($salf);
3226
3227 $salm = new ilTextInputGUI(
3228 $lng->txt("mail_salutation_male"),
3229 "sal_m_" . $lang_key
3230 );
3231 // $salm->setRequired(true);
3232 $salm->setValue($amail["sal_m"]);
3233 $form->addItem($salm);
3234
3235 $body = new ilTextAreaInputGUI(
3236 $lng->txt("message_content"),
3237 "body_" . $lang_key
3238 );
3239 // $body->setRequired(true);
3240 $body->setValue($amail["body"]);
3241 $body->setRows(10);
3242 $body->setCols(100);
3243 $form->addItem($body);
3244
3245 $att = new ilFileInputGUI(
3246 $lng->txt("attachment"),
3247 "att_" . $lang_key
3248 );
3249 $att->setAllowDeletion(true);
3250 if ($amail["att_file"]) {
3251 $att->setValue($amail["att_file"]);
3252 }
3253 $form->addItem($att);
3254 }
3255
3256 $form->addCommandButton(
3257 "saveNewAccountMail",
3258 $lng->txt("save")
3259 );
3260 $form->addCommandButton(
3261 "cancelNewAccountMail",
3262 $lng->txt("cancel")
3263 );
3264
3265 return $form;
3266 }
3267
3271 public function newAccountMailObject()
3272 {
3273 global $DIC;
3274
3275 $lng = $DIC['lng'];
3276
3277 $this->setSubTabs('settings');
3278 $this->tabs_gui->setTabActive('settings');
3279 $this->tabs_gui->setSubTabActive('user_new_account_mail');
3280
3281 $form = $this->initNewAccountMailForm();
3282
3283 $ftpl = new ilTemplate(
3284 'tpl.usrf_new_account_mail.html',
3285 true,
3286 true,
3287 'Services/User'
3288 );
3289 $ftpl->setVariable(
3290 "FORM",
3291 $form->getHTML()
3292 );
3293 unset($form);
3294
3295 // placeholder help text
3296 $ftpl->setVariable(
3297 "TXT_USE_PLACEHOLDERS",
3298 $lng->txt("mail_nacc_use_placeholder")
3299 );
3300 $ftpl->setVariable(
3301 "TXT_MAIL_SALUTATION",
3302 $lng->txt("mail_nacc_salutation")
3303 );
3304 $ftpl->setVariable(
3305 "TXT_FIRST_NAME",
3306 $lng->txt("firstname")
3307 );
3308 $ftpl->setVariable(
3309 "TXT_LAST_NAME",
3310 $lng->txt("lastname")
3311 );
3312 $ftpl->setVariable(
3313 "TXT_EMAIL",
3314 $lng->txt("email")
3315 );
3316 $ftpl->setVariable(
3317 "TXT_LOGIN",
3318 $lng->txt("mail_nacc_login")
3319 );
3320 $ftpl->setVariable(
3321 "TXT_PASSWORD",
3322 $lng->txt("password")
3323 );
3324 $ftpl->setVariable(
3325 "TXT_PASSWORD_BLOCK",
3326 $lng->txt("mail_nacc_pw_block")
3327 );
3328 $ftpl->setVariable(
3329 "TXT_NOPASSWORD_BLOCK",
3330 $lng->txt("mail_nacc_no_pw_block")
3331 );
3332 $ftpl->setVariable(
3333 "TXT_ADMIN_MAIL",
3334 $lng->txt("mail_nacc_admin_mail")
3335 );
3336 $ftpl->setVariable(
3337 "TXT_ILIAS_URL",
3338 $lng->txt("mail_nacc_ilias_url")
3339 );
3340 $ftpl->setVariable(
3341 "TXT_CLIENT_NAME",
3342 $lng->txt("mail_nacc_client_name")
3343 );
3344 $ftpl->setVariable(
3345 "TXT_TARGET",
3346 $lng->txt("mail_nacc_target")
3347 );
3348 $ftpl->setVariable(
3349 "TXT_TARGET_TITLE",
3350 $lng->txt("mail_nacc_target_title")
3351 );
3352 $ftpl->setVariable(
3353 "TXT_TARGET_TYPE",
3354 $lng->txt("mail_nacc_target_type")
3355 );
3356 $ftpl->setVariable(
3357 "TXT_TARGET_BLOCK",
3358 $lng->txt("mail_nacc_target_block")
3359 );
3360 $ftpl->setVariable(
3361 "TXT_IF_TIMELIMIT",
3362 $lng->txt("mail_nacc_if_timelimit")
3363 );
3364 $ftpl->setVariable(
3365 "TXT_TIMELIMIT",
3366 $lng->txt("mail_nacc_timelimit")
3367 );
3368
3369 $this->tpl->setContent($ftpl->get());
3370 }
3371
3373 {
3374 $this->ctrl->redirect(
3375 $this,
3376 "settings"
3377 );
3378 }
3379
3381 {
3382 global $DIC;
3383
3384 $lng = $DIC['lng'];
3385
3386 $langs = $lng->getInstalledLanguages();
3387 foreach ($langs as $lang_key) {
3388 $this->object->_writeNewAccountMail(
3389 $lang_key,
3390 ilUtil::stripSlashes($_POST["subject_" . $lang_key]),
3391 ilUtil::stripSlashes($_POST["sal_g_" . $lang_key]),
3392 ilUtil::stripSlashes($_POST["sal_f_" . $lang_key]),
3393 ilUtil::stripSlashes($_POST["sal_m_" . $lang_key]),
3394 ilUtil::stripSlashes($_POST["body_" . $lang_key])
3395 );
3396
3397 if ($_FILES["att_" . $lang_key]["tmp_name"]) {
3398 $this->object->_updateAccountMailAttachment(
3399 $lang_key,
3400 $_FILES["att_" . $lang_key]["tmp_name"],
3401 $_FILES["att_" . $lang_key]["name"]
3402 );
3403 }
3404
3405 if ($_POST["att_" . $lang_key . "_delete"]) {
3406 $this->object->_deleteAccountMailAttachment($lang_key);
3407 }
3408 }
3409
3410 ilUtil::sendSuccess(
3411 $this->lng->txt("msg_obj_modified"),
3412 true
3413 );
3414 $this->ctrl->redirect(
3415 $this,
3416 "newAccountMail"
3417 );
3418 }
3419
3420 public function getAdminTabs()
3421 {
3422 $this->getTabs();
3423 }
3424
3430 public function getTabs()
3431 {
3432 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
3433
3434 global $DIC;
3435
3436 $rbacsystem = $DIC['rbacsystem'];
3437 $access = $DIC->access();
3438
3439 if ($rbacsystem->checkAccess(
3440 "visible,read",
3441 $this->object->getRefId()
3442 )) {
3443 $this->tabs_gui->addTarget(
3444 "usrf",
3445 $this->ctrl->getLinkTarget(
3446 $this,
3447 "view"
3448 ),
3449 array("view", "delete", "resetFilter", "userAction", ""),
3450 "",
3451 ""
3452 );
3453 }
3454
3455 if ($access->checkRbacOrPositionPermissionAccess(
3456 "read_users",
3459 )) {
3460 $this->tabs_gui->addTarget(
3461 "search_user_extended",
3462 $this->ctrl->getLinkTargetByClass(
3463 'ilRepositorySearchGUI',
3464 ''
3465 ),
3466 [],
3467 "ilrepositorysearchgui",
3468 ""
3469 );
3470 }
3471
3472 if ($rbacsystem->checkAccess(
3473 "write,read_users",
3474 $this->object->getRefId()
3475 )) {
3476 $this->tabs_gui->addTarget(
3477 "settings",
3478 $this->ctrl->getLinkTarget(
3479 $this,
3480 "generalSettings"
3481 ),
3482 array('askForUserPasswordReset',
3483 'forceUserPasswordReset',
3484 'settings',
3485 'generalSettings',
3486 'listUserDefinedField',
3487 'newAccountMail'
3488 )
3489 );
3490
3491 $this->tabs_gui->addTarget(
3492 "export",
3493 $this->ctrl->getLinkTarget(
3494 $this,
3495 "export"
3496 ),
3497 "export",
3498 "",
3499 ""
3500 );
3501 }
3502
3503 if ($rbacsystem->checkAccess(
3504 'edit_permission',
3505 $this->object->getRefId()
3506 )) {
3507 $this->tabs_gui->addTarget(
3508 "perm_settings",
3509 $this->ctrl->getLinkTargetByClass(
3510 array(get_class($this), 'ilpermissiongui'),
3511 "perm"
3512 ),
3513 array("perm", "info", "owner"),
3514 'ilpermissiongui'
3515 );
3516 }
3517 }
3518
3522 public function setSubTabs($a_tab)
3523 {
3524 global $DIC;
3525
3526 $rbacsystem = $DIC['rbacsystem'];
3527 $ilUser = $DIC['ilUser'];
3528
3529 switch ($a_tab) {
3530 case "settings":
3531 $this->tabs_gui->addSubTabTarget(
3532 'general_settings',
3533 $this->ctrl->getLinkTarget(
3534 $this,
3535 'generalSettings'
3536 ),
3537 'generalSettings',
3538 get_class($this)
3539 );
3540 $this->tabs_gui->addSubTabTarget(
3541 "standard_fields",
3542 $this->ctrl->getLinkTarget(
3543 $this,
3544 'settings'
3545 ),
3546 array("settings", "saveGlobalUserSettings"),
3547 get_class($this)
3548 );
3549 $this->tabs_gui->addSubTabTarget(
3550 "user_defined_fields",
3551 $this->ctrl->getLinkTargetByClass(
3552 "ilcustomuserfieldsgui",
3553 "listUserDefinedFields"
3554 ),
3555 "listUserDefinedFields",
3556 get_class($this)
3557 );
3558 $this->tabs_gui->addSubTabTarget(
3559 "user_new_account_mail",
3560 $this->ctrl->getLinkTarget(
3561 $this,
3562 'newAccountMail'
3563 ),
3564 "newAccountMail",
3565 get_class($this)
3566 );
3567
3568 $this->tabs_gui->addSubTabTarget(
3569 "starting_points",
3570 $this->ctrl->getLinkTargetByClass(
3571 "iluserstartingpointgui",
3572 "startingPoints"
3573 ),
3574 "startingPoints",
3575 get_class($this)
3576 );
3577
3578 $this->tabs_gui->addSubTabTarget(
3579 "user_profile_info",
3580 $this->ctrl->getLinkTargetByClass(
3581 "ilUserProfileInfoSettingsGUI",
3582 ''
3583 ),
3584 "",
3585 "ilUserProfileInfoSettingsGUI"
3586 );
3587
3588 #$this->tabs_gui->addSubTab("account_codes", $this->lng->txt("user_account_codes"),
3589 # $this->ctrl->getLinkTargetByClass("ilaccountcodesgui"));
3590 break;
3591 }
3592 }
3593
3595 {
3596 global $DIC;
3597
3598 $ilSetting = $DIC['ilSetting'];
3599
3600 $show_blocking_time_in_days = (int) $ilSetting->get('loginname_change_blocking_time') / 86400;
3601
3602 $this->initLoginSettingsForm();
3603 $this->loginSettingsForm->setValuesByArray(
3604 array(
3605 'allow_change_loginname' => (bool) $ilSetting->get('allow_change_loginname'),
3606 'create_history_loginname' => (bool) $ilSetting->get('create_history_loginname'),
3607 'reuse_of_loginnames' => (bool) $ilSetting->get('reuse_of_loginnames'),
3608 'loginname_change_blocking_time' => (float) $show_blocking_time_in_days
3609 )
3610 );
3611
3612 $this->tpl->setVariable(
3613 'ADM_CONTENT',
3614 $this->loginSettingsForm->getHTML()
3615 );
3616 }
3617
3618 private function initLoginSettingsForm()
3619 {
3620 $this->setSubTabs('settings');
3621 $this->tabs_gui->setTabActive('settings');
3622 $this->tabs_gui->setSubTabActive('loginname_settings');
3623
3624 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3625 $this->loginSettingsForm = new ilPropertyFormGUI;
3626 $this->loginSettingsForm->setFormAction(
3627 $this->ctrl->getFormAction(
3628 $this,
3629 'saveLoginnameSettings'
3630 )
3631 );
3632 $this->loginSettingsForm->setTitle($this->lng->txt('loginname_settings'));
3633
3634 $chbChangeLogin = new ilCheckboxInputGUI(
3635 $this->lng->txt('allow_change_loginname'),
3636 'allow_change_loginname'
3637 );
3638 $chbChangeLogin->setValue(1);
3639 $this->loginSettingsForm->addItem($chbChangeLogin);
3640 $chbCreateHistory = new ilCheckboxInputGUI(
3641 $this->lng->txt('history_loginname'),
3642 'create_history_loginname'
3643 );
3644 $chbCreateHistory->setInfo($this->lng->txt('loginname_history_info'));
3645 $chbCreateHistory->setValue(1);
3646 $chbChangeLogin->addSubItem($chbCreateHistory);
3647 $chbReuseLoginnames = new ilCheckboxInputGUI(
3648 $this->lng->txt('reuse_of_loginnames_contained_in_history'),
3649 'reuse_of_loginnames'
3650 );
3651 $chbReuseLoginnames->setValue(1);
3652 $chbReuseLoginnames->setInfo($this->lng->txt('reuse_of_loginnames_contained_in_history_info'));
3653 $chbChangeLogin->addSubItem($chbReuseLoginnames);
3654 $chbChangeBlockingTime = new ilNumberInputGUI(
3655 $this->lng->txt('loginname_change_blocking_time'),
3656 'loginname_change_blocking_time'
3657 );
3658 $chbChangeBlockingTime->allowDecimals(true);
3659 $chbChangeBlockingTime->setSuffix($this->lng->txt('days'));
3660 $chbChangeBlockingTime->setInfo($this->lng->txt('loginname_change_blocking_time_info'));
3661 $chbChangeBlockingTime->setSize(10);
3662 $chbChangeBlockingTime->setMaxLength(10);
3663 $chbChangeLogin->addSubItem($chbChangeBlockingTime);
3664
3665 $this->loginSettingsForm->addCommandButton(
3666 'saveLoginnameSettings',
3667 $this->lng->txt('save')
3668 );
3669 }
3670
3672 {
3673 global $DIC;
3674
3675 $ilUser = $DIC['ilUser'];
3676 $ilSetting = $DIC['ilSetting'];
3677
3678 $this->initLoginSettingsForm();
3679 if ($this->loginSettingsForm->checkInput()) {
3680 $valid = true;
3681
3682 if (!strlen($this->loginSettingsForm->getInput('loginname_change_blocking_time'))) {
3683 $valid = false;
3684 $this->loginSettingsForm->getItemByPostVar('loginname_change_blocking_time')
3685 ->setAlert($this->lng->txt('loginname_change_blocking_time_invalidity_info'));
3686 }
3687
3688 if ($valid) {
3689 $save_blocking_time_in_seconds = (int) $this->loginSettingsForm->getInput(
3690 'loginname_change_blocking_time'
3691 ) * 86400;
3692
3693 $ilSetting->set(
3694 'allow_change_loginname',
3695 (int) $this->loginSettingsForm->getInput('allow_change_loginname')
3696 );
3697 $ilSetting->set(
3698 'create_history_loginname',
3699 (int) $this->loginSettingsForm->getInput('create_history_loginname')
3700 );
3701 $ilSetting->set(
3702 'reuse_of_loginnames',
3703 (int) $this->loginSettingsForm->getInput('reuse_of_loginnames')
3704 );
3705 $ilSetting->set(
3706 'loginname_change_blocking_time',
3707 (int) $save_blocking_time_in_seconds
3708 );
3709
3710 ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
3711 } else {
3712 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
3713 }
3714 } else {
3715 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
3716 }
3717 $this->loginSettingsForm->setValuesByPost();
3718
3719 $this->tpl->setVariable(
3720 'ADM_CONTENT',
3721 $this->loginSettingsForm->getHTML()
3722 );
3723 }
3724
3728 public static function _goto($a_user)
3729 {
3730 global $DIC;
3731
3732 $ilAccess = $DIC['ilAccess'];
3733 $ilErr = $DIC['ilErr'];
3734 $lng = $DIC['lng'];
3735 $ctrl = $DIC['ilCtrl'];
3736
3737 $a_target = USER_FOLDER_ID;
3738
3739 if ($ilAccess->checkAccess(
3740 "read",
3741 "",
3742 $a_target
3743 )) {
3744 $ctrl->redirectToURL("ilias.php?baseClass=ilAdministrationGUI&ref_id=" . $a_target . "&jmpToUser=" . $a_user);
3745 exit;
3746 } else {
3747 if ($ilAccess->checkAccess(
3748 "read",
3749 "",
3751 )) {
3753 sprintf(
3754 $lng->txt("msg_no_perm_read_item"),
3756 ),
3757 true
3758 );
3760 }
3761 }
3762 $ilErr->raiseError(
3763 $lng->txt("msg_no_perm_read"),
3764 $ilErr->FATAL
3765 );
3766 }
3767
3771 public function jumpToUserObject()
3772 {
3773 global $DIC;
3774
3775 $ilCtrl = $DIC['ilCtrl'];
3776
3777 if (((int) $_GET["jmpToUser"]) > 0 && ilObject::_lookupType((int) $_GET["jmpToUser"]) == "usr") {
3778 $ilCtrl->setParameterByClass(
3779 "ilobjusergui",
3780 "obj_id",
3781 (int) $_GET["jmpToUser"]
3782 );
3783 $ilCtrl->redirectByClass(
3784 "ilobjusergui",
3785 "view"
3786 );
3787 }
3788 }
3789
3794 public function searchUserAccessFilterCallable(array $a_user_ids) : array
3795 {
3796 global $DIC;
3797 $access = $DIC->access();
3798
3799 if (!$this->checkPermissionBool("read_users")) {
3800 $a_user_ids = $access->filterUserIdsByPositionOfCurrentUser(
3803 $a_user_ids
3804 );
3805 }
3806
3807 return $a_user_ids;
3808 }
3809
3813 public function searchResultHandler($a_usr_ids, $a_cmd)
3814 {
3815 if (!count((array) $a_usr_ids)) {
3816 ilUtil::sendFailure($this->lng->txt('select_one'));
3817 return false;
3818 }
3819
3820 $_POST['id'] = $a_usr_ids;
3821
3822 // no real confirmation here
3823 if (stristr(
3824 $a_cmd,
3825 "export"
3826 )) {
3827 $cmd = $a_cmd . "Object";
3828 return $this->$cmd();
3829 }
3830
3831 $_POST['selectedAction'] = $a_cmd;
3832 return $this->showActionConfirmation(
3833 $a_cmd,
3834 true
3835 );
3836 }
3837
3838 public function getUserMultiCommands($a_search_form = false)
3839 {
3840 global $DIC;
3841
3842 $rbacsystem = $DIC['rbacsystem'];
3843 $ilUser = $DIC['ilUser'];
3844
3845 $cmds = [];
3846 // see searchResultHandler()
3847 if ($a_search_form) {
3848 if ($rbacsystem->checkAccess('write', $this->object->getRefId())) {
3849 $cmds = [
3850 'activate' => $this->lng->txt('activate'),
3851 'deactivate' => $this->lng->txt('deactivate'),
3852 'accessRestrict' => $this->lng->txt('accessRestrict'),
3853 'accessFree' => $this->lng->txt('accessFree')
3854 ];
3855 }
3856
3857 if ($rbacsystem->checkAccess('delete', $this->object->getRefId())) {
3858 $cmds["delete"] = $this->lng->txt("delete");
3859 }
3860 } // show confirmation
3861 else {
3862 if ($rbacsystem->checkAccess('write', $this->object->getRefId())) {
3863 $cmds = [
3864 'activateUsers' => $this->lng->txt('activate'),
3865 'deactivateUsers' => $this->lng->txt('deactivate'),
3866 'restrictAccess' => $this->lng->txt('accessRestrict'),
3867 'freeAccess' => $this->lng->txt('accessFree')
3868 ];
3869 }
3870
3871 if ($rbacsystem->checkAccess('delete', $this->object->getRefId())) {
3872 $cmds["deleteUsers"] = $this->lng->txt("delete");
3873 }
3874 }
3875
3876 if ($rbacsystem->checkAccess('write', $this->object->getRefId())) {
3877 $export_types = array("userfolder_export_excel_x86", "userfolder_export_csv", "userfolder_export_xml");
3878 foreach ($export_types as $type) {
3879 $cmd = explode(
3880 "_",
3881 $type
3882 );
3883 $cmd = array_pop($cmd);
3884 $cmds['usrExport' . ucfirst($cmd)] = $this->lng->txt('export') . ' - ' .
3885 $this->lng->txt($type);
3886 }
3887 }
3888
3889 // check if current user may send mails
3890 include_once "Services/Mail/classes/class.ilMail.php";
3891 $mail = new ilMail($ilUser->getId());
3892 if ($rbacsystem->checkAccess(
3893 'internal_mail',
3894 $mail->getMailObjectReferenceId()
3895 )) {
3896 $cmds["mail"] = $this->lng->txt("send_mail");
3897 }
3898
3899 $cmds['addToClipboard'] = $this->lng->txt('clipboard_add_btn');
3900
3901 return $cmds;
3902 }
3903
3907 protected function usrExportX86Object()
3908 {
3909 $user_ids = $this->getActionUserIds();
3910 if (!$user_ids) {
3912 $this->lng->txt('select_one'),
3913 true
3914 );
3915 return $this->ctrl->redirect(
3916 $this,
3917 'view'
3918 );
3919 }
3920
3921 if ($this->checkPermissionBool('write,read_users')) {
3922 $this->object->buildExportFile(
3924 $user_ids
3925 );
3926 $this->ctrl->redirectByClass(
3927 "ilobjuserfoldergui",
3928 "export"
3929 );
3930 } elseif ($this->checkUserManipulationAccessBool()) {
3931 $fullname = $this->object->buildExportFile(
3933 $user_ids,
3934 true
3935 );
3937 $fullname . '.xlsx',
3938 $this->object->getExportFilename(ilObjUserFolder::FILE_TYPE_EXCEL) . '.xlsx',
3939 '',
3940 false,
3941 true
3942 );
3943 }
3944 }
3945
3949 protected function usrExportCsvObject()
3950 {
3951 $user_ids = $this->getActionUserIds();
3952 if (!$user_ids) {
3954 $this->lng->txt('select_one'),
3955 true
3956 );
3957 return $this->ctrl->redirect(
3958 $this,
3959 'view'
3960 );
3961 }
3962
3963 if ($this->checkPermissionBool("write,read_users")) {
3964 $this->object->buildExportFile(
3966 $user_ids
3967 );
3968 $this->ctrl->redirectByClass(
3969 "ilobjuserfoldergui",
3970 "export"
3971 );
3972 } elseif ($this->checkUserManipulationAccessBool()) {
3973 $fullname = $this->object->buildExportFile(
3975 $user_ids,
3976 true
3977 );
3979 $fullname,
3980 $this->object->getExportFilename(ilObjUserFolder::FILE_TYPE_CSV),
3981 '',
3982 false,
3983 true
3984 );
3985 }
3986 }
3987
3991 protected function usrExportXmlObject()
3992 {
3993 $user_ids = $this->getActionUserIds();
3994 if (!$user_ids) {
3996 $this->lng->txt('select_one'),
3997 true
3998 );
3999 return $this->ctrl->redirect(
4000 $this,
4001 'view'
4002 );
4003 }
4004 if ($this->checkPermissionBool("write,read_users")) {
4005 $this->object->buildExportFile(
4007 $user_ids
4008 );
4009 $this->ctrl->redirectByClass(
4010 "ilobjuserfoldergui",
4011 "export"
4012 );
4013 } elseif ($this->checkUserManipulationAccessBool()) {
4014 $fullname = $this->object->buildExportFile(
4016 $user_ids,
4017 true
4018 );
4020 $fullname,
4021 $this->object->getExportFilename(ilObjUserFolder::FILE_TYPE_XML),
4022 '',
4023 false,
4024 true
4025 );
4026 }
4027 }
4028
4032 protected function mailObject()
4033 {
4034 global $DIC;
4035
4036 $ilUser = $DIC['ilUser'];
4037
4038 $user_ids = $this->getActionUserIds();
4039 if (!$user_ids) {
4041 $this->lng->txt('select_one'),
4042 true
4043 );
4044 return $this->ctrl->redirect(
4045 $this,
4046 'view'
4047 );
4048 }
4049
4050 // remove existing (temporary) lists
4051 include_once "Services/Contact/classes/class.ilMailingLists.php";
4052 $list = new ilMailingLists($ilUser);
4053 $list->deleteTemporaryLists();
4054
4055 // create (temporary) mailing list
4056 include_once "Services/Contact/classes/class.ilMailingList.php";
4057 $list = new ilMailingList($ilUser);
4058 $list->setMode(ilMailingList::MODE_TEMPORARY);
4059 $list->setTitle("-TEMPORARY SYSTEM LIST-");
4060 $list->setDescription("-USER ACCOUNTS MAIL-");
4061 $list->setCreateDate(date("Y-m-d H:i:s"));
4062 $list->insert();
4063 $list_id = $list->getId();
4064
4065 // after list has been saved...
4066 foreach ($user_ids as $user_id) {
4067 $list->assignUser($user_id);
4068 }
4069
4070 include_once "Services/Mail/classes/class.ilFormatMail.php";
4071 $umail = new ilFormatMail($ilUser->getId());
4072 $mail_data = $umail->getSavedData();
4073
4074 if (!is_array($mail_data)) {
4075 $mail_data = array("user_id" => $ilUser->getId());
4076 }
4077
4078 // ???
4079 // $mail_data = $umail->appendSearchResult(array('#il_ml_'.$list_id), 'to');
4080
4081 $umail->savePostData(
4082 $mail_data['user_id'],
4083 $mail_data['attachments'],
4084 '#il_ml_' . $list_id,
4085 // $mail_data['rcp_to'],
4086 $mail_data['rcp_cc'],
4087 $mail_data['rcp_bcc'],
4088 $mail_data['m_type'],
4089 $mail_data['m_email'],
4090 $mail_data['m_subject'],
4091 $mail_data['m_message'],
4092 $mail_data['use_placeholders'],
4093 $mail_data['tpl_ctx_id'],
4094 $mail_data['tpl_ctx_params']
4095 );
4096
4097 require_once 'Services/Mail/classes/class.ilMailFormCall.php';
4100 $this,
4101 '',
4102 [],
4103 array(
4104 'type' => 'search_res'
4105 )
4106 )
4107 );
4108 }
4109
4110 public function addToExternalSettingsForm($a_form_id)
4111 {
4112 global $DIC;
4113
4114 switch ($a_form_id) {
4116
4117 include_once('./Services/PrivacySecurity/classes/class.ilSecuritySettings.php');
4119
4120 $fields = [];
4121
4122 $subitems = array(
4123 'ps_password_change_on_first_login_enabled' => array($security->isPasswordChangeOnFirstLoginEnabled(
4124 ),
4126 ),
4127 'ps_password_must_not_contain_loginame' => array((bool) $security->getPasswordMustNotContainLoginnameStatus(
4128 ),
4130 ),
4131 'ps_password_chars_and_numbers_enabled' => array($security->isPasswordCharsAndNumbersEnabled(),
4133 ),
4134 'ps_password_special_chars_enabled' => array($security->isPasswordSpecialCharsEnabled(),
4136 ),
4137 'ps_password_min_length' => (int) $security->getPasswordMinLength(),
4138 'ps_password_max_length' => (int) $security->getPasswordMaxLength(),
4139 'ps_password_uppercase_chars_num' => (int) $security->getPasswordNumberOfUppercaseChars(),
4140 'ps_password_lowercase_chars_num' => (int) $security->getPasswordNumberOfLowercaseChars(),
4141 'ps_password_max_age' => (int) $security->getPasswordMaxAge()
4142 );
4143 $fields['ps_password_settings'] = array(null, null, $subitems);
4144
4145 $subitems = array(
4146 'ps_login_max_attempts' => (int) $security->getLoginMaxAttempts(),
4147 'ps_prevent_simultaneous_logins' => array($security->isPreventionOfSimultaneousLoginsEnabled(),
4149 )
4150 );
4151 $fields['ps_security_protection'] = array(null, null, $subitems);
4152
4153 return array(array("generalSettings", $fields));
4154
4156 return [
4157 [
4158 'generalSettings', [
4159 'tos_withdrawal_usr_deletion' => $DIC->settings()->get(
4160 'tos_withdrawal_usr_deletion',
4161 false
4162 ) ? $DIC->language()->txt('enabled') : $DIC->language()->txt('disabled'),
4163 ]
4164 ],
4165 ];
4166 }
4167 }
4168
4172 protected function addToClipboardObject()
4173 {
4174 $users = $this->getActionUserIds();
4175 if (!count($users)) {
4177 $this->lng->txt('select_one'),
4178 true
4179 );
4180 $this->ctrl->redirect(
4181 $this,
4182 'view'
4183 );
4184 }
4185 include_once './Services/User/classes/class.ilUserClipboard.php';
4186 $clip = ilUserClipboard::getInstance($GLOBALS['DIC']['ilUser']->getId());
4187 $clip->add($users);
4188 $clip->save();
4189
4190 ilUtil::sendSuccess(
4191 $this->lng->txt('clipboard_user_added'),
4192 true
4193 );
4194 $this->ctrl->redirect(
4195 $this,
4196 'view'
4197 );
4198 }
4199} // END class.ilObjUserFolderGUI
$result
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$n
Definition: RandomTest.php:85
$_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 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 _getUserFolderId()
static _getAllUserIds($a_filter=0)
static getLogger($a_component_id)
Get component logger.
static getRedirectTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
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.
addToClipboardObject()
Add users to clipboard.
deactivateUsersObject()
Deactivate users.
importCancelledObject()
import cancelled @access private
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 @access public.
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.
getPasswordPolicySettingsMap(\ilSecuritySettings $security)
__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor @access public.
filterUserIdsByRbacOrPositionOfCurrentUser(array $user_ids)
confirmdeleteObject()
confirm delete Object @access public
initFormGeneralSettings()
init general settings form
getUserMultiCommands($a_search_form=false)
getAdminTabs()
administration tabs show only permissions and trash folder
initUserRoleAssignmentForm($xml_file_full_path)
viewObject($reset_filter=false)
list users @access public
setAccessRestrictionObject($a_form=null, $a_from_search=false)
importUserFormObject()
display form for user import
confirmaccessFreeObject()
"access free"
importUserRoleAssignmentObject()
display form for user import with new FileSystem implementation
jumpToUserObject()
Jump to edit screen for user.
__buildUserFilterSelect()
build select form to distinguish between active and non-active users
importUsersObject()
Import Users with new form implementation.
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 Sends a selected export file for download.
confirmDeleteExportFileObject()
confirmation screen for export file deletion
settingsObject()
Global user settings Allows to define global settings for user accounts Note: The Global user setting...
static _goto($a_user)
goto target group
getImportDir()
get user import directory name with new FileSystem implementation
getTabs()
get tabs @access public
showActionConfirmation($action, $a_from_search=false)
display activation confirmation screen
searchUserAccessFilterCallable(array $a_user_ids)
showActions($with_subobjects=false)
show possible action (form buttons)
setSubTabs($a_tab)
set sub tabs
handleUploadedFiles()
Handles uploaded zip/xmp files with Filesystem implementation.
executeCommand()
execute command
deleteExportFileObject()
delete export files
generalSettingsObject()
Show user account general settings.
checkUserManipulationAccessBool()
Check if current user has access to manipulate user data.
confirmactivateObject()
Set the selected users active @access public.
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(?array $user_ids=null)
Get first letters of all lastnames.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObjectGUI Basic methods of all Output classes.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
prepareOutput($a_show_subobjects=true)
prepare output
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
Singleton class that stores all security settings.
isPasswordSpecialCharsEnabled()
get boolean if the passwords have to contain special characters
getPasswordMustNotContainLoginnameStatus()
Return whether the password must not contain the loginname or not.
getPasswordMinLength()
get the minimum length for passwords
getPasswordMaxLength()
get the maximum length for passwords
getPasswordNumberOfUppercaseChars()
Returns number of uppercase characters required.
isPasswordCharsAndNumbersEnabled()
get boolean if the passwords have to contain characters and numbers
static _getInstance()
Get instance of ilSecuritySettings.
getPasswordNumberOfLowercaseChars()
Returns number of lowercase characters required.
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.
static getInstance()
Factory.
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.
static getInstance()
Single method to reduce footprint (included files, created instances)
User profile info settings UI class.
Class ilUserProfile.
static _saveStatus($a_key, $a_enabled)
User settings configuration (what preferences can be visible/changed/...)
Class ilUserStartingPointGUI.
TableGUI class for user administration.
static getDataDir()
get data directory (outside webspace)
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
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 getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const SYSTEM_ROLE_ID
Definition: constants.php:27
const ANONYMOUS_ROLE_ID
Definition: constants.php:26
const USER_FOLDER_ID
Definition: constants.php:31
const ROLE_FOLDER_ID
Definition: constants.php:32
const ROOT_FOLDER_ID
Definition: constants.php:30
$login
Definition: cron.php:13
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
$valid
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$i
Definition: metadata.php:24
$keys
Definition: metadata.php:187
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
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
$message
Definition: xapiexit.php:14