ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilAccessRBACOperationDeletedObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Setup;
23 
24 class ilAccessRBACOperationDeletedObjective implements Setup\Objective
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 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
static _getObjectTypeIdByTitle(string $type, ?\ilDBInterface $ilDB=null)