ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLocalUserGUI Class Reference

Class ilLocalUserGUI. More...

+ Collaboration diagram for ilLocalUserGUI:

Public Member Functions

 __construct ($parent_gui)
 
 executeCommand ()
 
 index ($show_delete=false)
 
 performDeleteUsers ()
 Delete User. More...
 
 deleteUsers ()
 
 assignRoles ()
 
 assignSave ()
 
 __checkGlobalRoles ($new_assigned)
 
 __getAssignableRoles ()
 
 __showRolesTable ($a_result_set, $a_from="")
 

Data Fields

 $object
 

Protected Member Functions

 resetFilter ()
 Reset filter (note: this function existed before data table filter has been introduced. More...
 
 applyFilter ()
 Apply filter. More...
 
 addUserAutoCompleteObject ()
 Show auto complete results. More...
 
 checkPermission ($permission)
 

Protected Attributes

 $tabs_gui
 
 $form
 
 $toolbar
 
 $ctrl
 
 $tpl
 
 $lng
 
 $ilAccess
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLocalUserGUI::__construct (   $parent_gui)
Parameters
$parent_gui

Definition at line 50 of file class.ilLocalUserGUI.php.

51 {
52 global $DIC;
53 $tpl = $DIC['tpl'];
54 $ilCtrl = $DIC['ilCtrl'];
55 $ilTabs = $DIC['ilTabs'];
56 $ilToolbar = $DIC['ilToolbar'];
57 $lng = $DIC['lng'];
58 $rbacsystem = $DIC['rbacsystem'];
59 $ilAccess = $DIC['ilAccess'];
60 $this->tpl = $tpl;
61 $this->ctrl = $ilCtrl;
62 $this->parent_gui = $parent_gui;
63 $this->object = $parent_gui->object;
64 $this->tabs_gui = $this->parent_gui->tabs_gui;
65 $this->toolbar = $ilToolbar;
66 $this->lng = $lng;
67 $this->ilAccess = $ilAccess;
68 $this->lng->loadLanguageModule('user');
69 if (!$rbacsystem->checkAccess("cat_administrate_users", $this->parent_gui->object->getRefId())) {
70 ilUtil::sendFailure($this->lng->txt("msg_no_perm_admin_users"), true);
71 }
72 }
Class ilAccessHandler.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7

References $DIC, $ilAccess, $ilCtrl, $lng, $tpl, and ilUtil\sendFailure().

+ Here is the call graph for this function:

Member Function Documentation

◆ __checkGlobalRoles()

ilLocalUserGUI::__checkGlobalRoles (   $new_assigned)

Definition at line 327 of file class.ilLocalUserGUI.php.

328 {
329 global $DIC;
330 $rbacreview = $DIC['rbacreview'];
331 $ilUser = $DIC['ilUser'];
332 if (!$this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
333 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
334 $this->ctrl->redirect($this, "");
335 }
336 // return true if it's not a local user
337 $tmp_obj =&ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
338 if ($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
339 !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
340 ) {
341 return true;
342 }
343 // new assignment by form
344 $new_assigned = $new_assigned ? $new_assigned : array();
345 $assigned = $rbacreview->assignedRoles((int) $_GET['obj_id']);
346 // all assignable globals
347 if (!in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
348 $ga = $rbacreview->getGlobalAssignableRoles();
349 } else {
350 $ga = $rbacreview->getGlobalRolesArray();
351 }
352 $global_assignable = array();
353 foreach ($ga as $role) {
354 $global_assignable[] = $role['obj_id'];
355 }
356 $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
357 $all_assigned_roles = array_intersect($assigned, $rbacreview->getGlobalRoles());
358 $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
359 if (!count($new_visible_assigned_roles) and !count($main_assigned_roles)) {
360 return false;
361 }
362
363 return true;
364 }
$_GET["client_id"]
checkAccess($a_permission, $a_cmd, $a_ref_id, $a_type="", $a_obj_id="", $a_tree_id="")
check access for an object (provide $a_type and $a_obj_id if available for better performance)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$ilUser
Definition: imgupload.php:18

References $_GET, $DIC, $ilUser, ilAccess\checkAccess(), ilObjectFactory\getInstanceByObjId(), and ilUtil\sendFailure().

Referenced by assignSave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __getAssignableRoles()

ilLocalUserGUI::__getAssignableRoles ( )

Definition at line 367 of file class.ilLocalUserGUI.php.

368 {
369 global $DIC;
370 $rbacreview = $DIC['rbacreview'];
371 $ilUser = $DIC['ilUser'];
372 // check local user
373 $tmp_obj =&ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
374 // Admin => all roles
375 if (in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
376 $global_roles = $rbacreview->getGlobalRolesArray();
377 } elseif ($tmp_obj->getTimeLimitOwner() == $this->object->getRefId()) {
378 $global_roles = $rbacreview->getGlobalAssignableRoles();
379 } else {
380 $global_roles = array();
381 }
382
383 return $roles = array_merge($global_roles, $rbacreview->getAssignableChildRoles($this->object->getRefId()));
384 }

References $DIC, $ilUser, and ilObjectFactory\getInstanceByObjId().

Referenced by assignRoles(), and assignSave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __showRolesTable()

ilLocalUserGUI::__showRolesTable (   $a_result_set,
  $a_from = "" 
)

Definition at line 387 of file class.ilLocalUserGUI.php.

388 {
389 if (!$this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
390 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
391 $this->ctrl->redirect($this, "");
392 }
393 $tbl =&$this->parent_gui->__initTableGUI();
394 $tpl =&$tbl->getTemplateObject();
395 // SET FORMAACTION
396 $tpl->setCurrentBlock("tbl_form_header");
397 $this->ctrl->setParameter($this, 'obj_id', $_GET['obj_id']);
398 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
399 $tpl->parseCurrentBlock();
400 // SET FOOTER BUTTONS
401 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
402 $tpl->setVariable("BTN_NAME", "assignSave");
403 $tpl->setVariable("BTN_VALUE", $this->lng->txt("change_assignment"));
404 $tpl->setCurrentBlock("tbl_action_row");
405 $tpl->setVariable("TPLPATH", $this->tpl->tplPath);
406 $tpl->parseCurrentBlock();
407 $tmp_obj =&ilObjectFactory::getInstanceByObjId($_GET['obj_id']);
408 $title = $this->lng->txt('role_assignment') . ' (' . $tmp_obj->getFullname() . ')';
409 $tbl->setTitle($title, "icon_role.svg", $this->lng->txt("role_assignment"));
410 $tbl->setHeaderNames(array(
411 '',
412 $this->lng->txt("title"),
413 $this->lng->txt('description'),
414 $this->lng->txt("type")
415 ));
416 $tbl->setHeaderVars(array(
417 "",
418 "title",
419 "description",
420 "type"
421 ), (get_class($this->parent_gui) == 'ilObjOrgUnitGUI') ? array(
422 "ref_id" => $this->object->getRefId(),
423 "cmd" => "assignRoles",
424 "obj_id" => $_GET['obj_id'],
425 "cmdNode" => $_GET["cmdNode"],
426 "baseClass" => 'ilAdministrationGUI',
427 "admin_mode" => "settings"
428 ) : array(
429 "ref_id" => $this->object->getRefId(),
430 "cmd" => "assignRoles",
431 "obj_id" => $_GET['obj_id'],
432 "cmdClass" => "ilobjcategorygui",
433 "baseClass" => 'ilRepositoryGUI',
434 "cmdNode" => $_GET["cmdNode"],
435 ));
436 $tbl->setColumnWidth(array( "4%", "35%", "45%", "16%" ));
437 $this->set_unlimited = true;
438 $this->parent_gui->__setTableGUIBasicData($tbl, $a_result_set, $a_from, true);
439 $tbl->render();
440 $this->tpl->setVariable('OBJECTS', $tbl->getTemplateObject()->get());
441
442 return true;
443 }
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$tbl
Definition: example_048.php:81

References $_GET, $tbl, $title, $tpl, ilAccess\checkAccess(), ilUtil\getImagePath(), ilObjectFactory\getInstanceByObjId(), and ilUtil\sendFailure().

Referenced by assignRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addUserAutoCompleteObject()

ilLocalUserGUI::addUserAutoCompleteObject ( )
protected

Show auto complete results.

Definition at line 168 of file class.ilLocalUserGUI.php.

169 {
170 $auto = new ilUserAutoComplete();
171 $auto->setSearchFields(array( 'login', 'firstname', 'lastname', 'email' ));
172 $auto->enableFieldSearchableCheck(true);
173 $auto->setMoreLinkAvailable(true);
174
175 if (($_REQUEST['fetchall'])) {
176 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
177 }
178
179 echo $auto->getList($_REQUEST['term']);
180 exit();
181 }
Auto completion class for user lists.

References exit, and ilUserAutoComplete\MAX_ENTRIES.

◆ applyFilter()

ilLocalUserGUI::applyFilter ( )
protected

Apply filter.

Returns

Definition at line 115 of file class.ilLocalUserGUI.php.

116 {
118 $table->resetOffset();
119 $table->writeFilterToSession();
120 $this->index();
121 }
index($show_delete=false)
TableGUI class for user administration.
if(empty($password)) $table
Definition: pwgen.php:24

References $table, index(), and ilUserTableGUI\MODE_LOCAL_USER.

+ Here is the call graph for this function:

◆ assignRoles()

ilLocalUserGUI::assignRoles ( )

Definition at line 235 of file class.ilLocalUserGUI.php.

236 {
237 global $DIC;
238 $rbacreview = $DIC['rbacreview'];
239 if (!$this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
240 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
241 $this->ctrl->redirect($this, "");
242 }
243 $offset = $_GET["offset"];
244 // init sort_by (unfortunatly sort_by is preset with 'title'
245 if ($_GET["sort_by"] == "title" or empty($_GET["sort_by"])) {
246 $_GET["sort_by"] = "login";
247 }
248 $order = $_GET["sort_by"];
249 $direction = $_GET["sort_order"];
250 if (!isset($_GET['obj_id'])) {
251 ilUtil::sendFailure('no_user_selected');
252 $this->index();
253
254 return true;
255 }
256 $roles = $this->__getAssignableRoles();
257 $this->tpl->addBlockfile(
258 'ADM_CONTENT',
259 'adm_content',
260 'tpl.cat_role_assignment.html',
261 "Modules/Category"
262 );
263 $ass_roles = $rbacreview->assignedRoles($_GET['obj_id']);
264 $counter = 0;
265 foreach ($roles as $role) {
266 $role_obj =&ilObjectFactory::getInstanceByObjId($role['obj_id']);
267 $disabled = false;
268 $f_result[$counter][] = ilUtil::formCheckbox(
269 in_array($role['obj_id'], $ass_roles) ? 1 : 0,
270 'role_ids[]',
271 $role['obj_id'],
272 $disabled
273 );
274 $f_result[$counter][] = $role_obj->getTitle();
275 $f_result[$counter][] = $role_obj->getDescription()?$role_obj->getDescription():'';
276 $f_result[$counter][] = $role['role_type'] == 'global' ?
277 $this->lng->txt('global') :
278 $this->lng->txt('local');
279 unset($role_obj);
280 ++$counter;
281 }
282 $this->__showRolesTable($f_result, "assignRolesObject");
283 }
__showRolesTable($a_result_set, $a_from="")
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
$counter

References $_GET, $counter, $DIC, __getAssignableRoles(), __showRolesTable(), ilAccess\checkAccess(), ilUtil\formCheckbox(), ilObjectFactory\getInstanceByObjId(), index(), and ilUtil\sendFailure().

Referenced by assignSave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignSave()

ilLocalUserGUI::assignSave ( )

Definition at line 286 of file class.ilLocalUserGUI.php.

287 {
288 global $DIC;
289 $rbacreview = $DIC['rbacreview'];
290 $rbacadmin = $DIC['rbacadmin'];
291 if (!$this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
292 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
293 $this->ctrl->redirect($this, "");
294 }
295 // check hack
296 if (!isset($_GET['obj_id']) or !in_array($_REQUEST['obj_id'], ilLocalUser::_getAllUserIds())) {
297 ilUtil::sendFailure('no_user_selected');
298 $this->index();
299
300 return true;
301 }
302 $roles = $this->__getAssignableRoles();
303 // check minimum one global role
304 if (!$this->__checkGlobalRoles($_POST['role_ids'])) {
305 ilUtil::sendFailure($this->lng->txt('no_global_role_left'));
306 $this->assignRolesObject();
307
308 return false;
309 }
310 $new_role_ids = $_POST['role_ids'] ? $_POST['role_ids'] : array();
311 $assigned_roles = $rbacreview->assignedRoles((int) $_REQUEST['obj_id']);
312 foreach ($roles as $role) {
313 if (in_array($role['obj_id'], $new_role_ids) and !in_array($role['obj_id'], $assigned_roles)) {
314 $rbacadmin->assignUser($role['obj_id'], (int) $_REQUEST['obj_id']);
315 }
316 if (in_array($role['obj_id'], $assigned_roles) and !in_array($role['obj_id'], $new_role_ids)) {
317 $rbacadmin->deassignUser($role['obj_id'], (int) $_REQUEST['obj_id']);
318 }
319 }
320 ilUtil::sendSuccess($this->lng->txt('role_assignment_updated'));
321 $this->assignRoles();
322
323 return true;
324 }
$_POST["username"]
__checkGlobalRoles($new_assigned)
static _getAllUserIds($a_filter=0)
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References $_GET, $_POST, $DIC, __checkGlobalRoles(), __getAssignableRoles(), ilLocalUser\_getAllUserIds(), assignRoles(), ilAccess\checkAccess(), index(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ checkPermission()

ilLocalUserGUI::checkPermission (   $permission)
protected
Parameters
$permission

Definition at line 448 of file class.ilLocalUserGUI.php.

449 {
450 if (!$this->ilAccess->checkAccess($permission, "", $_GET["ref_id"])) {
451 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
452 $this->ctrl->redirect($this, "");
453 }
454 }

References $_GET, ilAccess\checkAccess(), and ilUtil\sendFailure().

Referenced by deleteUsers(), and performDeleteUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteUsers()

ilLocalUserGUI::deleteUsers ( )

Definition at line 209 of file class.ilLocalUserGUI.php.

210 {
211 $this->checkPermission("cat_administrate_users");
212 if (!count($_POST['id'])) {
213 ilUtil::sendFailure($this->lng->txt('no_users_selected'));
214 $this->index();
215
216 return true;
217 }
218 $confirm = new ilConfirmationGUI();
219 $confirm->setFormAction($this->ctrl->getFormAction($this));
220 $confirm->setHeaderText($this->lng->txt('sure_delete_selected_users'));
221 $confirm->setConfirm($this->lng->txt('delete'), 'performDeleteUsers');
222 $confirm->setCancel($this->lng->txt('cancel'), 'index');
223 foreach ($_POST['id'] as $user) {
225 $confirm->addItem(
226 'user_ids[]',
227 $user,
228 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']'
229 );
230 }
231 $this->tpl->setContent($confirm->getHTML());
232 }
Confirmation screen class.
checkPermission($permission)
static _lookupName($a_user_id)
lookup user name
if($format !==null) $name
Definition: metadata.php:146

References $_POST, $name, ilObjUser\_lookupName(), checkPermission(), index(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ executeCommand()

ilLocalUserGUI::executeCommand ( )
Returns
bool

Definition at line 78 of file class.ilLocalUserGUI.php.

79 {
80 $cmd = $this->ctrl->getCmd();
81 switch ($cmd) {
82 case "assignRoles":
83 case "assignSave":
84 $this->tabs_gui->clearTargets();
85 $this->tabs_gui->setBackTarget($this->lng->txt("back"), $this->ctrl->getLinkTargetByClass("illocalusergui", 'index'));
86 $this->$cmd();
87 break;
88 default:
89 $this->$cmd();
90 break;
91 }
92
93 return true;
94 }

◆ index()

ilLocalUserGUI::index (   $show_delete = false)

Definition at line 124 of file class.ilLocalUserGUI.php.

125 {
126 global $DIC;
127 $ilUser = $DIC['ilUser'];
128 $rbacreview = $DIC['rbacreview'];
129 $rbacsystem = $DIC['rbacsystem'];
130 $this->tpl->addBlockfile(
131 'ADM_CONTENT',
132 'adm_content',
133 'tpl.cat_admin_users.html',
134 "Modules/Category"
135 );
136 if (count($rbacreview->getGlobalAssignableRoles())
137 or in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
138 ) {
139 $this->toolbar->addButton(
140 $this->lng->txt('add_user'),
141 $this->ctrl->getLinkTargetByClass('ilobjusergui', 'create')
142 );
143 $this->toolbar->addButton(
144 $this->lng->txt('import_users'),
145 $this->ctrl->getLinkTargetByClass('ilobjuserfoldergui', 'importUserForm')
146 );
147 } else {
148 ilUtil::sendInfo($this->lng->txt('no_roles_user_can_be_assigned_to'));
149 }
150 if ($show_delete) {
151 $this->tpl->setCurrentBlock("confirm_delete");
152 $this->tpl->setVariable("CONFIRM_FORMACTION", $this->ctrl->getFormAction($this));
153 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt('cancel'));
154 $this->tpl->setVariable("CONFIRM_CMD", 'performDeleteUsers');
155 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt('delete'));
156 $this->tpl->parseCurrentBlock();
157 }
159 $this->tpl->setVariable('USERS_TABLE', $table->getHTML());
160
161 return true;
162 }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $DIC, $ilUser, $table, ilUserTableGUI\MODE_LOCAL_USER, and ilUtil\sendInfo().

Referenced by applyFilter(), assignRoles(), assignSave(), deleteUsers(), and resetFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performDeleteUsers()

ilLocalUserGUI::performDeleteUsers ( )

Delete User.

Definition at line 187 of file class.ilLocalUserGUI.php.

188 {
189 global $DIC;
190 $ilLog = $DIC['ilLog'];
191 $this->checkPermission("cat_administrate_users");
192 foreach ($_POST['user_ids'] as $user_id) {
193 if (!in_array($user_id, ilLocalUser::_getAllUserIds($_GET['ref_id']))) {
194 $ilLog->write(__FILE__ . ":" . __LINE__ . " User with id $user_id could not be found.");
195 ilUtil::sendFailure($this->lng->txt('user_not_found_to_delete'));
196 }
197 if (!$tmp_obj =&ilObjectFactory::getInstanceByObjId($user_id, false)) {
198 continue;
199 }
200 $tmp_obj->delete();
201 }
202 ilUtil::sendSuccess($this->lng->txt('deleted_users'), true);
203 $this->ctrl->redirect($this, 'index');
204
205 return true;
206 }

References $_GET, $_POST, $DIC, $ilLog, ilLocalUser\_getAllUserIds(), checkPermission(), ilObjectFactory\getInstanceByObjId(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ resetFilter()

ilLocalUserGUI::resetFilter ( )
protected

Reset filter (note: this function existed before data table filter has been introduced.

Definition at line 101 of file class.ilLocalUserGUI.php.

102 {
104 $table->resetOffset();
105 $table->resetFilter();
106 $this->index();
107 }

References $table, index(), and ilUserTableGUI\MODE_LOCAL_USER.

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilLocalUserGUI::$ctrl
protected

Definition at line 27 of file class.ilLocalUserGUI.php.

◆ $form

ilLocalUserGUI::$form
protected

Definition at line 19 of file class.ilLocalUserGUI.php.

◆ $ilAccess

ilLocalUserGUI::$ilAccess
protected

Definition at line 43 of file class.ilLocalUserGUI.php.

Referenced by __construct().

◆ $lng

ilLocalUserGUI::$lng
protected

Definition at line 39 of file class.ilLocalUserGUI.php.

Referenced by __construct().

◆ $object

ilLocalUserGUI::$object

Definition at line 35 of file class.ilLocalUserGUI.php.

◆ $tabs_gui

ilLocalUserGUI::$tabs_gui
protected

Definition at line 15 of file class.ilLocalUserGUI.php.

◆ $toolbar

ilLocalUserGUI::$toolbar
protected

Definition at line 23 of file class.ilLocalUserGUI.php.

◆ $tpl

ilLocalUserGUI::$tpl
protected

Definition at line 31 of file class.ilLocalUserGUI.php.

Referenced by __construct(), and __showRolesTable().


The documentation for this class was generated from the following file: