ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AccessRBACOperationClonedObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Setup;
25
27{
28 protected string $src_ops;
29 protected string $dest_ops;
30
31 public function __construct(string $type, string $src_ops, string $dest_ops)
32 {
34 $this->src_ops = $src_ops;
35 $this->dest_ops = $dest_ops;
36 }
37
38 public function getHash(): string
39 {
40 return hash("sha256", self::class . $this->type . ":" . $this->src_ops . ":" . $this->dest_ops);
41 }
42
43 public function getLabel(): string
44 {
45 return "Clone rbac operation from $this->src_ops to $this->dest_ops";
46 }
47
48 public function achieve(Environment $environment): Environment
49 {
51 $this->src_id = \ilRbacReview::_getCustomRBACOperationId($this->src_ops, $db);
52 $this->dest_id = \ilRbacReview::_getCustomRBACOperationId($this->dest_ops, $db);
53 ;
54 $env = parent::achieve($environment);
55 $db->insert("settings", [
56 "module" => ["text", $this->type],
57 "keyword" => ["text", $this->getSettingsKeyword()],
58 "value" => ["text", "1"]
59 ]);
60
61 return $env;
62 }
63
64 protected function getSettingsKeyword(): string
65 {
66 return "copied_perm_" . $this->src_ops . "_" . $this->dest_ops;
67 }
68
69 public function isApplicable(Environment $environment): bool
70 {
72
73 $set = $db->queryF(
74 "SELECT value FROM settings " .
75 " WHERE module = %s AND keyword = %s",
76 ["text", "text"],
77 [$this->type, $this->getSettingsKeyword()]
78 );
79 if ($rec = $db->fetchAssoc($set)) {
80 if ($rec["value"] === "1") {
81 return false;
82 }
83 }
84 return true;
85 }
86
87}
static _getCustomRBACOperationId(string $operation, ?\ilDBInterface $ilDB=null)
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.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...