ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAccessRBACTemplateAddedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
23
25{
26 protected string $type;
27 protected string $id;
28 protected string $description;
29 protected array $op_ids;
30
31 public function __construct(string $type, string $id, string $description, array $op_ids = [])
32 {
33 $this->type = $type;
34 $this->id = $id;
35 $this->description = $description;
36 $this->op_ids = $op_ids;
37 }
38
39 public function getHash(): string
40 {
41 return hash("sha256", self::class);
42 }
43
44 public function getLabel(): string
45 {
46 $op_ids = implode(",", $this->op_ids);
47 return "Add rbac template (type=$this->type;id=$this->id;description=$this->description;op_ids=$op_ids)";
48 }
49
50 public function isNotable(): bool
51 {
52 return true;
53 }
54
55 public function getPreconditions(Environment $environment): array
56 {
57 return [
59 ];
60 }
61
62 public function achieve(Environment $environment): Environment
63 {
64 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
65
66 $tpl_id = $db->nextId("object_data");
67 $values = [
68 "obj_id" => ["integer", $tpl_id],
69 "type" => ["text", "rolt"],
70 "title" => ["text", $this->id],
71 "description" => ["text", $this->description],
72 "owner" => ["integer", -1],
73 "create_date" => ["timestamp", date("Y-m-d H:i:s")],
74 "last_update" => ["timestamp", date("Y-m-d H:i:s")]
75 ];
76 $db->insert("object_data", $values);
77
78 $values = [
79 "rol_id" => ["integer", $tpl_id],
80 "parent" => ["integer", 8],
81 "assign" => ["text", "n"],
82 "protected" => ["text", "n"]
83 ];
84 $db->insert("rbac_fa", $values);
85
86 foreach ($this->op_ids as $op_id) {
87 $values = [
88 "rol_id" => ["integer", $tpl_id],
89 "type" => ["text", $this->type],
90 "ops_id" => ["integer", $op_id],
91 "parent" => ["integer", 8]
92 ];
93 $db->insert("rbac_templates", $values);
94 }
95
96 return $environment;
97 }
98
99 public function isApplicable(Environment $environment): bool
100 {
101 return (bool) count($this->op_ids);
102 }
103}
__construct(string $type, string $id, string $description, array $op_ids=[])
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...