ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $tpl, $ilCtrl, $ilTabs, $ilToolbar, $lng, $rbacsystem, $ilAccess;
55 $this->tpl = $tpl;
56 $this->ctrl = $ilCtrl;
57 $this->parent_gui = $parent_gui;
58 $this->object = $parent_gui->object;
59 $this->tabs_gui = $this->parent_gui->tabs_gui;
60 $this->toolbar = $ilToolbar;
61 $this->lng = $lng;
62 $this->ilAccess = $ilAccess;
63 $this->lng->loadLanguageModule('user');
64 if (! $rbacsystem->checkAccess("cat_administrate_users", $this->parent_gui->object->getRefId())) {
65 ilUtil::sendFailure($this->lng->txt("msg_no_perm_admin_users"), true);
66 }
67 }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18

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

302 {
303 global $rbacreview, $ilUser;
304 if (! $this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
305 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
306 $this->ctrl->redirect($this, "");
307 }
308 // return true if it's not a local user
309 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
310 if ($tmp_obj->getTimeLimitOwner() != $this->object->getRefId() and
311 ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
312 ) {
313 return true;
314 }
315 // new assignment by form
316 $new_assigned = $new_assigned ? $new_assigned : array();
317 $assigned = $rbacreview->assignedRoles((int)$_GET['obj_id']);
318 // all assignable globals
319 if (! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
320 $ga = $rbacreview->getGlobalAssignableRoles();
321 } else {
322 $ga = $rbacreview->getGlobalRolesArray();
323 }
324 $global_assignable = array();
325 foreach ($ga as $role) {
326 $global_assignable[] = $role['obj_id'];
327 }
328 $new_visible_assigned_roles = array_intersect($new_assigned, $global_assignable);
329 $all_assigned_roles = array_intersect($assigned, $rbacreview->getGlobalRoles());
330 $main_assigned_roles = array_diff($all_assigned_roles, $global_assignable);
331 if (! count($new_visible_assigned_roles) and ! count($main_assigned_roles)) {
332 return false;
333 }
334
335 return true;
336 }
$_GET["client_id"]
getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15

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

339 {
340 global $rbacreview, $ilUser;
341 // check local user
342 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_REQUEST['obj_id']);
343 // Admin => all roles
344 if (in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))) {
345 $global_roles = $rbacreview->getGlobalRolesArray();
346 } elseif ($tmp_obj->getTimeLimitOwner() == $this->object->getRefId()) {
347 $global_roles = $rbacreview->getGlobalAssignableRoles();
348 } else {
349 $global_roles = array();
350 }
351
352 return $roles = array_merge($global_roles, $rbacreview->getAssignableChildRoles($this->object->getRefId()));
353 }

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

356 {
357 if (! $this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
358 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
359 $this->ctrl->redirect($this, "");
360 }
361 $tbl =& $this->parent_gui->__initTableGUI();
362 $tpl =& $tbl->getTemplateObject();
363 // SET FORMAACTION
364 $tpl->setCurrentBlock("tbl_form_header");
365 $this->ctrl->setParameter($this, 'obj_id', $_GET['obj_id']);
366 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
367 $tpl->parseCurrentBlock();
368 // SET FOOTER BUTTONS
369 $tpl->setVariable("COLUMN_COUNTS", 4);
370 $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
371 $tpl->setVariable("BTN_NAME", "assignSave");
372 $tpl->setVariable("BTN_VALUE", $this->lng->txt("change_assignment"));
373 $tpl->setCurrentBlock("tbl_action_row");
374 $tpl->setVariable("TPLPATH", $this->tpl->tplPath);
375 $tpl->parseCurrentBlock();
376 $tmp_obj =& ilObjectFactory::getInstanceByObjId($_GET['obj_id']);
377 $title = $this->lng->txt('role_assignment') . ' (' . $tmp_obj->getFullname() . ')';
378 $tbl->setTitle($title, "icon_role.svg", $this->lng->txt("role_assignment"));
379 $tbl->setHeaderNames(array(
380 '',
381 $this->lng->txt("title"),
382 $this->lng->txt('description'),
383 $this->lng->txt("type")
384 ));
385 $tbl->setHeaderVars(array(
386 "",
387 "title",
388 "description",
389 "type"
390 ), (get_class($this->parent_gui) == 'ilObjOrgUnitGUI') ? array(
391 "ref_id" => $this->object->getRefId(),
392 "cmd" => "assignRoles",
393 "obj_id" => $_GET['obj_id'],
394 "cmdNode" => $_GET["cmdNode"],
395 "baseClass" => 'ilAdministrationGUI',
396 "admin_mode" => "settings"
397 ) : array(
398 "ref_id" => $this->object->getRefId(),
399 "cmd" => "assignRoles",
400 "obj_id" => $_GET['obj_id'],
401 "cmdClass" => "ilobjcategorygui",
402 "baseClass" => 'ilRepositoryGUI',
403 "cmdNode" => $_GET["cmdNode"],
404 ));
405 $tbl->setColumnWidth(array( "4%", "35%", "45%", "16%" ));
406 $this->set_unlimited = true;
407 $this->parent_gui->__setTableGUIBasicData($tbl, $a_result_set, $a_from, true);
408 $tbl->render();
409 $this->tpl->setVariable("ROLES_TABLE", $tbl->tpl->get());
410
411 return true;
412 }
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, $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 152 of file class.ilLocalUserGUI.php.

152 {
153 include_once './Services/User/classes/class.ilUserAutoComplete.php';
154 $auto = new ilUserAutoComplete();
155 $auto->setSearchFields(array( 'login', 'firstname', 'lastname', 'email' ));
156 $auto->enableFieldSearchableCheck(true);
157 $auto->setMoreLinkAvailable(true);
158
159 if(($_REQUEST['fetchall']))
160 {
161 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
162 }
163
164 echo $auto->getList($_REQUEST['term']);
165 exit();
166 }
Auto completion class for user lists.
exit
Definition: login.php:54

References $_REQUEST, exit, and ilUserAutoComplete\MAX_ENTRIES.

◆ applyFilter()

ilLocalUserGUI::applyFilter ( )
protected

Apply filter.

Returns

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

108 {
109 $table = new ilUserTableGUI($this, "index", ilUserTableGUI::MODE_LOCAL_USER);
110 $table->resetOffset();
111 $table->writeFilterToSession();
112 $this->index();
113 }
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 219 of file class.ilLocalUserGUI.php.

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

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

263 {
264 global $rbacreview, $rbacadmin;
265 if (! $this->ilAccess->checkAccess("cat_administrate_users", "", $_GET["ref_id"])) {
266 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
267 $this->ctrl->redirect($this, "");
268 }
269 include_once './Services/User/classes/class.ilLocalUser.php';
270 // check hack
271 if (! isset($_GET['obj_id']) or ! in_array($_REQUEST['obj_id'], ilLocalUser::_getAllUserIds())) {
272 ilUtil::sendFailure('no_user_selected');
273 $this->index();
274
275 return true;
276 }
277 $roles = $this->__getAssignableRoles();
278 // check minimum one global role
279 if (! $this->__checkGlobalRoles($_POST['role_ids'])) {
280 ilUtil::sendFailure($this->lng->txt('no_global_role_left'));
281 $this->assignRolesObject();
282
283 return false;
284 }
285 $new_role_ids = $_POST['role_ids'] ? $_POST['role_ids'] : array();
286 $assigned_roles = $rbacreview->assignedRoles((int)$_REQUEST['obj_id']);
287 foreach ($roles as $role) {
288 if (in_array($role['obj_id'], $new_role_ids) and ! in_array($role['obj_id'], $assigned_roles)) {
289 $rbacadmin->assignUser($role['obj_id'], (int)$_REQUEST['obj_id']);
290 }
291 if (in_array($role['obj_id'], $assigned_roles) and ! in_array($role['obj_id'], $new_role_ids)) {
292 $rbacadmin->deassignUser($role['obj_id'], (int)$_REQUEST['obj_id']);
293 }
294 }
295 ilUtil::sendSuccess($this->lng->txt('role_assignment_updated'));
296 $this->assignRoles();
297
298 return true;
299 }
__checkGlobalRoles($new_assigned)
_getAllUserIds($a_filter=0)
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12

References $_GET, $_POST, $_REQUEST, __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 417 of file class.ilLocalUserGUI.php.

417 {
418 if (! $this->ilAccess->checkAccess($permission, "", $_GET["ref_id"])) {
419 ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
420 $this->ctrl->redirect($this, "");
421 }
422 }

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

193 {
194 $this->checkPermission("cat_administrate_users");
195 if (! count($_POST['id'])) {
196 ilUtil::sendFailure($this->lng->txt('no_users_selected'));
197 $this->index();
198
199 return true;
200 }
201 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
202 $confirm = new ilConfirmationGUI();
203 $confirm->setFormAction($this->ctrl->getFormAction($this));
204 $confirm->setHeaderText($this->lng->txt('sure_delete_selected_users'));
205 $confirm->setConfirm($this->lng->txt('delete'), 'performDeleteUsers');
206 $confirm->setCancel($this->lng->txt('cancel'), 'index');
207 foreach ($_POST['id'] as $user) {
208 $name = ilObjUser::_lookupName($user);
209 $confirm->addItem(
210 'user_ids[]',
211 $user,
212 $name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']'
213 );
214 }
215 $this->tpl->setContent($confirm->getHTML());
216 }
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 73 of file class.ilLocalUserGUI.php.

73 {
74 $cmd = $this->ctrl->getCmd();
75 switch ($cmd) {
76 case "assignRoles":
77 case "assignSave":
78 $this->tabs_gui->clearTargets();
79 $this->tabs_gui->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTargetByClass("illocalusergui", 'index'));
80 $this->$cmd();
81 break;
82 default:
83 $this->$cmd();
84 break;
85 }
86
87 return true;
88 }
$cmd
Definition: sahs_server.php:35

References $cmd.

◆ index()

ilLocalUserGUI::index (   $show_delete = false)

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

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

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

172 {
173 global $ilLog;
174 include_once './Services/User/classes/class.ilLocalUser.php';
175 $this->checkPermission("cat_administrate_users");
176 foreach ($_POST['user_ids'] as $user_id) {
177 if (! in_array($user_id, ilLocalUser::_getAllUserIds($_GET['ref_id']))) {
178 $ilLog->write(__FILE__.":".__LINE__." User with id $user_id could not be found.");
179 ilUtil::sendFailure($this->lng->txt('user_not_found_to_delete'));
180 }
181 if (! $tmp_obj =& ilObjectFactory::getInstanceByObjId($user_id, false)) {
182 continue;
183 }
184 $tmp_obj->delete();
185 }
186 ilUtil::sendSuccess($this->lng->txt('deleted_users'), true);
187 $this->ctrl->redirect($this, 'index');
188
189 return true;
190 }

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

95 {
96 $table = new ilUserTableGUI($this, "index", ilUserTableGUI::MODE_LOCAL_USER);
97 $table->resetOffset();
98 $table->resetFilter();
99 $this->index();
100 }

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: