ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.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 getLabel(): string
39 {
40 return "Clone rbac operation from $this->src_ops to $this->dest_ops";
41 }
42
43 public function achieve(Environment $environment): Environment
44 {
46 $this->src_id = \ilRbacReview::_getCustomRBACOperationId($this->src_ops, $db);
47 $this->dest_id = \ilRbacReview::_getCustomRBACOperationId($this->dest_ops, $db);
48 ;
49 $env = parent::achieve($environment);
50 $db->insert("settings", [
51 "module" => ["text", $this->type],
52 "keyword" => ["text", $this->getSettingsKeyword()],
53 "value" => ["text", "1"]
54 ]);
55
56 return $env;
57 }
58
59 protected function getSettingsKeyword(): string
60 {
61 return "copied_perm_" . $this->src_ops . "_" . $this->dest_ops;
62 }
63
64 public function isApplicable(Environment $environment): bool
65 {
67
68 $set = $db->queryF(
69 "SELECT value FROM settings " .
70 " WHERE module = %s AND keyword = %s",
71 ["text", "text"],
72 [$this->type, $this->getSettingsKeyword()]
73 );
74 if ($rec = $db->fetchAssoc($set)) {
75 if ($rec["value"] === "1") {
76 return false;
77 }
78 }
79
80 return true;
81 }
82
83}
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...