ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ExternalToolsRemovedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ilIniFile;
31
33{
34 public function getHash(): string
35 {
36 return hash("sha256", self::class);
37 }
38
39 public function getLabel(): string
40 {
41 return "Remove external tools admin folder";
42 }
43
44 public function isNotable(): bool
45 {
46 return true;
47 }
48
49 public function getPreconditions(Environment $environment): array
50 {
51 return [
53 ];
54 }
55
56 public function achieve(Environment $environment): Environment
57 {
60
61 $query = "
62 SELECT op.ops_id
63 FROM rbac_operations op
64 JOIN rbac_ta ta ON ta.ops_id = op.ops_id
65 JOIN object_data d ON d.obj_id = ta.typ_id AND d.`type` = 'typ' AND d.title ='extt'
66 ";
67
68 $result = $db->query($query);
69 while ($row = $db->fetchAssoc($result)) {
70 $objective = new ilAccessRBACOperationDeletedObjective('extt', $row['ops_id']);
71 $objective->achieve($environment);
72 }
73
74 $query = "
75 SELECT r.ref_id, r.obj_id
76 FROM object_reference r
77 JOIN object_data d ON r.obj_id = d.obj_id
78 WHERE d.`type` = 'extt';
79 ";
80
81 $result = $db->query($query);
82 if ($row = $db->fetchAssoc($result)) {
83 $db->manipulateF("DELETE FROM rbac_pa WHERE ref_id = %s", [ilDBConstants::T_INTEGER], [$row['ref_id']]);
84 $db->manipulateF("DELETE FROM rbac_fa WHERE parent = %s", [ilDBConstants::T_INTEGER], [$row['ref_id']]);
85 $db->manipulateF("DELETE FROM object_reference WHERE obj_id = %s", [ilDBConstants::T_INTEGER], [$row['obj_id']]);
86 $db->manipulateF("DELETE FROM object_data WHERE obj_id = %s", [ilDBConstants::T_INTEGER], [$row['obj_id']]);
87 }
88
89 return $environment;
90 }
91
92 public function isApplicable(Environment $environment): bool
93 {
95 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
96
97 $result = $db->query("SELECT obj_id FROM object_data WHERE `type` = 'extt'");
98 return (bool) $db->fetchAssoc($result);
99 }
100}
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
isNotable()
Get to know if this is an interesting objective for a human.
Class ilDBConstants.
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
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
isApplicable(Environment $environment)
Get to know whether the objective is applicable.
achieve(Environment $environment)
Objectives can be achieved.
Interface ilDBInterface.