ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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{
20 function saveScreenIdsForChapter($a_chap, $a_ids)
21 {
22 global $ilDB;
23
25 if (is_array($a_ids))
26 {
27 foreach ($a_ids as $id)
28 {
29 $id = trim($id);
30 $id = explode("/", $id);
31 if ($id[0] != "")
32 {
33 if ($id[1] == "")
34 {
35 $id[1] = "-";
36 }
37 $id2 = explode("#", $id[2]);
38 if ($id2[0] == "")
39 {
40 $id2[0] = "-";
41 }
42 if ($id2[1] == "")
43 {
44 $id2[1] = "-";
45 }
46 $ilDB->replace("help_map",
47 array("chap" => array("integer", $a_chap),
48 "component" => array("text", $id[0]),
49 "screen_id" => array("text", $id[1]),
50 "screen_sub_id" => array("text", $id2[0]),
51 "perm" => array("text", $id2[1]),
52 "module_id" => array("integer", 0)
53 ),
54 array()
55 );
56 }
57 }
58 }
59 }
60
67 static function saveMappingEntry($a_chap, $a_comp, $a_screen_id,
68 $a_screen_sub_id, $a_perm, $a_module_id = 0)
69 {
70 global $ilDB;
71
72 $ilDB->replace("help_map",
73 array("chap" => array("integer", $a_chap),
74 "component" => array("text", $a_comp),
75 "screen_id" => array("text", $a_screen_id),
76 "screen_sub_id" => array("text", $a_screen_sub_id),
77 "perm" => array("text", $a_perm),
78 "module_id" => array("integer", $a_module_id)
79 ),
80 array()
81 );
82 }
83
84
91 function removeScreenIdsOfChapter($a_chap, $a_module_id = 0)
92 {
93 global $ilDB;
94
95 $ilDB->manipulate("DELETE FROM help_map WHERE ".
96 " chap = ".$ilDB->quote($a_chap, "integer").
97 " AND module_id = ".$ilDB->quote($a_module_id, "integer")
98 );
99 }
100
107 function getScreenIdsOfChapter($a_chap, $a_module_id = 0)
108 {
109 global $ilDB;
110
111 $set = $ilDB->query("SELECT * FROM help_map ".
112 " WHERE chap = ".$ilDB->quote($a_chap, "integer").
113 " AND module_id = ".$ilDB->quote($a_module_id, "integer").
114 " ORDER BY component, screen_id, screen_sub_id"
115 );
116 $screen_ids = array();
117 while ($rec = $ilDB->fetchAssoc($set))
118 {
119 if ($rec["screen_id"] == "-")
120 {
121 $rec["screen_id"] = "";
122 }
123 if ($rec["screen_sub_id"] == "-")
124 {
125 $rec["screen_sub_id"] = "";
126 }
127 $id = $rec["component"]."/".$rec["screen_id"]."/".$rec["screen_sub_id"];
128 if ($rec["perm"] != "" && $rec["perm"] != "-")
129 {
130 $id.= "#".$rec["perm"];
131 }
132 $screen_ids[] = $id;
133 }
134 return $screen_ids;
135 }
136
143 static function getHelpSectionsForId($a_screen_id, $a_ref_id)
144 {
145 global $ilDB, $ilAccess, $ilSetting, $rbacreview, $ilUser, $ilObjDataCache;
146
147 if (OH_REF_ID > 0)
148 {
149 $module = 0;
150 }
151 else
152 {
153 $module = (int) $ilSetting->get("help_module");
154 if ($module == 0)
155 {
156 return array();
157 }
158 }
159
160 $sc_id = explode("/", $a_screen_id);
161 $chaps = array();
162 if ($sc_id[0] != "")
163 {
164 if ($sc_id[1] == "")
165 {
166 $sc_id[1] = "-";
167 }
168 if ($sc_id[2] == "")
169 {
170 $sc_id[2] = "-";
171 }
172 $set = $ilDB->query("SELECT chap, perm FROM help_map JOIN lm_tree".
173 " ON (help_map.chap = lm_tree.child) ".
174 " WHERE (component = ".$ilDB->quote($sc_id[0], "text").
175 " OR component = ".$ilDB->quote("*", "text").")".
176 " AND screen_id = ".$ilDB->quote($sc_id[1], "text").
177 " AND screen_sub_id = ".$ilDB->quote($sc_id[2], "text").
178 " AND module_id = ".$ilDB->quote($module, "integer").
179 " ORDER BY lm_tree.lft"
180 );
181 while ($rec = $ilDB->fetchAssoc($set))
182 {
183 if ($rec["perm"] != "" && $rec["perm"] != "-")
184 {
185 // check special "create*" permission
186 if ($rec["perm"] == "create*")
187 {
188 $has_create_perm = false;
189
190 // check owner
191 if ($ilUser->getId() == $ilObjDataCache->lookupOwner(ilObject::_lookupObjId($a_ref_id)))
192 {
193 $has_create_perm = true;
194 }
195 else if ($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) // check admin
196 {
197 $has_create_perm = true;
198 }
199 else if ($ilAccess->checkAccess("read", "", (int) $a_ref_id))
200 {
201 $perm = $rbacreview->getUserPermissionsOnObject($ilUser->getId(), (int) $a_ref_id);
202 foreach ($perm as $p)
203 {
204 if (substr($p, 0, 7) == "create_")
205 {
206 $has_create_perm = true;
207 }
208 }
209 }
210 if ($has_create_perm)
211 {
212 $chaps[] = $rec["chap"];
213 }
214 }
215 else if ($ilAccess->checkAccess($rec["perm"], "", (int) $a_ref_id))
216 {
217 $chaps[] = $rec["chap"];
218 }
219 }
220 else
221 {
222 $chaps[] = $rec["chap"];
223 }
224 }
225 }
226 return $chaps;
227 }
228
240 function hasScreenIdSections($a_screen_id)
241 {
242 global $ilDB, $ilAccess, $ilSetting, $ilUser;
243
244 if ($ilUser->getLanguage() != "de")
245 {
246 return false;
247 }
248
249 if ($ilSetting->get("help_mode") == "2")
250 {
251 return false;
252 }
253
254 if (OH_REF_ID > 0)
255 {
256 $module = 0;
257 }
258 else
259 {
260 $module = (int) $ilSetting->get("help_module");
261 if ($module == 0)
262 {
263 return false;
264 }
265 }
266
267 $sc_id = explode("/", $a_screen_id);
268 if ($sc_id[0] != "")
269 {
270 if ($sc_id[1] == "")
271 {
272 $sc_id[1] = "-";
273 }
274 if ($sc_id[2] == "")
275 {
276 $sc_id[2] = "-";
277 }
278 $set = $ilDB->query("SELECT chap, perm FROM help_map ".
279 " WHERE (component = ".$ilDB->quote($sc_id[0], "text").
280 " OR component = ".$ilDB->quote("*", "text").")".
281 " AND screen_id = ".$ilDB->quote($sc_id[1], "text").
282 " AND screen_sub_id = ".$ilDB->quote($sc_id[2], "text").
283 " AND module_id = ".$ilDB->quote($module, "integer")
284 );
285 while ($rec = $ilDB->fetchAssoc($set))
286 {
287 return true;
288
289 // no permission check, since it takes to much performance
290 // getHelpSectionsForId() does the permission checks.
291 /*if ($rec["perm"] != "" && $rec["perm"] != "-")
292 {
293 if ($ilAccess->checkAccess($rec["perm"], "", (int) $a_ref_id))
294 {
295 return true;
296 }
297 }
298 else
299 {
300 return true;
301 }*/
302 }
303 }
304 return false;
305 }
306
313 static function deleteEntriesOfModule($a_id)
314 {
315 global $ilDB;
316
317 $ilDB->manipulate("DELETE FROM help_map WHERE ".
318 " module_id = ".$ilDB->quote($a_id, "integer"));
319
320 }
321
322
323}
324
325?>
static saveMappingEntry($a_chap, $a_comp, $a_screen_id, $a_screen_sub_id, $a_perm, $a_module_id=0)
Save mapping entry.
static deleteEntriesOfModule($a_id)
Delete entries of module.
static getHelpSectionsForId($a_screen_id, $a_ref_id)
Get help sections for screen id.
saveScreenIdsForChapter($a_chap, $a_ids)
Save screen ids for chapter.
getScreenIdsOfChapter($a_chap, $a_module_id=0)
Get screen ids of chapter.
hasScreenIdSections($a_screen_id)
Has given screen Id any sections?
removeScreenIdsOfChapter($a_chap, $a_module_id=0)
Remove screen ids of chapter.
static _lookupObjId($a_id)
global $ilSetting
Definition: privfeed.php:40
global $ilDB
global $ilUser
Definition: imgupload.php:15