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();
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']);
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) {
476 if (strpos($object_data[
'title'],
"il_") === 0) {
478 'Rolenames are not allowed to start with "il_" ',
483 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
485 $role->setTitle($object_data[
'title']);
486 $role->setDescription($object_data[
'description']);
487 $role->setImportId($object_data[
'import_id']);
493 $rbacadmin->copyRoleTemplatePermissions($template_id,
ROLE_FOLDER_ID, $target_id, $role->getId());
496 $ops = $rbacreview->getOperationsOfRole($role->getId(), $tmp_obj->getType(),
$target_id);
497 $rbacadmin->grantPermission($role->getId(), $ops,
$target_id);
498 $new_roles[] = $role->getId();
517 $rbacsystem = $DIC[
'rbacsystem'];
518 $rbacreview = $DIC[
'rbacreview'];
519 $ilAccess = $DIC[
'ilAccess'];
523 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
530 'No valid user id given.',
536 return $this->
raiseError(
"Parent with ID " . $ref_id .
"has been deleted.",
'CLIENT_TARGET_DELETED');
540 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'visible',
'', $tmp_obj->getRefId())) {
543 $op_data = $rbacreview->getOperation(2);
544 $ops_data[] = $op_data;
546 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'read',
'', $tmp_obj->getRefId())) {
551 $ops = $rbacreview->getOperationsOnTypeString($tmp_obj->getType());
552 foreach ($ops as $ops_id) {
553 $op_data = $rbacreview->getOperation($ops_id);
555 if ($rbacsystem->checkAccessOfUser($user_id, $op_data[
'operation'], $tmp_obj->getRefId())) {
556 $ops_data[$ops_id] = $op_data;
561 foreach ($ops_data as
$data) {
581 $rbacsystem = $DIC[
'rbacsystem'];
582 $rbacreview = $DIC[
'rbacreview'];
584 $ilDB = $DIC[
'ilDB'];
586 if (strcasecmp($role_type,
"") !== 0 &&
587 strcasecmp($role_type,
"local") !== 0 &&
588 strcasecmp($role_type,
"global") !== 0 &&
589 strcasecmp($role_type,
"user") !== 0 &&
590 strcasecmp($role_type,
"user_login") !== 0 &&
591 strcasecmp($role_type,
"template") !== 0) {
593 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
600 if (strcasecmp($role_type,
"template") === 0) {
602 $roles = $rbacreview->getRolesByFilter(6,
$ilUser->getId());
603 } elseif (strcasecmp($role_type,
"user") === 0 || strcasecmp($role_type,
"user_login") === 0) {
606 if ((
int) $user_id !==
$ilUser->getId()) {
609 $timelimitOwner = $tmpUser->getTimeLimitOwner();
610 if (!$rbacsystem->checkAccess(
'read', $timelimitOwner)) {
611 return $this->
raiseError(
'Check access for time limit owner failed.',
'Server');
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 implode(
"','", $rbacreview->assignedRoles($user_id))
623 if ($rbacrow[
"assign"] !==
"y") {
637 "obj_id" => $rbacrow[
"rol_id"],
638 "title" => $tmp_obj->getTitle(),
639 "description" => $tmp_obj->getDescription(),
644 } elseif ($id === -1) {
647 return $this->
raiseError(
'Check access failed.',
'Server');
650 $roles = $rbacreview->getAssignableRoles(
false,
true);
654 if (!$rbacsystem->checkAccess(
'edit_permission', $id)) {
655 return $this->
raiseError(
'Check access for local roles failed.',
'Server');
658 $role_type =
"local";
660 foreach ($rbacreview->getRolesOfRoleFolder($id,
false) as $role_id) {
663 "obj_id" => $role_id,
664 "title" => $tmp_obj->getTitle(),
665 "description" => $tmp_obj->getDescription(),
666 "role_type" => $role_type
672 include_once
'./webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
675 $xml_writer->setObjects($roles);
676 $xml_writer->setType($role_type);
677 if ($xml_writer->start()) {
678 return $xml_writer->getXML();
688 public function searchRoles(
string $sid,
string $key,
string $combination,
string $role_type)
699 $rbacsystem = $DIC[
'rbacsystem'];
700 $rbacreview = $DIC[
'rbacreview'];
702 $ilDB = $DIC[
'ilDB'];
704 if (strcasecmp($role_type,
"") !== 0 &&
705 strcasecmp($role_type,
"local") !== 0 &&
706 strcasecmp($role_type,
"global") !== 0 &&
707 strcasecmp($role_type,
"template") !== 0) {
709 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
714 if ($combination !==
'and' && $combination !==
'or') {
716 'No valid combination given. Must be "and" or "or".',
721 include_once
'./Services/Search/classes/class.ilQueryParser.php';
724 $query_parser->setMinWordLength(3);
726 $query_parser->parse();
727 if (!$query_parser->validate()) {
728 return $this->
raiseError($query_parser->getMessage(),
'Client');
731 include_once
'./Services/Search/classes/class.ilObjectSearchFactory.php';
734 $object_search->setFilter(array(
"role",
"rolt"));
736 $res = $object_search->performSearch();
740 foreach (
$res->getUniqueResults() as $entry) {
741 $obj_ids [] = $entry[
'obj_id'];
745 if (count($obj_ids) > 0) {
746 $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type ===
"template");
749 include_once
'./webservice/soap/classes/class.ilSoapRoleObjectXMLWriter.php';
751 $xml_writer->setObjects($roles);
752 $xml_writer->setType($role_type);
753 if ($xml_writer->start()) {
754 return $xml_writer->getXML();
762 if (strcasecmp($role_type,
"user") === 0) {
765 if (!is_numeric($user_id)) {
766 return $this->
raiseError(
'ID must be either numeric or ILIAS conform id for type \'user\'',
'Client');
768 } elseif (strcasecmp($role_type,
"user_login") === 0) {
773 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)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
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
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)