ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 53 of file class.ilLocalUserGUI.php.

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

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

319 {
320 global $DIC;
321 $rbacreview = $DIC['rbacreview'];
322 $ilUser = $DIC['ilUser'];
323 if (! $this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
324 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
325 $this->ctrl->redirect($this, "");
326 }
327 // return true if it's not a local user
328 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
329 if ($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
330 ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
331 ) {
332 return true;
333 }
334 // new assignment by form
335 $new_assigned = $new_assigned ? $new_assigned : array();
336 $assigned = $rbacreview->assignedRoles((int)$_GET['obj_id']);
337 // all assignable globals
338 if (! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
339 $ga = $rbacreview->getGlobalAssignableRoles();
340 } else {
341 $ga = $rbacreview->getGlobalRolesArray();
342 }
343 $global_assignable = array();
344 foreach ($ga as $role) {
345 $global_assignable[] = $role['obj_id'];
346 }
347 $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
348 $all_assigned_roles = array_intersect($assigned, $rbacreview->getGlobalRoles());
349 $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
350 if (! count($new_visible_assigned_roles) and ! count($main_assigned_roles)) {
351 return false;
352 }
353
354 return true;
355 }
$_GET["client_id"]
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, 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 358 of file class.ilLocalUserGUI.php.

358 {
359 global $DIC;
360 $rbacreview = $DIC['rbacreview'];
361 $ilUser = $DIC['ilUser'];
362 // check local user
363 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
364 // Admin => all roles
365 if (in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
366 $global_roles = $rbacreview->getGlobalRolesArray();
367 } elseif ($tmp_obj->getTimeLimitOwner() == $this->object->getRefId()) {
368 $global_roles = $rbacreview->getGlobalAssignableRoles();
369 } else {
370 $global_roles = array();
371 }
372
373 return $roles = array_merge($global_roles, $rbacreview->getAssignableChildRoles($this->object->getRefId()));
374 }

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

377 {
378 if (! $this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
379 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
380 $this->ctrl->redirect($this, "");
381 }
382 $tbl =& $this->parent_gui->__initTableGUI();
383 $tpl =& $tbl->getTemplateObject();
384 // SET FORMAACTION
385 $tpl->setCurrentBlock("tbl_form_header");
386 $this->ctrl->setParameter($this, 'obj_id', $_GET['obj_id']);
387 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
388 $tpl->parseCurrentBlock();
389 // SET FOOTER BUTTONS
390 $tpl->setVariable("COLUMN_COUNTS", 4);
391 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
392 $tpl->setVariable("BTN_NAME", "assignSave");
393 $tpl->setVariable("BTN_VALUE", $this->lng->txt("change_assignment"));
394 $tpl->setCurrentBlock("tbl_action_row");
395 $tpl->setVariable("TPLPATH", $this->tpl->tplPath);
396 $tpl->parseCurrentBlock();
397 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_GET['obj_id']);
398 $title = $this->lng->txt('role_assignment') . ' (' . $tmp_obj->getFullname() . ')';
399 $tbl->setTitle($title, "icon_role.svg", $this->lng->txt("role_assignment"));
400 $tbl->setHeaderNames(array(
401 '',
402 $this->lng->txt("title"),
403 $this->lng->txt('description'),
404 $this->lng->txt("type")
405 ));
406 $tbl->setHeaderVars(array(
407 "",
408 "title",
409 "description",
410 "type"
411 ), (get_class($this->parent_gui) == 'ilObjOrgUnitGUI') ? array(
412 "ref_id" => $this->object->getRefId(),
413 "cmd" => "assignRoles",
414 "obj_id" => $_GET['obj_id'],
415 "cmdNode" => $_GET["cmdNode"],
416 "baseClass" => 'ilAdministrationGUI',
417 "admin_mode" => "settings"
418 ) : array(
419 "ref_id" => $this->object->getRefId(),
420 "cmd" => "assignRoles",
421 "obj_id" => $_GET['obj_id'],
422 "cmdClass" => "ilobjcategorygui",
423 "baseClass" => 'ilRepositoryGUI',
424 "cmdNode" => $_GET["cmdNode"],
425 ));
426 $tbl->setColumnWidth(array( "4%", "35%", "45%", "16%" ));
427 $this->set_unlimited = true;
428 $this->parent_gui->__setTableGUIBasicData($tbl, $a_result_set, $a_from, true);
429 $tbl->render();
430 $this->tpl->setVariable("ROLES_TABLE", $tbl->tpl->get());
431
432 return true;
433 }
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, 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 162 of file class.ilLocalUserGUI.php.

162 {
163 include_once './Services/User/classes/class.ilUserAutoComplete.php';
164 $auto = new ilUserAutoComplete();
165 $auto->setSearchFields(array( 'login', 'firstname', 'lastname', 'email' ));
166 $auto->enableFieldSearchableCheck(true);
167 $auto->setMoreLinkAvailable(true);
168
169 if(($_REQUEST['fetchall']))
170 {
171 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
172 }
173
174 echo $auto->getList($_REQUEST['term']);
175 exit();
176 }
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.

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

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

References $_GET, $counter, $DIC, __getAssignableRoles(), __showRolesTable(), 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 275 of file class.ilLocalUserGUI.php.

275 {
276 global $DIC;
277 $rbacreview = $DIC['rbacreview'];
278 $rbacadmin = $DIC['rbacadmin'];
279 if (! $this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
280 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
281 $this->ctrl->redirect($this, "");
282 }
283 include_once './Services/User/classes/class.ilLocalUser.php';
284 // check hack
285 if (! isset($_GET['obj_id']) or ! in_array($_REQUEST['obj_id'], ilLocalUser::_getAllUserIds())) {
286 ilUtil::sendFailure('no_user_selected');
287 $this->index();
288
289 return true;
290 }
291 $roles = $this->__getAssignableRoles();
292 // check minimum one global role
293// !!!DIC refactoring-script warning.!!!
294// There is an isolated 'global' whithout any variable behind.
295// Either this is a comment, or something is seriously wrong
296 if (! $this->__checkGlobalRoles($_POST['role_ids'])) {
297 ilUtil::sendFailure($this->lng->txt('no_global_role_left'));
298 $this->assignRolesObject();
299
300 return false;
301 }
302 $new_role_ids = $_POST['role_ids'] ? $_POST['role_ids'] : array();
303 $assigned_roles = $rbacreview->assignedRoles((int)$_REQUEST['obj_id']);
304 foreach ($roles as $role) {
305 if (in_array($role['obj_id'], $new_role_ids) and ! in_array($role['obj_id'], $assigned_roles)) {
306 $rbacadmin->assignUser($role['obj_id'], (int)$_REQUEST['obj_id']);
307 }
308 if (in_array($role['obj_id'], $assigned_roles) and ! in_array($role['obj_id'], $new_role_ids)) {
309 $rbacadmin->deassignUser($role['obj_id'], (int)$_REQUEST['obj_id']);
310 }
311 }
312 ilUtil::sendSuccess($this->lng->txt('role_assignment_updated'));
313 $this->assignRoles();
314
315 return true;
316 }
$_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(), index(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ checkPermission()

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

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

438 {
439 if (! $this->ilAccess->checkAccess($permission, "", $_GET["ref_id"])) {
440 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
441 $this->ctrl->redirect($this, "");
442 }
443 }

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

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

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

+ Here is the call graph for this function:

◆ executeCommand()

ilLocalUserGUI::executeCommand ( )
Returns
bool

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

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

References $cmd.

◆ index()

ilLocalUserGUI::index (   $show_delete = false)

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

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

References $DIC, $ilUser, 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 182 of file class.ilLocalUserGUI.php.

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

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

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

References index(), and ilUserTableGUI\MODE_LOCAL_USER.

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilLocalUserGUI::$ctrl
protected

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

◆ $form

ilLocalUserGUI::$form
protected

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

◆ $ilAccess

ilLocalUserGUI::$ilAccess
protected

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

Referenced by __construct().

◆ $lng

ilLocalUserGUI::$lng
protected

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

Referenced by __construct().

◆ $object

ilLocalUserGUI::$object

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

◆ $tabs_gui

ilLocalUserGUI::$tabs_gui
protected

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

◆ $toolbar

ilLocalUserGUI::$toolbar
protected

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

◆ $tpl

ilLocalUserGUI::$tpl
protected

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

Referenced by __construct(), and __showRolesTable().


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