ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
AccessRBACOperationClonedObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use 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  {
33  parent::__construct($type, 0, 0);
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)
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
__construct(Container $dic, ilPlugin $plugin)
__construct(string $type, string $src_ops, string $dest_ops)