ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
MapManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Help\Map;
22 
25 
27 {
28  protected \ilObjUser $user;
29  protected \ilRbacReview $rbacreview;
30  protected \ilSetting $settings;
31  protected \ilAccessHandler $access;
34 
35  public function __construct(
36  InternalRepoService $repo,
37  InternalDomainService $domain
38  ) {
39  $this->repo = $repo->map();
40  $this->domain = $domain;
41 
42  $this->access = $domain->access();
43  $this->settings = $domain->settings();
44  $this->rbacreview = $domain->rbac()->review();
45  $this->user = $domain->user();
46  }
47 
48  public function saveScreenIdsForChapter(
49  int $chap,
50  array $ids
51  ): void {
52  $this->repo->saveScreenIdsForChapter($chap, $ids);
53  }
54 
55  public function saveMappingEntry(
56  int $chap,
57  string $comp,
58  string $screen_id,
59  string $screen_sub_id,
60  string $perm,
61  int $module_id = 0
62  ): void {
63  $this->repo->saveMappingEntry(
64  $chap,
65  $comp,
66  $screen_id,
67  $screen_sub_id,
68  $perm,
69  $module_id
70  );
71  }
72 
73  public function removeScreenIdsOfChapter(
74  int $chap,
75  int $module_id = 0
76  ): void {
77  $this->repo->removeScreenIdsOfChapter(
78  $chap,
79  $module_id
80  );
81  }
82 
83  public function getScreenIdsOfChapter(
84  int $chap,
85  int $module_id = 0
86  ): array {
87  return $this->repo->getScreenIdsOfChapter(
88  $chap,
89  $module_id
90  );
91  }
92 
93 
94  public function getHelpSectionsForId(
95  string $a_screen_id,
96  int $a_ref_id
97  ): array {
98  if ($this->domain->module()->isAuthoringMode()) {
99  $module_ids = [0];
100  } else {
101  $module_ids = $this->domain->module()->getActiveModules();
102  }
103  $chaps = [];
104  foreach ($this->repo->getChaptersForScreenId($a_screen_id, $module_ids) as $rec) {
105  if ($rec["perm"] != "" && $rec["perm"] != "-") {
106  // check special "create*" permission
107  if ($rec["perm"] === "create*") {
108  $has_create_perm = false;
109 
110  // check owner
111  if ($this->user->getId() === \ilObject::_lookupOwner(\ilObject::_lookupObjId($a_ref_id))) {
112  $has_create_perm = true;
113  } elseif ($this->rbacreview->isAssigned($this->user->getId(), SYSTEM_ROLE_ID)) { // check admin
114  $has_create_perm = true;
115  } elseif ($this->access->checkAccess("read", "", $a_ref_id)) {
116  $perm = $this->rbacreview->getUserPermissionsOnObject($this->user->getId(), $a_ref_id);
117  foreach ($perm as $p) {
118  if (strpos($p, "create_") === 0) {
119  $has_create_perm = true;
120  }
121  }
122  }
123  if ($has_create_perm) {
124  $chaps[] = $rec["chap"];
125  }
126  } elseif ($this->access->checkAccess($rec["perm"], "", $a_ref_id)) {
127  $chaps[] = $rec["chap"];
128  }
129  } else {
130  $chaps[] = $rec["chap"];
131  }
132  }
133  return $chaps;
134  }
135 
143  public function hasScreenIdSections(
144  string $a_screen_id
145  ): bool {
146 
147  if ($this->user->getLanguage() !== "de") {
148  return false;
149  }
150 
151  if ($this->settings->get("help_mode") === "2") {
152  return false;
153  }
154 
155  if ($this->domain->module()->isAuthoringMode()) {
156  $module_ids = [0];
157  } else {
158  $module_ids = $this->domain->module()->getActiveModules();
159  }
160 
161  foreach ($this->repo->getChaptersForScreenId($a_screen_id, $module_ids) as $rec) {
162  return true;
163  }
164  return false;
165  }
166 
167  public function deleteEntriesOfModule(
168  int $id
169  ): void {
170  $this->repo->deleteEntriesOfModule($id);
171  }
172 }
ilAccessHandler $access
Definition: MapManager.php:31
getScreenIdsOfChapter(int $chap, int $module_id=0)
Definition: MapManager.php:83
hasScreenIdSections(string $a_screen_id)
Has given screen Id any sections? Note: We removed the "ref_id" parameter here, since this method sho...
Definition: MapManager.php:143
const SYSTEM_ROLE_ID
Definition: constants.php:29
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID.
static _lookupObjId(int $ref_id)
getHelpSectionsForId(string $a_screen_id, int $a_ref_id)
Definition: MapManager.php:94
MapDBRepository $repo
Definition: MapManager.php:33
removeScreenIdsOfChapter(int $chap, int $module_id=0)
Definition: MapManager.php:73
saveScreenIdsForChapter(int $chap, array $ids)
Definition: MapManager.php:48
ilRbacReview $rbacreview
Definition: MapManager.php:29
__construct(InternalRepoService $repo, InternalDomainService $domain)
Definition: MapManager.php:35
saveMappingEntry(int $chap, string $comp, string $screen_id, string $screen_sub_id, string $perm, int $module_id=0)
Definition: MapManager.php:55
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
InternalDomainService $domain
Definition: MapManager.php:32