ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSoapRBACAdministration Class Reference
+ Inheritance diagram for ilSoapRBACAdministration:
+ Collaboration diagram for ilSoapRBACAdministration:

Public Member Functions

 deleteRole ($sid, $role_id)
 
 addUserRoleEntry ($sid, $user_id, $role_id)
 
 deleteUserRoleEntry ($sid, $user_id, $role_id)
 
 getOperations ($sid)
 
 revokePermissions ($sid, $ref_id, $role_id)
 
 grantPermissions ($sid, $ref_id, $role_id, $permissions)
 
 getLocalRoles ($sid, $ref_id)
 
 getUserRoles ($sid, $user_id)
 
 addRole ($sid, $target_id, $role_xml)
 
 addRoleFromTemplate ($sid, $target_id, $role_xml, $template_id)
 
 getObjectTreeOperations ($sid, $ref_id, $user_id)
 
 getRoles ($sid, $role_type, $id)
 get roles for a specific type and id More...
 
 searchRoles ($sid, $key, $combination, $role_type)
 search for roles. More...
 
- Public Member Functions inherited from ilSoapAdministration
 __construct ($use_nusoap=true)
 Constructor. More...
 
 initErrorWriter ()
 Overwrite error handler. More...
 
 __explodeSid ($sid)
 
 __setMessage ($a_str)
 
 __getMessage ()
 
 __appendMessage ($a_str)
 
 __setMessageCode ($a_code)
 
 __getMessageCode ()
 
 initAuth ($sid)
 Init authentication. More...
 
 initIlias ()
 
 __initAuthenticationObject ($a_auth_mode=AUTH_LOCAL)
 
 __raiseError ($a_message, $a_code)
 
 getNIC ($sid)
 get client information from current as xml result set More...
 
 isFault ($object)
 
 checkObjectAccess ($ref_id, $expected_type, $permission, $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 
 getInstallationInfoXML ()
 
 getClientInfoXML ($clientid)
 

Private Member Functions

 parseUserID ($id, $role_type)
 

Additional Inherited Members

- Static Public Member Functions inherited from ilSoapAdministration
static return_bytes ($val)
 calculate bytes from K,M,G modifiers e.g: 8M = 8 * 1024 * 1024 bytes More...
 
- Data Fields inherited from ilSoapAdministration
 $sauth = null
 
 $error_method = null
 
- Protected Attributes inherited from ilSoapAdministration
 $soap_check = true
 

Detailed Description

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

Member Function Documentation

◆ addRole()

ilSoapRBACAdministration::addRole (   $sid,
  $target_id,
  $role_xml 
)

Definition at line 357 of file class.ilSoapRBACAdministration.php.

References $DIC, $GLOBALS, $target_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

358  {
359  $this->initAuth($sid);
360  $this->initIlias();
361 
362  if (!$this->__checkSession($sid)) {
363  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
364  }
365 
366  global $DIC;
367 
368  $rbacreview = $DIC['rbacreview'];
369  $objDefinition = $DIC['objDefinition'];
370  $rbacsystem = $DIC['rbacsystem'];
371  $ilAccess = $DIC['ilAccess'];
372 
373  if (!$tmp_obj =&ilObjectFactory::getInstanceByRefId($target_id, false)) {
374  return $this->__raiseError(
375  'No valid ref id given. Please choose an existing reference id of an ILIAS object',
376  'Client'
377  );
378  }
379 
381  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
382  }
383 
384  if (!$ilAccess->checkAccess('edit_permission', '', $target_id)) {
385  return $this->__raiseError('Check access failed. No permission to create roles', 'Server');
386  }
387 
388  include_once 'webservice/soap/classes/class.ilObjectXMLParser.php';
389 
390  $xml_parser = new ilObjectXMLParser($role_xml);
391  $xml_parser->startParsing();
392 
393  foreach ($xml_parser->getObjectData() as $object_data) {
394 
395  // check if role title has il_ prefix
396  if (substr($object_data['title'], 0, 3) == "il_") {
397  return $this->__raiseError(
398  'Rolenames are not allowed to start with "il_" ',
399  'Client'
400  );
401  }
402 
403  include_once './Services/AccessControl/classes/class.ilObjRole.php';
404  $role = new ilObjRole();
405  $role->setTitle($object_data['title']);
406  $role->setDescription($object_data['description']);
407  $role->setImportId($object_data['import_id']);
408  $role->create();
409 
410  $GLOBALS['DIC']['rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
411  $new_roles[] = $role->getId();
412  }
413 
414  return $new_roles ? $new_roles : array();
415  }
Class ilObjRole.
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
$target_id
Definition: goto.php:49
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ addRoleFromTemplate()

ilSoapRBACAdministration::addRoleFromTemplate (   $sid,
  $target_id,
  $role_xml,
  $template_id 
)

Definition at line 417 of file class.ilSoapRBACAdministration.php.

References $DIC, $GLOBALS, $target_id, $template_id, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObject\_lookupType(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

418  {
419  $this->initAuth($sid);
420  $this->initIlias();
421 
422  if (!$this->__checkSession($sid)) {
423  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
424  }
425 
426  global $DIC;
427 
428  $rbacreview = $DIC['rbacreview'];
429  $objDefinition = $DIC['objDefinition'];
430  $rbacsystem = $DIC['rbacsystem'];
431  $rbacadmin = $DIC['rbacadmin'];
432  $ilAccess = $DIC['ilAccess'];
433 
434  if (!$tmp_obj =&ilObjectFactory::getInstanceByRefId($target_id, false)) {
435  return $this->__raiseError(
436  'No valid ref id given. Please choose an existing reference id of an ILIAS object',
437  'Client'
438  );
439  }
440  if (ilObject::_lookupType($template_id) != 'rolt') {
441  return $this->__raiseError(
442  'No valid template id given. Please choose an existing object id of an ILIAS role template',
443  'Client'
444  );
445  }
446 
447 
449  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
450  }
451 
452  if (!$ilAccess->checkAccess('edit_permission', '', $target_id)) {
453  return $this->__raiseError('Check access failed. No permission to create roles', 'Server');
454  }
455 
456 
457  include_once 'webservice/soap/classes/class.ilObjectXMLParser.php';
458 
459  $xml_parser = new ilObjectXMLParser($role_xml);
460  $xml_parser->startParsing();
461 
462  foreach ($xml_parser->getObjectData() as $object_data) {
463 
464  // check if role title has il_ prefix
465  if (substr($object_data['title'], 0, 3) == "il_") {
466  return $this->__raiseError(
467  'Rolenames are not allowed to start with "il_" ',
468  'Client'
469  );
470  }
471 
472  include_once './Services/AccessControl/classes/class.ilObjRole.php';
473  $role = new ilObjRole();
474  $role->setTitle($object_data['title']);
475  $role->setDescription($object_data['description']);
476  $role->setImportId($object_data['import_id']);
477  $role->create();
478 
479  $GLOBALS['DIC']['rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
480 
481  // Copy permssions
482  $rbacadmin->copyRoleTemplatePermissions($template_id, ROLE_FOLDER_ID, $target_id, $role->getId());
483 
484  // Set object permissions according to role template
485  $ops = $rbacreview->getOperationsOfRole($role->getId(), $tmp_obj->getType(), $target_id);
486  $rbacadmin->grantPermission($role->getId(), $ops, $target_id);
487  $new_roles[] = $role->getId();
488  }
489 
490 
491  // CREATE ADMIN ROLE
492 
493 
494 
495 
496 
497  return $new_roles ? $new_roles : array();
498  }
Class ilObjRole.
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
$target_id
Definition: goto.php:49
__raiseError($a_message, $a_code)
static _lookupType($a_id, $a_reference=false)
lookup object type
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$template_id
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ addUserRoleEntry()

ilSoapRBACAdministration::addUserRoleEntry (   $sid,
  $user_id,
  $role_id 
)

Definition at line 83 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

84  {
85  $this->initAuth($sid);
86  $this->initIlias();
87 
88  if (!$this->__checkSession($sid)) {
89  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
90  }
91 
92  global $DIC;
93 
94  $rbacadmin = $DIC['rbacadmin'];
95  $rbacreview = $DIC['rbacreview'];
96  $ilAccess = $DIC['ilAccess'];
97 
98  if ($tmp_user =&ilObjectFactory::getInstanceByObjId($user_id) and $tmp_user->getType() != 'usr') {
99  return $this->__raiseError(
100  'No valid user id given. Please choose an existing id of an ILIAS user',
101  'Client'
102  );
103  }
104  if ($tmp_role =&ilObjectFactory::getInstanceByObjId($role_id) and $tmp_role->getType() != 'role') {
105  return $this->__raiseError(
106  'No valid role id given. Please choose an existing id of an ILIAS role',
107  'Client'
108  );
109  }
110 
111  $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
112  if (!$ilAccess->checkAccess('edit_permission', '', $obj_ref)) {
113  return $this->__raiseError('Check access failed. No permission to assign users', 'Server');
114  }
115 
116  if (!$rbacadmin->assignUser($role_id, $user_id)) {
117  return $this->__raiseError(
118  'Error rbacadmin->assignUser()',
119  'Server'
120  );
121  }
122  return true;
123  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ deleteRole()

ilSoapRBACAdministration::deleteRole (   $sid,
  $role_id 
)

Definition at line 37 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

38  {
39  $this->initAuth($sid);
40  $this->initIlias();
41 
42  if (!$this->__checkSession($sid)) {
43  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
44  }
45 
46  global $DIC;
47 
48  $rbacreview = $DIC['rbacreview'];
49  $rbacsystem = $DIC['rbacsystem'];
50  $ilAccess = $DIC['ilAccess'];
51 
52  if (!$tmp_role =&ilObjectFactory::getInstanceByObjId($role_id, false) or $tmp_role->getType() != 'role') {
53  return $this->__raiseError(
54  'No valid role id given. Please choose an existing id of an ILIAS role',
55  'Client'
56  );
57  }
58 
59 
60  $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
61  if (!$ilAccess->checkAccess('edit_permission', '', $obj_ref)) {
62  return $this->__raiseError('Check access failed. No permission to delete role', 'Server');
63  }
64 
65  // if it's last role of an user
66  foreach ($assigned_users = $rbacreview->assignedUsers($role_id) as $user_id) {
67  if (count($rbacreview->assignedRoles($user_id)) == 1) {
68  return $this->__raiseError(
69  'Cannot deassign last role of users',
70  'Client'
71  );
72  }
73  }
74 
75  // set parent id (role folder id) of role
76  $rolf_id = end($rolf_ids = $rbacreview->getFoldersAssignedToRole($role_id, true));
77  $tmp_role->setParent($rolf_id);
78  $tmp_role->delete();
79 
80  return true;
81  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ deleteUserRoleEntry()

ilSoapRBACAdministration::deleteUserRoleEntry (   $sid,
  $user_id,
  $role_id 
)

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

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

125  {
126  $this->initAuth($sid);
127  $this->initIlias();
128 
129  if (!$this->__checkSession($sid)) {
130  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
131  }
132 
133  global $DIC;
134 
135  $rbacadmin = $DIC['rbacadmin'];
136  $ilAccess = $DIC['ilAccess'];
137  $rbacreview = $DIC['rbacreview'];
138 
139  if ($tmp_user =&ilObjectFactory::getInstanceByObjId($user_id, false) and $tmp_user->getType() != 'usr') {
140  return $this->__raiseError(
141  'No valid user id given. Please choose an existing id of an ILIAS user',
142  'Client'
143  );
144  }
145  if ($tmp_role =&ilObjectFactory::getInstanceByObjId($role_id, false) and $tmp_role->getType() != 'role') {
146  return $this->__raiseError(
147  'No valid role id given. Please choose an existing id of an ILIAS role',
148  'Client'
149  );
150  }
151 
152  $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
153  if (!$ilAccess->checkAccess('edit_permission', '', $obj_ref)) {
154  return $this->__raiseError('Check access failed. No permission to deassign users', 'Server');
155  }
156 
157  if (!$rbacadmin->deassignUser($role_id, $user_id)) {
158  return $this->__raiseError(
159  'Error rbacadmin->deassignUser()',
160  'Server'
161  );
162  }
163  return true;
164  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ getLocalRoles()

ilSoapRBACAdministration::getLocalRoles (   $sid,
  $ref_id 
)

Definition at line 277 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

278  {
279  $this->initAuth($sid);
280  $this->initIlias();
281 
282  if (!$this->__checkSession($sid)) {
283  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
284  }
285 
286  global $DIC;
287 
288  $rbacreview = $DIC['rbacreview'];
289  $ilAccess = $DIC['ilAccess'];
290 
291  if (!$tmp_obj =&ilObjectFactory::getInstanceByRefId($ref_id, false)) {
292  return $this->__raiseError(
293  'No valid ref id given. Please choose an existing reference id of an ILIAS object',
294  'Client'
295  );
296  }
297 
298  if (!$ilAccess->checkAccess('edit_permission', '', $ref_id)) {
299  return $this->__raiseError('Check access failed. No permission to access role information', 'Server');
300  }
301 
302 
303  foreach ($rbacreview->getRolesOfRoleFolder($ref_id, false) as $role_id) {
304  if ($tmp_obj = ilObjectFactory::getInstanceByObjId($role_id, false)) {
305  $objs[] = $tmp_obj;
306  }
307  }
308  if (count($objs)) {
309  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
310 
311  $xml_writer = new ilObjectXMLWriter();
312  $xml_writer->setObjects($objs);
313  if ($xml_writer->start()) {
314  return $xml_writer->getXML();
315  }
316  }
317  return '';
318  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getObjectTreeOperations()

ilSoapRBACAdministration::getObjectTreeOperations (   $sid,
  $ref_id,
  $user_id 
)

Definition at line 500 of file class.ilSoapRBACAdministration.php.

References $data, $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObject\_isInTrash(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

501  {
502  $this->initAuth($sid);
503  $this->initIlias();
504 
505  if (!$this->__checkSession($sid)) {
506  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
507  }
508 
509  global $DIC;
510 
511  $rbacsystem = $DIC['rbacsystem'];
512  $rbacreview = $DIC['rbacreview'];
513  $ilAccess = $DIC['ilAccess'];
514 
515 
516  if (!$tmp_obj =&ilObjectFactory::getInstanceByRefId($ref_id, false)) {
517  return $this->__raiseError(
518  'No valid ref id given. Please choose an existing reference id of an ILIAS object',
519  'Client'
520  );
521  }
522 
523  if (!$tmp_user =&ilObjectFactory::getInstanceByObjId($user_id, false)) {
524  return $this->__raiseError(
525  'No valid user id given.',
526  'Client'
527  );
528  }
529 
530  if (ilObject::_isInTrash($ref_id)) {
531  return $this->__raiseError("Parent with ID $target_id has been deleted.", 'CLIENT_TARGET_DELETED');
532  }
533 
534 
535 
536  // check visible for all upper tree entries
537  if (!$ilAccess->checkAccessOfUser($tmp_user->getId(), 'visible', '', $tmp_obj->getRefId())) {
538  return array();
539  }
540  $op_data = $rbacreview->getOperation(2);
541  $ops_data[] = $op_data;
542 
543  if (!$ilAccess->checkAccessOfUser($tmp_user->getId(), 'read', '', $tmp_obj->getRefId())) {
544  return $ops_data;
545  }
546 
547 
548  $ops_data = array();
549  $ops = $rbacreview->getOperationsOnTypeString($tmp_obj->getType());
550  foreach ($ops as $ops_id) {
551  $op_data = $rbacreview->getOperation($ops_id);
552 
553  if ($rbacsystem->checkAccessOfUser($user_id, $op_data['operation'], $tmp_obj->getRefId())) {
554  $ops_data[$ops_id] = $op_data;
555  }
556  }
557 
558  foreach ($ops_data as $data) {
559  $ret_data[] = $data;
560  }
561  return $ret_data ? $ret_data : array();
562  }
global $DIC
Definition: saml.php:7
static _isInTrash($a_ref_id)
checks wether object is in trash
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getOperations()

ilSoapRBACAdministration::getOperations (   $sid)

Definition at line 166 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

167  {
168  $this->initAuth($sid);
169  $this->initIlias();
170 
171  if (!$this->__checkSession($sid)) {
172  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
173  }
174 
175  global $DIC;
176 
177  $rbacreview = $DIC['rbacreview'];
178 
179  if (is_array($ops = $rbacreview->getOperations())) {
180  return $ops;
181  } else {
182  return $this->__raiseError('Unknown error', 'Server');
183  }
184  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ getRoles()

ilSoapRBACAdministration::getRoles (   $sid,
  $role_type,
  $id 
)

get roles for a specific type and id

Parameters
String$sidsession id
String$role_typecan be empty which means "local & global", "local", "global", "user", "user_login" or "template"
Mixed$idcan be -1 for system role folder, can be ref id in case for role type "local/global/template", can be user id with "user" or login in case for role type "user_login"
Returns
String according DTD role_3_7

Definition at line 572 of file class.ilSoapRBACAdministration.php.

References $DIC, $id, $ilDB, $ilUser, $query, $type, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilDBConstants\FETCHMODE_ASSOC, ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and parseUserID().

573  {
574  $this->initAuth($sid);
575  $this->initIlias();
576 
577  if (!$this->__checkSession($sid)) {
578  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
579  }
580 
581  global $DIC;
582 
583  $rbacsystem = $DIC['rbacsystem'];
584  $rbacreview = $DIC['rbacreview'];
585  $ilUser = $DIC['ilUser'];
586  $ilDB = $DIC['ilDB'];
587 
588  if (strcasecmp($role_type, "") != 0 &&
589  strcasecmp($role_type, "local") != 0 &&
590  strcasecmp($role_type, "global") != 0 &&
591  strcasecmp($role_type, "user") != 0 &&
592  strcasecmp($role_type, "user_login") != 0 &&
593  strcasecmp($role_type, "template") != 0) {
594  return $this->__raiseError('Called service with wrong role_type parameter \'' . $role_type . '\'', 'Client');
595  }
596 
597  $roles = array();
598 
599 
600  if (strcasecmp($role_type, "template") == 0) {
601  // get templates
602  $roles = $rbacreview->getRolesByFilter(6, $ilUser->getId());
603  } elseif (strcasecmp($role_type, "user")==0 || strcasecmp($role_type, "user_login")==0) {
604  // handle user roles
605  $user_id = $this->parseUserID($id, $role_type);
606  if ($user_id != $ilUser->getId()) {
607  // check access for user folder
608  $tmpUser = new ilObjUser($user_id);
609  $timelimitOwner = $tmpUser->getTimeLimitOwner();
610  if (!$rbacsystem->checkAccess('read', $timelimitOwner)) {
611  return $this->__raiseError('Check access for time limit owner failed.', 'Server');
612  }
613  }
614  $role_type = ""; // local and global roles for user
615 
616  $query = sprintf(
617  "SELECT object_data.title, rbac_fa.* FROM object_data, rbac_ua, rbac_fa WHERE rbac_ua.rol_id IN ('%s') AND rbac_ua.rol_id = rbac_fa.rol_id AND object_data.obj_id = rbac_fa.rol_id AND rbac_ua.usr_id=" . $user_id,
618  join("','", $rbacreview->assignedRoles($user_id))
619  );
620 
621  $rbacresult = $ilDB->query($query);
622  while ($rbacrow = $rbacresult->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
623  if ($rbacrow["assign"] != "y") {
624  continue;
625  }
626 
627  $type = "";
628 
629  if ($rbacrow["parent"] == ROLE_FOLDER_ID) {
630  $type = "Global";
631  } else {
632  $type = "Local";
633  }
634  if (strlen($type) && $tmp_obj = ilObjectFactory::getInstanceByObjId($rbacrow["rol_id"], false)) {
635  /* @var $tmp_obj IlObjRole */
636  $roles[] = array(
637  "obj_id" =>$rbacrow["rol_id"],
638  "title" => $tmp_obj->getTitle(),
639  "description" => $tmp_obj->getDescription(),
640  "role_type" => $type);
641  }
642  }
643  } elseif ($id == "-1") {
644  // get all roles of system role folder
645  if (!$rbacsystem->checkAccess('read', ROLE_FOLDER_ID)) {
646  return $this->__raiseError('Check access failed.', 'Server');
647  }
648 
649  $roles = $rbacreview->getAssignableRoles(false, true);
650  } else {
651  // get local roles for a specific repository object
652  // needs permission to read permissions of this object
653  if (!$rbacsystem->checkAccess('edit_permission', $id)) {
654  return $this->__raiseError('Check access for local roles failed.', 'Server');
655  }
656 
657  if (!is_numeric($id)) {
658  return $this->__raiseError('Id must be numeric to process roles of a repository object.', 'Client');
659  }
660 
661  $role_type = "local";
662 
663  foreach ($rbacreview->getRolesOfRoleFolder($id, false) as $role_id) {
664  if ($tmp_obj = ilObjectFactory::getInstanceByObjId($role_id, false)) {
665  $roles[] = array("obj_id" => $role_id, "title" => $tmp_obj->getTitle(), "description" => $tmp_obj->getDescription(), "role_type" => $role_type);
666  }
667  }
668  }
669 
670 
671  include_once './webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
672 
673  $xml_writer = new ilSoapRoleObjectXMLWriter();
674  $xml_writer->setObjects($roles);
675  $xml_writer->setType($role_type);
676  if ($xml_writer->start()) {
677  return $xml_writer->getXML();
678  }
679  }
$type
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
$query
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
global $ilDB
+ Here is the call graph for this function:

◆ getUserRoles()

ilSoapRBACAdministration::getUserRoles (   $sid,
  $user_id 
)

Definition at line 320 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

321  {
322  $this->initAuth($sid);
323  $this->initIlias();
324 
325  if (!$this->__checkSession($sid)) {
326  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
327  }
328 
329  global $DIC;
330 
331  $rbacreview = $DIC['rbacreview'];
332 
333  if (!$tmp_user =&ilObjectFactory::getInstanceByObjId($user_id, false)) {
334  return $this->__raiseError(
335  'No valid user id given. Please choose an existing id of an ILIAS user',
336  'Client'
337  );
338  }
339 
340  foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
341  if ($tmp_obj = ilObjectFactory::getInstanceByObjId($role_id, false)) {
342  $objs[] = $tmp_obj;
343  }
344  }
345  if (count($objs)) {
346  include_once './webservice/soap/classes/class.ilObjectXMLWriter.php';
347 
348  $xml_writer = new ilObjectXMLWriter();
349  $xml_writer->setObjects($objs);
350  if ($xml_writer->start()) {
351  return $xml_writer->getXML();
352  }
353  }
354  return '';
355  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
+ Here is the call graph for this function:

◆ grantPermissions()

ilSoapRBACAdministration::grantPermissions (   $sid,
  $ref_id,
  $role_id,
  $permissions 
)

Definition at line 227 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

228  {
229  $this->initAuth($sid);
230  $this->initIlias();
231 
232  if (!$this->__checkSession($sid)) {
233  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
234  }
235 
236  global $DIC;
237 
238  $rbacadmin = $DIC['rbacadmin'];
239  $ilAccess = $DIC['ilAccess'];
240 
241  if (!$tmp_obj =&ilObjectFactory::getInstanceByRefId($ref_id, false)) {
242  return $this->__raiseError(
243  'No valid ref id given. Please choose an existing reference id of an ILIAS object',
244  'Client'
245  );
246  }
247  if ($tmp_role =&ilObjectFactory::getInstanceByObjId($role_id, false) and $tmp_role->getType() != 'role') {
248  return $this->__raiseError(
249  'No valid role id given. Please choose an existing id of an ILIAS role',
250  'Client'
251  );
252  }
253 
254  if (!$ilAccess->checkAccess('edit_permission', '', $ref_id)) {
255  return $this->__raiseError('Check access failed. No permission to grant permissions', 'Server');
256  }
257 
258 
259  // mjansen@databay.de: dirty fix
260  if (isset($permissions['item'])) {
261  $permissions = $permissions['item'];
262  }
263 
264  if (!is_array($permissions)) {
265  return $this->__raiseError(
266  'No valid permissions given.' . print_r($permissions),
267  'Client'
268  );
269  }
270 
271  $rbacadmin->revokePermission($ref_id, $role_id);
272  $rbacadmin->grantPermission($role_id, $permissions, $ref_id);
273 
274  return true;
275  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ parseUserID()

ilSoapRBACAdministration::parseUserID (   $id,
  $role_type 
)
private

Definition at line 761 of file class.ilSoapRBACAdministration.php.

References $id, ilUtil\__extractId(), ilSoapAdministration\__raiseError(), and ilObjUser\_lookupId().

Referenced by getRoles().

762  {
763  if (strcasecmp($role_type, "user")==0) {
764  // get user roles for user id, which can be numeric or ilias id
765  $user_id = !is_numeric($id) ? ilUtil::__extractId($id, IL_INST_ID) : $id;
766  if (!is_numeric($user_id)) {
767  return $this->__raiseError('ID must be either numeric or ILIAS conform id for type \'user\'', 'Client');
768  }
769  } elseif (strcasecmp($role_type, "user_login") == 0) {
770  // check for login
771  $user_id = ilObjUser::_lookupId($id);
772  if (!$user_id) {
773  // could not find a valid user
774  return $this->__raiseError('User with login \'' . $id . '\' does not exist!', 'Client');
775  }
776  }
777  return $user_id;
778  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupId($a_user_str)
Lookup id by login.
__raiseError($a_message, $a_code)
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ revokePermissions()

ilSoapRBACAdministration::revokePermissions (   $sid,
  $ref_id,
  $role_id 
)

Definition at line 186 of file class.ilSoapRBACAdministration.php.

References $DIC, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectFactory\getInstanceByObjId(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\initAuth(), and ilSoapAdministration\initIlias().

187  {
188  $this->initAuth($sid);
189  $this->initIlias();
190 
191  if (!$this->__checkSession($sid)) {
192  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
193  }
194 
195  global $DIC;
196 
197  $rbacadmin = $DIC['rbacadmin'];
198  $ilAccess = $DIC['ilAccess'];
199 
200  if (!$tmp_obj =&ilObjectFactory::getInstanceByRefId($ref_id, false)) {
201  return $this->__raiseError(
202  'No valid ref id given. Please choose an existing reference id of an ILIAS object',
203  'Client'
204  );
205  }
206  if ($tmp_role =&ilObjectFactory::getInstanceByObjId($role_id, false) and $tmp_role->getType() != 'role') {
207  return $this->__raiseError(
208  'No valid role id given. Please choose an existing id of an ILIAS role',
209  'Client'
210  );
211  }
212  if ($role_id == SYSTEM_ROLE_ID) {
213  return $this->__raiseError(
214  'Cannot revoke permissions of system role',
215  'Client'
216  );
217  }
218 
219  if (!$ilAccess->checkAccess('edit_permission', '', $ref_id)) {
220  return $this->__raiseError('Check access failed. No permission to revoke permissions', 'Server');
221  }
222 
223  $rbacadmin->revokePermission($ref_id, $role_id);
224 
225  return true;
226  }
global $DIC
Definition: saml.php:7
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
initAuth($sid)
Init authentication.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ searchRoles()

ilSoapRBACAdministration::searchRoles (   $sid,
  $key,
  $combination,
  $role_type 
)

search for roles.

Parameters
String$sid
String$searchtermscomma separated search terms
String$operatormust be or or and
String$role_typecan be empty which means "local & global", "local", "global", "user" = roles of user, "user_login" or "template"

Definition at line 691 of file class.ilSoapRBACAdministration.php.

References $DIC, $ilDB, $ilUser, $key, $res, ilSoapAdministration\__getMessage(), ilSoapAdministration\__getMessageCode(), ilSoapAdministration\__raiseError(), ilObjectSearchFactory\_getObjectSearchInstance(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), QP_COMBINATION_AND, and QP_COMBINATION_OR.

692  {
693  $this->initAuth($sid);
694  $this->initIlias();
695 
696  if (!$this->__checkSession($sid)) {
697  return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
698  }
699 
700  global $DIC;
701 
702  $rbacsystem = $DIC['rbacsystem'];
703  $rbacreview = $DIC['rbacreview'];
704  $ilUser = $DIC['ilUser'];
705  $ilDB = $DIC['ilDB'];
706 
707 
708  if (strcasecmp($role_type, "") != 0 &&
709  strcasecmp($role_type, "local") != 0 &&
710  strcasecmp($role_type, "global") != 0 &&
711  strcasecmp($role_type, "template") != 0) {
712  return $this->__raiseError('Called service with wrong role_type parameter \'' . $role_type . '\'', 'Client');
713  }
714 
715  if ($combination != 'and' and $combination != 'or') {
716  return $this->__raiseError(
717  'No valid combination given. Must be "and" or "or".',
718  'Client'
719  );
720  }
721 
722  include_once './Services/Search/classes/class.ilQueryParser.php';
723 
724  $query_parser = new ilQueryParser($key);
725  $query_parser->setMinWordLength(3);
726  $query_parser->setCombination($combination == 'and' ? QP_COMBINATION_AND : QP_COMBINATION_OR);
727  $query_parser->parse();
728  if (!$query_parser->validate()) {
729  return $this->__raiseError($query_parser->getMessage(), 'Client');
730  }
731 
732  include_once './Services/Search/classes/class.ilObjectSearchFactory.php';
733 
734  $object_search = ilObjectSearchFactory::_getObjectSearchInstance($query_parser);
735  $object_search->setFilter(array("role","rolt"));
736 
737  $res = $object_search->performSearch();
738  $res->filter(ROOT_FOLDER_ID, $combination == 'and' ? true : false);
739 
740  $obj_ids = array();
741  foreach ($res->getUniqueResults() as $entry) {
742  $obj_ids [] = $entry['obj_id'];
743  }
744 
745  $roles = array();
746  if (count($obj_ids)> 0) {
747  #print_r($obj_ids);
748  $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type == "template");
749  }
750  #print_r($roles);
751  include_once './webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
752  $xml_writer = new ilSoapRoleObjectXMLWriter();
753  $xml_writer->setObjects($roles);
754  $xml_writer->setType($role_type);
755  if ($xml_writer->start()) {
756  return $xml_writer->getXML();
757  }
758  }
global $DIC
Definition: saml.php:7
const QP_COMBINATION_OR
foreach($_POST as $key=> $value) $res
__raiseError($a_message, $a_code)
$ilUser
Definition: imgupload.php:18
static _getObjectSearchInstance($query_parser)
get reference of ilFulltext/LikeObjectSearch.
initAuth($sid)
Init authentication.
global $ilDB
const QP_COMBINATION_AND
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

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