ILIAS  release_7 Revision v7.30-3-g800a261c036
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 49 of file class.ilLocalUserGUI.php.

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __checkGlobalRoles()

ilLocalUserGUI::__checkGlobalRoles (   $new_assigned)

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

329 {
330 global $DIC;
331 $rbacreview = $DIC['rbacreview'];
332 $ilUser = $DIC['ilUser'];
333 if (!$this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
334 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
335 $this->ctrl->redirect($this, "");
336 }
337 // return true if it's not a local user
338 $tmp_obj = &ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
339 if ($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
340 !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
341 ) {
342 return true;
343 }
344 // new assignment by form
345 $new_assigned = $new_assigned ? $new_assigned : array();
346 $assigned = $rbacreview->assignedRoles((int) $_GET['obj_id']);
347 // all assignable globals
348 if (!in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
349 $ga = $rbacreview->getGlobalAssignableRoles();
350 } else {
351 $ga = $rbacreview->getGlobalRolesArray();
352 }
353 $global_assignable = array();
354 foreach ($ga as $role) {
355 $global_assignable[] = $role['obj_id'];
356 }
357 $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
358 $all_assigned_roles = array_intersect($assigned, $rbacreview->getGlobalRoles());
359 $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
360 if (!count($new_visible_assigned_roles) and !count($main_assigned_roles)) {
361 return false;
362 }
363
364 return true;
365 }
$_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
const SYSTEM_ROLE_ID
Definition: constants.php:27
$ilUser
Definition: imgupload.php:18

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

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 368 of file class.ilLocalUserGUI.php.

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

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

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 388 of file class.ilLocalUserGUI.php.

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

References $_GET, $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 167 of file class.ilLocalUserGUI.php.

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

References exit, and ilUserAutoComplete\MAX_ENTRIES.

◆ applyFilter()

ilLocalUserGUI::applyFilter ( )
protected

Apply filter.

Returns

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

115 {
116 $table = new ilUserTableGUI($this, "index", ilUserTableGUI::MODE_LOCAL_USER);
117 $table->resetOffset();
118 $table->writeFilterToSession();
119 $this->index();
120 }
index($show_delete=false)
TableGUI class for user administration.

References index(), and ilUserTableGUI\MODE_LOCAL_USER.

+ Here is the call graph for this function:

◆ assignRoles()

ilLocalUserGUI::assignRoles ( )

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

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

References $_GET, $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 287 of file class.ilLocalUserGUI.php.

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

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

+ Here is the call graph for this function:

◆ checkPermission()

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

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

453 {
454 if (!$this->ilAccess->checkAccess($permission, "", $_GET["ref_id"])) {
455 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
456 $this->ctrl->redirect($this, "");
457 }
458 }

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 208 of file class.ilLocalUserGUI.php.

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

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 77 of file class.ilLocalUserGUI.php.

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

◆ index()

ilLocalUserGUI::index (   $show_delete = false)

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

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

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

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 186 of file class.ilLocalUserGUI.php.

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

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

+ 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 100 of file class.ilLocalUserGUI.php.

101 {
102 $table = new ilUserTableGUI($this, "index", ilUserTableGUI::MODE_LOCAL_USER);
103 $table->resetOffset();
104 $table->resetFilter();
105 $this->index();
106 }

References index(), and ilUserTableGUI\MODE_LOCAL_USER.

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilLocalUserGUI::$ctrl
protected

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

◆ $form

ilLocalUserGUI::$form
protected

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

◆ $ilAccess

ilLocalUserGUI::$ilAccess
protected

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

Referenced by __construct().

◆ $lng

ilLocalUserGUI::$lng
protected

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

Referenced by __construct().

◆ $object

ilLocalUserGUI::$object

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

◆ $tabs_gui

ilLocalUserGUI::$tabs_gui
protected

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

◆ $toolbar

ilLocalUserGUI::$toolbar
protected

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

◆ $tpl

ilLocalUserGUI::$tpl
protected

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

Referenced by __construct(), and __showRolesTable().


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