ILIAS  release_8 Revision v8.25
class.ilAccessRolePermissionSetObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2021 - Daniel Weise <daniel.weise@concepts-and-training.de> - Extended GPL, see LICENSE */
6
9
11{
12 protected const RBAC_OP_COPY = 99;
13
14 protected int $role_id;
15 protected string $type;
16 protected array $ops;
17 protected int $ref_id;
18
19 public function __construct(int $role_id, string $type, array $ops, int $ref_id)
20 {
21 $this->role_id = $role_id;
22 $this->type = $type;
23 $this->ops = $ops;
24 $this->ref_id = $ref_id;
25 }
26
27 public function getHash(): string
28 {
29 return hash("sha256", self::class);
30 }
31
32 public function getLabel(): string
33 {
34 $ops = implode(",", $this->ops);
35 return "Set role permission (role id=$this->role_id;type=$this->type;ops=$ops;ref id=$this->ref_id)";
36 }
37
38 public function isNotable(): bool
39 {
40 return true;
41 }
42
43 public function getPreconditions(Environment $environment): array
44 {
45 return [
47 ];
48 }
49
50 public function achieve(Environment $environment): Environment
51 {
52 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
53
54 foreach ($this->ops as $ops_id) {
55 if ($ops_id == self::RBAC_OP_COPY) {
57 }
58
59 $db->replace(
60 'rbac_templates',
61 [
62 'rol_id' => ['integer', $this->role_id],
63 'type' => ['text', $this->type],
64 'ops_id' => ['integer', $ops_id],
65 'parent' => ['integer', $this->ref_id]
66 ],
67 []
68 );
69 }
70
71 return $environment;
72 }
73
74 public function isApplicable(Environment $environment): bool
75 {
76 return true;
77 }
78}
__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...