ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilHelpMapping.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
17  protected $db;
18 
19 
23  public function __construct()
24  {
25  global $DIC;
26 
27  $this->db = $DIC->database();
28  }
29 
36  public static function saveScreenIdsForChapter($a_chap, $a_ids)
37  {
38  global $DIC;
39 
40  $ilDB = $DIC->database();
41 
42  self::removeScreenIdsOfChapter($a_chap);
43  if (is_array($a_ids)) {
44  foreach ($a_ids as $id) {
45  $id = trim($id);
46  $id = explode("/", $id);
47  if ($id[0] != "") {
48  if ($id[1] == "") {
49  $id[1] = "-";
50  }
51  $id2 = explode("#", $id[2]);
52  if ($id2[0] == "") {
53  $id2[0] = "-";
54  }
55  if ($id2[1] == "") {
56  $id2[1] = "-";
57  }
58  $ilDB->replace(
59  "help_map",
60  array("chap" => array("integer", $a_chap),
61  "component" => array("text", $id[0]),
62  "screen_id" => array("text", $id[1]),
63  "screen_sub_id" => array("text", $id2[0]),
64  "perm" => array("text", $id2[1]),
65  "module_id" => array("integer", 0)
66  ),
67  array()
68  );
69  }
70  }
71  }
72  }
73 
80  public static function saveMappingEntry(
81  $a_chap,
82  $a_comp,
83  $a_screen_id,
84  $a_screen_sub_id,
85  $a_perm,
86  $a_module_id = 0
87  ) {
88  global $DIC;
89 
90  $ilDB = $DIC->database();
91 
92  $ilDB->replace(
93  "help_map",
94  array("chap" => array("integer", $a_chap),
95  "component" => array("text", $a_comp),
96  "screen_id" => array("text", $a_screen_id),
97  "screen_sub_id" => array("text", $a_screen_sub_id),
98  "perm" => array("text", $a_perm),
99  "module_id" => array("integer", $a_module_id)
100  ),
101  array()
102  );
103  }
104 
105 
112  public static function removeScreenIdsOfChapter($a_chap, $a_module_id = 0)
113  {
114  global $DIC;
115 
116  $ilDB = $DIC->database();
117 
118  $ilDB->manipulate(
119  "DELETE FROM help_map WHERE " .
120  " chap = " . $ilDB->quote($a_chap, "integer") .
121  " AND module_id = " . $ilDB->quote($a_module_id, "integer")
122  );
123  }
124 
131  public static function getScreenIdsOfChapter($a_chap, $a_module_id = 0)
132  {
133  global $DIC;
134 
135  $ilDB = $DIC->database();
136 
137  $set = $ilDB->query(
138  "SELECT * FROM help_map " .
139  " WHERE chap = " . $ilDB->quote($a_chap, "integer") .
140  " AND module_id = " . $ilDB->quote($a_module_id, "integer") .
141  " ORDER BY component, screen_id, screen_sub_id"
142  );
143  $screen_ids = array();
144  while ($rec = $ilDB->fetchAssoc($set)) {
145  if ($rec["screen_id"] == "-") {
146  $rec["screen_id"] = "";
147  }
148  if ($rec["screen_sub_id"] == "-") {
149  $rec["screen_sub_id"] = "";
150  }
151  $id = $rec["component"] . "/" . $rec["screen_id"] . "/" . $rec["screen_sub_id"];
152  if ($rec["perm"] != "" && $rec["perm"] != "-") {
153  $id.= "#" . $rec["perm"];
154  }
155  $screen_ids[] = $id;
156  }
157  return $screen_ids;
158  }
159 
166  public static function getHelpSectionsForId($a_screen_id, $a_ref_id)
167  {
168  global $DIC;
169 
170  $ilDB = $DIC->database();
171  $ilAccess = $DIC->access();
172  $ilSetting = $DIC->settings();
173  $rbacreview = $DIC->rbac()->review();
174  $ilUser = $DIC->user();
175  $ilObjDataCache = $DIC["ilObjDataCache"];
176 
177  if (OH_REF_ID > 0) {
178  $module = 0;
179  } else {
180  $module = (int) $ilSetting->get("help_module");
181  if ($module == 0) {
182  return array();
183  }
184  }
185 
186  $sc_id = explode("/", $a_screen_id);
187  $chaps = array();
188  if ($sc_id[0] != "") {
189  if ($sc_id[1] == "") {
190  $sc_id[1] = "-";
191  }
192  if ($sc_id[2] == "") {
193  $sc_id[2] = "-";
194  }
195  $set = $ilDB->query(
196  "SELECT chap, perm FROM help_map JOIN lm_tree" .
197  " ON (help_map.chap = lm_tree.child) " .
198  " WHERE (component = " . $ilDB->quote($sc_id[0], "text") .
199  " OR component = " . $ilDB->quote("*", "text") . ")" .
200  " AND screen_id = " . $ilDB->quote($sc_id[1], "text") .
201  " AND screen_sub_id = " . $ilDB->quote($sc_id[2], "text") .
202  " AND module_id = " . $ilDB->quote($module, "integer") .
203  " ORDER BY lm_tree.lft"
204  );
205  while ($rec = $ilDB->fetchAssoc($set)) {
206  if ($rec["perm"] != "" && $rec["perm"] != "-") {
207  // check special "create*" permission
208  if ($rec["perm"] == "create*") {
209  $has_create_perm = false;
210 
211  // check owner
212  if ($ilUser->getId() == $ilObjDataCache->lookupOwner(ilObject::_lookupObjId($a_ref_id))) {
213  $has_create_perm = true;
214  } elseif ($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) { // check admin
215  $has_create_perm = true;
216  } elseif ($ilAccess->checkAccess("read", "", (int) $a_ref_id)) {
217  $perm = $rbacreview->getUserPermissionsOnObject($ilUser->getId(), (int) $a_ref_id);
218  foreach ($perm as $p) {
219  if (substr($p, 0, 7) == "create_") {
220  $has_create_perm = true;
221  }
222  }
223  }
224  if ($has_create_perm) {
225  $chaps[] = $rec["chap"];
226  }
227  } elseif ($ilAccess->checkAccess($rec["perm"], "", (int) $a_ref_id)) {
228  $chaps[] = $rec["chap"];
229  }
230  } else {
231  $chaps[] = $rec["chap"];
232  }
233  }
234  }
235  return $chaps;
236  }
237 
249  public static function hasScreenIdSections($a_screen_id)
250  {
251  global $DIC;
252 
253  $ilDB = $DIC->database();
254  $ilAccess = $DIC->access();
255  $ilSetting = $DIC->settings();
256  $ilUser = $DIC->user();
257 
258  if ($ilUser->getLanguage() != "de") {
259  return false;
260  }
261 
262  if ($ilSetting->get("help_mode") == "2") {
263  return false;
264  }
265 
266  if (OH_REF_ID > 0) {
267  $module = 0;
268  } else {
269  $module = (int) $ilSetting->get("help_module");
270  if ($module == 0) {
271  return false;
272  }
273  }
274 
275  $sc_id = explode("/", $a_screen_id);
276  if ($sc_id[0] != "") {
277  if ($sc_id[1] == "") {
278  $sc_id[1] = "-";
279  }
280  if ($sc_id[2] == "") {
281  $sc_id[2] = "-";
282  }
283  $set = $ilDB->query(
284  "SELECT chap, perm FROM help_map " .
285  " WHERE (component = " . $ilDB->quote($sc_id[0], "text") .
286  " OR component = " . $ilDB->quote("*", "text") . ")" .
287  " AND screen_id = " . $ilDB->quote($sc_id[1], "text") .
288  " AND screen_sub_id = " . $ilDB->quote($sc_id[2], "text") .
289  " AND module_id = " . $ilDB->quote($module, "integer")
290  );
291  while ($rec = $ilDB->fetchAssoc($set)) {
292  return true;
293 
294  // no permission check, since it takes to much performance
295  // getHelpSectionsForId() does the permission checks.
296  /*if ($rec["perm"] != "" && $rec["perm"] != "-")
297  {
298  if ($ilAccess->checkAccess($rec["perm"], "", (int) $a_ref_id))
299  {
300  return true;
301  }
302  }
303  else
304  {
305  return true;
306  }*/
307  }
308  }
309  return false;
310  }
311 
318  public static function deleteEntriesOfModule($a_id)
319  {
320  global $DIC;
321 
322  $ilDB = $DIC->database();
323 
324  $ilDB->manipulate("DELETE FROM help_map WHERE " .
325  " module_id = " . $ilDB->quote($a_id, "integer"));
326  }
327 }
__construct()
Constructor.
static deleteEntriesOfModule($a_id)
Delete entries of module.
global $DIC
Definition: saml.php:7
static getHelpSectionsForId($a_screen_id, $a_ref_id)
Get help sections for screen id.
if(!array_key_exists('StateId', $_REQUEST)) $id
static hasScreenIdSections($a_screen_id)
Has given screen Id any sections?
static removeScreenIdsOfChapter($a_chap, $a_module_id=0)
Remove screen ids of chapter.
if($modEnd===false) $module
Definition: module.php:59
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
static getScreenIdsOfChapter($a_chap, $a_module_id=0)
Get screen ids of chapter.
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
global $ilDB
static saveScreenIdsForChapter($a_chap, $a_ids)
Save screen ids for chapter.
Help mapping.
static saveMappingEntry( $a_chap, $a_comp, $a_screen_id, $a_screen_sub_id, $a_perm, $a_module_id=0)
Save mapping entry.