42 private \ILIAS\DI\LoggingServices
$logger;
50 $this->tpl =
$DIC->ui()->mainTemplate();
51 $this->
ctrl = $DIC->ctrl();
52 $this->
toolbar = $DIC->toolbar();
53 $this->
lng = $DIC->language();
54 $this->rbacSystem =
$DIC->rbac()->system();
55 $this->rbacReview =
$DIC->rbac()->review();
56 $this->rbacAdmin =
$DIC->rbac()->admin();
57 $this->
user = $DIC->user();
58 $this->
access = $DIC->access();
59 $this->tabsGui =
$DIC->tabs();
60 $this->
logger = $DIC->logger();
62 $this->
lng->loadLanguageModule(
'user');
63 if (!$this->rbacSystem->checkAccess(
"cat_administrate_users", $this->parentGui->getObject()->getRefId())) {
64 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_perm_admin_users"),
true);
70 $cmd = $this->
ctrl->getCmd();
74 $this->tabsGui->clearTargets();
75 $this->tabsGui->setBackTarget(
76 $this->
lng->txt(
"back"),
77 $this->ctrl->getLinkTargetByClass(
"illocalusergui",
'index')
96 $table->resetOffset();
97 $table->resetFilter();
104 $table->resetOffset();
105 $table->writeFilterToSession();
109 public function index(
bool $show_delete =
false): bool
111 $this->tpl->addBlockfile(
114 'tpl.cat_admin_users.html',
117 if (count($this->rbacReview->getGlobalAssignableRoles())
118 or in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId()))
121 $this->
lng->txt(
'add_user'),
122 $this->ctrl->getLinkTargetByClass(
'ilobjusergui',
'create')
125 $this->
lng->txt(
'import_users'),
126 $this->ctrl->getLinkTargetByClass(
'ilobjuserfoldergui',
'importUserForm')
129 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_roles_user_can_be_assigned_to'));
132 $this->tpl->setCurrentBlock(
"confirm_delete");
133 $this->tpl->setVariable(
"CONFIRM_FORMACTION", $this->
ctrl->getFormAction($this));
134 $this->tpl->setVariable(
"TXT_CANCEL", $this->
lng->txt(
'cancel'));
135 $this->tpl->setVariable(
"CONFIRM_CMD",
'performDeleteUsers');
136 $this->tpl->setVariable(
"TXT_CONFIRM", $this->
lng->txt(
'delete'));
137 $this->tpl->parseCurrentBlock();
140 $this->tpl->setVariable(
'USERS_TABLE', $table->getHTML());
148 $auto->setSearchFields(array(
'login',
'firstname',
'lastname',
'email'));
149 $auto->enableFieldSearchableCheck(
true);
150 $auto->setMoreLinkAvailable(
true);
152 if (($_REQUEST[
'fetchall'])) {
156 echo $auto->getList($_REQUEST[
'term']);
163 foreach ($_POST[
'user_ids'] as $user_id) {
165 $this->
logger->write(__FILE__ .
":" . __LINE__ .
" User with id $user_id could not be found.");
166 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'user_not_found_to_delete'));
173 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'deleted_users'),
true);
174 $this->
ctrl->redirect($this,
'index');
182 if (!count($_POST[
'id'])) {
183 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_users_selected'));
188 $confirm->setFormAction($this->
ctrl->getFormAction($this));
189 $confirm->setHeaderText($this->
lng->txt(
'sure_delete_selected_users'));
190 $confirm->setConfirm($this->
lng->txt(
'delete'),
'performDeleteUsers');
191 $confirm->setCancel($this->
lng->txt(
'cancel'),
'index');
192 foreach ($_POST[
'id'] as
$user) {
197 $name[
'lastname'] .
', ' .
$name[
'firstname'] .
' [' .
$name[
'login'] .
']'
200 $this->tpl->setContent($confirm->getHTML());
211 if (!$this->
access->checkAccess(
"cat_administrate_users",
"",
$_GET[
"ref_id"])) {
212 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
213 $this->
ctrl->redirect($this,
"");
215 $offset = isset(
$_GET[
"offset"]) ?
$_GET[
"offset"] : 0;
217 if (!isset(
$_GET[
"sort_by"]) ||
$_GET[
"sort_by"] ==
"title" || empty(
$_GET[
"sort_by"])) {
220 $order =
$_GET[
"sort_by"];
223 $direction = isset(
$_GET[
"sort_order"]) ?
$_GET[
"sort_order"] :
'asc';
224 if (!isset(
$_GET[
'obj_id'])) {
225 $this->tpl->setOnScreenMessage(
'failure',
'no_user_selected');
230 $this->tpl->addBlockfile(
233 'tpl.cat_role_assignment.html',
236 $ass_roles = $this->rbacReview->assignedRoles(
$_GET[
'obj_id']);
238 foreach ($roles as $role) {
242 in_array($role[
'obj_id'], $ass_roles) ? 1 : 0,
247 $f_result[$counter][] = $role_obj->getTitle();
248 $f_result[$counter][] = $role_obj->getDescription() ? $role_obj->getDescription() :
'';
249 $f_result[$counter][] = (isset($role[
'role_type']) && $role[
'role_type'] ==
'global')
251 $this->
lng->txt(
'global')
253 $this->
lng->txt(
'local');
262 if (!$this->
access->checkAccess(
"cat_administrate_users",
"",
$_GET[
"ref_id"])) {
263 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
264 $this->
ctrl->redirect($this,
"");
268 $this->tpl->setOnScreenMessage(
'failure',
'no_user_selected');
276 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_global_role_left'));
277 $this->assignRolesObject();
281 $new_role_ids = $_POST[
'role_ids'] ? $_POST[
'role_ids'] : array();
282 $assigned_roles = $this->rbacReview->assignedRoles((
int) $_REQUEST[
'obj_id']);
283 foreach ($roles as $role) {
284 if (in_array($role[
'obj_id'], $new_role_ids) and !in_array($role[
'obj_id'], $assigned_roles)) {
285 $this->rbacAdmin->assignUser($role[
'obj_id'], (
int) $_REQUEST[
'obj_id']);
287 if (in_array($role[
'obj_id'], $assigned_roles) and !in_array($role[
'obj_id'], $new_role_ids)) {
288 $this->rbacAdmin->deassignUser($role[
'obj_id'], (
int) $_REQUEST[
'obj_id']);
291 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'role_assignment_updated'));
299 if (!$this->
access->checkAccess(
"cat_administrate_users",
"",
$_GET[
"ref_id"])) {
300 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
301 $this->
ctrl->redirect($this,
"");
305 if ($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
306 !in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId()))
311 $new_assigned = $new_assigned ? $new_assigned : array();
312 $assigned = $this->rbacReview->assignedRoles((
int)
$_GET[
'obj_id']);
314 if (!in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId()))) {
315 $ga = $this->rbacReview->getGlobalAssignableRoles();
317 $ga = $this->rbacReview->getGlobalRolesArray();
319 $global_assignable = array();
320 foreach ($ga as $role) {
321 $global_assignable[] = $role[
'obj_id'];
323 $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
324 $all_assigned_roles = array_intersect($assigned, $this->rbacReview->getGlobalRoles());
325 $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
326 if (!count($new_visible_assigned_roles) and !count($main_assigned_roles)) {
343 if (in_array(
SYSTEM_ROLE_ID, $this->rbacReview->assignedRoles($this->user->getId())) ===
true) {
344 $global_roles = $this->rbacReview->getGlobalRolesArray();
345 } elseif ($tmp_obj->getTimeLimitOwner() == $this->object->getRefId()) {
346 $global_roles = $this->rbacReview->getGlobalAssignableRoles();
348 $global_roles = array();
351 return array_merge($global_roles, $this->rbacReview->getAssignableChildRoles($this->object->getRefId()));
363 if ($this->
access->checkAccess(
"cat_administrate_users",
"",
$_GET[
"ref_id"]) ===
false) {
364 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
365 $this->
ctrl->redirect($this,
"");
368 $tpl = $tbl->getTemplateObject();
371 $this->
ctrl->setParameter($this,
'obj_id',
$_GET[
'obj_id']);
381 $title = $this->
lng->txt(
'role_assignment') .
' (' . $tmp_obj->getFullname() .
')';
382 $tbl->setTitle($title,
"icon_role.svg", $this->
lng->txt(
"role_assignment"));
383 $tbl->setHeaderNames(array(
385 $this->
lng->txt(
"title"),
386 $this->lng->txt(
'description'),
387 $this->lng->txt(
"type"),
389 $tbl->setHeaderVars(array(
394 ), (get_class($this->parentGui) ==
'ilObjOrgUnitGUI')
396 "ref_id" => $this->
object->getRefId(),
397 "cmd" =>
"assignRoles",
398 "obj_id" =>
$_GET[
'obj_id'],
399 "cmdNode" =>
$_GET[
"cmdNode"],
400 "baseClass" =>
'ilAdministrationGUI',
401 "admin_mode" =>
"settings",
404 "ref_id" => $this->
object->getRefId(),
405 "cmd" =>
"assignRoles",
406 "obj_id" =>
$_GET[
'obj_id'],
407 "cmdClass" =>
"ilobjcategorygui",
408 "baseClass" =>
'ilRepositoryGUI',
409 "cmdNode" =>
$_GET[
"cmdNode"],
411 $tbl->setColumnWidth(array(
"4%",
"35%",
"45%",
"16%"));
412 $this->set_unlimited =
true;
415 $this->tpl->setVariable(
'OBJECTS', $tbl->getTemplateObject()->get());
427 $order = isset(
$_GET[
"sort_by"]) ?
$_GET[
"sort_by"] :
'title';
428 $direction = isset(
$_GET[
"sort_order"]) ?
$_GET[
"sort_order"] :
'asc';
429 $offset = isset(
$_GET[
"offset"]) ?
$_GET[
"offset"] : 0;
430 $limit = isset(
$_GET[
"limit"]) ?
$_GET[
"limit"] : 0;
432 if ($a_from ==
'clipboardObject') $tbl->disable(
"footer");
433 $tbl->disable(
"linkbar");
435 $tbl->setOrderColumn((
string) $order);
436 $tbl->setOrderDirection((
string) $direction);
437 $tbl->setOffset((
int) $offset);
438 $tbl->setLimit((
int) $limit);
439 $tbl->setFooter(
"tblfooter", $this->
lng->txt(
"previous"), $this->lng->txt(
"next"));
440 $tbl->setData($result_set);
445 if (!$this->
access->checkAccess($permission,
"",
$_GET[
"ref_id"])) {
446 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"permission_denied"),
true);
447 $this->
ctrl->redirect($this,
"");
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTableGUIBasicData($tbl, &$result_set, string $a_from="")
showRolesTable($a_result_set, $a_from="")
ILIAS DI LoggingServices $logger
ilGlobalTemplateInterface $tpl
addUserAutoCompleteObject()
index(bool $show_delete=false)
__construct(ilObjectGUI $parentGui)
checkPermission(string $permission)
checkGlobalRoles($new_assigned)
static _getAllUserIds(int $a_filter=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupName(int $a_user_id)
lookup user name
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.
Class ilRbacAdmin Core functions for role based access control.
class ilRbacReview Contains Review functions of core Rbac.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
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 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)
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...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.