ILIAS  release_8 Revision v8.24
class.ilAccessRBACOperationDeletedObjective.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 string $type;
13 protected int $ops_id;
14
15 public function __construct(string $type, int $ops_id)
16 {
17 $this->type = $type;
18 $this->ops_id = $ops_id;
19 }
20
21 public function getHash(): string
22 {
23 return hash("sha256", self::class);
24 }
25
26 public function getLabel(): string
27 {
28 return "Delete rbac operation and rbac template for type $this->type and id $this->ops_id";
29 }
30
31 public function isNotable(): bool
32 {
33 return true;
34 }
35
36 public function getPreconditions(Environment $environment): array
37 {
38 return [
40 ];
41 }
42
43 public function achieve(Environment $environment): Environment
44 {
45 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
46
47 $type_id = ilObject::_getObjectTypeIdByTitle($this->type);
48
49 $sql =
50 "DELETE FROM rbac_ta" . PHP_EOL
51 . "WHERE typ_id = " . $db->quote($type_id, "integer") . PHP_EOL
52 . "AND ops_id = " . $db->quote($this->ops_id, "integer") . PHP_EOL
53 ;
54
55 $db->manipulate($sql);
56
57 $sql =
58 "DELETE FROM rbac_templates" . PHP_EOL
59 . "WHERE type = " . $db->quote($this->type, "text") . PHP_EOL
60 . "ops_id = " . $db->quote($this->ops_id, "integer") . PHP_EOL
61 ;
62
63 $db->manipulate($sql);
64
65 return $environment;
66 }
67
68 public function isApplicable(Environment $environment): bool
69 {
70 return true;
71 }
72}
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...