ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAssignedUsersTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
26 {
27  protected int $role_id;
28  protected bool $roleAssignmentEditable = true;
29  protected bool $isAdministrationContext = false;
30 
31  public function __construct(
32  object $a_parent_obj,
33  string $a_parent_cmd,
34  int $a_role_id,
35  bool $a_editable = true,
36  bool $isAdministrationContext = false
37  ) {
38  $this->setId("rbac_ua_" . $a_role_id);
39  $this->role_id = $a_role_id;
40  $this->roleAssignmentEditable = $a_editable;
41  $this->isAdministrationContext = $isAdministrationContext;
42 
43  parent::__construct($a_parent_obj, $a_parent_cmd);
44  // $this->setTitle($this->lng->txt("users"));
45 
46  $this->addColumn("", "", "1", true);
47  $this->addColumn($this->lng->txt("login"), "login", "29%");
48  $this->addColumn($this->lng->txt("firstname"), "firstname", "29%");
49  $this->addColumn($this->lng->txt("lastname"), "lastname", "29%");
50  $this->addColumn($this->lng->txt('actions'), '', '13%');
51 
52  $this->setExternalSorting(true);
53  $this->setExternalSegmentation(true);
54  $this->setEnableHeader(true);
55  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj, $a_parent_cmd));
56  $this->setRowTemplate("tpl.user_assignment_row.html", "Services/AccessControl");
57 
58  $this->setEnableTitle(true);
59  $this->setDefaultOrderField("login");
60  $this->setDefaultOrderDirection("asc");
61 
62  $this->setShowRowsSelector(true);
63 
64  if ($this->roleAssignmentEditable) {
65  $this->addMultiCommand("deassignUser", $this->lng->txt("remove"));
66  }
67 
68  $this->setSelectAllCheckbox("user_id[]");
69  $this->lng->loadLanguageModule('user');
70  $this->addMultiCommand(
71  'addToClipboard',
72  $this->lng->txt('clipboard_add_btn')
73  );
74  $this->getItems();
75  }
76 
80  public function getRoleId(): int
81  {
82  return $this->role_id;
83  }
84 
88  public function isRoleAssignmentEditable(): bool
89  {
91  }
92 
96  public function getItems(): void
97  {
98  $this->determineOffsetAndOrder();
99  $usr_data = ilUserQuery::getUserListData(
102  $this->getOffset(),
103  $this->getLimit(),
104  '',
105  '',
106  null,
107  false,
108  false,
109  0,
110  $this->getRoleId()
111  );
112  $this->setMaxCount((int) $usr_data["cnt"]);
113  $this->setData((array) $usr_data["set"]);
114  }
115 
119  protected function fillRow(array $a_set): void
120  {
121  $this->tpl->setVariable("VAL_FIRSTNAME", $a_set["firstname"]);
122  $this->tpl->setVariable("VAL_LASTNAME", $a_set["lastname"]);
123 
124  if (
125  $a_set['usr_id'] != SYSTEM_USER_ID and
126  ($a_set['usr_id'] != ANONYMOUS_USER_ID or $this->getRoleId() != ANONYMOUS_ROLE_ID) and
127  $this->isRoleAssignmentEditable()) {
128  $this->tpl->setVariable("ID", $a_set["usr_id"]);
129  }
130 
131  $actions = new ilAdvancedSelectionListGUI();
132  $actions->setSelectionHeaderClass("small");
133  $actions->setItemLinkClass("small");
134 
135  $actions->setListTitle($this->lng->txt('actions'));
136  $actions->setId((string) $a_set['usr_id']);
137 
138  $link_contact = ilMailFormCall::getLinkTarget(
139  $this->getParentObject(),
140  $this->getParentCmd(),
141  array('fr' => rawurlencode(base64_encode($this->ctrl->getLinkTarget(
142  $this->getParentObject(),
143  'userassignment',
144  '',
145  false,
146  false
147  )))
148  ),
149  array('type' => 'new', 'rcp_to' => $a_set['login'])
150  );
151  $actions->addItem(
152  $this->lng->txt('message'),
153  '',
154  $link_contact
155  );
156 
157  if ($this->isAdministrationContext) {
158  $this->ctrl->setParameterByClass("ilobjusergui", "ref_id", 7);
159  $this->ctrl->setParameterByClass("ilobjusergui", "obj_id", $a_set["usr_id"]);
160 
161  $link_change = $this->ctrl->getLinkTargetByClass(array("iladministrationgui", "ilobjusergui"), "view");
162 
163  $this->tpl->setVariable('VAL_LOGIN', $a_set['login']);
164  $this->tpl->setVariable('HREF_LOGIN', $link_change);
165  $actions->addItem(
166  $this->lng->txt("edit"),
167  '',
168  $link_change
169  );
170  } else {
171  $this->tpl->setVariable('VAL_PLAIN_LOGIN', $a_set['login']);
172  }
173 
174  if (
175  ($this->getRoleId() != SYSTEM_ROLE_ID or $a_set['usr_id'] != SYSTEM_USER_ID) and
176  ($this->getRoleId() != ANONYMOUS_ROLE_ID or $a_set['usr_id'] != ANONYMOUS_USER_ID) and
177  $this->isRoleAssignmentEditable()) {
178  $this->ctrl->setParameter($this->getParentObject(), "user_id", $a_set["usr_id"]);
179  $link_leave = $this->ctrl->getLinkTarget($this->getParentObject(), "deassignUser");
180 
181  $actions->addItem(
182  $this->lng->txt('remove'),
183  '',
184  $link_leave
185  );
186  }
187 
188  $this->tpl->setVariable('VAL_ACTIONS', $actions->getHTML());
189  }
190 }
setData(array $a_data)
const ANONYMOUS_USER_ID
Definition: constants.php:27
fillRow(array $a_set)
Fill table row.
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
const SYSTEM_ROLE_ID
Definition: constants.php:29
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
const SYSTEM_USER_ID
This file contains constants for PHPStan analyis, see: https://phpstan.org/config-reference#constants...
Definition: constants.php:26
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_role_id, bool $a_editable=true, bool $isAdministrationContext=false)
static getLinkTarget( $gui, string $cmd, array $gui_params=[], array $mail_params=[], array $context_params=[])
setId(string $a_val)
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setDefaultOrderField(string $a_defaultorderfield)
isRoleAssignmentEditable()
Check if role assignment is editable.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
static getUserListData(string $a_order_field, string $a_order_dir, int $a_offset, int $a_limit, string $a_string_filter="", string $a_activation_filter="", ?ilDateTime $a_last_login_filter=null, bool $a_limited_access_filter=false, bool $a_no_courses_filter=false, int $a_course_group_filter=0, int $a_role_filter=0, array $a_user_folder_filter=null, array $a_additional_fields=null, array $a_user_filter=null, string $a_first_letter="", string $a_authentication_filter="")
Get data for user administration list.
addMultiCommand(string $a_cmd, string $a_text)
determineOffsetAndOrder(bool $a_omit_offset=false)
setEnableHeader(bool $a_enableheader)
setMaxCount(int $a_max_count)
set max.
setExternalSegmentation(bool $a_val)