ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
WebFeedCreationDeletedObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21namespace ILIAS\Container\Setup;
22
24
26{
27 protected string $type;
28 protected string $ops_name;
29
30 public function __construct(string $type, string $ops_name)
31 {
32 $this->type = $type;
33 $this->ops_name = $ops_name;
34 }
35
36 public function getHash(): string
37 {
38 return hash("sha256", self::class . $this->type . $this->ops_name);
39 }
40
41 public function getLabel(): string
42 {
43 return "Delete webfeed creation permissions $this->type and name $this->ops_name";
44 }
45
46 public function isNotable(): bool
47 {
48 return true;
49 }
50
51 public function getPreconditions(Environment $environment): array
52 {
53 return [
54 new \ilDatabaseInitializedObjective()
55 ];
56 }
57
58 public function achieve(Environment $environment): Environment
59 {
61
62 $set = $db->queryF(
63 "SELECT * FROM rbac_operations " .
64 " WHERE operation = %s ",
65 ["text"],
66 [$this->ops_name]
67 );
68 while ($rec = $db->fetchAssoc($set)) {
69 $this->ops_id = (int) $rec["ops_id"];
70 if ($this->ops_id > 0) {
71
72 $set2 = $db->query(
73 "SELECT obj_id FROM object_data"
74 . " WHERE type = 'typ'"
75 . " AND title = " . $db->quote($this->type, 'text')
76 )
77 ;
78 if ($rec2 = $db->fetchAssoc($set2)) {
79 $type_id = (int) $rec2["obj_id"];
80 if ($type_id > 0) {
81
82 $sql =
83 "DELETE FROM rbac_ta" . PHP_EOL
84 . "WHERE typ_id = " . $db->quote($type_id, "integer") . PHP_EOL
85 . "AND ops_id = " . $db->quote($this->ops_id, "integer") . PHP_EOL
86 ;
87
88 $db->manipulate($sql);
89
90 $sql =
91 "DELETE FROM rbac_templates" . PHP_EOL
92 . " WHERE type = " . $db->quote($this->type, "text") . PHP_EOL
93 . " AND ops_id = " . $db->quote($this->ops_id, "integer") . PHP_EOL
94 ;
95
96 $db->manipulate($sql);
97 }
98 }
99 }
100 }
101 return $environment;
102 }
103
104}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...