45 $rbacreview = $DIC[
'rbacreview'];
46 $rbacsystem = $DIC[
'rbacsystem'];
47 $ilAccess = $DIC[
'ilAccess'];
51 'No valid role id given. Please choose an existing id of an ILIAS role',
56 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
57 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
58 return $this->
raiseError(
'Check access failed. No permission to delete role',
'Server');
62 foreach ($assigned_users = $rbacreview->assignedUsers($role_id) as
$user_id) {
63 if (count($rbacreview->assignedRoles(
$user_id)) === 1) {
65 'Cannot deassign last role of users',
72 $rolf_ids = $rbacreview->getFoldersAssignedToRole($role_id,
true);
73 $rolf_id = end($rolf_ids);
74 $tmp_role->setParent((
int) $rolf_id);
93 $rbacadmin = $DIC[
'rbacadmin'];
94 $rbacreview = $DIC[
'rbacreview'];
95 $ilAccess = $DIC[
'ilAccess'];
100 'No valid user id given. Please choose an existing id of an ILIAS user',
107 'No valid role id given. Please choose an existing id of an ILIAS role',
112 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
113 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
114 return $this->
raiseError(
'Check access failed. No permission to assign users',
'Server');
117 $rbacadmin->assignUser($role_id, $user_id);
135 $rbacadmin = $DIC[
'rbacadmin'];
136 $ilAccess = $DIC[
'ilAccess'];
137 $rbacreview = $DIC[
'rbacreview'];
141 'No valid user id given. Please choose an existing id of an ILIAS user',
147 'No valid role id given. Please choose an existing id of an ILIAS role',
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');
157 $rbacadmin->deassignUser($role_id, $user_id);
175 $rbacreview = $DIC[
'rbacreview'];
177 if (is_array($ops = $rbacreview->getOperations())) {
181 return $this->
raiseError(
'Unknown error',
'Server');
198 $rbacadmin = $DIC[
'rbacadmin'];
199 $ilAccess = $DIC[
'ilAccess'];
203 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
209 'No valid role id given. Please choose an existing id of an ILIAS role',
215 'Cannot revoke permissions of system role',
220 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
221 return $this->
raiseError(
'Check access failed. No permission to revoke permissions',
'Server');
223 $rbacadmin->revokePermission($ref_id, $role_id);
241 $rbacadmin = $DIC[
'rbacadmin'];
242 $ilAccess = $DIC[
'ilAccess'];
246 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
252 'No valid role id given. Please choose an existing id of an ILIAS role',
257 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
258 return $this->
raiseError(
'Check access failed. No permission to grant permissions',
'Server');
262 if (isset($permissions[
'item'])) {
263 $permissions = $permissions[
'item'];
266 if (!is_array($permissions)) {
268 'No valid permissions given.' . print_r($permissions),
273 $rbacadmin->revokePermission($ref_id, $role_id);
274 $rbacadmin->grantPermission($role_id, $permissions, $ref_id);
292 $rbacreview = $DIC[
'rbacreview'];
293 $ilAccess = $DIC[
'ilAccess'];
297 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
302 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
303 return $this->
raiseError(
'Check access failed. No permission to access role information',
'Server');
307 foreach ($rbacreview->getRolesOfRoleFolder($ref_id,
false) as $role_id) {
315 $xml_writer->setObjects($objs);
316 if ($xml_writer->start()) {
317 return $xml_writer->getXML();
337 $rbacreview = $DIC[
'rbacreview'];
341 'No valid user id given. Please choose an existing id of an ILIAS user',
347 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
355 $xml_writer->setObjects($objs);
356 if ($xml_writer->start()) {
357 return $xml_writer->getXML();
366 public function addRole(
string $sid,
int $target_id,
string $role_xml)
377 $rbacreview = $DIC[
'rbacreview'];
378 $objDefinition = $DIC[
'objDefinition'];
379 $rbacsystem = $DIC[
'rbacsystem'];
380 $ilAccess = $DIC[
'ilAccess'];
384 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
390 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
393 if (!$ilAccess->checkAccess(
'edit_permission',
'', $target_id)) {
394 return $this->
raiseError(
'Check access failed. No permission to create roles',
'Server');
398 $xml_parser->startParsing();
401 foreach ($xml_parser->getObjectData() as $object_data) {
403 if (strpos($object_data[
'title'],
"il_") === 0) {
405 'Rolenames are not allowed to start with "il_" ',
411 $role->setTitle($object_data[
'title']);
412 $role->setDescription($object_data[
'description']);
413 $role->setImportId($object_data[
'import_id']);
416 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
417 $new_roles[] = $role->getId();
436 $rbacreview = $DIC[
'rbacreview'];
437 $objDefinition = $DIC[
'objDefinition'];
438 $rbacsystem = $DIC[
'rbacsystem'];
439 $rbacadmin = $DIC[
'rbacadmin'];
440 $ilAccess = $DIC[
'ilAccess'];
444 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
450 'No valid template id given. Please choose an existing object id of an ILIAS role template',
456 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
459 if (!$ilAccess->checkAccess(
'edit_permission',
'', $target_id)) {
460 return $this->
raiseError(
'Check access failed. No permission to create roles',
'Server');
464 $xml_parser->startParsing();
467 foreach ($xml_parser->getObjectData() as $object_data) {
469 if (strpos($object_data[
'title'],
"il_") === 0) {
471 'Rolenames are not allowed to start with "il_" ',
477 $role->setTitle($object_data[
'title']);
478 $role->setDescription($object_data[
'description']);
479 $role->setImportId($object_data[
'import_id']);
482 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
485 $rbacadmin->copyRoleTemplatePermissions($template_id,
ROLE_FOLDER_ID, $target_id, $role->getId());
488 $ops = $rbacreview->getOperationsOfRole($role->getId(), $tmp_obj->getType(), $target_id);
489 $rbacadmin->grantPermission($role->getId(), $ops, $target_id);
490 $new_roles[] = $role->getId();
509 $rbacsystem = $DIC[
'rbacsystem'];
510 $rbacreview = $DIC[
'rbacreview'];
511 $ilAccess = $DIC[
'ilAccess'];
515 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
522 'No valid user id given.',
528 return $this->
raiseError(
"Parent with ID " . $ref_id .
"has been deleted.",
'CLIENT_TARGET_DELETED');
532 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'visible',
'', $tmp_obj->getRefId())) {
535 $op_data = $rbacreview->getOperation(2);
536 $ops_data[] = $op_data;
538 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'read',
'', $tmp_obj->getRefId())) {
543 $ops = $rbacreview->getOperationsOnTypeString($tmp_obj->getType());
544 foreach ($ops as $ops_id) {
545 $op_data = $rbacreview->getOperation($ops_id);
547 if ($rbacsystem->checkAccessOfUser($user_id, $op_data[
'operation'], $tmp_obj->getRefId())) {
548 $ops_data[$ops_id] = $op_data;
553 foreach ($ops_data as
$data) {
573 $rbacsystem = $DIC[
'rbacsystem'];
574 $rbacreview = $DIC[
'rbacreview'];
575 $ilUser = $DIC[
'ilUser'];
576 $ilDB = $DIC[
'ilDB'];
578 if (strcasecmp($role_type,
"") !== 0 &&
579 strcasecmp($role_type,
"local") !== 0 &&
580 strcasecmp($role_type,
"global") !== 0 &&
581 strcasecmp($role_type,
"user") !== 0 &&
582 strcasecmp($role_type,
"user_login") !== 0 &&
583 strcasecmp($role_type,
"template") !== 0) {
585 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
592 if (strcasecmp($role_type,
"template") === 0) {
594 $roles = $rbacreview->getRolesByFilter(6, $ilUser->getId());
595 } elseif (strcasecmp($role_type,
"user") === 0 || strcasecmp($role_type,
"user_login") === 0) {
598 if ((
int)
$user_id !== $ilUser->getId()) {
601 $timelimitOwner = $tmpUser->getTimeLimitOwner();
602 if (!$rbacsystem->checkAccess(
'read', $timelimitOwner)) {
603 return $this->
raiseError(
'Check access for time limit owner failed.',
'Server');
609 "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,
610 implode(
"','", $rbacreview->assignedRoles(
$user_id))
613 $rbacresult =
$ilDB->query($query);
615 if ($rbacrow[
"assign"] !==
"y") {
629 "obj_id" => $rbacrow[
"rol_id"],
630 "title" => $tmp_obj->getTitle(),
631 "description" => $tmp_obj->getDescription(),
636 } elseif ($id === -1) {
639 return $this->
raiseError(
'Check access failed.',
'Server');
642 $roles = $rbacreview->getAssignableRoles(
false,
true);
646 if (!$rbacsystem->checkAccess(
'edit_permission', $id)) {
647 return $this->
raiseError(
'Check access for local roles failed.',
'Server');
650 $role_type =
"local";
652 foreach ($rbacreview->getRolesOfRoleFolder($id,
false) as $role_id) {
655 "obj_id" => $role_id,
656 "title" => $tmp_obj->getTitle(),
657 "description" => $tmp_obj->getDescription(),
658 "role_type" => $role_type
665 $xml_writer->setObjects($roles);
666 $xml_writer->setType($role_type);
667 if ($xml_writer->start()) {
668 return $xml_writer->getXML();
678 public function searchRoles(
string $sid,
string $key,
string $combination,
string $role_type)
689 $rbacsystem = $DIC[
'rbacsystem'];
690 $rbacreview = $DIC[
'rbacreview'];
691 $ilUser = $DIC[
'ilUser'];
692 $ilDB = $DIC[
'ilDB'];
694 if (strcasecmp($role_type,
"") !== 0 &&
695 strcasecmp($role_type,
"local") !== 0 &&
696 strcasecmp($role_type,
"global") !== 0 &&
697 strcasecmp($role_type,
"template") !== 0) {
699 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
704 if ($combination !==
'and' && $combination !==
'or') {
706 'No valid combination given. Must be "and" or "or".',
712 $query_parser->setMinWordLength(3);
714 $query_parser->parse();
715 if (!$query_parser->validate()) {
716 return $this->
raiseError($query_parser->getMessage(),
'Client');
721 $object_search->setFilter(array(
"role",
"rolt"));
723 $res = $object_search->performSearch();
727 foreach (
$res->getUniqueResults() as $entry) {
728 $obj_ids [] = $entry[
'obj_id'];
732 if (count($obj_ids) > 0) {
733 $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type ===
"template");
737 $xml_writer->setObjects($roles);
738 $xml_writer->setType($role_type);
739 if ($xml_writer->start()) {
740 return $xml_writer->getXML();
748 if (strcasecmp($role_type,
"user") === 0) {
752 return $this->
raiseError(
'ID must be either numeric or ILIAS conform id for type \'user\'',
'Client');
754 } elseif (strcasecmp($role_type,
"user_login") === 0) {
759 return $this->
raiseError(
'User with login \'' . $id .
'\' does not exist!
', 'Client
');
addRole(string $sid, int $target_id, string $role_xml)
revokePermissions(string $sid, int $ref_id, int $role_id)
searchRoles(string $sid, string $key, string $combination, string $role_type)
search for roles.
raiseError(string $a_message, $a_code)
static _lookupId($a_user_str)
grantPermissions(string $sid, int $ref_id, int $role_id, array $permissions)
addUserRoleEntry(string $sid, int $user_id, int $role_id)
deleteRole(string $sid, int $role_id)
getUserRoles(string $sid, int $user_id)
checkSession(string $sid)
static _isInTrash(int $ref_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _getObjectSearchInstance(ilQueryParser $query_parser)
getObjectTreeOperations(string $sid, int $ref_id, int $user_id)
getRoles(string $sid, string $role_type, int $id)
parseUserID(int $id, string $role_type)
Soap rbac administration methods.
getOperations(string $sid)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLocalRoles(string $sid, int $ref_id)
XML writer class Class to simplify manual writing of xml documents.
addRoleFromTemplate(string $sid, int $target_id, string $role_xml, int $template_id)
static _lookupType(int $id, bool $reference=false)
XML writer class Class to simplify manual writing of xml documents.
deleteUserRoleEntry(string $sid, int $user_id, int $role_id)