19 declare(strict_types=1);
42 private \ILIAS\DI\LoggingServices
$logger;
54 $this->tpl = $DIC->ui()->mainTemplate();
55 $this->
ctrl = $DIC->ctrl();
56 $this->
toolbar = $DIC->toolbar();
57 $this->
lng = $DIC->language();
58 $this->rbacSystem = $DIC->rbac()->system();
59 $this->rbacReview = $DIC->rbac()->review();
60 $this->rbacAdmin = $DIC->rbac()->admin();
61 $this->
user = $DIC->user();
62 $this->
access = $DIC->access();
63 $this->tabsGui = $DIC->tabs();
64 $this->
logger = $DIC->logger();
65 $this->ui_factory = $DIC[
'ui.factory'];
67 $this->query_wrapper = $DIC[
'http']->wrapper()->query();
69 $this->
lng->loadLanguageModule(
'user');
70 if (!$this->rbacSystem->checkAccess(
"cat_administrate_users", $this->parentGui->getObject()->getRefId())) {
71 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_perm_admin_users"),
true);
86 return $this->query_wrapper->retrieve(
94 $cmd = $this->
ctrl->getCmd();
98 $this->tabsGui->clearTargets();
99 $this->tabsGui->setBackTarget(
100 $this->
lng->txt(
"back"),
101 $this->
ctrl->getLinkTargetByClass(
"illocalusergui",
'index')
120 $table->resetOffset();
121 $table->resetFilter();
128 $table->resetOffset();
129 $table->writeFilterToSession();
133 public function index(
bool $show_delete =
false): bool
135 $this->tpl->addBlockfile(
138 'tpl.cat_admin_users.html',
139 "components/ILIAS/Category" 141 if (count($this->rbacReview->getGlobalAssignableRoles())
142 or in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId()))
145 $this->ui_factory->link()->standard(
146 $this->
lng->txt(
'add_user'),
147 $this->
ctrl->getLinkTargetByClass(
"ilobjusergui",
"create")
151 $this->ui_factory->link()->standard(
152 $this->
lng->txt(
'import_users'),
153 $this->
ctrl->getLinkTargetByClass(
"ilobjuserfoldergui",
"importUserForm")
157 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_roles_user_can_be_assigned_to'));
160 $this->tpl->setCurrentBlock(
"confirm_delete");
161 $this->tpl->setVariable(
"CONFIRM_FORMACTION", $this->
ctrl->getFormAction($this));
162 $this->tpl->setVariable(
"TXT_CANCEL", $this->
lng->txt(
'cancel'));
163 $this->tpl->setVariable(
"CONFIRM_CMD",
'performDeleteUsers');
164 $this->tpl->setVariable(
"TXT_CONFIRM", $this->
lng->txt(
'delete'));
165 $this->tpl->parseCurrentBlock();
168 $this->tpl->setVariable(
'USERS_TABLE', $table->getHTML());
176 $auto->setSearchFields(array(
'login',
'firstname',
'lastname',
'email'));
177 $auto->enableFieldSearchableCheck(
true);
178 $auto->setMoreLinkAvailable(
true);
180 if (($_REQUEST[
'fetchall'])) {
184 echo $auto->getList($_REQUEST[
'term']);
191 foreach ($_POST[
'user_ids'] as
$user_id) {
193 $this->
logger->write(__FILE__ .
":" . __LINE__ .
" User with id $user_id could not be found.");
194 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'user_not_found_to_delete'));
201 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'deleted_users'),
true);
202 $this->
ctrl->redirect($this,
'index');
210 if (!count($_POST[
'id'])) {
211 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_users_selected'));
216 $confirm->setFormAction($this->
ctrl->getFormAction($this));
217 $confirm->setHeaderText($this->
lng->txt(
'sure_delete_selected_users'));
218 $confirm->setConfirm($this->
lng->txt(
'delete'),
'performDeleteUsers');
219 $confirm->setCancel($this->
lng->txt(
'cancel'),
'index');
220 foreach ($_POST[
'id'] as $user) {
225 $name[
'lastname'] .
', ' . $name[
'firstname'] .
' [' . $name[
'login'] .
']' 228 $this->tpl->setContent($confirm->getHTML());
239 if (!$this->
access->checkAccess(
"cat_administrate_users",
"", $this->getRefId())) {
240 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
241 $this->
ctrl->redirect($this,
"");
245 $this->tpl->setOnScreenMessage(
'failure',
'no_user_selected');
250 $this->tpl->addBlockfile(
253 'tpl.cat_role_assignment.html',
254 "components/ILIAS/Category" 256 $ass_roles = $this->rbacReview->assignedRoles($this->
getObjId());
259 foreach ($roles as $role) {
263 in_array($role[
'obj_id'], $ass_roles) ?
true :
false,
265 (
string) $role[
'obj_id'],
268 $f_result[$counter][] = $role_obj->getTitle();
269 $f_result[$counter][] = $role_obj->getDescription() ? $role_obj->getDescription() :
'';
270 $f_result[$counter][] = (isset($role[
'role_type']) && $role[
'role_type'] ==
'global')
272 $this->
lng->txt(
'global')
274 $this->
lng->txt(
'local');
283 if (!$this->
access->checkAccess(
"cat_administrate_users",
"", $this->getRefId())) {
284 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
285 $this->
ctrl->redirect($this,
"");
289 $this->tpl->setOnScreenMessage(
'failure',
'no_user_selected');
297 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_global_role_left'));
302 $new_role_ids = $_POST[
'role_ids'] ? $_POST[
'role_ids'] : array();
303 $assigned_roles = $this->rbacReview->assignedRoles($this->
getObjId());
304 foreach ($roles as $role) {
305 if (in_array($role[
'obj_id'], $new_role_ids) and !in_array($role[
'obj_id'], $assigned_roles)) {
306 $this->rbacAdmin->assignUser($role[
'obj_id'], $this->
getObjId());
308 if (in_array($role[
'obj_id'], $assigned_roles) and !in_array($role[
'obj_id'], $new_role_ids)) {
309 $this->rbacAdmin->deassignUser($role[
'obj_id'], $this->
getObjId());
312 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'role_assignment_updated'));
320 if (!$this->
access->checkAccess(
"cat_administrate_users",
"", $this->getRefId())) {
321 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
322 $this->
ctrl->redirect($this,
"");
326 if ($tmp_obj->getTimeLimitOwner() != $this->
object->getRefId() and
327 !in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId()))
332 $new_assigned = $new_assigned ? $new_assigned : array();
333 $assigned = $this->rbacReview->assignedRoles((
int) $this->
getObjId());
335 if (!in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId()))) {
336 $ga = $this->rbacReview->getGlobalAssignableRoles();
338 $ga = $this->rbacReview->getGlobalRolesArray();
340 $global_assignable = array();
341 foreach ($ga as $role) {
342 $global_assignable[] = $role[
'obj_id'];
344 $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
345 $all_assigned_roles = array_intersect($assigned, $this->rbacReview->getGlobalRoles());
346 $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
347 if (!count($new_visible_assigned_roles) and !count($main_assigned_roles)) {
364 if (in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId())) ===
true) {
365 $global_roles = $this->rbacReview->getGlobalRolesArray();
366 } elseif ($tmp_obj->getTimeLimitOwner() == $this->
object->getRefId()) {
367 $global_roles = $this->rbacReview->getGlobalAssignableRoles();
369 $global_roles = array();
372 return array_merge($global_roles, $this->rbacReview->getAssignableChildRoles($this->object->getRefId()));
384 if ($this->
access->checkAccess(
"cat_administrate_users",
"", $this->getRefId()) ===
false) {
385 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
386 $this->
ctrl->redirect($this,
"");
389 $tpl = $tbl->getTemplateObject();
392 $this->
ctrl->setParameter($this,
'obj_id', $this->
getObjId());
398 $tpl->
setVariable(
"BTN_VALUE", $this->
lng->txt(
"change_assignment"));
402 $title = $this->
lng->txt(
'role_assignment') .
' (' . $tmp_obj->getFullname() .
')';
403 $tbl->setTitle($title,
"standard/icon_role.svg", $this->
lng->txt(
"role_assignment"));
404 $tbl->setHeaderNames(array(
406 $this->
lng->txt(
"title"),
407 $this->
lng->txt(
'description'),
408 $this->
lng->txt(
"type"),
410 $tbl->setHeaderVars(array(
415 ), (get_class($this->parentGui) ==
'ilObjOrgUnitGUI')
417 "ref_id" => $this->
object->getRefId(),
418 "cmd" =>
"assignRoles",
420 "cmdNode" =>
$_GET[
"cmdNode"],
421 "baseClass" =>
'ilAdministrationGUI',
422 "admin_mode" =>
"settings",
425 "ref_id" => $this->
object->getRefId(),
426 "cmd" =>
"assignRoles",
428 "cmdClass" =>
"ilobjcategorygui",
429 "baseClass" =>
'ilRepositoryGUI',
430 "cmdNode" =>
$_GET[
"cmdNode"],
432 $tbl->setColumnWidth(array(
"4%",
"35%",
"45%",
"16%"));
433 $this->set_unlimited =
true;
436 $this->tpl->setVariable(
'OBJECTS', $tbl->getTemplateObject()->get());
449 $order = $this->query_wrapper->retrieve(
"sort_by",
$r->byTrying([
450 $r->kindlyTo()->string(),
453 $direction = $this->query_wrapper->retrieve(
"sort_order",
$r->byTrying([
454 $r->kindlyTo()->string(),
457 $offset = $this->query_wrapper->retrieve(
"offset",
$r->byTrying([
458 $r->kindlyTo()->int(),
461 $limit = $this->query_wrapper->retrieve(
"limit",
$r->byTrying([
462 $r->kindlyTo()->int(),
466 if ($a_from ==
'clipboardObject') {
467 $tbl->disable(
"footer");
469 $tbl->disable(
"linkbar");
471 $tbl->setOrderColumn((
string) $order);
472 $tbl->setOrderDirection((
string) $direction);
473 $tbl->setOffset((
int) $offset);
474 $tbl->setLimit((
int) $limit);
475 $tbl->setFooter(
"tblfooter", $this->
lng->txt(
"previous"), $this->
lng->txt(
"next"));
476 $tbl->setData($result_set);
481 if (!$this->
access->checkAccess($permission,
"", $this->getRefId())) {
482 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
483 $this->
ctrl->redirect($this,
"");
static _getAllUserIds(int $a_filter=0)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
index(bool $show_delete=false)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
static _lookupName(int $a_user_id)
lookup user name
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable(string $variable, $value='')
Sets the given variable to the given value.
ILIAS UI Factory $ui_factory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TableGUI class for user administration.
ILIAS DI LoggingServices $logger
ILIAS Refinery Factory $refinery
Class ilObjectGUI Basic methods of all Output classes.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
ilGlobalTemplateInterface $tpl
ILIAS HTTP Wrapper RequestWrapper $query_wrapper
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
checkGlobalRoles($new_assigned)
addUserAutoCompleteObject()
Class ilRbacAdmin Core functions for role based access control.
showRolesTable($a_result_set, $a_from="")
getIntFromQuery(string $var)
__construct(ilObjectGUI $parentGui)
checkPermission(string $permission)
setTableGUIBasicData($tbl, &$result_set, string $a_from="")