ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
AdminNodesVisibilityRemovedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ilIniFile;
30
32{
34 private const int RBAC_OP_VISIBLE = 2;
35
36 public function getHash(): string
37 {
38 return hash("sha256", self::class);
39 }
40
41 public function getLabel(): string
42 {
43 return "Remove visibility permissions from admin nodes";
44 }
45
46 public function isNotable(): bool
47 {
48 return true;
49 }
50
51 public function getPreconditions(Environment $environment): array
52 {
53 return [
56 ];
57 }
58
59 public function achieve(Environment $environment): Environment
60 {
61 foreach ($this->getTypesToChange($environment) as $type) {
62 $objective = new ilAccessRBACOperationDeletedObjective($type, self::RBAC_OP_VISIBLE);
63 $objective->achieve($environment);
64 }
65 return $environment;
66 }
67
68 public function isApplicable(Environment $environment): bool
69 {
70 return !empty($this->getTypesToChange($environment));
71 }
72
77 private function getTypesToChange(Environment $environment): array
78 {
79 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
81
82 $folder_id = (int) $client_ini->readVariable('system', 'SYSTEM_FOLDER_ID');
83 if (!$folder_id) {
84 return [];
85 }
86
87 // get all types of admin nodes where the visible permission is still defined
88 // exclude the user folder which gets a special treatment in a separate objective
89 // exclude org units to keep the info screen of subunits visible without read access
90 $query = "
91 SELECT d1.`type`
92 FROM tree t
93 JOIN object_reference r ON r.ref_id = t.child
94 JOIN object_data d1 ON d1.obj_id = r.obj_id
95 JOIN object_data d2 ON d2.`type` = 'typ' AND d2.title = d1.`type`
96 JOIN rbac_ta a ON a.typ_id = d2.obj_id AND a.ops_id = %s
97 WHERE t.parent = %s
98 AND d1.`type` <> 'usrf'
99 AND d1.`type` <> 'orgu'
100 ORDER BY d1.`type`
101 ";
102
103 $result = $db->queryF($query, ['integer', 'integer'], [self::RBAC_OP_VISIBLE, $folder_id]);
104
105 $types = [];
106 foreach ($db->fetchAll($result) as $row) {
107 $types[] = (string) $row['type'];
108 }
109 return $types;
110 }
111}
getTypesToChange(Environment $environment)
Get the types of admin nodes where the visible permission needs to be removed.
isApplicable(Environment $environment)
Get to know whether the objective is applicable.
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
isNotable()
Get to know if this is an interesting objective for a human.
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
Interface ilDBInterface.