ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAccessRolePermissionSetObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
23
25{
26 protected const RBAC_OP_COPY = 99;
27
28 protected int $role_id;
29 protected string $type;
30 protected array $ops;
31 protected int $ref_id;
32
33 public function __construct(int $role_id, string $type, array $ops, int $ref_id)
34 {
35 $this->role_id = $role_id;
36 $this->type = $type;
37 $this->ops = $ops;
38 $this->ref_id = $ref_id;
39 }
40
41 public function getHash(): string
42 {
43 return hash("sha256", self::class);
44 }
45
46 public function getLabel(): string
47 {
48 $ops = implode(",", $this->ops);
49 return "Set role permission (role id=$this->role_id;type=$this->type;ops=$ops;ref id=$this->ref_id)";
50 }
51
52 public function isNotable(): bool
53 {
54 return true;
55 }
56
57 public function getPreconditions(Environment $environment): array
58 {
59 return [
61 ];
62 }
63
64 public function achieve(Environment $environment): Environment
65 {
66 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
67
68 foreach ($this->ops as $ops_id) {
69 if ($ops_id == self::RBAC_OP_COPY) {
71 }
72
73 $db->replace(
74 'rbac_templates',
75 [
76 'rol_id' => ['integer', $this->role_id],
77 'type' => ['text', $this->type],
78 'ops_id' => ['integer', $ops_id],
79 'parent' => ['integer', $this->ref_id]
80 ],
81 []
82 );
83 }
84
85 return $environment;
86 }
87
88 public function isApplicable(Environment $environment): bool
89 {
90 return true;
91 }
92}
__construct(int $role_id, string $type, array $ops, int $ref_id)
static _getCustomRBACOperationId(string $operation, ?\ilDBInterface $ilDB=null)
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...