ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
AddReadAllAccountsPermissionObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28
30{
31 private const string TYPE = 'usrf';
32 private const int VISIBLE = 2;
33 private const int READ = 3;
34
35 public function getHash(): string
36 {
37 return hash('sha256', self::class);
38 }
39
40 public function getLabel(): string
41 {
42 return ('Add the "Read All Accounts" permission to the user folder');
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 {
60 'read_all_accounts',
61 'read all accounts',
62 'object',
63 2100,
64 [self::TYPE]
65 ))->achieve($environment);
66
67 $new_id = $this->getAddedOperationId($environment);
68 if ($new_id !== null) {
69
71 self::TYPE,
72 self::READ,
73 $new_id
74 ))->achieve($environment);
75
77 self::TYPE,
78 self::VISIBLE,
79 self::READ
80 ))->achieve($environment);
81
82 (new \ilAccessRBACOperationDeletedObjective(
83 self::TYPE,
84 self::VISIBLE
85 ))->achieve($environment);
86 }
87
88 return $environment;
89 }
90
91 public function isApplicable(Environment $environment): bool
92 {
93 return $this->getAddedOperationId($environment) === null;
94 }
95
96 private function getAddedOperationId(Environment $environment): ?int
97 {
100
101 $query = 'SELECT ops_id FROM rbac_operations WHERE operation ="read_all_accounts"';
102 $result = $db->query($query);
103 while ($row = $db->fetchAssoc($result)) {
104 return (int) $row['ops_id'];
105 }
106 return null;
107 }
108}
isNotable()
Get to know if this is an interesting objective for a human.
isApplicable(Environment $environment)
Get to know whether the objective is applicable.
achieve(Environment $environment)
Objectives can be achieved.
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
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...