19declare(strict_types=1);
32use ILIAS\User\Profile\Fields\CustomFieldsGUI;
58 use ilTableCommandHelper;
61 'visible' =>
'user_visible_in_profile',
62 'changeable' =>
'changeable',
63 'searchable' =>
'header_searchable',
64 'required' =>
'required_field',
66 'course_export' =>
'course_export',
67 'group_export' =>
'group_export',
68 'prg_export' =>
'prg_export',
69 'visib_reg' =>
'header_visible_registration',
70 'visib_lua' =>
'usr_settings_visib_lua',
71 'changeable_lua' =>
'usr_settings_changeable_lua'
96 bool $a_call_by_reference
101 $this->
event = $DIC[
'ilAppEventHandler'];
102 $this->
filesystem = $DIC->filesystem()->storage();
103 $this->
upload = $DIC[
'upload'];
104 $this->db =
$DIC[
'ilDB'];
105 $this->mail_mustache_factory =
$DIC->mail()->mustacheFactory();
106 $this->archives =
$DIC->legacyArchives();
107 $this->irss =
$DIC[
'resource_storage'];
109 $local_dic = LocalDIC::dic();
110 $this->account_mail_repo = $local_dic[NewAccountMailRepository::class];
111 $this->user_settings_repo = $local_dic[UserSettingsConfigurationRepository::class];
112 $this->profile_configuration_repo = $local_dic[ProfileConfigurationRepository::class];
113 $this->profile_field_change_listeners = $local_dic[
'profile.fields.changelisteners'];
115 $this->type =
'usrf';
119 $a_call_by_reference,
123 $this->
lng->loadLanguageModule(
'search');
124 $this->
lng->loadLanguageModule(
'user');
125 $this->
lng->loadLanguageModule(
'tos');
126 $this->
lng->loadLanguageModule(
'ps');
127 $this->
lng->loadLanguageModule(
'registration');
128 $this->
lng->loadLanguageModule(
'tos');
129 $this->
lng->loadLanguageModule(
'dpro');
130 $this->
lng->loadLanguageModule(
'ui');
131 $this->
lng->loadLanguageModule(
'mail');
132 $this->
lng->loadLanguageModule(
'meta');
133 $this->
lng->loadLanguageModule(
'chatroom');
134 $this->
lng->loadLanguageModule(
'administration');
135 $this->
lng->loadLanguageModule(
'dateplaner');
136 $this->
lng->loadLanguageModule(
'style');
137 $this->
lng->loadLanguageModule(
'awrn');
138 $this->
lng->loadLanguageModule(
'buddysystem');
140 $this->
ctrl->saveParameter(
158 $this->selected_action = $this->user_request->getSelectedAction();
161 $this->requested_ids = $this->user_request->getIds();
166 $this->user_owner_id = $a_id;
178 $next_class = $this->
ctrl->getNextClass($this);
179 $cmd = $this->
ctrl->getCmd();
182 switch ($next_class) {
183 case strtolower(ilUserTableGUI::class):
188 $u_table->initFilter();
189 $this->
ctrl->setReturn(
193 $this->
ctrl->forwardCommand($u_table);
195 case strtolower(ilRepositorySearchGUI::class):
196 if (!$this->
access->checkRbacOrPositionPermissionAccess(
201 $this->
ilias->raiseError(
202 $this->
lng->txt(
'permission_denied'),
203 $this->ilias->error_obj->MESSAGE
208 $user_search->setTitle($this->
lng->txt(
'search_user_extended'));
209 $user_search->enableSearchableCheck(
false);
210 $user_search->setUserLimitations(
false);
211 $user_search->setCallback(
213 'searchResultHandler',
216 $user_search->addUserAccessFilterCallable([$this,
'searchUserAccessFilterCallable']);
217 $this->
ctrl->setReturn(
221 $this->
ctrl->forwardCommand($user_search);
223 case strtolower(AdminSettingsGUI::class):
225 $this->
ctrl->forwardCommand(
226 new AdminSettingsGUI(
236 $this->profile_configuration_repo
240 case strtolower(UserSettingsConfigurationGUI::class):
242 $this->
ctrl->forwardCommand(
243 new UserSettingsConfigurationGUI(
252 $this->request_wrapper,
254 $this->user_settings_repo
258 case strtolower(NewAccountMailSettingsGUI::class):
260 $this->
ctrl->forwardCommand(
261 new NewAccountMailSettingsGUI(
266 $this->mail_mustache_factory,
272 $this->account_mail_repo
276 case strtolower(StartingPointSettingsGUI::class):
278 $this->
ctrl->forwardCommand(
279 new StartingPointSettingsGUI($this->ref_id)
282 case strtolower(ProfileFieldsConfigurationGUI::class):
284 $this->
ctrl->forwardCommand(
285 new ProfileFieldsConfigurationGUI(
296 $this->request_wrapper,
299 $this->profile_field_change_listeners,
300 $this->profile_configuration_repo
304 case strtolower(CustomFieldsGUI::class):
306 $this->
ctrl->forwardCommand(
308 $this->requested_ref_id,
309 $this->user_request->getFieldId()
313 case strtolower(ProfileSettingsGUI::class):
315 $this->
ctrl->forwardCommand(
316 new ProfileSettingsGUI(
324 new PromptRepository(
332 case strtolower(ilPermissionGUI::class):
334 $this->
ctrl->forwardCommand($perm_gui);
352 $utab->resetOffset();
353 $utab->resetFilter();
362 $this->
ctrl->setParameterByClass(
367 $this->
ctrl->redirectByClass(
368 [
'iladministrationgui',
'ilobjusergui'],
379 $utab->resetOffset();
380 $utab->writeFilterToSession();
389 if ($this->rbac_system->checkAccess(
'create_usr', $this->
object->
getRefId())
390 || $this->rbac_system->checkAccess(
'cat_administrate_users', $this->
object->
getRefId())) {
392 $this->ui_factory->link()->standard(
393 $this->lng->txt(
'usr_add'),
394 $this->ctrl->getLinkTarget($this,
'addUser')
399 $this->ui_factory->link()->standard(
400 $this->lng->txt(
'import_users'),
401 $this->ctrl->getLinkTarget($this,
'importUserForm')
412 $utab->addFilterItemValue(
418 $this->tpl->setContent($utab->getHTML());
424 $auto->addUserAccessFilterCallable(\Closure::fromCallable([$this,
'filterUserIdsByRbacOrPositionOfCurrentUser']));
425 $auto->setSearchFields([
'login',
'firstname',
'lastname',
'email',
'second_email']);
426 $auto->enableFieldSearchableCheck(
false);
427 $auto->setMoreLinkAvailable(
true);
429 if ($this->user_request->getFetchAll()) {
433 echo $auto->getList($this->user_request->getTerm());
442 return $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
452 $this->
ctrl->redirect(
466 $d = $this->obj_definition->getCreatableSubObjects($this->
object->getType());
468 if (!$this->rbac_system->checkAccess(
470 $this->object->getRefId()
476 foreach (
$d as $row) {
478 if ($row[
'max'] > 0) {
480 for ($i = 0, $iMax = count($this->data[
'ctrl']); $i < $iMax; $i++) {
481 if ($this->data[
'ctrl'][$i][
'type'] == $row[
'name']) {
486 if ($row[
'max'] ==
'' || $count < $row[
'max']) {
487 $subobj[] = $row[
'name'];
492 if (is_array($subobj)) {
499 $this->tpl->setCurrentBlock(
'add_object');
500 $this->tpl->setVariable(
504 $this->tpl->setVariable(
508 $this->tpl->setVariable(
510 $this->
lng->txt(
'add')
512 $this->tpl->parseCurrentBlock();
518 $this->
ctrl->redirect(
526 $this->
ctrl->redirectByClass(
527 'ilrepositorysearchgui',
534 if (!$this->checkUserManipulationAccessBool()) {
535 $this->
ilias->raiseError(
536 $this->
lng->txt(
'msg_no_perm_write'),
537 $this->ilias->error_obj->WARNING
542 foreach ($this->getActionUserIds() as
$id) {
548 if (!$obj->getActive()) {
549 $obj->setLoginAttempts(0);
559 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'user_activated'),
true);
561 if ($this->user_request->getFrSearch()) {
562 $this->
ctrl->redirectByClass(
563 'ilRepositorySearchGUI',
567 $this->
ctrl->redirect(
576 if (!$this->checkUserManipulationAccessBool()) {
577 $this->
ilias->raiseError(
578 $this->
lng->txt(
'msg_no_perm_write'),
579 $this->ilias->error_obj->WARNING
583 foreach ($this->getActionUserIds() as
$id) {
598 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'user_deactivated'),
true);
600 if ($this->user_request->getFrSearch()) {
601 $this->
ctrl->redirectByClass(
602 'ilRepositorySearchGUI',
606 $this->
ctrl->redirect(
615 if (!$this->checkUserManipulationAccessBool()) {
616 $this->
ilias->raiseError(
617 $this->
lng->txt(
'msg_no_perm_write'),
618 $this->ilias->error_obj->WARNING
622 foreach ($this->getActionUserIds() as
$id) {
628 $obj->setTimeLimitUnlimited(
true);
629 $obj->setTimeLimitFrom(
null);
630 $obj->setTimeLimitUntil(
null);
636 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'access_free_granted'),
true);
638 if ($this->user_request->getFrSearch()) {
639 $this->
ctrl->redirectByClass(
640 'ilRepositorySearchGUI',
644 $this->
ctrl->redirect(
653 bool $a_from_search =
false
656 $a_form = $this->initAccessRestrictionForm($a_from_search);
658 $this->tpl->setContent($a_form->getHTML());
665 bool $a_from_search =
false
667 $user_ids = $this->getActionUserIds();
669 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
675 $form->
setTitle($this->
lng->txt(
'time_limit_add_time_limit_for_selected'));
677 $this->
ctrl->getFormAction(
679 'confirmaccessRestrict'
684 $this->
lng->txt(
'access_from'),
687 $from->setShowTime(
true);
688 $from->setRequired(
true);
692 $this->
lng->txt(
'access_until'),
695 $to->setRequired(
true);
696 $to->setShowTime(
true);
700 'confirmaccessRestrict',
701 $this->
lng->txt(
'confirm')
705 $this->
lng->txt(
'cancel')
710 $ufield->setValue((
string)
$user_id);
715 if ($a_from_search || $this->user_request->getFrSearch()) {
717 $field->setValue(
'1');
731 $form = $this->initAccessRestrictionForm();
733 return $this->setAccessRestrictionObject($form);
738 if ($timeuntil <= $timefrom) {
739 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'time_limit_not_valid'));
740 return $this->setAccessRestrictionObject($form);
743 if (!$this->checkUserManipulationAccessBool()) {
744 $this->
ilias->raiseError(
745 $this->
lng->txt(
'msg_no_perm_write'),
746 $this->ilias->error_obj->WARNING
749 foreach ($this->getActionUserIds() as
$id) {
755 $obj->setTimeLimitUnlimited(
false);
756 $obj->setTimeLimitFrom((
int) $timefrom);
757 $obj->setTimeLimitUntil((
int) $timeuntil);
761 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'access_restricted'),
true);
763 if ($this->user_request->getFrSearch()) {
764 $this->
ctrl->redirectByClass(
765 'ilRepositorySearchGUI',
769 $this->
ctrl->redirect(
779 if (!$this->rbac_system->checkAccess(
781 $this->object->getRefId()
783 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_perm_delete'),
true);
784 $this->
ctrl->redirect(
790 $ids = $this->user_request->getIds();
792 $this->
user->getId(),
795 $this->
ilias->raiseError(
796 $this->
lng->txt(
'msg_no_delete_yourself'),
797 $this->ilias->error_obj->WARNING
802 foreach ($ids as
$id) {
809 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'user_deleted'),
true);
811 if ($this->user_request->getFrSearch()) {
812 $this->
ctrl->redirectByClass(
813 'ilRepositorySearchGUI',
817 $this->
ctrl->redirect(
830 if ($this->getSelectAllPostArray()[
'select_cmd_all']) {
838 if (!$this->
access->checkAccess(
843 $this->access->checkRbacOrPositionPermissionAccess(
849 $filtered_users = $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
856 $utab->addFilterItemValue(
862 return $utab->getUserIdsForFilter();
864 return $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
875 return $this->
access->checkRbacOrPositionPermissionAccess(
884 bool $a_from_search =
false
886 $user_ids = $this->getActionUserIds();
888 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'));
897 return $this->setAccessRestrictionObject(
909 if (strcmp($action,
'addToClipboard') === 0) {
910 $this->addToClipboardObject();
916 if (!$a_from_search) {
917 $cancel =
'cancelUserFolderAction';
919 $cancel =
'cancelSearchAction';
924 $cgui->setFormAction($this->
ctrl->getFormAction($this));
925 $cgui->setHeaderText($this->
lng->txt(
'info_' . $action .
'_sure'));
927 $this->
lng->txt(
'cancel'),
931 $this->
lng->txt(
'confirm'),
935 if ($a_from_search) {
936 $cgui->addHiddenItem(
942 foreach ($user_ids as
$id) {
945 $login = $user->getLastLogin();
947 $login = $this->
lng->txt(
'never');
957 $caption = $user->getFullname() .
' (' . $user->getLogin() .
')' .
', ' .
958 $user->getEmail() .
' - ' . $this->
lng->txt(
'last_login') .
': ' . $login;
967 $this->tpl->setContent($cgui->getHTML());
974 if (!$this->
access->checkRbacOrPositionPermissionAccess(
979 $this->
ilias->raiseError(
980 $this->
lng->txt(
'permission_denied'),
981 $this->ilias->error_obj->MESSAGE
985 if (in_array($this->
user->getId(), $this->getActionUserIds())) {
986 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_delete_yourself'));
990 $this->showActionConfirmation(
'delete');
995 $this->raiseErrorOnMissingWrite();
996 $this->showActionConfirmation(
'activate');
1001 $this->raiseErrorOnMissingWrite();
1002 if (in_array($this->
user->getId(), $this->getActionUserIds())) {
1003 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_deactivate_yourself'));
1004 $this->viewObject();
1007 $this->showActionConfirmation(
'deactivate');
1012 $this->raiseErrorOnMissingWrite();
1013 $this->showActionConfirmation(
'accessRestrict');
1018 $this->raiseErrorOnMissingWrite();
1019 $this->showActionConfirmation(
'accessFree');
1024 $this->raiseErrorOnMissingWrite();
1025 $this->showActionConfirmation($this->user_request->getSelectedAction());
1030 $this->tabs_gui->clearTargets();
1031 $this->tabs_gui->setBackTarget(
1032 $this->
lng->txt(
'usrf'),
1033 $this->ctrl->getLinkTarget(
1039 !$this->rbac_system->checkAccess(
'create_usr', $this->object->getRefId())
1040 && !$this->access->checkAccess(
'cat_administrate_users',
'', $this->object->getRefId())
1042 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'));
1045 $this->initUserImportForm();
1046 $this->tpl->setContent($this->
form->getHTML());
1055 $this->
lng->txt(
'import_file'),
1058 $fi->setSuffixes([
'xml']);
1059 $fi->setRequired(
true);
1060 $this->
form->addItem($fi);
1062 $this->
form->addCommandButton(
1063 'importUserRoleAssignment',
1064 $this->
lng->txt(
'import')
1066 $this->
form->addCommandButton(
1068 $this->
lng->txt(
'cancel')
1071 $this->
form->setTitle($this->
lng->txt(
'import_users'));
1072 $this->
form->setFormAction($this->
ctrl->getFormAction($this));
1077 return (strtolower($this->user_request->getBaseClass()) ===
'iladministrationgui');
1082 $import_dir = $this->getImportDir();
1083 if ($this->
filesystem->hasDir($import_dir)) {
1087 if ($this->inAdministration()) {
1088 $this->
ctrl->redirect(
1093 $this->
ctrl->redirectByClass(
1106 $importDir =
'user_import/usr_' . $this->
user->getId() .
'_' . mb_substr(session_id(), 0, 8);
1116 $this->tabs_gui->clearTargets();
1117 $this->tabs_gui->setBackTarget(
1118 $this->
lng->txt(
'usrf'),
1119 $this->ctrl->getLinkTarget(
1125 $this->initUserImportForm();
1126 if ($this->
form->checkInput()) {
1127 $xml_file = $this->handleUploadedFiles();
1130 list($form, $message) = $this->initUserRoleAssignmentForm($xml_file_full_path);
1132 $this->tpl->setContent($message . $this->ui_renderer->render($form));
1134 $this->
form->setValuesByPost();
1135 $this->tpl->setContent($this->
form->getHTML());
1145 $global_roles_assignment_info =
null;
1146 $local_roles_assignment_info =
null;
1149 $xml_file_full_path,
1152 $import_parser->startParsing();
1154 $message = $this->verifyXmlData($import_parser);
1156 $xml_file_name = explode(
1160 $roles_import_filename = $this->ui_factory->input()->field()
1161 ->text($this->
lng->txt(
'import_file'))
1162 ->withDisabled(
true)
1163 ->withValue(end($xml_file_name));
1165 $roles_import_count = $this->ui_factory->input()->field()
1166 ->numeric($this->
lng->txt(
'num_users'))
1167 ->withDisabled(
true)
1168 ->withValue($import_parser->getUserCount());
1171 $xml_file_full_path,
1174 $import_parser->startParsing();
1176 $roles = $import_parser->getCollectedRoles();
1177 $all_gl_roles = $this->rbac_review->getRoleListByObject(
ROLE_FOLDER_ID);
1179 $roles_of_user = $this->rbac_review->assignedRoles($this->
user->getId());
1180 foreach ($all_gl_roles as $obj_data) {
1193 $gl_roles[$obj_data[
'obj_id']] = $obj_data[
'title'];
1198 $got_globals =
false;
1199 $global_selects = [];
1200 foreach ($roles as $role_id => $role) {
1201 if ($role[
'type'] ===
'Global') {
1202 $select_options = [];
1203 if (!$got_globals) {
1204 $global_roles_assignment_info = $this->ui_factory->input()->field()
1205 ->text($this->
lng->txt(
'roles_of_import_global'))
1206 ->withDisabled(
true)
1207 ->withValue($this->
lng->txt(
'assign_global_role'));
1209 $select_options[] = $this->
lng->txt(
'usrimport_ignore_role');
1212 foreach ($gl_roles as $key => $value) {
1213 $select_options[$role_id .
'-' . $key] = $value;
1217 $pre_select = array_search(
1222 switch ($role[
'name']) {
1223 case 'Administrator':
1224 $pre_select = array_search(
1231 $pre_select = array_search(
1238 $pre_select = array_search(
1245 $pre_select = array_search(
1252 $pre_select = array_search(
1260 $select = $this->ui_factory->input()->field()
1265 ->withValue($pre_select);
1267 if (!$got_globals) {
1268 $got_globals =
true;
1269 $global_selects[] = $select->withRequired(
true);
1271 $global_selects[] = $select;
1277 $got_locals =
false;
1278 foreach ($roles as $role_id => $role) {
1279 if ($role[
'type'] ==
'Local') {
1286 $local_roles_assignment_info = $this->ui_factory->input()->field()
1287 ->text($this->
lng->txt(
'roles_of_import_local'))
1288 ->withDisabled(
true)
1289 ->withValue($this->
lng->txt(
'assign_local_role'));
1301 foreach ($roles as $role_id => $role) {
1302 if ($role[
'type'] ==
'Local') {
1303 $searchName = (strpos($role[
'name'],
'#') === 0) ? $role[
'name'] :
'#' . $role[
'name'];
1304 $matching_role_ids = $roleMailboxSearch->searchRoleIdsByAddressString($searchName);
1305 foreach ($matching_role_ids as $mid) {
1310 $loc_roles[] = $mid;
1319 $loc_roles = $this->rbac_review->getAssignableRolesInSubtree($this->
object->getRefId());
1324 foreach ($loc_roles as $key => $loc_role) {
1326 $rolf = $this->rbac_review->getFoldersAssignedToRole(
1336 !$this->rbac_review->isDeleted($rolf[0]) &&
1337 $this->rbac_system->checkAccess(
1354 if ($this->tree->isInTree($rolf[0])) {
1357 $tmpPath = $this->tree->getPathFull($rolf[0]);
1358 $tmpPath[] = $rolf[0];
1360 for ($i = 1, $n = count($tmpPath) - 1; $i < $n; $i++) {
1361 if ($i < 3 || $i > $n - 3) {
1362 $path_array[] = $tmpPath[$i][
'title'];
1363 } elseif ($i == 3 || $i == $n - 3) {
1364 $path_array[] =
'...';
1367 $is_in_subtree |= $tmpPath[$i][
'obj_id'] == $this->
object->getId();
1372 array_reverse($path_array)
1375 $path =
'<b>Rolefolder ' . $rolf[0] .
' not found in tree! (Role ' . $loc_role .
')</b>';
1377 $roleMailboxAddress = (new \ilRoleMailboxAddress($loc_role))->value();
1378 $l_roles[$loc_role] = $roleMailboxAddress .
', ' .
$path;
1382 natcasesort($l_roles);
1383 $l_roles[
'ignore'] = $this->
lng->txt(
'usrimport_ignore_role');
1386 $local_selects = [];
1387 foreach ($roles as $role_id => $role) {
1388 if ($role[
'type'] ==
'Local') {
1389 $searchName = (strpos($role[
'name'],
'#') === 0) ? $role[
'name'] :
'#' . $role[
'name'];
1390 $matching_role_ids = $roleMailboxSearch->searchRoleIdsByAddressString($searchName);
1391 $pre_select = count($matching_role_ids) == 1 ? $role_id .
'-' . $matching_role_ids[0] :
'ignore';
1393 $selectable_roles = [];
1398 $selectable_roles[
'ignore'] = $this->
lng->txt(
'usrimport_ignore_role');
1399 foreach ($matching_role_ids as
$id) {
1400 $selectable_roles[$role_id .
'-' .
$id] = $l_roles[
$id];
1403 foreach ($l_roles as $local_role_id => $value) {
1404 if ($local_role_id !==
'ignore') {
1405 $selectable_roles[$role_id .
'-' . $local_role_id] = $value;
1410 if (count($selectable_roles) > 0) {
1411 $select = $this->ui_factory->input()->field()
1412 ->select($role[
'name'], $selectable_roles)
1413 ->withRequired(
true);
1414 if (array_key_exists($pre_select, $selectable_roles)) {
1415 $select = $select->withValue($pre_select);
1417 $local_selects[] = $select;
1428 $conflict_action_select = $this->ui_factory->input()->field()
1430 $this->
lng->txt(
'conflict_handling'),
1435 $this->
lng->txt(
'usrimport_conflict_handling_info')
1439 ->withRequired(
true);
1442 $this->
lng->loadLanguageModule(
'mail');
1443 $amail = $this->account_mail_repo->getFor($this->
lng->getDefaultLanguage());
1444 $mail_section =
null;
1445 if ($amail->getSubject() !==
'' && $amail->getBody() !==
'') {
1446 $send_checkbox = $this->ui_factory->input()->field()->checkbox($this->
lng->txt(
'user_send_new_account_mail'))
1449 $mail_section = $this->ui_factory->input()->field()->section(
1451 $this->
lng->txt(
'mail_account_mail')
1455 $file_info_section = $this->ui_factory->input()->field()->section(
1457 'filename' => $roles_import_filename,
1458 'import_count' => $roles_import_count,
1460 $this->
lng->txt(
'file_info')
1463 $form_action = $this->
ctrl->getFormActionByClass(self::class,
'importUsers');
1466 'file_info' => $file_info_section
1469 if (!empty($global_selects)) {
1470 $global_role_info_section = $this->ui_factory->input()
1472 ->section([$global_roles_assignment_info], $this->
lng->txt(
'global_role_assignment'));
1473 $global_role_selection_section = $this->ui_factory->input()->field()->section($global_selects,
'');
1474 $form_elements[
'global_role_info'] = $global_role_info_section;
1475 $form_elements[
'global_role_selection'] = $global_role_selection_section;
1478 if (!empty($local_selects)) {
1479 $local_role_info_section = $this->ui_factory->input()->field()->section(
1480 [$local_roles_assignment_info],
1481 $this->
lng->txt(
'local_role_assignment')
1483 $local_role_selection_section = $this->ui_factory->input()->field()->section(
1488 $form_elements[
'local_role_info'] = $local_role_info_section;
1489 $form_elements[
'local_role_selection'] = $local_role_selection_section;
1492 $form_elements[
'conflict_action'] = $this->ui_factory->input()->field()->section([$conflict_action_select],
'');
1494 if ($mail_section !==
null) {
1495 $form_elements[
'send_mail'] = $mail_section;
1498 return [$this->ui_factory->input()->container()->form()->standard(
1509 $import_dir = $this->getImportDir();
1511 if (!$this->
upload->hasBeenProcessed()) {
1512 $this->
upload->process();
1516 if ($this->
filesystem->hasDir($import_dir)) {
1521 foreach ($this->
upload->getResults() as $single_file_upload) {
1522 $file_name = $single_file_upload->getName();
1523 $parts = pathinfo($file_name);
1526 if (!$single_file_upload->isOK()) {
1528 $this->
ilias->raiseError(
1529 $this->
lng->txt(
'no_import_file_found'),
1530 $this->ilias->error_obj->MESSAGE
1535 $this->
upload->moveFilesTo(
1541 if ($single_file_upload->getMimeType() ==
'application/zip') {
1544 . $this->
user->getId() .
'_' . session_id() .
'/' . $file_name;
1545 $this->archives->unzip($full_path);
1548 $file_list = $this->
filesystem->listContents($import_dir);
1550 foreach ($file_list as $key => $a_file) {
1555 unset($file_list[$key]);
1556 $xml_file = $a_file->getPath();
1562 foreach ($file_list as $a_file) {
1563 $this->
filesystem->delete($a_file->getPath());
1566 if (is_null($xml_file)) {
1569 '.' .
$parts[
'extension']
1571 $xml_file = $import_dir .
'/' . $subdir .
'/' . $subdir .
'.xml';
1577 $xml_file = $file->getPath();
1583 $this->
ilias->raiseError(
1584 $this->
lng->txt(
'no_xml_file_found_in_zip')
1585 .
' ' . $subdir .
'/' . $subdir .
'.xml',
1586 $this->ilias->error_obj->MESSAGE
1596 $import_dir = $this->getImportDir();
1604 $this->tpl->setOnScreenMessage(
1607 $this->lng->txt(
'verification_failure_log')
1611 $this->
ctrl->redirectByClass(self::class,
'importUserForm');
1622 $import_dir = $this->getImportDir();
1624 $file_list = $this->
filesystem->listContents($import_dir);
1626 if (count($file_list) > 1) {
1628 $this->tpl->setOnScreenMessage($this->
lng->txt(
'usrimport_wrong_file_count'),
true);
1629 $this->redirectAfterImport();
1631 $xml_file = $file_list[0]->getPath();
1636 if (!$this->user_request->isPost()) {
1637 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'usrimport_form_not_evaluabe'),
true);
1638 $this->redirectAfterImport();
1641 $form = $this->initUserRoleAssignmentForm($xml_path)[0]->withRequest($this->user_request->getRequest());
1642 $result = $form->getData();
1644 if ($result ===
null) {
1645 $this->tpl->setContent($this->ui_renderer->render($form));
1649 $rule = $result[
'conflict_action'][0] ?? 1;
1652 $local_role_selection = (array) ($result[
'local_role_selection'] ?? []);
1653 $global_role_selection = (array) ($result[
'global_role_selection'] ?? []);
1654 $roles = array_merge(
1655 $local_role_selection,
1656 $global_role_selection
1659 $role_assignment = [];
1660 foreach ($roles as $value) {
1665 if (count($keys) === 2) {
1666 $role_assignment[$keys[0]] = $keys[1];
1675 $import_parser->setFolderId($this->getUserOwnerId());
1680 if (!empty($role_assignment)) {
1681 $global_roles = $this->rbac_review->getGlobalRoles();
1682 $roles_of_user = $this->rbac_review->assignedRoles($this->
user->getId());
1683 foreach ($role_assignment as $role_id_string) {
1684 $role_id = $this->
refinery->byTrying([
1685 $this->
refinery->kindlyTo()->int(),
1686 $this->refinery->always(
null)
1687 ])->transform($role_id_string);
1688 if ($role_id ===
null) {
1691 $this->redirectOnRoleWithMissingWrite(
1700 if (isset($result[
'send_mail'])) {
1701 $import_parser->setSendMail($result[
'send_mail'][0]);
1704 $import_parser->setRoleAssignment($role_assignment);
1705 $import_parser->startParsing();
1710 switch ($import_parser->getErrorLevel()) {
1712 $this->tpl->setOnScreenMessage(
1714 $this->
lng->txt(
'user_imported'),
1719 $this->tpl->setOnScreenMessage(
1721 $this->
lng->txt(
'user_imported_with_warnings')
1722 . $import_parser->getProtocolAsHTML(
1723 $this->lng->txt(
'import_warning_log')
1729 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'user_import_failed'),
true);
1730 $this->redirectAfterImport();
1734 if ($this->inAdministration()) {
1735 $this->
ctrl->redirect(
1740 $this->
ctrl->redirectByClass(
1749 array $roles_of_user,
1750 array $global_roles,
1769 $this->tpl->setOnScreenMessage(
1771 $this->
lng->txt(
'usrimport_with_specified_role_not_permitted'),
1774 $this->redirectAfterImport();
1779 $rolf = $this->rbac_review->getFoldersAssignedToRole(
1783 if ($this->rbac_review->isDeleted($rolf[0])
1784 || !$this->rbac_system->checkAccess(
1790 $this->tpl->setOnScreenMessage(
1792 $this->
lng->txt(
'usrimport_with_specified_role_not_permitted'),
1795 $this->redirectAfterImport();
1805 $files = $this->user_request->getFiles();
1806 if (count($files) == 0) {
1807 $this->
ilias->raiseError(
1808 $this->
lng->txt(
'no_checkbox'),
1809 $this->ilias->error_obj->MESSAGE
1813 if (count($files) > 1) {
1814 $this->
ilias->raiseError(
1815 $this->
lng->txt(
'select_max_one_item'),
1816 $this->ilias->error_obj->MESSAGE
1820 $file = basename($files[0]);
1822 $export_dir = $this->
object->getExportDirectory();
1824 $export_dir .
'/' . $file,
1831 $files = $this->user_request->getFiles();
1832 if (count($files) == 0) {
1833 $this->
ilias->raiseError(
1834 $this->
lng->txt(
'no_checkbox'),
1835 $this->ilias->error_obj->MESSAGE
1840 $cgui->setFormAction($this->
ctrl->getFormAction($this));
1841 $cgui->setHeaderText($this->
lng->txt(
'info_delete_sure'));
1843 $this->
lng->txt(
'cancel'),
1844 'cancelDeleteExportFile'
1847 $this->
lng->txt(
'confirm'),
1852 foreach ($files as $file) {
1858 $this->lng->txt(
'obj_usrf')
1862 $this->tpl->setContent($cgui->getHTML());
1867 $this->
ctrl->redirectByClass(
1868 [self::class, ilExportGUI::class],
1875 $this->raiseErrorOnMissingWrite();
1876 $files = $this->user_request->getFiles();
1877 $export_dir = $this->
object->getExportDirectory();
1878 foreach ($files as $file) {
1879 $file = basename($file);
1881 $exp_file = $export_dir .
'/' . $file;
1882 if (is_file($exp_file)) {
1886 $this->
ctrl->redirectByClass(
1887 [self::class, ilExportGUI::class],
1900 $this->
object->buildExportFile($this->user_request->getExportType());
1901 $this->
ctrl->redirectByClass(
1902 [self::class, ilExportGUI::class],
1912 'userfolder_export_excel_x86',
1913 'userfolder_export_xml'
1916 foreach ($export_types as $type) {
1917 $this->
ctrl->setParameterByClass(self::class,
'export_type', $type);
1918 $options[] = $this->ui_factory->button()->shy(
1919 $this->
lng->txt($type),
1920 $this->ctrl->getLinkTargetByClass(self::class,
'performExport')
1923 $type_selection = $this->ui_factory->dropdown()->standard(
$options)
1924 ->withLabel($this->
lng->txt(
'create_export_file'));
1931 $table = new \ilUserExportFileTableGUI(
1936 $table->parse($this->
object->getExportFiles());
1938 $this->tpl->setContent($table->getHTML());
1948 $this->admin_tabs->initializeTabs();
1951 public static function _goto(
string $a_user): void
1955 $a_user = (
int) $a_user;
1956 $main_tpl =
$DIC->ui()->mainTemplate();
1958 $ilAccess =
$DIC[
'ilAccess'];
1961 $ctrl =
$DIC[
'ilCtrl'];
1965 if ($ilAccess->checkAccess(
1970 $ctrl->redirectToURL(
'ilias.php?baseClass=ilAdministrationGUI&ref_id=' . $a_target .
'&jmpToUser=' . $a_user);
1973 if ($ilAccess->checkAccess(
1978 $main_tpl->setOnScreenMessage(
'failure', sprintf(
1979 $lng->txt(
'msg_no_perm_read_item'),
1986 $lng->txt(
'msg_no_perm_read'),
1996 $jump_to_user = $this->user_request->getJumpToUser();
1998 $this->
ctrl->setParameterByClass(
2003 $this->
ctrl->redirectByClass(
2013 || $this->checkPermissionBool(
'read_users')) {
2017 return $this->
access->filterUserIdsByPositionOfCurrentUser(
2031 if (!count($a_usr_ids)) {
2032 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'));
2036 $this->requested_ids = $a_usr_ids;
2039 if (stripos($a_cmd,
'export') !==
false) {
2040 $cmd = $a_cmd .
'Object';
2041 return $this->$cmd();
2044 return $this->showActionConfirmation(
2054 if ($a_search_form) {
2055 if ($this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
2057 'activate' => $this->
lng->txt(
'activate'),
2058 'deactivate' => $this->
lng->txt(
'deactivate'),
2059 'accessRestrict' => $this->
lng->txt(
'accessRestrict'),
2060 'accessFree' => $this->
lng->txt(
'accessFree')
2064 if ($this->rbac_system->checkAccess(
'delete', $this->object->getRefId())) {
2065 $cmds[
'delete'] = $this->
lng->txt(
'delete');
2068 if ($this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
2070 'activateUsers' => $this->
lng->txt(
'activate'),
2071 'deactivateUsers' => $this->
lng->txt(
'deactivate'),
2072 'restrictAccess' => $this->
lng->txt(
'accessRestrict'),
2073 'freeAccess' => $this->
lng->txt(
'accessFree')
2077 if ($this->rbac_system->checkAccess(
'delete', $this->object->getRefId())) {
2078 $cmds[
'deleteUsers'] = $this->
lng->txt(
'delete');
2082 if ($this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
2084 'userfolder_export_excel_x86',
2085 'userfolder_export_xml'
2087 foreach ($export_types as $type) {
2092 $cmd = array_pop($cmd);
2093 $cmds[
'usrExport' . ucfirst($cmd)] = $this->
lng->txt(
'export') .
' - ' .
2094 $this->
lng->txt($type);
2100 if ($this->rbac_system->checkAccess(
2102 $mail->getMailObjectReferenceId()
2104 $cmds[
'mail'] = $this->
lng->txt(
'send_mail');
2107 $cmds[
'addToClipboard'] = $this->
lng->txt(
'clipboard_add_btn');
2114 $user_ids = $this->getActionUserIds();
2116 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
2117 $this->
ctrl->redirectByClass(
2124 $this->
object->buildExportFile(
2128 $this->
ctrl->redirectByClass(
2129 [self::class, ilExportGUI::class],
2132 } elseif ($this->checkUserManipulationAccessBool()) {
2133 $fullname = $this->
object->buildExportFile(
2139 $fullname .
'.xlsx',
2150 $user_ids = $this->getActionUserIds();
2152 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
2153 $this->
ctrl->redirect(
2160 $this->
object->buildExportFile(
2164 $this->
ctrl->redirectByClass(
2165 'ilobjuserfoldergui',
2168 } elseif ($this->checkUserManipulationAccessBool()) {
2169 $fullname = $this->
object->buildExportFile(
2186 $user_ids = $this->getActionUserIds();
2188 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
2189 $this->
ctrl->redirectByClass(
2195 $this->
object->buildExportFile(
2199 $this->
ctrl->redirectByClass(
2200 [self::class, ilExportGUI::class],
2203 } elseif ($this->checkUserManipulationAccessBool()) {
2204 $fullname = $this->
object->buildExportFile(
2221 $user_ids = $this->getActionUserIds();
2223 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
2224 $this->
ctrl->redirect(
2233 $old_lists->deleteTemporaryLists();
2238 $list->setTitle(
'-TEMPORARY SYSTEM LIST-');
2239 $list->setDescription(
'-USER ACCOUNTS MAIL-');
2240 $list->setCreatedate(date(
'Y-m-d H:i:s'));
2242 $list_id = $list->getId();
2250 $mail_data = $umail->retrieveFromStage();
2252 $umail->persistToStage(
2253 $mail_data[
'user_id'],
2254 '#il_ml_' . $list_id,
2255 $mail_data[
'rcp_cc'],
2256 $mail_data[
'rcp_bcc'],
2257 $mail_data[
'm_subject'],
2258 $mail_data[
'm_message'],
2259 $mail_data[
'attachments'],
2260 $mail_data[
'use_placeholders'],
2261 $mail_data[
'tpl_ctx_id'],
2262 $mail_data[
'tpl_ctx_params']
2265 $this->
ctrl->redirectToURL(
2270 [
'type' =>
'search_res']
2277 switch ($a_form_id) {
2284 'ps_password_change_on_first_login_enabled' => [
2285 $security->isPasswordChangeOnFirstLoginEnabled(),
2288 'ps_password_must_not_contain_loginame' => [
2289 $security->getPasswordMustNotContainLoginnameStatus(),
2292 'ps_password_chars_and_numbers_enabled' => [
2293 $security->isPasswordCharsAndNumbersEnabled(),
2296 'ps_password_special_chars_enabled' => [
2297 $security->isPasswordSpecialCharsEnabled(),
2300 'ps_password_min_length' => $security->getPasswordMinLength(),
2301 'ps_password_max_length' => $security->getPasswordMaxLength(),
2302 'ps_password_uppercase_chars_num' => $security->getPasswordNumberOfUppercaseChars(),
2303 'ps_password_lowercase_chars_num' => $security->getPasswordNumberOfLowercaseChars(),
2304 'ps_password_max_age' => $security->getPasswordMaxAge()
2306 $fields[
'ps_password_settings'] = [
null,
null, $subitems];
2309 'ps_login_max_attempts' => $security->getLoginMaxAttempts(),
2310 'ps_prevent_simultaneous_logins' => [
2311 $security->isPreventionOfSimultaneousLoginsEnabled(),
2315 $fields[
'ps_security_protection'] = [
null,
null, $subitems];
2317 return [[
'generalSettings', $fields]];
2324 if ($this->inAdministration()) {
2325 $this->
ctrl->redirect(
2331 $this->
ctrl->redirectByClass(
2339 $users = $this->getActionUserIds();
2340 if (!count($users)) {
2341 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_one'),
true);
2342 $this->
ctrl->redirect(
2351 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'clipboard_user_added'),
true);
2352 $this->
ctrl->redirect(
2364 if ($this->
access->checkPositionAccess(
2368 return $this->
access->filterUserIdsByPositionOfCurrentUser(
2381 $checkbox->setInfo($this->
lng->txt($name .
'_desc'));
2382 $checkbox->setValue(
'1');
2389 if (!$this->
access->checkRbacOrPositionPermissionAccess(
2394 $this->
ilias->raiseError(
2395 $this->
lng->txt(
'permission_denied'),
2396 $this->ilias->error_obj->MESSAGE
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
@ilCtrl_Calls ILIAS\User\Settings\NewAccountMail\SettingsGUI: ILIAS\User\Settings\NewAccountMail\Uplo...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static getDataDir()
get data directory (outside webspace)
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.
final const int MODE_TEMPORARY
static _getAssignUsersStatus(int $a_role_id)
addUserObject()
Add new user.
initUserRoleAssignmentForm(string $xml_file_full_path)
setUserOwnerId(int $a_id)
NewAccountMailRepository $account_mail_repo
addUserAutoCompleteObject()
static _goto(string $a_user)
confirmdeactivateObject()
getUserMultiCommands(bool $a_search_form=false)
cancelSearchActionObject()
ProfileConfigurationRepository $profile_configuration_repo
verifyXmlData(ilUserImportParser $import_parser)
showPossibleSubObjects()
show possible subobjects (pulldown menu) overwritten to prevent displaying of role templates in local...
searchResultHandler(array $a_usr_ids, string $a_cmd)
Handles multi command from repository search gui.
filterUserIdsByRbacOrPositionOfCurrentUser(array $user_ids)
array $profile_field_change_listeners
getAdminTabs()
administration tabs show only permissions and trash folder
raiseErrorOnMissingWrite()
redirectOnRoleWithMissingWrite(int $role_id, array $roles_of_user, array $global_roles, string $import_dir)
confirmaccessFreeObject()
importUserRoleAssignmentObject()
display form for user import with new FileSystem implementation
addToExternalSettingsForm(int $a_form_id)
jumpToUserObject()
Jump to edit screen for user.
showActionConfirmation(string $action, bool $a_from_search=false)
importUsersObject()
Import Users with new form implementation.
ilMustacheFactory $mail_mustache_factory
getActionUserIds()
Get selected items for table action.
cancelDeleteExportFileObject()
downloadExportFileObject()
Download selected export files Sends a selected export file for download.
confirmDeleteExportFileObject()
const USER_FIELD_TRANSLATION_MAPPING
cancelUserFolderActionObject()
getTabs()
@abstract overwrite in derived GUI class of your object type
UserSettingsConfigurationRepository $user_settings_repo
searchUserAccessFilterCallable(array $a_user_ids)
UserGUIRequest $user_request
checkUserManipulationAccessBool()
confirmaccessRestrictObject()
setAccessRestrictionObject(?ilPropertyFormGUI $a_form=null, bool $a_from_search=false)
initAccessRestrictionForm(bool $a_from_search=false)
const ORG_OP_EDIT_USER_ACCOUNTS
const string PERM_READ_ALL_AND_WRITE
const string PERM_READ_ALL
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.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
prepareOutput(bool $show_sub_objects=true)
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)
static _getInstance()
Get instance of ilSecuritySettings.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_usr_id)
const IL_IGNORE_ON_CONFLICT
getProtocolAsHTML(string $a_log_title)
Returns the protocol as a HTML table.
const IL_UPDATE_ON_CONFLICT
getErrorLevel()
Returns the error level.
TableGUI class for user administration.
The filesystem interface provides the public interface for the Filesystem service API consumer.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form(?array $class_path, string $cmd, string $submit_caption="")
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Class ilObjForumAdministration.
if(!file_exists('../ilias.ini.php'))