ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAccessRBACOperationDeletedObjective.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 int $ops_id;
28
29 public function __construct(string $type, int $ops_id)
30 {
31 $this->type = $type;
32 $this->ops_id = $ops_id;
33 }
34
35 public function getHash(): string
36 {
37 return hash("sha256", self::class);
38 }
39
40 public function getLabel(): string
41 {
42 return "Delete rbac operation and rbac template for type $this->type and id $this->ops_id";
43 }
44
45 public function isNotable(): bool
46 {
47 return true;
48 }
49
50 public function getPreconditions(Environment $environment): array
51 {
52 return [
54 ];
55 }
56
57 public function achieve(Environment $environment): Environment
58 {
59 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
60
61 $type_id = ilObject::_getObjectTypeIdByTitle($this->type, $db);
62
63 $sql =
64 "DELETE FROM rbac_ta" . PHP_EOL
65 . "WHERE typ_id = " . $db->quote($type_id, "integer") . PHP_EOL
66 . "AND ops_id = " . $db->quote($this->ops_id, "integer") . PHP_EOL
67 ;
68
69 $db->manipulate($sql);
70
71 $sql =
72 "DELETE FROM rbac_templates" . PHP_EOL
73 . "WHERE type = " . $db->quote($this->type, "text") . PHP_EOL
74 . "AND ops_id = " . $db->quote($this->ops_id, "integer") . PHP_EOL
75 ;
76
77 $db->manipulate($sql);
78
79 return $environment;
80 }
81
82 public function isApplicable(Environment $environment): bool
83 {
84 return true;
85 }
86}
static _getObjectTypeIdByTitle(string $type, ?\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...