38 $rbacreview = $DIC[
'rbacreview'];
39 $rbacsystem = $DIC[
'rbacsystem'];
40 $ilAccess = $DIC[
'ilAccess'];
44 'No valid role id given. Please choose an existing id of an ILIAS role',
49 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
50 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
51 return $this->
raiseError(
'Check access failed. No permission to delete role',
'Server');
55 foreach ($assigned_users = $rbacreview->assignedUsers($role_id) as
$user_id) {
56 if (count($rbacreview->assignedRoles(
$user_id)) === 1) {
58 'Cannot deassign last role of users',
65 $rolf_ids = $rbacreview->getFoldersAssignedToRole($role_id,
true);
66 $rolf_id = end($rolf_ids);
67 $tmp_role->setParent((
int) $rolf_id);
86 $rbacadmin = $DIC[
'rbacadmin'];
87 $rbacreview = $DIC[
'rbacreview'];
88 $ilAccess = $DIC[
'ilAccess'];
93 'No valid user id given. Please choose an existing id of an ILIAS user',
100 'No valid role id given. Please choose an existing id of an ILIAS role',
105 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
106 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
107 return $this->
raiseError(
'Check access failed. No permission to assign users',
'Server');
110 $rbacadmin->assignUser($role_id, $user_id);
128 $rbacadmin = $DIC[
'rbacadmin'];
129 $ilAccess = $DIC[
'ilAccess'];
130 $rbacreview = $DIC[
'rbacreview'];
134 'No valid user id given. Please choose an existing id of an ILIAS user',
140 'No valid role id given. Please choose an existing id of an ILIAS role',
145 $obj_ref = $rbacreview->getObjectReferenceOfRole($role_id);
146 if (!$ilAccess->checkAccess(
'edit_permission',
'', $obj_ref)) {
147 return $this->
raiseError(
'Check access failed. No permission to deassign users',
'Server');
150 $rbacadmin->deassignUser($role_id, $user_id);
168 $rbacreview = $DIC[
'rbacreview'];
170 if (is_array($ops = $rbacreview->getOperations())) {
174 return $this->
raiseError(
'Unknown error',
'Server');
191 $rbacadmin = $DIC[
'rbacadmin'];
192 $ilAccess = $DIC[
'ilAccess'];
196 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
202 'No valid role id given. Please choose an existing id of an ILIAS role',
208 'Cannot revoke permissions of system role',
213 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
214 return $this->
raiseError(
'Check access failed. No permission to revoke permissions',
'Server');
216 $rbacadmin->revokePermission($ref_id, $role_id);
234 $rbacadmin = $DIC[
'rbacadmin'];
235 $ilAccess = $DIC[
'ilAccess'];
239 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
245 'No valid role id given. Please choose an existing id of an ILIAS role',
250 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
251 return $this->
raiseError(
'Check access failed. No permission to grant permissions',
'Server');
255 if (isset($permissions[
'item'])) {
256 $permissions = $permissions[
'item'];
259 if (!is_array($permissions)) {
261 'No valid permissions given.' . print_r($permissions),
266 $rbacadmin->revokePermission($ref_id, $role_id);
267 $rbacadmin->grantPermission($role_id, $permissions, $ref_id);
285 $rbacreview = $DIC[
'rbacreview'];
286 $ilAccess = $DIC[
'ilAccess'];
290 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
295 if (!$ilAccess->checkAccess(
'edit_permission',
'', $ref_id)) {
296 return $this->
raiseError(
'Check access failed. No permission to access role information',
'Server');
300 foreach ($rbacreview->getRolesOfRoleFolder($ref_id,
false) as $role_id) {
308 $xml_writer->setObjects($objs);
309 if ($xml_writer->start()) {
310 return $xml_writer->getXML();
330 $rbacreview = $DIC[
'rbacreview'];
334 'No valid user id given. Please choose an existing id of an ILIAS user',
340 foreach ($rbacreview->assignedRoles($user_id) as $role_id) {
348 $xml_writer->setObjects($objs);
349 if ($xml_writer->start()) {
350 return $xml_writer->getXML();
359 public function addRole(
string $sid,
int $target_id,
string $role_xml)
370 $rbacreview = $DIC[
'rbacreview'];
371 $objDefinition = $DIC[
'objDefinition'];
372 $rbacsystem = $DIC[
'rbacsystem'];
373 $ilAccess = $DIC[
'ilAccess'];
377 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
383 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
386 if (!$ilAccess->checkAccess(
'edit_permission',
'', $target_id)) {
387 return $this->
raiseError(
'Check access failed. No permission to create roles',
'Server');
391 $xml_parser->startParsing();
394 foreach ($xml_parser->getObjectData() as $object_data) {
396 if (strpos($object_data[
'title'],
"il_") === 0) {
398 'Rolenames are not allowed to start with "il_" ',
404 $role->setTitle($object_data[
'title']);
405 $role->setDescription($object_data[
'description']);
406 $role->setImportId($object_data[
'import_id']);
409 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
410 $new_roles[] = $role->getId();
429 $rbacreview = $DIC[
'rbacreview'];
430 $objDefinition = $DIC[
'objDefinition'];
431 $rbacsystem = $DIC[
'rbacsystem'];
432 $rbacadmin = $DIC[
'rbacadmin'];
433 $ilAccess = $DIC[
'ilAccess'];
437 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
443 'No valid template id given. Please choose an existing object id of an ILIAS role template',
449 return $this->
raiseError(
"Parent with ID $target_id has been deleted.",
'CLIENT_TARGET_DELETED');
452 if (!$ilAccess->checkAccess(
'edit_permission',
'', $target_id)) {
453 return $this->
raiseError(
'Check access failed. No permission to create roles',
'Server');
457 $xml_parser->startParsing();
460 foreach ($xml_parser->getObjectData() as $object_data) {
462 if (strpos($object_data[
'title'],
"il_") === 0) {
464 'Rolenames are not allowed to start with "il_" ',
470 $role->setTitle($object_data[
'title']);
471 $role->setDescription($object_data[
'description']);
472 $role->setImportId($object_data[
'import_id']);
475 $GLOBALS[
'DIC'][
'rbacadmin']->assignRoleToFolder($role->getId(), $target_id);
478 $rbacadmin->copyRoleTemplatePermissions($template_id,
ROLE_FOLDER_ID, $target_id, $role->getId());
481 $ops = $rbacreview->getOperationsOfRole($role->getId(), $tmp_obj->getType(), $target_id);
482 $rbacadmin->grantPermission($role->getId(), $ops, $target_id);
483 $new_roles[] = $role->getId();
502 $rbacsystem = $DIC[
'rbacsystem'];
503 $rbacreview = $DIC[
'rbacreview'];
504 $ilAccess = $DIC[
'ilAccess'];
508 'No valid ref id given. Please choose an existing reference id of an ILIAS object',
515 'No valid user id given.',
521 return $this->
raiseError(
"Parent with ID " . $ref_id .
"has been deleted.",
'CLIENT_TARGET_DELETED');
525 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'visible',
'', $tmp_obj->getRefId())) {
528 $op_data = $rbacreview->getOperation(2);
529 $ops_data[] = $op_data;
531 if (!$ilAccess->checkAccessOfUser($tmp_user->getId(),
'read',
'', $tmp_obj->getRefId())) {
536 $ops = $rbacreview->getOperationsOnTypeString($tmp_obj->getType());
537 foreach ($ops as $ops_id) {
538 $op_data = $rbacreview->getOperation($ops_id);
540 if ($rbacsystem->checkAccessOfUser($user_id, $op_data[
'operation'], $tmp_obj->getRefId())) {
541 $ops_data[$ops_id] = $op_data;
546 foreach ($ops_data as
$data) {
566 $rbacsystem = $DIC[
'rbacsystem'];
567 $rbacreview = $DIC[
'rbacreview'];
568 $ilUser = $DIC[
'ilUser'];
569 $ilDB = $DIC[
'ilDB'];
571 if (strcasecmp($role_type,
"") !== 0 &&
572 strcasecmp($role_type,
"local") !== 0 &&
573 strcasecmp($role_type,
"global") !== 0 &&
574 strcasecmp($role_type,
"user") !== 0 &&
575 strcasecmp($role_type,
"user_login") !== 0 &&
576 strcasecmp($role_type,
"template") !== 0) {
578 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
585 if (strcasecmp($role_type,
"template") === 0) {
587 $roles = $rbacreview->getRolesByFilter(6, $ilUser->getId());
588 } elseif (strcasecmp($role_type,
"user") === 0 || strcasecmp($role_type,
"user_login") === 0) {
591 if ((
int)
$user_id !== $ilUser->getId()) {
594 $timelimitOwner = $tmpUser->getTimeLimitOwner();
595 if (!$rbacsystem->checkAccess(
'read', $timelimitOwner)) {
596 return $this->
raiseError(
'Check access for time limit owner failed.',
'Server');
602 "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,
603 implode(
"','", $rbacreview->assignedRoles(
$user_id))
606 $rbacresult =
$ilDB->query($query);
608 if ($rbacrow[
"assign"] !==
"y") {
622 "obj_id" => $rbacrow[
"rol_id"],
623 "title" => $tmp_obj->getTitle(),
624 "description" => $tmp_obj->getDescription(),
629 } elseif ($id === -1) {
632 return $this->
raiseError(
'Check access failed.',
'Server');
635 $roles = $rbacreview->getAssignableRoles(
false,
true);
639 if (!$rbacsystem->checkAccess(
'edit_permission', $id)) {
640 return $this->
raiseError(
'Check access for local roles failed.',
'Server');
643 $role_type =
"local";
645 foreach ($rbacreview->getRolesOfRoleFolder($id,
false) as $role_id) {
648 "obj_id" => $role_id,
649 "title" => $tmp_obj->getTitle(),
650 "description" => $tmp_obj->getDescription(),
651 "role_type" => $role_type
658 $xml_writer->setObjects($roles);
659 $xml_writer->setType($role_type);
660 if ($xml_writer->start()) {
661 return $xml_writer->getXML();
671 public function searchRoles(
string $sid,
string $key,
string $combination,
string $role_type)
682 $rbacsystem = $DIC[
'rbacsystem'];
683 $rbacreview = $DIC[
'rbacreview'];
684 $ilUser = $DIC[
'ilUser'];
685 $ilDB = $DIC[
'ilDB'];
687 if (strcasecmp($role_type,
"") !== 0 &&
688 strcasecmp($role_type,
"local") !== 0 &&
689 strcasecmp($role_type,
"global") !== 0 &&
690 strcasecmp($role_type,
"template") !== 0) {
692 'Called service with wrong role_type parameter \'' . $role_type .
'\'',
697 if ($combination !==
'and' && $combination !==
'or') {
699 'No valid combination given. Must be "and" or "or".',
705 $query_parser->setMinWordLength(3);
707 $query_parser->parse();
708 if (!$query_parser->validate()) {
709 return $this->
raiseError($query_parser->getMessage(),
'Client');
714 $object_search->setFilter(array(
"role",
"rolt"));
716 $res = $object_search->performSearch();
720 foreach (
$res->getUniqueResults() as $entry) {
721 $obj_ids [] = $entry[
'obj_id'];
725 if (count($obj_ids) > 0) {
726 $roles = $rbacreview->getRolesForIDs($obj_ids, $role_type ===
"template");
730 $xml_writer->setObjects($roles);
731 $xml_writer->setType($role_type);
732 if ($xml_writer->start()) {
733 return $xml_writer->getXML();
741 if (strcasecmp($role_type,
"user") === 0) {
745 return $this->
raiseError(
'ID must be either numeric or ILIAS conform id for type \'user\'',
'Client');
747 } elseif (strcasecmp($role_type,
"user_login") === 0) {
752 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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addRoleFromTemplate(string $sid, int $target_id, string $role_xml, int $template_id)
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deleteUserRoleEntry(string $sid, int $user_id, int $role_id)