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