24 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
46 $rbacreview = $DIC[
'rbacreview'];
47 $rbacsystem = $DIC[
'rbacsystem'];
48 $ilAccess = $DIC[
'ilAccess'];
52 'No valid role id given. Please choose an existing id of an ILIAS role',
57 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
58 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
59 return $this->
raiseError(
'Check access failed. No permission to delete role',
'Server');
63 foreach ($assigned_users = $rbacreview->assignedUsers($role_id) as $user_id) {
64 if (count($rbacreview->assignedRoles($user_id)) === 1) {
66 'Cannot deassign last role of users',
73 $rolf_ids = $rbacreview->getFoldersAssignedToRole($role_id,
true);
74 $rolf_id = end($rolf_ids);
75 $tmp_role->setParent((
int) $rolf_id);
94 $rbacadmin = $DIC[
'rbacadmin'];
95 $rbacreview = $DIC[
'rbacreview'];
96 $ilAccess = $DIC[
'ilAccess'];
101 'No valid user id given. Please choose an existing id of an ILIAS user',
108 'No valid role id given. Please choose an existing id of an ILIAS role',
113 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
114 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
115 return $this->
raiseError(
'Check access failed. No permission to assign users',
'Server');
118 $rbacadmin->assignUser($role_id, $user_id);
136 $rbacadmin = $DIC[
'rbacadmin'];
137 $ilAccess = $DIC[
'ilAccess'];
138 $rbacreview = $DIC[
'rbacreview'];
142 'No valid user id given. Please choose an existing id of an ILIAS user',
148 'No valid role id given. Please choose an existing id of an ILIAS role',
153 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
154 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
155 return $this->
raiseError(
'Check access failed. No permission to deassign users',
'Server');
158 $rbacadmin->deassignUser($role_id, $user_id);
176 $rbacreview = $DIC[
'rbacreview'];
178 if (is_array($ops = $rbacreview->getOperations())) {
182 return $this->
raiseError(
'Unknown error',
'Server');
199 $rbacadmin = $DIC[
'rbacadmin'];
200 $ilAccess = $DIC[
'ilAccess'];
204 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
210 'No valid role id given. Please choose an existing id of an ILIAS role',
216 'Cannot revoke permissions of system role',
221 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
222 return $this->
raiseError(
'Check access failed. No permission to revoke permissions',
'Server');
224 $rbacadmin->revokePermission($ref_id, $role_id);
242 $rbacadmin = $DIC[
'rbacadmin'];
243 $ilAccess = $DIC[
'ilAccess'];
247 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
253 'No valid role id given. Please choose an existing id of an ILIAS role',
258 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
259 return $this->
raiseError(
'Check access failed. No permission to grant permissions',
'Server');
263 if (isset($permissions[
'item'])) {
264 $permissions = $permissions[
'item'];
267 if (!is_array($permissions)) {
269 'No valid permissions given.' . print_r($permissions),
274 $rbacadmin->revokePermission($ref_id, $role_id);
275 $rbacadmin->grantPermission($role_id, $permissions, $ref_id);
293 $rbacreview = $DIC[
'rbacreview'];
294 $ilAccess = $DIC[
'ilAccess'];
298 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
303 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
304 return $this->
raiseError(
'Check access failed. No permission to access role information',
'Server');
308 foreach ($rbacreview->getRolesOfRoleFolder($ref_id,
false) as $role_id) {
314 include_once
'./webservice/soap/classes/class.ilObjectXMLWriter.php';
317 $xml_writer->setObjects($objs);
318 if ($xml_writer->start()) {
319 return $xml_writer->getXML();
339 $rbacreview = $DIC[
'rbacreview'];
343 'No valid user id given. Please choose an existing id of an ILIAS user',
349 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
355 include_once
'./webservice/soap/classes/class.ilObjectXMLWriter.php';
358 $xml_writer->setObjects($objs);
359 if ($xml_writer->start()) {
360 return $xml_writer->getXML();
369 public function addRole(
string $sid,
int $target_id,
string $role_xml)
380 $rbacreview = $DIC[
'rbacreview'];
381 $objDefinition = $DIC[
'objDefinition'];
382 $rbacsystem = $DIC[
'rbacsystem'];
383 $ilAccess = $DIC[
'ilAccess'];
387 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
393 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
396 if (!$ilAccess->checkAccess(
'edit_permission',
'', $target_id)) {
397 return $this->
raiseError(
'Check access failed. No permission to create roles',
'Server');
400 include_once
'webservice/soap/classes/class.ilObjectXMLParser.php';
402 $xml_parser->startParsing();
405 foreach ($xml_parser->getObjectData() as $object_data) {
407 if (strpos($object_data[
'title'],
"il_") === 0) {
409 'Rolenames are not allowed to start with "il_" ',
414 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
416 $role->setTitle($object_data[
'title']);
417 $role->setDescription($object_data[
'description']);
418 $role->setImportId($object_data[
'import_id']);
421 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
422 $new_roles[] = $role->getId();
441 $rbacreview = $DIC[
'rbacreview'];
442 $objDefinition = $DIC[
'objDefinition'];
443 $rbacsystem = $DIC[
'rbacsystem'];
444 $rbacadmin = $DIC[
'rbacadmin'];
445 $ilAccess = $DIC[
'ilAccess'];
449 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
455 'No valid template id given. Please choose an existing object id of an ILIAS role template',
461 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
464 if (!$ilAccess->checkAccess(
'edit_permission',
'', $target_id)) {
465 return $this->
raiseError(
'Check access failed. No permission to create roles',
'Server');
468 include_once
'webservice/soap/classes/class.ilObjectXMLParser.php';
470 $xml_parser->startParsing();
473 foreach ($xml_parser->getObjectData() as $object_data) {
475 if (strpos($object_data[
'title'],
"il_") === 0) {
477 'Rolenames are not allowed to start with "il_" ',
482 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
484 $role->setTitle($object_data[
'title']);
485 $role->setDescription($object_data[
'description']);
486 $role->setImportId($object_data[
'import_id']);
489 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
492 $rbacadmin->copyRoleTemplatePermissions($template_id,
ROLE_FOLDER_ID, $target_id, $role->getId());
495 $ops = $rbacreview->getOperationsOfRole($role->getId(), $tmp_obj->getType(), $target_id);
496 $rbacadmin->grantPermission($role->getId(), $ops, $target_id);
497 $new_roles[] = $role->getId();
516 $rbacsystem = $DIC[
'rbacsystem'];
517 $rbacreview = $DIC[
'rbacreview'];
518 $ilAccess = $DIC[
'ilAccess'];
522 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
529 'No valid user id given.',
535 return $this->
raiseError(
"Parent with ID " . $ref_id .
"has been deleted.",
'CLIENT_TARGET_DELETED');
539 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'visible',
'', $tmp_obj->getRefId())) {
542 $op_data = $rbacreview->getOperation(2);
543 $ops_data[] = $op_data;
545 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'read',
'', $tmp_obj->getRefId())) {
550 $ops = $rbacreview->getOperationsOnTypeString($tmp_obj->getType());
551 foreach ($ops as $ops_id) {
552 $op_data = $rbacreview->getOperation($ops_id);
554 if ($rbacsystem->checkAccessOfUser($user_id, $op_data[
'operation'], $tmp_obj->getRefId())) {
555 $ops_data[$ops_id] = $op_data;
560 foreach ($ops_data as
$data) {
580 $rbacsystem = $DIC[
'rbacsystem'];
581 $rbacreview = $DIC[
'rbacreview'];
582 $ilUser = $DIC[
'ilUser'];
583 $ilDB = $DIC[
'ilDB'];
585 if (strcasecmp($role_type,
"") !== 0 &&
586 strcasecmp($role_type,
"local") !== 0 &&
587 strcasecmp($role_type,
"global") !== 0 &&
588 strcasecmp($role_type,
"user") !== 0 &&
589 strcasecmp($role_type,
"user_login") !== 0 &&
590 strcasecmp($role_type,
"template") !== 0) {
592 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
599 if (strcasecmp($role_type,
"template") === 0) {
601 $roles = $rbacreview->getRolesByFilter(6, $ilUser->getId());
602 } elseif (strcasecmp($role_type,
"user") === 0 || strcasecmp($role_type,
"user_login") === 0) {
605 if ((
int) $user_id !== $ilUser->getId()) {
608 $timelimitOwner = $tmpUser->getTimeLimitOwner();
609 if (!$rbacsystem->checkAccess(
'read', $timelimitOwner)) {
610 return $this->
raiseError(
'Check access for time limit owner failed.',
'Server');
616 "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,
617 implode(
"','", $rbacreview->assignedRoles($user_id))
620 $rbacresult =
$ilDB->query($query);
622 if ($rbacrow[
"assign"] !==
"y") {
636 "obj_id" => $rbacrow[
"rol_id"],
637 "title" => $tmp_obj->getTitle(),
638 "description" => $tmp_obj->getDescription(),
643 } elseif ($id === -1) {
646 return $this->
raiseError(
'Check access failed.',
'Server');
649 $roles = $rbacreview->getAssignableRoles(
false,
true);
653 if (!$rbacsystem->checkAccess(
'edit_permission', $id)) {
654 return $this->
raiseError(
'Check access for local roles failed.',
'Server');
657 $role_type =
"local";
659 foreach ($rbacreview->getRolesOfRoleFolder($id,
false) as $role_id) {
662 "obj_id" => $role_id,
663 "title" => $tmp_obj->getTitle(),
664 "description" => $tmp_obj->getDescription(),
665 "role_type" => $role_type
671 include_once
'./webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
674 $xml_writer->setObjects($roles);
675 $xml_writer->setType($role_type);
676 if ($xml_writer->start()) {
677 return $xml_writer->getXML();
687 public function searchRoles(
string $sid,
string $key,
string $combination,
string $role_type)
698 $rbacsystem = $DIC[
'rbacsystem'];
699 $rbacreview = $DIC[
'rbacreview'];
700 $ilUser = $DIC[
'ilUser'];
701 $ilDB = $DIC[
'ilDB'];
703 if (strcasecmp($role_type,
"") !== 0 &&
704 strcasecmp($role_type,
"local") !== 0 &&
705 strcasecmp($role_type,
"global") !== 0 &&
706 strcasecmp($role_type,
"template") !== 0) {
708 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
713 if ($combination !==
'and' && $combination !==
'or') {
715 'No valid combination given. Must be "and" or "or".',
720 include_once
'./Services/Search/classes/class.ilQueryParser.php';
723 $query_parser->setMinWordLength(3);
725 $query_parser->parse();
726 if (!$query_parser->validate()) {
727 return $this->
raiseError($query_parser->getMessage(),
'Client');
730 include_once
'./Services/Search/classes/class.ilObjectSearchFactory.php';
733 $object_search->setFilter(array(
"role",
"rolt"));
735 $res = $object_search->performSearch();
739 foreach (
$res->getUniqueResults() as $entry) {
740 $obj_ids [] = $entry[
'obj_id'];
744 if (count($obj_ids) > 0) {
745 $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type ===
"template");
748 include_once
'./webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
750 $xml_writer->setObjects($roles);
751 $xml_writer->setType($role_type);
752 if ($xml_writer->start()) {
753 return $xml_writer->getXML();
761 if (strcasecmp($role_type,
"user") === 0) {
764 if (!is_numeric($user_id)) {
765 return $this->
raiseError(
'ID must be either numeric or ILIAS conform id for type \'user\'',
'Client');
767 } elseif (strcasecmp($role_type,
"user_login") === 0) {
772 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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
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)