1 | <?php |
||
2 | |||
3 | /* For licensing terms, see /license.txt */ |
||
4 | |||
5 | use Chamilo\CourseBundle\Entity\CLpCategory; |
||
6 | use Chamilo\CourseBundle\Entity\CTool; |
||
7 | |||
8 | /** |
||
9 | * Class CourseHome. |
||
10 | */ |
||
11 | class CourseHome |
||
12 | { |
||
13 | /** |
||
14 | * Gets the html content to show in the 3 column view. |
||
15 | * |
||
16 | * @param string $cat |
||
17 | * @param int $userId |
||
18 | * |
||
19 | * @return string |
||
20 | */ |
||
21 | public static function show_tool_3column($cat, $userId = null) |
||
22 | { |
||
23 | $_user = api_get_user_info($userId); |
||
24 | $course_id = api_get_course_int_id(); |
||
25 | |||
26 | $TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST); |
||
27 | $TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE); |
||
28 | |||
29 | $numcols = 3; |
||
30 | $table = new HTML_Table('width="100%"'); |
||
31 | $all_tools = []; |
||
32 | switch ($cat) { |
||
33 | case 'Basic': |
||
34 | $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND t.position="basic" '; |
||
35 | if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && |
||
36 | $_SESSION['studentview'] != 'studentview' |
||
37 | ) { |
||
38 | $condition_display_tools = ' WHERE |
||
39 | a.c_id = '.$course_id.' AND |
||
40 | a.link=t.link AND |
||
41 | (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") |
||
42 | '; |
||
43 | } |
||
44 | |||
45 | $sql = "SELECT a.*, t.image img, t.row, t.column |
||
46 | FROM $TBL_ACCUEIL a, $TABLE_TOOLS t |
||
47 | $condition_display_tools ORDER BY t.row, t.column"; |
||
48 | break; |
||
49 | case 'External': |
||
50 | if (api_is_allowed_to_edit()) { |
||
51 | $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t |
||
52 | WHERE |
||
53 | a.c_id = $course_id AND |
||
54 | ((a.link=t.link AND t.position='external') OR |
||
55 | (a.visibility <= 1 AND |
||
56 | (a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND |
||
57 | a.image=t.image)) |
||
58 | ORDER BY a.id"; |
||
59 | } else { |
||
60 | $sql = "SELECT a.*, t.image img FROM $TBL_ACCUEIL a, $TABLE_TOOLS t |
||
61 | WHERE |
||
62 | a.c_id = $course_id AND |
||
63 | (a.visibility = 1 AND ((a.link=t.link AND t.position='external') OR |
||
64 | ((a.image = 'external.gif' OR a.image = 'scormbuilder.gif' OR t.image = 'blog.gif') AND |
||
65 | a.image=t.image))) |
||
66 | ORDER BY a.id"; |
||
67 | } |
||
68 | break; |
||
69 | case 'courseAdmin': |
||
70 | $sql = "SELECT a.*, t.image img, t.row, t.column |
||
71 | FROM $TBL_ACCUEIL a, $TABLE_TOOLS t |
||
72 | WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link |
||
73 | ORDER BY t.row, t.column"; |
||
74 | break; |
||
75 | |||
76 | case 'platformAdmin': |
||
77 | $sql = "SELECT *, image img FROM $TBL_ACCUEIL |
||
78 | WHERE c_id = $course_id AND visibility = 2 |
||
79 | ORDER BY id"; |
||
80 | } |
||
81 | $result = Database::query($sql); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
82 | |||
83 | // Grabbing all the tools from $course_tool_table |
||
84 | while ($tool = Database::fetch_array($result)) { |
||
85 | $all_tools[] = $tool; |
||
86 | } |
||
87 | |||
88 | // Grabbing all the links that have the property on_homepage set to 1 |
||
89 | if ($cat === 'External') { |
||
90 | $tbl_link = Database::get_course_table(TABLE_LINK); |
||
91 | $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); |
||
92 | if (api_is_allowed_to_edit(null, true)) { |
||
93 | $sql_links = "SELECT tl.*, tip.visibility |
||
94 | FROM $tbl_link tl |
||
95 | LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id |
||
96 | WHERE |
||
97 | tl.c_id = $course_id AND |
||
98 | tip.c_id = $course_id AND |
||
99 | tl.on_homepage='1' AND |
||
100 | tip.visibility != 2"; |
||
101 | } else { |
||
102 | $sql_links = "SELECT tl.*, tip.visibility |
||
103 | FROM $tbl_link tl |
||
104 | LEFT JOIN $tbl_item_property tip ON tip.tool='link' AND tip.ref=tl.id |
||
105 | WHERE |
||
106 | tl.c_id = $course_id AND |
||
107 | tip.c_id = $course_id AND |
||
108 | tl.on_homepage='1' AND |
||
109 | tip.visibility = 1"; |
||
110 | } |
||
111 | $result_links = Database::query($sql_links); |
||
112 | while ($links_row = Database::fetch_array($result_links)) { |
||
113 | $properties = []; |
||
114 | $properties['name'] = $links_row['title']; |
||
115 | $properties['link'] = $links_row['url']; |
||
116 | $properties['visibility'] = $links_row['visibility']; |
||
117 | $properties['img'] = 'external.gif'; |
||
118 | $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id']; |
||
119 | $all_tools[] = $properties; |
||
120 | } |
||
121 | } |
||
122 | |||
123 | $cell_number = 0; |
||
124 | // Draw line between basic and external, only if there are entries in External |
||
125 | if ($cat == 'External' && count($all_tools)) { |
||
126 | $table->setCellContents(0, 0, '<hr noshade="noshade" size="1"/>'); |
||
127 | $table->updateCellAttributes(0, 0, 'colspan="3"'); |
||
128 | $cell_number += $numcols; |
||
129 | } |
||
130 | |||
131 | foreach ($all_tools as &$tool) { |
||
132 | if (isset($tool['image']) && $tool['image'] == 'scormbuilder.gif') { |
||
133 | // check if the published learnpath is visible for student |
||
134 | $lpId = self::getPublishedLpIdFromLink($tool['link']); |
||
135 | |||
136 | if (!api_is_allowed_to_edit(null, true) && |
||
137 | !learnpath::is_lp_visible_for_student( |
||
138 | $lpId, |
||
139 | api_get_user_id(), |
||
140 | api_get_course_info(), |
||
141 | api_get_session_id() |
||
142 | ) |
||
143 | ) { |
||
144 | continue; |
||
145 | } |
||
146 | } |
||
147 | |||
148 | if (api_get_session_id() != 0 && |
||
149 | in_array($tool['name'], ['course_maintenance', 'course_setting']) |
||
150 | ) { |
||
151 | continue; |
||
152 | } |
||
153 | |||
154 | $cell_content = ''; |
||
155 | // The name of the tool |
||
156 | $tool_name = self::translate_tool_name($tool); |
||
157 | |||
158 | $link_annex = ''; |
||
159 | // The url of the tool |
||
160 | if ($tool['img'] != 'external.gif') { |
||
161 | $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link']; |
||
162 | $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&'; |
||
163 | $link_annex = $qm_or_amp.api_get_cidreq(); |
||
164 | } else { |
||
165 | // If an external link ends with 'login=', add the actual login... |
||
166 | $pos = strpos($tool['link'], '?login='); |
||
167 | $pos2 = strpos($tool['link'], '&login='); |
||
168 | if ($pos !== false or $pos2 !== false) { |
||
169 | $link_annex = $_user['username']; |
||
170 | } |
||
171 | } |
||
172 | |||
173 | // Setting the actual image url |
||
174 | $tool['img'] = Display::returnIconPath($tool['img']); |
||
175 | $target = isset($tool['target']) ? $tool['target'] : ''; |
||
176 | |||
177 | // VISIBLE |
||
178 | if (($tool['visibility'] || |
||
179 | ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && $tool['name'] == TOOL_TRACKING)) || |
||
180 | $cat == 'courseAdmin' || $cat == 'platformAdmin' |
||
181 | ) { |
||
182 | if (strpos($tool['name'], 'visio_') !== false) { |
||
183 | $cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; |
||
184 | } elseif (strpos($tool['name'], 'chat') !== false && |
||
185 | api_get_course_setting('allow_open_chat_window') |
||
186 | ) { |
||
187 | // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'] |
||
188 | $cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; |
||
189 | } else { |
||
190 | // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'] |
||
191 | $cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$target.'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; |
||
192 | } |
||
193 | } else { |
||
194 | // INVISIBLE |
||
195 | if (api_is_allowed_to_edit(null, true)) { |
||
196 | if (strpos($tool['name'], 'visio_') !== false) { |
||
197 | $cell_content .= '<a href="javascript: void(0);" onclick="window.open(\''.$tool['link'].$link_annex.'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'"><img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; |
||
198 | } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) { |
||
199 | // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'] |
||
200 | $cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'" class="text-muted"><img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; |
||
201 | } else { |
||
202 | // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'] |
||
203 | $cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'" class="text-muted"> |
||
204 | <img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>'; |
||
205 | } |
||
206 | } else { |
||
207 | // don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'] |
||
208 | $cell_content .= '<img src="'.str_replace(".gif", "_na.gif", $tool['img']).'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'; |
||
209 | $cell_content .= '<span class="text-muted">'.$tool_name.'</span>'; |
||
210 | } |
||
211 | } |
||
212 | |||
213 | $lnk = []; |
||
214 | if (api_is_allowed_to_edit(null, true) && |
||
215 | $cat != "courseAdmin" && |
||
216 | !strpos($tool['link'], 'learnpath_handler.php?learnpath_id') && |
||
217 | !api_is_coach() |
||
218 | ) { |
||
219 | if ($tool['visibility']) { |
||
220 | $link['name'] = Display::return_icon( |
||
221 | 'remove.gif', |
||
222 | get_lang('Deactivate'), |
||
223 | ['style' => 'vertical-align: middle;'] |
||
224 | ); |
||
225 | $link['cmd'] = "hide=yes"; |
||
226 | $lnk[] = $link; |
||
227 | } else { |
||
228 | $link['name'] = Display::return_icon( |
||
229 | 'add.gif', |
||
230 | get_lang('Activate'), |
||
231 | ['style' => 'vertical-align: middle;'] |
||
232 | ); |
||
233 | $link['cmd'] = "restore=yes"; |
||
234 | $lnk[] = $link; |
||
235 | } |
||
236 | if (is_array($lnk)) { |
||
237 | foreach ($lnk as &$this_lnk) { |
||
238 | if (isset($tool['adminlink']) && $tool['adminlink']) { |
||
239 | $cell_content .= '<a href="'.$properties['adminlink'].'">'. |
||
240 | Display::return_icon('edit.gif', get_lang('Edit')).'</a>'; |
||
241 | } else { |
||
242 | $cell_content .= '<a href="'.api_get_self().'?id='.$tool['id'].'&'.$this_lnk['cmd'].'">'.$this_lnk['name'].'</a>'; |
||
243 | } |
||
244 | } |
||
245 | } |
||
246 | } |
||
247 | $table->setCellContents($cell_number / $numcols, ($cell_number) % $numcols, $cell_content); |
||
248 | $table->updateCellAttributes($cell_number / $numcols, ($cell_number) % $numcols, 'width="32%" height="42"'); |
||
249 | $cell_number++; |
||
250 | } |
||
251 | |||
252 | return $table->toHtml(); |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * Displays the tools of a certain category. |
||
257 | * |
||
258 | * @param string $course_tool_category contains the category of tools to display: |
||
259 | * "Public", "PublicButHide", "courseAdmin", "claroAdmin" |
||
260 | * |
||
261 | * @return string |
||
262 | */ |
||
263 | public static function show_tool_2column($course_tool_category) |
||
264 | { |
||
265 | $html = ''; |
||
266 | $web_code_path = api_get_path(WEB_CODE_PATH); |
||
267 | $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); |
||
268 | $course_id = api_get_course_int_id(); |
||
269 | switch ($course_tool_category) { |
||
270 | case TOOL_PUBLIC: |
||
271 | $condition_display_tools = ' WHERE c_id = '.$course_id.' AND visibility = 1 '; |
||
272 | if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && |
||
273 | $_SESSION['studentview'] != 'studentview' |
||
274 | ) { |
||
275 | $condition_display_tools = ' WHERE |
||
276 | c_id = '.$course_id.' AND |
||
277 | (visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'")) '; |
||
278 | } |
||
279 | $result = Database::query("SELECT * FROM $course_tool_table $condition_display_tools ORDER BY id"); |
||
280 | $col_link = "##003399"; |
||
281 | break; |
||
282 | case TOOL_PUBLIC_BUT_HIDDEN: |
||
283 | $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility=0 AND admin=0 ORDER BY id"); |
||
284 | $col_link = "##808080"; |
||
285 | break; |
||
286 | case TOOL_COURSE_ADMIN: |
||
287 | $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND admin=1 AND visibility != 2 ORDER BY id"); |
||
288 | $col_link = "##003399"; |
||
289 | break; |
||
290 | case TOOL_PLATFORM_ADMIN: |
||
291 | $result = Database::query("SELECT * FROM $course_tool_table WHERE c_id = $course_id AND visibility = 2 ORDER BY id"); |
||
292 | $col_link = "##003399"; |
||
293 | } |
||
294 | $i = 0; |
||
295 | |||
296 | // Grabbing all the tools from $course_tool_table |
||
297 | while ($temp_row = Database::fetch_array($result)) { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
298 | if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN && $temp_row['image'] != 'scormbuilder.gif') { |
||
299 | $temp_row['image'] = str_replace('.gif', '_na.gif', $temp_row['image']); |
||
300 | } |
||
301 | $all_tools_list[] = $temp_row; |
||
302 | } |
||
303 | |||
304 | // Grabbing all the links that have the property on_homepage set to 1 |
||
305 | $course_link_table = Database::get_course_table(TABLE_LINK); |
||
306 | $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
||
307 | |||
308 | switch ($course_tool_category) { |
||
309 | case TOOL_PUBLIC: |
||
310 | $sql_links = "SELECT tl.*, tip.visibility |
||
311 | FROM $course_link_table tl |
||
312 | LEFT JOIN $course_item_property_table tip |
||
313 | ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id |
||
314 | WHERE tl.on_homepage='1' AND tip.visibility = 1"; |
||
315 | break; |
||
316 | case TOOL_PUBLIC_BUT_HIDDEN: |
||
317 | $sql_links = "SELECT tl.*, tip.visibility |
||
318 | FROM $course_link_table tl |
||
319 | LEFT JOIN $course_item_property_table tip |
||
320 | ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id |
||
321 | WHERE tl.on_homepage='1' AND tip.visibility = 0"; |
||
322 | |||
323 | break; |
||
324 | default: |
||
325 | $sql_links = null; |
||
326 | break; |
||
327 | } |
||
328 | if ($sql_links != null) { |
||
329 | $properties = []; |
||
330 | $result_links = Database::query($sql_links); |
||
331 | while ($links_row = Database::fetch_array($result_links)) { |
||
332 | unset($properties); |
||
333 | $properties['name'] = $links_row['title']; |
||
334 | $properties['link'] = $links_row['url']; |
||
335 | $properties['visibility'] = $links_row['visibility']; |
||
336 | $properties['image'] = $course_tool_category == TOOL_PUBLIC_BUT_HIDDEN ? 'external_na.gif' : 'external.gif'; |
||
337 | $properties['adminlink'] = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink&id='.$links_row['id']; |
||
338 | $all_tools_list[] = $properties; |
||
339 | } |
||
340 | } |
||
341 | $lnk = []; |
||
342 | if (isset($all_tools_list)) { |
||
343 | foreach ($all_tools_list as &$tool) { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
344 | if ($tool['image'] == 'scormbuilder.gif') { |
||
345 | // check if the published learnpath is visible for student |
||
346 | $lpId = self::getPublishedLpIdFromLink($tool['link']); |
||
347 | |||
348 | if (!api_is_allowed_to_edit(null, true) && |
||
349 | !learnpath::is_lp_visible_for_student( |
||
350 | $lpId, |
||
351 | api_get_user_id(), |
||
352 | api_get_course_info(), |
||
353 | api_get_session_id() |
||
354 | ) |
||
355 | ) { |
||
356 | continue; |
||
357 | } |
||
358 | } |
||
359 | |||
360 | if (api_get_session_id() != 0 && |
||
361 | in_array($tool['name'], ['course_maintenance', 'course_setting']) |
||
362 | ) { |
||
363 | continue; |
||
364 | } |
||
365 | |||
366 | if (!($i % 2)) { |
||
367 | $html .= "<tr valign=\"top\">"; |
||
368 | } |
||
369 | |||
370 | // NOTE : Table contains only the image file name, not full path |
||
371 | if (stripos($tool['link'], 'http://') === false && |
||
372 | stripos($tool['link'], 'https://') === false && |
||
373 | stripos($tool['link'], 'ftp://') === false |
||
374 | ) { |
||
375 | $tool['link'] = $web_code_path.$tool['link']; |
||
376 | } |
||
377 | $class = ''; |
||
378 | if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) { |
||
379 | $class = 'class="text-muted"'; |
||
380 | } |
||
381 | $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&'; |
||
382 | |||
383 | $tool['link'] = $tool['link']; |
||
384 | $html .= '<td width="50%" height="30">'; |
||
385 | |||
386 | if (strpos($tool['name'], 'visio_') !== false) { |
||
387 | $html .= '<a '.$class.' href="javascript: void(0);" onclick="javascript: window.open(\''.htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'">'; |
||
388 | } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) { |
||
389 | $html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq().'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'" '.$class.'>'; |
||
390 | } else { |
||
391 | $target = isset($tool['target']) ? $tool['target'] : ''; |
||
392 | $html .= '<a href="'. |
||
393 | htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$target.'" '.$class.'>'; |
||
394 | } |
||
395 | |||
396 | $tool_name = self::translate_tool_name($tool); |
||
397 | $html .= Display::return_icon( |
||
398 | $tool['image'], |
||
399 | $tool_name, |
||
400 | [], |
||
401 | null, |
||
402 | ICON_SIZE_MEDIUM |
||
403 | ).' '.$tool_name. |
||
404 | '</a>'; |
||
405 | |||
406 | // This part displays the links to hide or remove a tool. |
||
407 | // These links are only visible by the course manager. |
||
408 | $lnk = []; |
||
409 | if (api_is_allowed_to_edit(null, true) && !api_is_coach()) { |
||
410 | if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) { |
||
411 | $link['name'] = Display::returnFontAwesomeIcon('minus'); |
||
412 | $link['title'] = get_lang('Deactivate'); |
||
413 | $link['cmd'] = 'hide=yes'; |
||
414 | $lnk[] = $link; |
||
415 | } |
||
416 | |||
417 | if ($course_tool_category == TOOL_PUBLIC_BUT_HIDDEN) { |
||
418 | //$link['name'] = Display::return_icon('add.gif', get_lang('Activate')); |
||
419 | $link['name'] = Display::returnFontAwesomeIcon('plus'); |
||
420 | $link['title'] = get_lang('Activate'); |
||
421 | $link['cmd'] = 'restore=yes'; |
||
422 | $lnk[] = $link; |
||
423 | |||
424 | if ($tool['added_tool'] == 1) { |
||
425 | //$link['name'] = Display::return_icon('delete.gif', get_lang('Remove')); |
||
426 | $link['name'] = Display::returnFontAwesomeIcon('trash'); |
||
427 | $link['title'] = get_lang('Remove'); |
||
428 | $link['cmd'] = 'remove=yes'; |
||
429 | $lnk[] = $link; |
||
430 | } |
||
431 | } |
||
432 | if (isset($tool['adminlink'])) { |
||
433 | $html .= '<a href="'.$tool['adminlink'].'">'. |
||
434 | Display::return_icon('edit.gif', get_lang('Edit')).'</a>'; |
||
435 | } |
||
436 | } |
||
437 | if (api_is_platform_admin() && !api_is_coach()) { |
||
438 | if ($tool['visibility'] == 2) { |
||
439 | $link['name'] = Display::returnFontAwesomeIcon('undo'); |
||
440 | $link['title'] = get_lang('Activate'); |
||
441 | $link['cmd'] = 'hide=yes'; |
||
442 | $lnk[] = $link; |
||
443 | |||
444 | if ($tool['added_tool'] == 1) { |
||
445 | $link['name'] = get_lang('Delete'); |
||
446 | $link['cmd'] = 'askDelete=yes'; |
||
447 | $lnk[] = $link; |
||
448 | } |
||
449 | } |
||
450 | if ($tool['visibility'] == 0 && $tool['added_tool'] == 0) { |
||
451 | $link['name'] = Display::returnFontAwesomeIcon('trash'); |
||
452 | $link['title'] = get_lang('Remove'); |
||
453 | $link['cmd'] = 'remove=yes'; |
||
454 | $lnk[] = $link; |
||
455 | } |
||
456 | } |
||
457 | if (is_array($lnk)) { |
||
458 | $html .= '<div class="pull-right">'; |
||
459 | $html .= '<div class="btn-options">'; |
||
460 | $html .= '<div class="btn-group btn-group-sm" role="group">'; |
||
461 | foreach ($lnk as &$this_link) { |
||
462 | if (!isset($tool['adminlink'])) { |
||
463 | $html .= '<a class="btn btn-default" title='.$this_link['title'].' href="'.api_get_self().'?'.api_get_cidreq().'&id='.$tool['id'].'&'.$this_link['cmd'].'">'.$this_link['name'].'</a>'; |
||
464 | } |
||
465 | } |
||
466 | $html .= '</div>'; |
||
467 | $html .= '</div>'; |
||
468 | $html .= '</div>'; |
||
469 | } |
||
470 | $html .= "</td>"; |
||
471 | |||
472 | if ($i % 2) { |
||
473 | $html .= "</tr>"; |
||
474 | } |
||
475 | $i++; |
||
476 | } |
||
477 | } |
||
478 | |||
479 | if ($i % 2) { |
||
480 | $html .= "<td width=\"50%\"> </td></tr>"; |
||
481 | } |
||
482 | |||
483 | return $html; |
||
484 | } |
||
485 | |||
486 | /** |
||
487 | * Gets the tools of a certain category. Returns an array expected |
||
488 | * by show_tools_category(). |
||
489 | * |
||
490 | * @param string $course_tool_category contains the category of tools to |
||
491 | * display: "toolauthoring", "toolinteraction", "tooladmin", "tooladminplatform", "toolplugin" |
||
492 | * @param int $courseId Optional |
||
493 | * @param int $sessionId Optional |
||
494 | * |
||
495 | * @return array |
||
496 | */ |
||
497 | public static function get_tools_category($course_tool_category, $courseId = 0, $sessionId = 0) |
||
498 | { |
||
499 | $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); |
||
500 | $is_platform_admin = api_is_platform_admin(); |
||
501 | $all_tools_list = []; |
||
502 | |||
503 | // Condition for the session |
||
504 | $sessionId = $sessionId ?: api_get_session_id(); |
||
505 | $course_id = $courseId ?: api_get_course_int_id(); |
||
506 | $courseInfo = api_get_course_info_by_id($course_id); |
||
507 | $userId = api_get_user_id(); |
||
508 | $user = api_get_user_entity($userId); |
||
509 | $condition_session = api_get_session_condition( |
||
510 | $sessionId, |
||
511 | true, |
||
512 | true, |
||
513 | 't.session_id' |
||
514 | ); |
||
515 | |||
516 | $lpTable = Database::get_course_table(TABLE_LP_MAIN); |
||
517 | $tblLpCategory = Database::get_course_table(TABLE_LP_CATEGORY); |
||
518 | $orderBy = ' ORDER BY id '; |
||
519 | |||
520 | switch ($course_tool_category) { |
||
521 | case TOOL_STUDENT_VIEW: |
||
522 | $conditions = ' WHERE visibility = 1 AND |
||
523 | (category = "authoring" OR category = "interaction" OR category = "plugin") AND |
||
524 | t.name <> "notebookteacher" '; |
||
525 | if ((api_is_coach() || api_is_course_tutor() || $is_platform_admin) && |
||
526 | $_SESSION['studentview'] !== 'studentview' |
||
527 | ) { |
||
528 | $conditions = ' WHERE ( |
||
529 | visibility = 1 AND ( |
||
530 | category = "authoring" OR |
||
531 | category = "interaction" OR |
||
532 | category = "plugin" |
||
533 | ) OR |
||
534 | (t.name = "'.TOOL_TRACKING.'") |
||
535 | OR ( |
||
536 | image = "scormbuilder.gif" |
||
537 | ) |
||
538 | )'; |
||
539 | } |
||
540 | |||
541 | if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) { |
||
542 | $plugin = Positioning::create(); |
||
543 | $block = $plugin->get('block_course_if_initial_exercise_not_attempted'); |
||
544 | if ('true' === $block) { |
||
545 | $initialData = $plugin->getInitialExercise($course_id, $sessionId); |
||
546 | if ($initialData && isset($initialData['exercise_id'])) { |
||
547 | $results = Event::getExerciseResultsByUser( |
||
548 | $userId, |
||
549 | $initialData['exercise_id'], |
||
550 | $course_id, |
||
551 | $sessionId |
||
552 | ); |
||
553 | |||
554 | if (empty($results)) { |
||
555 | $conditions .= ' AND t.name = "positioning"'; |
||
556 | } |
||
557 | } |
||
558 | } |
||
559 | } |
||
560 | |||
561 | // Add order if there are LPs |
||
562 | $sql = "SELECT t.* FROM $course_tool_table t |
||
563 | LEFT JOIN $lpTable l |
||
564 | ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%')) |
||
565 | LEFT JOIN $tblLpCategory lc |
||
566 | ON (t.c_id = lc.c_id AND l.category_id = lc.iid) |
||
567 | $conditions AND |
||
568 | t.c_id = $course_id $condition_session |
||
569 | ORDER BY |
||
570 | CASE WHEN l.category_id IS NULL THEN 0 ELSE 1 END, |
||
571 | CASE WHEN l.display_order IS NULL THEN 0 ELSE 1 END, |
||
572 | lc.position, |
||
573 | l.display_order, |
||
574 | t.id"; |
||
575 | |||
576 | $orderBy = ''; |
||
577 | break; |
||
578 | case TOOL_AUTHORING: |
||
579 | $sql = "SELECT t.* FROM $course_tool_table t |
||
580 | LEFT JOIN $lpTable l |
||
581 | ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%')) |
||
582 | LEFT JOIN $tblLpCategory lc |
||
583 | ON (t.c_id = lc.c_id AND l.category_id = lc.iid) |
||
584 | WHERE |
||
585 | category = 'authoring' AND t.c_id = $course_id $condition_session |
||
586 | ORDER BY |
||
587 | CASE WHEN l.category_id IS NULL THEN 0 ELSE 1 END, |
||
588 | CASE WHEN l.display_order IS NULL THEN 0 ELSE 1 END, |
||
589 | lc.position, |
||
590 | l.display_order, |
||
591 | t.id"; |
||
592 | $orderBy = ''; |
||
593 | break; |
||
594 | case TOOL_INTERACTION: |
||
595 | $sql = "SELECT * FROM $course_tool_table t |
||
596 | WHERE category = 'interaction' AND c_id = $course_id $condition_session |
||
597 | "; |
||
598 | break; |
||
599 | case TOOL_ADMIN_VISIBLE: |
||
600 | $sql = "SELECT * FROM $course_tool_table t |
||
601 | WHERE category = 'admin' AND visibility ='1' AND c_id = $course_id $condition_session |
||
602 | "; |
||
603 | break; |
||
604 | case TOOL_ADMIN_PLATFORM: |
||
605 | $sql = "SELECT * FROM $course_tool_table t |
||
606 | WHERE category = 'admin' AND c_id = $course_id $condition_session |
||
607 | "; |
||
608 | break; |
||
609 | case TOOL_DRH: |
||
610 | $sql = "SELECT * FROM $course_tool_table t |
||
611 | WHERE t.name IN ('tracking') AND c_id = $course_id $condition_session |
||
612 | "; |
||
613 | break; |
||
614 | case TOOL_COURSE_PLUGIN: |
||
615 | //Other queries recover id, name, link, image, visibility, admin, address, added_tool, target, category and session_id |
||
616 | // but plugins are not present in the tool table, only globally and inside the course_settings table once configured |
||
617 | $sql = "SELECT * FROM $course_tool_table t |
||
618 | WHERE category = 'plugin' AND name <> 'courseblock' AND c_id = $course_id $condition_session |
||
619 | "; |
||
620 | break; |
||
621 | } |
||
622 | $sql .= $orderBy; |
||
623 | $result = Database::query($sql); |
||
624 | $tools = []; |
||
625 | while ($row = Database::fetch_assoc($result)) { |
||
626 | $tools[] = $row; |
||
627 | } |
||
628 | |||
629 | // Get the list of hidden tools - this might imply performance slowdowns |
||
630 | // if the course homepage is loaded many times, so the list of hidden |
||
631 | // tools might benefit from a shared memory storage later on |
||
632 | $list = api_get_settings('Tools', 'list', api_get_current_access_url_id()); |
||
633 | |||
634 | $hide_list = []; |
||
635 | $check = false; |
||
636 | foreach ($list as $line) { |
||
637 | // Admin can see all tools even if the course_hide_tools configuration is set |
||
638 | if ($is_platform_admin) { |
||
639 | continue; |
||
640 | } |
||
641 | if ($line['variable'] === 'course_hide_tools' && $line['selected_value'] === 'true') { |
||
642 | $hide_list[] = $line['subkey']; |
||
643 | $check = true; |
||
644 | } |
||
645 | } |
||
646 | |||
647 | $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); |
||
648 | // If exists same tool (by name) from session in base course then avoid it. Allow them pass in other cases |
||
649 | $tools = array_filter($tools, function (array $toolToFilter) use ($tools) { |
||
650 | if (!empty($toolToFilter['session_id'])) { |
||
651 | foreach ($tools as $originalTool) { |
||
652 | if ($toolToFilter['name'] == $originalTool['name'] && empty($originalTool['session_id'])) { |
||
653 | return false; |
||
654 | } |
||
655 | } |
||
656 | } |
||
657 | |||
658 | return true; |
||
659 | }); |
||
660 | |||
661 | $isAllowToEdit = api_is_allowed_to_edit(null, true); |
||
662 | $showInvisibleLpsForStudents = api_get_configuration_value('show_invisible_lp_in_course_home'); |
||
663 | foreach ($tools as $temp_row) { |
||
664 | $add = false; |
||
665 | if ($check) { |
||
666 | if (!in_array($temp_row['name'], $hide_list)) { |
||
667 | $add = true; |
||
668 | } |
||
669 | } else { |
||
670 | $add = true; |
||
671 | } |
||
672 | |||
673 | if (false === $showInvisibleLpsForStudents && |
||
674 | false === $isAllowToEdit && |
||
675 | $allowEditionInSession && !empty($sessionId) |
||
676 | ) { |
||
677 | // Checking if exist row in session |
||
678 | $criteria = [ |
||
679 | 'cId' => $course_id, |
||
680 | 'name' => $temp_row['name'], |
||
681 | 'sessionId' => $sessionId, |
||
682 | ]; |
||
683 | /** @var CTool $toolObj */ |
||
684 | $toolObj = Database::getManager()->getRepository('ChamiloCourseBundle:CTool')->findOneBy($criteria); |
||
685 | if ($toolObj && $toolObj->getVisibility() == false) { |
||
686 | continue; |
||
687 | } |
||
688 | } |
||
689 | |||
690 | switch ($temp_row['image']) { |
||
691 | case 'scormbuilder.gif': |
||
692 | $lpId = self::getPublishedLpIdFromLink($temp_row['link']); |
||
693 | $lp = new learnpath( |
||
694 | $courseInfo['code'], |
||
695 | $lpId, |
||
696 | $userId |
||
697 | ); |
||
698 | $path = $lp->get_preview_image_path(ICON_SIZE_BIG); |
||
699 | |||
700 | if ($isAllowToEdit) { |
||
701 | $add = true; |
||
702 | } else { |
||
703 | if ($showInvisibleLpsForStudents) { |
||
704 | $add = true; |
||
705 | } else { |
||
706 | $add = learnpath::is_lp_visible_for_student( |
||
707 | $lpId, |
||
708 | $userId, |
||
709 | $courseInfo, |
||
710 | $sessionId |
||
711 | ); |
||
712 | // Check if LP is visible. |
||
713 | $visibility = api_get_item_visibility($courseInfo, TOOL_LEARNPATH, $lpId, $sessionId); |
||
714 | if (1 !== $visibility) { |
||
715 | $add = false; |
||
716 | } |
||
717 | } |
||
718 | } |
||
719 | if ($path) { |
||
720 | $temp_row['custom_image'] = $path; |
||
721 | } |
||
722 | break; |
||
723 | case 'lp_category.gif': |
||
724 | $lpCategory = self::getPublishedLpCategoryFromLink($temp_row['link']); |
||
725 | if ($showInvisibleLpsForStudents) { |
||
726 | $add = true; |
||
727 | } else { |
||
728 | $add = learnpath::categoryIsVisibleForStudent($lpCategory, $user); |
||
729 | } |
||
730 | |||
731 | break; |
||
732 | } |
||
733 | |||
734 | if ($add) { |
||
735 | $all_tools_list[] = $temp_row; |
||
736 | } |
||
737 | } |
||
738 | |||
739 | // Grabbing all the links that have the property on_homepage set to 1 |
||
740 | $course_link_table = Database::get_course_table(TABLE_LINK); |
||
741 | $course_item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); |
||
742 | $condition_session = api_get_session_condition( |
||
743 | $sessionId, |
||
744 | true, |
||
745 | true, |
||
746 | 'tip.session_id' |
||
747 | ); |
||
748 | |||
749 | $filterVisibility = ''; |
||
750 | if (!($is_platform_admin || api_is_course_admin())) { |
||
751 | if ($sessionId) { |
||
752 | $filterVisibility = ' AND ( |
||
753 | (tip.visibility = 1 AND (tip.session_id = 0 OR tip.session_id IS NULL)) OR |
||
754 | (tip.visibility = 1 AND tip.session_id <> 0) |
||
755 | ) '; |
||
756 | |||
757 | if (api_is_coach()) { |
||
758 | $filterVisibility = ' AND ( |
||
759 | (tip.visibility = 1 AND (tip.session_id = 0 OR tip.session_id IS NULL)) OR |
||
760 | (tip.visibility IN (1, 2) AND tip.session_id <> 0) |
||
761 | ) '; |
||
762 | } |
||
763 | } else { |
||
764 | $filterVisibility = ' AND tip.visibility = 1 '; |
||
765 | } |
||
766 | } |
||
767 | |||
768 | switch ($course_tool_category) { |
||
769 | case TOOL_ADMIN: |
||
770 | case TOOL_AUTHORING: |
||
771 | $sql_links = " |
||
772 | SELECT DISTINCT tl.*, tip.visibility |
||
773 | FROM $course_link_table tl |
||
774 | LEFT JOIN $course_item_property_table tip |
||
775 | ON tip.tool='link' AND tip.ref=tl.id |
||
776 | WHERE |
||
777 | tl.c_id = $course_id AND |
||
778 | tip.c_id = $course_id AND |
||
779 | tl.on_homepage='1' $condition_session |
||
780 | ORDER BY tip.visibility"; |
||
781 | break; |
||
782 | case TOOL_INTERACTION: |
||
783 | $sql_links = null; |
||
784 | break; |
||
785 | case TOOL_STUDENT_VIEW: |
||
786 | $sql_links = " |
||
787 | SELECT DISTINCT tl.*, tip.visibility |
||
788 | FROM $course_link_table tl |
||
789 | LEFT JOIN $course_item_property_table tip |
||
790 | ON tip.tool='link' AND tip.ref=tl.id |
||
791 | WHERE |
||
792 | tl.c_id = $course_id AND |
||
793 | tip.c_id = $course_id AND |
||
794 | tl.on_homepage ='1' |
||
795 | $condition_session |
||
796 | $filterVisibility |
||
797 | ORDER BY tip.visibility"; |
||
798 | break; |
||
799 | default: |
||
800 | $sql_links = null; |
||
801 | break; |
||
802 | } |
||
803 | |||
804 | // Edited by Kevin Van Den Haute ([email protected]) for integrating Smartblogs |
||
805 | if ($sql_links != null) { |
||
806 | $result_links = Database::query($sql_links); |
||
807 | if (Database::num_rows($result_links) > 0) { |
||
808 | $linkUrl = api_get_path(WEB_CODE_PATH).'link/link.php?action=editlink'; |
||
809 | $added = []; |
||
810 | while ($links_row = Database::fetch_array($result_links, 'ASSOC')) { |
||
811 | if (in_array($links_row['iid'], $added)) { |
||
812 | continue; |
||
813 | } |
||
814 | $properties = []; |
||
815 | $properties['id'] = $links_row['id']; |
||
816 | $properties['iid'] = $links_row['iid']; |
||
817 | $properties['name'] = $links_row['title']; |
||
818 | $properties['session_id'] = $links_row['session_id']; |
||
819 | $properties['link'] = $links_row['url']; |
||
820 | |||
821 | // For students, check if link is visible in the session. |
||
822 | if ($sessionId && !($is_platform_admin || api_is_course_admin())) { |
||
823 | $visibility = api_get_item_visibility($courseInfo, TOOL_LINK, $links_row['iid'], $sessionId); |
||
824 | if (1 !== $visibility) { |
||
825 | continue; |
||
826 | } |
||
827 | } |
||
828 | |||
829 | $properties['visibility'] = $links_row['visibility']; |
||
830 | $properties['image'] = $links_row['visibility'] == '0' ? 'file_html.png' : 'file_html.png'; |
||
831 | $properties['adminlink'] = $linkUrl.'&id='.$links_row['id'].'&cidReq='.$courseInfo['code']; |
||
832 | $properties['target'] = $links_row['target']; |
||
833 | $tmp_all_tools_list[] = $properties; |
||
834 | $added[] = $links_row['iid']; |
||
835 | } |
||
836 | } |
||
837 | } |
||
838 | |||
839 | if (isset($tmp_all_tools_list)) { |
||
840 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
||
841 | foreach ($tmp_all_tools_list as $tool) { |
||
842 | if ($tool['image'] === 'blog.gif') { |
||
843 | // Get blog id |
||
844 | $blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link'])); |
||
845 | |||
846 | // Get blog members |
||
847 | if ($is_platform_admin) { |
||
848 | $sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user |
||
849 | WHERE blog_id = ".$blog_id; |
||
850 | } else { |
||
851 | $sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user |
||
852 | WHERE blog_id = ".$blog_id." AND user_id = ".$userId; |
||
853 | } |
||
854 | $result = Database::query($sql); |
||
855 | if (Database::num_rows($result) > 0) { |
||
856 | $all_tools_list[] = $tool; |
||
857 | } |
||
858 | } else { |
||
859 | $all_tools_list[] = $tool; |
||
860 | } |
||
861 | } |
||
862 | } |
||
863 | |||
864 | return self::filterPluginTools($all_tools_list, $course_tool_category); |
||
865 | } |
||
866 | |||
867 | /** |
||
868 | * Displays the tools of a certain category. |
||
869 | * |
||
870 | * @param array $all_tools_list List of tools as returned by get_tools_category() |
||
871 | * |
||
872 | * @return array |
||
873 | */ |
||
874 | public static function show_tools_category($all_tools_list) |
||
875 | { |
||
876 | $_user = api_get_user_info(); |
||
877 | $theme = api_get_setting('homepage_view'); |
||
878 | |||
879 | if ($theme === 'vertical_activity') { |
||
880 | //ordering by get_lang name |
||
881 | $order_tool_list = []; |
||
882 | if (is_array($all_tools_list) && count($all_tools_list) > 0) { |
||
883 | foreach ($all_tools_list as $key => $new_tool) { |
||
884 | $tool_name = self::translate_tool_name($new_tool); |
||
885 | $order_tool_list[$key] = $tool_name; |
||
886 | } |
||
887 | natsort($order_tool_list); |
||
888 | $my_temp_tool_array = []; |
||
889 | foreach ($order_tool_list as $key => $new_tool) { |
||
890 | $my_temp_tool_array[] = $all_tools_list[$key]; |
||
891 | } |
||
892 | $all_tools_list = $my_temp_tool_array; |
||
893 | } else { |
||
894 | $all_tools_list = []; |
||
895 | } |
||
896 | } |
||
897 | $web_code_path = api_get_path(WEB_CODE_PATH); |
||
898 | $session_id = api_get_session_id(); |
||
899 | $courseId = api_get_course_int_id(); |
||
900 | $is_platform_admin = api_is_platform_admin(); |
||
901 | $courseInfo = api_get_course_info(); |
||
902 | $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); |
||
903 | |||
904 | if ($session_id == 0) { |
||
905 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin(); |
||
906 | } else { |
||
907 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach(); |
||
908 | if ($allowEditionInSession) { |
||
909 | $is_allowed_to_edit = (api_is_allowed_to_edit(null, true) && |
||
910 | api_is_coach($session_id, $courseId)) || $is_platform_admin; |
||
911 | } |
||
912 | } |
||
913 | |||
914 | $disableUsers = 3 === (int) $courseInfo['visibility'] && |
||
915 | api_get_configuration_value('disable_change_user_visibility_for_public_courses'); |
||
916 | |||
917 | $items = []; |
||
918 | $app_plugin = new AppPlugin(); |
||
919 | $toolRepo = Database::getManager()->getRepository('ChamiloCourseBundle:CTool'); |
||
920 | if (isset($all_tools_list)) { |
||
921 | $lnk = ''; |
||
922 | foreach ($all_tools_list as &$tool) { |
||
923 | $allowChangeVisibility = true; |
||
924 | $showIcon = true; |
||
925 | if ('user/user.php' === $tool['link'] && $disableUsers) { |
||
926 | $allowChangeVisibility = false; |
||
927 | $tool['visibility'] = 0; |
||
928 | $showIcon = $is_allowed_to_edit; |
||
929 | } |
||
930 | $item = []; |
||
931 | $studentview = false; |
||
932 | $tool['original_link'] = $tool['link']; |
||
933 | |||
934 | if ($tool['image'] === 'lp_category.gif') { |
||
935 | if ($session_id) { |
||
936 | if (api_is_coach() || api_is_allowed_to_edit()) { |
||
937 | $lpCategory = self::getPublishedLpCategoryFromLink($tool['link']); |
||
938 | $itemInfo = api_get_item_property_info( |
||
939 | $courseId, |
||
940 | TOOL_LEARNPATH_CATEGORY, |
||
941 | $lpCategory->getId(), |
||
942 | $session_id |
||
943 | ); |
||
944 | |||
945 | if ($itemInfo && 0 === (int) $itemInfo['visibility']) { |
||
946 | $tool['image'] = 'lp_category_na.gif'; |
||
947 | } |
||
948 | } else { |
||
949 | $categoryInSessionName = str_replace('id_session', $session_id, $tool['name']); |
||
950 | $criteria = [ |
||
951 | 'cId' => $courseId, |
||
952 | 'name' => $categoryInSessionName, |
||
953 | 'sessionId' => $session_id, |
||
954 | ]; |
||
955 | /** @var CTool $tool */ |
||
956 | $toolObj = $toolRepo->findOneBy($criteria); |
||
957 | if ($toolObj) { |
||
958 | $visibility = (int) $toolObj->getVisibility(); |
||
959 | if (0 === $visibility) { |
||
960 | continue; |
||
961 | } |
||
962 | } |
||
963 | } |
||
964 | } |
||
965 | } |
||
966 | |||
967 | if ($tool['image'] === 'scormbuilder.gif') { |
||
968 | // Check if the published learnpath is visible for student |
||
969 | $lpId = self::getPublishedLpIdFromLink($tool['link']); |
||
970 | if ($session_id && api_is_coach()) { |
||
971 | $itemInfo = api_get_item_property_info( |
||
972 | $courseId, |
||
973 | TOOL_LEARNPATH, |
||
974 | $lpId, |
||
975 | $session_id |
||
976 | ); |
||
977 | |||
978 | if ($itemInfo && 0 === (int) $itemInfo['visibility']) { |
||
979 | $tool['image'] = 'scormbuilder_na.gif'; |
||
980 | } |
||
981 | } |
||
982 | |||
983 | if (api_is_allowed_to_edit(null, true)) { |
||
984 | $studentview = true; |
||
985 | } |
||
986 | if (!api_is_allowed_to_edit(null, true) && |
||
987 | !learnpath::is_lp_visible_for_student( |
||
988 | $lpId, |
||
989 | api_get_user_id(), |
||
990 | $courseInfo, |
||
991 | $session_id |
||
992 | ) |
||
993 | ) { |
||
994 | continue; |
||
995 | } |
||
996 | } |
||
997 | |||
998 | if ($session_id != 0 && in_array($tool['name'], ['course_setting'])) { |
||
999 | continue; |
||
1000 | } |
||
1001 | |||
1002 | if (false === $showIcon) { |
||
1003 | continue; |
||
1004 | } |
||
1005 | |||
1006 | // This part displays the links to hide or remove a tool. |
||
1007 | // These links are only visible by the course manager. |
||
1008 | unset($lnk); |
||
1009 | |||
1010 | $item['extra'] = null; |
||
1011 | $toolAdmin = isset($tool['admin']) ? $tool['admin'] : ''; |
||
1012 | $extraClass = ''; |
||
1013 | $isSessionToolVisible = false; |
||
1014 | if ($is_allowed_to_edit && $allowChangeVisibility) { |
||
1015 | if (empty($session_id)) { |
||
1016 | if (isset($tool['id'])) { |
||
1017 | if ($tool['visibility'] == '1' && $toolAdmin != '1') { |
||
1018 | $isSessionToolVisible = true; |
||
1019 | $link['name'] = '<em |
||
1020 | id="'.'linktool_'.$tool['iid'].'" |
||
1021 | class="fa fa-eye" |
||
1022 | title="'.get_lang('Deactivate').'"></em>'; |
||
1023 | $link['cmd'] = 'hide=yes'; |
||
1024 | $lnk[] = $link; |
||
1025 | } |
||
1026 | if ($tool['visibility'] == '0' && $toolAdmin != '1') { |
||
1027 | $isSessionToolVisible = false; |
||
1028 | $link['name'] = '<em |
||
1029 | id="'.'linktool_'.$tool['iid'].'" |
||
1030 | class="fa fa-eye-slash text-muted" |
||
1031 | title="'.get_lang('Activate').'"></em>'; |
||
1032 | $link['cmd'] = 'restore=yes'; |
||
1033 | $extraClass = 'text-muted'; |
||
1034 | $lnk[] = $link; |
||
1035 | } |
||
1036 | } |
||
1037 | } elseif ($allowEditionInSession) { |
||
1038 | $criteria = [ |
||
1039 | 'cId' => $courseId, |
||
1040 | 'name' => $tool['name'], |
||
1041 | 'sessionId' => $session_id, |
||
1042 | ]; |
||
1043 | /** @var CTool $tool */ |
||
1044 | $toolObj = $toolRepo->findOneBy($criteria); |
||
1045 | if ($toolObj) { |
||
1046 | $visibility = (int) $toolObj->getVisibility(); |
||
1047 | switch ($visibility) { |
||
1048 | case 0: |
||
1049 | $isSessionToolVisible = false; |
||
1050 | if (in_array($tool['image'], ['scormbuilder.png', 'scormbuilder.gif'])) { |
||
1051 | $info = pathinfo($tool['image']); |
||
1052 | $basename = basename($tool['image'], '.'.$info['extension']); |
||
1053 | $tool['image'] = $basename.'_na.'.$info['extension']; |
||
1054 | } |
||
1055 | $link['name'] = '<em |
||
1056 | id="'.'linktool_'.$tool['iid'].'" |
||
1057 | class="fa fa-eye-slash text-muted" |
||
1058 | title="'.get_lang('Activate').'"></em>'; |
||
1059 | $link['cmd'] = 'restore=yes'; |
||
1060 | $extraClass = 'text-muted'; |
||
1061 | $lnk[] = $link; |
||
1062 | break; |
||
1063 | case 1: |
||
1064 | $isSessionToolVisible = true; |
||
1065 | $link['name'] = '<em |
||
1066 | id="'.'linktool_'.$tool['iid'].'" |
||
1067 | class="fa fa-eye" |
||
1068 | title="'.get_lang('Deactivate').'"></em>'; |
||
1069 | $link['cmd'] = 'hide=yes'; |
||
1070 | $lnk[] = $link; |
||
1071 | break; |
||
1072 | } |
||
1073 | } else { |
||
1074 | $isSessionToolVisible = true; |
||
1075 | $link['name'] = '<em |
||
1076 | id="'.'linktool_'.$tool['iid'].'" |
||
1077 | class="fa fa-eye" |
||
1078 | title="'.get_lang('Deactivate').'"></em>'; |
||
1079 | $link['cmd'] = 'hide=yes'; |
||
1080 | $lnk[] = $link; |
||
1081 | } |
||
1082 | } |
||
1083 | if (!empty($tool['adminlink']) && $tool['session_id'] == $session_id) { |
||
1084 | $item['extra'] = '<a href="'.$tool['adminlink'].'">'. |
||
1085 | Display::return_icon('edit.gif', get_lang('Edit')). |
||
1086 | '</a>'; |
||
1087 | } |
||
1088 | } |
||
1089 | |||
1090 | // Both checks are necessary as is_platform_admin doesn't take student view into account |
||
1091 | if ($is_platform_admin && $is_allowed_to_edit) { |
||
1092 | if ($toolAdmin != '1') { |
||
1093 | $link['cmd'] = 'hide=yes'; |
||
1094 | } |
||
1095 | } |
||
1096 | |||
1097 | $item['visibility'] = ''; |
||
1098 | if (isset($lnk) && is_array($lnk)) { |
||
1099 | foreach ($lnk as $this_link) { |
||
1100 | if (empty($tool['adminlink'])) { |
||
1101 | $item['visibility'] .= '<a |
||
1102 | class="make_visible_and_invisible" |
||
1103 | href="'.api_get_self().'?'.api_get_cidreq().'&id='.$tool['iid'].'&'.$this_link['cmd'].'" |
||
1104 | >'.$this_link['name'].'</a>'; |
||
1105 | } |
||
1106 | } |
||
1107 | } |
||
1108 | |||
1109 | // NOTE : Table contains only the image file name, not full path |
||
1110 | if (stripos($tool['link'], 'http://') === false && |
||
1111 | stripos($tool['link'], 'https://') === false && |
||
1112 | stripos($tool['link'], 'ftp://') === false |
||
1113 | ) { |
||
1114 | $tool['link'] = $web_code_path.$tool['link']; |
||
1115 | } |
||
1116 | |||
1117 | $class = ''; |
||
1118 | $info = pathinfo($tool['image']); |
||
1119 | $basename = basename($tool['image'], '.'.$info['extension']); |
||
1120 | |||
1121 | if ($tool['visibility'] == '0' && $toolAdmin != '1') { |
||
1122 | $class = 'text-muted'; |
||
1123 | if (!strpos($tool['image'], '_na')) { |
||
1124 | $tool['image'] = $basename.'_na.'.$info['extension']; |
||
1125 | } |
||
1126 | } |
||
1127 | |||
1128 | if ($is_allowed_to_edit && $allowChangeVisibility && |
||
1129 | ($tool['image'] === 'scormbuilder.gif' || $tool['image'] === 'scormbuilder_na.gif') |
||
1130 | ) { |
||
1131 | if (false === $isSessionToolVisible) { |
||
1132 | $tool['image'] = 'scormbuilder_na.gif'; |
||
1133 | } else { |
||
1134 | $tool['image'] = 'scormbuilder.gif'; |
||
1135 | } |
||
1136 | } |
||
1137 | |||
1138 | if ($is_allowed_to_edit && $allowChangeVisibility && |
||
1139 | ($tool['image'] === 'lp_category.gif' || $tool['image'] === 'lp_category_na.gif') |
||
1140 | ) { |
||
1141 | if (false === $isSessionToolVisible) { |
||
1142 | $tool['image'] = 'lp_category_na.gif'; |
||
1143 | } else { |
||
1144 | $tool['image'] = 'lp_category.gif'; |
||
1145 | } |
||
1146 | } |
||
1147 | |||
1148 | $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&'; |
||
1149 | |||
1150 | // If it's a link, we don't add the cidReq |
||
1151 | if ($tool['image'] === 'file_html.png' || $tool['image'] === 'file_html_na.png') { |
||
1152 | $tool['link'] = $tool['link']; |
||
1153 | } else { |
||
1154 | if (!in_array($tool['image'], ['lp_category.gif', 'lp_category_na.gif'])) { |
||
1155 | $tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq(true, false).'&gidReq=0'; |
||
1156 | } |
||
1157 | } |
||
1158 | |||
1159 | $toolIid = isset($tool['iid']) ? $tool['iid'] : null; |
||
1160 | |||
1161 | //@todo this visio stuff should be removed |
||
1162 | if (strpos($tool['name'], 'visio_') !== false) { |
||
1163 | $tool_link_params = [ |
||
1164 | 'id' => 'tooldesc_'.$toolIid, |
||
1165 | 'href' => '"javascript: void(0);"', |
||
1166 | 'class' => $class, |
||
1167 | 'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', |
||
1168 | 'target' => $tool['target'], |
||
1169 | ]; |
||
1170 | } elseif (strpos($tool['name'], 'chat') !== false && |
||
1171 | api_get_course_setting('allow_open_chat_window') |
||
1172 | ) { |
||
1173 | $tool_link_params = [ |
||
1174 | 'id' => 'tooldesc_'.$toolIid, |
||
1175 | 'class' => $class, |
||
1176 | 'href' => 'javascript: void(0);', |
||
1177 | 'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', //Chat Open Windows |
||
1178 | 'target' => $tool['target'], |
||
1179 | ]; |
||
1180 | } else { |
||
1181 | $tool_link_params = [ |
||
1182 | 'id' => 'tooldesc_'.$toolIid, |
||
1183 | 'href' => $tool['link'], |
||
1184 | 'class' => "$class $extraClass ", |
||
1185 | 'target' => $tool['target'], |
||
1186 | ]; |
||
1187 | } |
||
1188 | |||
1189 | $tool_name = self::translate_tool_name($tool); |
||
1190 | |||
1191 | // Including Courses Plugins |
||
1192 | // Creating title and the link |
||
1193 | if (isset($tool['category']) && $tool['category'] === 'plugin') { |
||
1194 | $plugin_info = $app_plugin->getPluginInfo($tool['name'], true); |
||
1195 | if (isset($plugin_info) && isset($plugin_info['title'])) { |
||
1196 | $tool_name = $plugin_info['title']; |
||
1197 | } |
||
1198 | |||
1199 | if (!file_exists(api_get_path(SYS_CODE_PATH).'img/'.$tool['image']) && |
||
1200 | !file_exists(api_get_path(SYS_CODE_PATH).'img/icons/64/'.$tool['image'])) { |
||
1201 | $tool['image'] = 'plugins.png'; |
||
1202 | } |
||
1203 | $tool_link_params['href'] = api_get_path(WEB_PLUGIN_PATH) |
||
1204 | .$tool['original_link'].$qm_or_amp.api_get_cidreq(); |
||
1205 | } |
||
1206 | |||
1207 | // Use in the course home |
||
1208 | $icon = Display::return_icon( |
||
1209 | $tool['image'], |
||
1210 | $tool_name, |
||
1211 | ['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid], |
||
1212 | ICON_SIZE_BIG, |
||
1213 | false |
||
1214 | ); |
||
1215 | |||
1216 | // Used in the top bar |
||
1217 | $iconMedium = Display::return_icon( |
||
1218 | $tool['image'], |
||
1219 | $tool_name, |
||
1220 | ['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid], |
||
1221 | ICON_SIZE_MEDIUM, |
||
1222 | false |
||
1223 | ); |
||
1224 | |||
1225 | // Used for vertical navigation |
||
1226 | $iconSmall = Display::return_icon( |
||
1227 | $tool['image'], |
||
1228 | $tool_name, |
||
1229 | ['class' => 'tool-img', 'id' => 'toolimage_'.$toolIid], |
||
1230 | ICON_SIZE_SMALL, |
||
1231 | false |
||
1232 | ); |
||
1233 | |||
1234 | // Validation when belongs to a session |
||
1235 | $session_img = api_get_session_image( |
||
1236 | $tool['session_id'], |
||
1237 | !empty($_user['status']) ? $_user['status'] : '' |
||
1238 | ); |
||
1239 | if ($studentview) { |
||
1240 | $tool_link_params['href'] .= '&isStudentView=true'; |
||
1241 | } |
||
1242 | $item['url_params'] = $tool_link_params; |
||
1243 | $item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params); |
||
1244 | $item['only_icon'] = $icon; |
||
1245 | $item['only_icon_medium'] = $iconMedium; |
||
1246 | $item['only_icon_small'] = $iconSmall; |
||
1247 | $item['only_href'] = $tool_link_params['href']; |
||
1248 | $item['tool'] = $tool; |
||
1249 | $item['name'] = $tool_name; |
||
1250 | $tool_link_params['id'] = 'is'.$tool_link_params['id']; |
||
1251 | $item['link'] = Display::url( |
||
1252 | $tool_name.$session_img, |
||
1253 | $tool_link_params['href'], |
||
1254 | $tool_link_params |
||
1255 | ); |
||
1256 | $items[] = $item; |
||
1257 | } |
||
1258 | } |
||
1259 | |||
1260 | foreach ($items as &$item) { |
||
1261 | $originalImage = self::getToolIcon($item, ICON_SIZE_BIG); |
||
1262 | $item['tool']['only_icon_medium'] = self::getToolIcon($item, ICON_SIZE_MEDIUM, false); |
||
1263 | $item['tool']['only_icon_small'] = self::getToolIcon($item, ICON_SIZE_SMALL, false); |
||
1264 | if ($theme === 'activity_big') { |
||
1265 | $item['tool']['image'] = Display::url( |
||
1266 | $originalImage, |
||
1267 | $item['url_params']['href'], |
||
1268 | $item['url_params'] |
||
1269 | ); |
||
1270 | } |
||
1271 | } |
||
1272 | |||
1273 | return $items; |
||
1274 | } |
||
1275 | |||
1276 | /** |
||
1277 | * Shows the general data for a particular meeting. |
||
1278 | * |
||
1279 | * @param int $id_session |
||
1280 | * |
||
1281 | * @return string session data |
||
1282 | */ |
||
1283 | public static function show_session_data($id_session) |
||
1284 | { |
||
1285 | $sessionInfo = api_get_session_info($id_session); |
||
1286 | |||
1287 | if (empty($sessionInfo)) { |
||
1288 | return ''; |
||
1289 | } |
||
1290 | |||
1291 | $table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); |
||
1292 | $sql = 'SELECT name FROM '.$table.' |
||
1293 | WHERE id = "'.intval($sessionInfo['session_category_id']).'"'; |
||
1294 | $rs_category = Database::query($sql); |
||
1295 | $session_category = ''; |
||
1296 | if (Database::num_rows($rs_category) > 0) { |
||
1297 | $rows_session_category = Database::store_result($rs_category); |
||
1298 | $rows_session_category = $rows_session_category[0]; |
||
1299 | $session_category = $rows_session_category['name']; |
||
1300 | } |
||
1301 | |||
1302 | $coachInfo = api_get_user_info($sessionInfo['id_coach']); |
||
1303 | |||
1304 | $output = ''; |
||
1305 | if (!empty($session_category)) { |
||
1306 | $output .= '<tr><td>'.get_lang('SessionCategory').': '.'<b>'.$session_category.'</b></td></tr>'; |
||
1307 | } |
||
1308 | $dateInfo = SessionManager::parseSessionDates($sessionInfo); |
||
1309 | |||
1310 | $msgDate = $dateInfo['access']; |
||
1311 | $output .= '<tr> |
||
1312 | <td style="width:50%">'.get_lang('SessionName').': '.'<b>'.$sessionInfo['name'].'</b></td> |
||
1313 | <td>'.get_lang('GeneralCoach').': '.'<b>'.$coachInfo['complete_name'].'</b></td></tr>'; |
||
1314 | $output .= '<tr> |
||
1315 | <td>'.get_lang('SessionIdentifier').': '. |
||
1316 | Display::return_icon('star.png', ' ', ['align' => 'absmiddle']).' |
||
1317 | </td> |
||
1318 | <td>'.get_lang('Date').': '.'<b>'.$msgDate.'</b> |
||
1319 | </td> |
||
1320 | </tr>'; |
||
1321 | |||
1322 | return $output; |
||
1323 | } |
||
1324 | |||
1325 | /** |
||
1326 | * Retrieves the name-field within a tool-record and translates it on necessity. |
||
1327 | * |
||
1328 | * @param array $tool the input record |
||
1329 | * |
||
1330 | * @return string returns the name of the corresponding tool |
||
1331 | */ |
||
1332 | public static function translate_tool_name(&$tool) |
||
1333 | { |
||
1334 | static $already_translated_icons = [ |
||
1335 | 'file_html.gif', |
||
1336 | 'file_html_na.gif', |
||
1337 | 'file_html.png', |
||
1338 | 'file_html_na.png', |
||
1339 | 'scormbuilder.gif', |
||
1340 | 'scormbuilder_na.gif', |
||
1341 | 'blog.gif', |
||
1342 | 'blog_na.gif', |
||
1343 | 'external.gif', |
||
1344 | 'external_na.gif', |
||
1345 | ]; |
||
1346 | |||
1347 | $toolName = Security::remove_XSS(stripslashes(strip_tags($tool['name']))); |
||
1348 | |||
1349 | if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) { |
||
1350 | return $toolName; |
||
1351 | } |
||
1352 | |||
1353 | $toolName = api_underscore_to_camel_case($toolName); |
||
1354 | |||
1355 | if (isset($tool['category']) && 'plugin' !== $tool['category'] && |
||
1356 | isset($GLOBALS['Tool'.$toolName]) |
||
1357 | ) { |
||
1358 | return get_lang('Tool'.$toolName); |
||
1359 | } |
||
1360 | |||
1361 | return $toolName; |
||
1362 | } |
||
1363 | |||
1364 | /** |
||
1365 | * Get published learning path id from link inside course home. |
||
1366 | * |
||
1367 | * @param string Link to published lp |
||
1368 | * |
||
1369 | * @return int Learning path id |
||
1370 | */ |
||
1371 | public static function getPublishedLpIdFromLink($link) |
||
1372 | { |
||
1373 | $lpId = 0; |
||
1374 | $param = strstr($link, 'lp_id='); |
||
1375 | if (!empty($param)) { |
||
1376 | $paramList = explode('=', $param); |
||
1377 | if (isset($paramList[1])) { |
||
1378 | $lpId = (int) $paramList[1]; |
||
1379 | } |
||
1380 | } |
||
1381 | |||
1382 | return $lpId; |
||
1383 | } |
||
1384 | |||
1385 | /** |
||
1386 | * Get published learning path category from link inside course home. |
||
1387 | * |
||
1388 | * @param string $link |
||
1389 | * |
||
1390 | * @return CLpCategory |
||
1391 | */ |
||
1392 | public static function getPublishedLpCategoryFromLink($link) |
||
1393 | { |
||
1394 | $query = parse_url($link, PHP_URL_QUERY); |
||
1395 | parse_str($query, $params); |
||
1396 | $id = isset($params['id']) ? (int) $params['id'] : 0; |
||
1397 | $em = Database::getManager(); |
||
1398 | /** @var CLpCategory $category */ |
||
1399 | $category = $em->find('ChamiloCourseBundle:CLpCategory', $id); |
||
1400 | |||
1401 | return $category; |
||
1402 | } |
||
1403 | |||
1404 | /** |
||
1405 | * Show a navigation menu. |
||
1406 | */ |
||
1407 | public static function show_navigation_menu() |
||
1408 | { |
||
1409 | $blocks = self::getUserBlocks(); |
||
1410 | $class = null; |
||
1411 | $idLearn = null; |
||
1412 | $item = null; |
||
1413 | $marginLeft = 160; |
||
1414 | |||
1415 | $html = '<div id="toolnav">'; |
||
1416 | $html .= '<ul id="toolnavbox">'; |
||
1417 | |||
1418 | $showOnlyText = api_get_setting('show_navigation_menu') === 'text'; |
||
1419 | $showOnlyIcons = api_get_setting('show_navigation_menu') === 'icons'; |
||
1420 | |||
1421 | foreach ($blocks as $block) { |
||
1422 | $blockItems = $block['content']; |
||
1423 | foreach ($blockItems as $item) { |
||
1424 | $html .= '<li>'; |
||
1425 | if ($showOnlyText) { |
||
1426 | $class = 'text'; |
||
1427 | $marginLeft = 170; |
||
1428 | $show = $item['name']; |
||
1429 | } elseif ($showOnlyIcons) { |
||
1430 | $class = 'icons'; |
||
1431 | $marginLeft = 25; |
||
1432 | $show = $item['tool']['only_icon_small']; |
||
1433 | } else { |
||
1434 | $class = 'icons-text'; |
||
1435 | $show = $item['name'].$item['tool']['only_icon_small']; |
||
1436 | } |
||
1437 | |||
1438 | $item['url_params']['class'] = 'btn btn-default text-left '.$class; |
||
1439 | $html .= Display::url( |
||
1440 | $show, |
||
1441 | $item['only_href'], |
||
1442 | $item['url_params'] |
||
1443 | ); |
||
1444 | $html .= '</li>'; |
||
1445 | } |
||
1446 | } |
||
1447 | |||
1448 | $html .= '</ul>'; |
||
1449 | $html .= '<script>$(function() { |
||
1450 | $("#toolnavbox a").stop().animate({"margin-left":"-'.$marginLeft.'px"},1000); |
||
1451 | $("#toolnavbox > li").hover( |
||
1452 | function () { |
||
1453 | $("a",$(this)).stop().animate({"margin-left":"-2px"},200); |
||
1454 | $("span",$(this)).css("display","block"); |
||
1455 | }, |
||
1456 | function () { |
||
1457 | $("a",$(this)).stop().animate({"margin-left":"-'.$marginLeft.'px"},200); |
||
1458 | $("span",$(this)).css("display","initial"); |
||
1459 | } |
||
1460 | ); |
||
1461 | });</script>'; |
||
1462 | $html .= '</div>'; |
||
1463 | |||
1464 | return $html; |
||
1465 | } |
||
1466 | |||
1467 | /** |
||
1468 | * Show a toolbar with shortcuts to the course tool. |
||
1469 | * |
||
1470 | * @param int $orientation |
||
1471 | * |
||
1472 | * @return string |
||
1473 | */ |
||
1474 | public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) |
||
1475 | { |
||
1476 | $origin = api_get_origin(); |
||
1477 | $courseInfo = api_get_course_info(); |
||
1478 | if ($origin === 'learnpath') { |
||
1479 | return ''; |
||
1480 | } |
||
1481 | |||
1482 | $blocks = self::getUserBlocks(); |
||
1483 | $html = ''; |
||
1484 | if (!empty($blocks)) { |
||
1485 | $styleId = 'toolshortcuts_vertical'; |
||
1486 | if ($orientation == SHORTCUTS_HORIZONTAL) { |
||
1487 | $styleId = 'toolshortcuts_horizontal'; |
||
1488 | } |
||
1489 | $html .= '<div id="'.$styleId.'">'; |
||
1490 | |||
1491 | $html .= Display::url( |
||
1492 | Display::return_icon('home.png', get_lang('CourseHomepageLink'), '', ICON_SIZE_MEDIUM), |
||
1493 | $courseInfo['course_public_url'], |
||
1494 | ['class' => 'items-icon'] |
||
1495 | ); |
||
1496 | |||
1497 | foreach ($blocks as $block) { |
||
1498 | $blockItems = $block['content']; |
||
1499 | foreach ($blockItems as $item) { |
||
1500 | $item['url_params']['id'] = ''; |
||
1501 | $item['url_params']['class'] = 'items-icon'; |
||
1502 | $html .= Display::url( |
||
1503 | $item['tool']['only_icon_medium'], |
||
1504 | $item['only_href'], |
||
1505 | $item['url_params'] |
||
1506 | ); |
||
1507 | if ($orientation == SHORTCUTS_VERTICAL) { |
||
1508 | $html .= '<br />'; |
||
1509 | } |
||
1510 | } |
||
1511 | } |
||
1512 | $html .= '</div>'; |
||
1513 | } |
||
1514 | |||
1515 | return $html; |
||
1516 | } |
||
1517 | |||
1518 | /** |
||
1519 | * List course homepage tools from authoring and interaction sections. |
||
1520 | * |
||
1521 | * @param int $courseId The course ID (guessed from context if not provided) |
||
1522 | * @param int $sessionId The session ID (guessed from context if not provided) |
||
1523 | * |
||
1524 | * @return array List of all tools data from the c_tools table |
||
1525 | */ |
||
1526 | public static function toolsIconsAction($courseId = null, $sessionId = null) |
||
1527 | { |
||
1528 | if (empty($courseId)) { |
||
1529 | $courseId = api_get_course_int_id(); |
||
1530 | } else { |
||
1531 | $courseId = intval($courseId); |
||
1532 | } |
||
1533 | if (empty($sessionId)) { |
||
1534 | $sessionId = api_get_session_id(); |
||
1535 | } else { |
||
1536 | $sessionId = intval($sessionId); |
||
1537 | } |
||
1538 | |||
1539 | if (empty($courseId)) { |
||
1540 | // We shouldn't get here, but for some reason api_get_course_int_id() |
||
1541 | // doesn't seem to get the course from the context, sometimes |
||
1542 | return []; |
||
1543 | } |
||
1544 | |||
1545 | $table = Database::get_course_table(TABLE_TOOL_LIST); |
||
1546 | $sql = "SELECT * FROM $table |
||
1547 | WHERE category in ('authoring','interaction') |
||
1548 | AND c_id = $courseId |
||
1549 | AND session_id = $sessionId |
||
1550 | ORDER BY id"; |
||
1551 | |||
1552 | $result = Database::query($sql); |
||
1553 | $data = Database::store_result($result, 'ASSOC'); |
||
1554 | |||
1555 | return $data; |
||
1556 | } |
||
1557 | |||
1558 | /** |
||
1559 | * @param int $editIcon |
||
1560 | * |
||
1561 | * @return array |
||
1562 | */ |
||
1563 | public static function getTool($editIcon) |
||
1564 | { |
||
1565 | $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); |
||
1566 | $editIcon = intval($editIcon); |
||
1567 | |||
1568 | $sql = "SELECT * FROM $course_tool_table |
||
1569 | WHERE iid = $editIcon"; |
||
1570 | $result = Database::query($sql); |
||
1571 | $tool = Database::fetch_assoc($result, 'ASSOC'); |
||
1572 | |||
1573 | return $tool; |
||
1574 | } |
||
1575 | |||
1576 | /** |
||
1577 | * @return string |
||
1578 | */ |
||
1579 | public static function getCustomSysIconPath() |
||
1580 | { |
||
1581 | // Check if directory exists or create it if it doesn't |
||
1582 | $dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/course_home_icons/'; |
||
1583 | if (!is_dir($dir)) { |
||
1584 | mkdir($dir, api_get_permissions_for_new_directories(), true); |
||
1585 | } |
||
1586 | |||
1587 | return $dir; |
||
1588 | } |
||
1589 | |||
1590 | /** |
||
1591 | * @return string |
||
1592 | */ |
||
1593 | public static function getCustomWebIconPath() |
||
1594 | { |
||
1595 | // Check if directory exists or create it if it doesn't |
||
1596 | $dir = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/course_home_icons/'; |
||
1597 | |||
1598 | return $dir; |
||
1599 | } |
||
1600 | |||
1601 | /** |
||
1602 | * @param string $icon |
||
1603 | * |
||
1604 | * @return string |
||
1605 | */ |
||
1606 | public static function getDisableIcon($icon) |
||
1607 | { |
||
1608 | $fileInfo = pathinfo($icon); |
||
1609 | |||
1610 | return $fileInfo['filename'].'_na.'.$fileInfo['extension']; |
||
1611 | } |
||
1612 | |||
1613 | /** |
||
1614 | * @param int $id |
||
1615 | * @param array $values |
||
1616 | */ |
||
1617 | public static function updateTool($id, $values) |
||
1618 | { |
||
1619 | $table = Database::get_course_table(TABLE_TOOL_LIST); |
||
1620 | $params = [ |
||
1621 | 'name' => $values['name'], |
||
1622 | 'link' => $values['link'], |
||
1623 | 'target' => $values['target'], |
||
1624 | 'visibility' => $values['visibility'], |
||
1625 | 'description' => $values['description'], |
||
1626 | ]; |
||
1627 | |||
1628 | if (isset($_FILES['icon']['size']) && $_FILES['icon']['size'] !== 0) { |
||
1629 | $dir = self::getCustomSysIconPath(); |
||
1630 | |||
1631 | // Resize image if it is larger than 64px |
||
1632 | $temp = new Image($_FILES['icon']['tmp_name']); |
||
1633 | $picture_infos = $temp->get_image_info(); |
||
1634 | if ($picture_infos['width'] > 64) { |
||
1635 | $thumbwidth = 64; |
||
1636 | } else { |
||
1637 | $thumbwidth = $picture_infos['width']; |
||
1638 | } |
||
1639 | if ($picture_infos['height'] > 64) { |
||
1640 | $new_height = 64; |
||
1641 | } else { |
||
1642 | $new_height = $picture_infos['height']; |
||
1643 | } |
||
1644 | $temp->resize($thumbwidth, $new_height, 0); |
||
1645 | |||
1646 | //copy the image to the course upload folder |
||
1647 | $path = $dir.$_FILES['icon']['name']; |
||
1648 | $result = $temp->send_image($path); |
||
1649 | |||
1650 | $temp = new Image($path); |
||
1651 | $r = $temp->convert2bw(); |
||
1652 | $ext = pathinfo($path, PATHINFO_EXTENSION); |
||
1653 | $bwPath = substr($path, 0, -(strlen($ext) + 1)).'_na.'.$ext; |
||
1654 | |||
1655 | if ($r === false) { |
||
1656 | error_log('Conversion to B&W of '.$path.' failed in '.__FILE__.' at line '.__LINE__); |
||
1657 | } else { |
||
1658 | $temp->send_image($bwPath); |
||
1659 | $iconName = $_FILES['icon']['name']; |
||
1660 | $params['custom_icon'] = $iconName; |
||
1661 | } |
||
1662 | } |
||
1663 | |||
1664 | Database::update( |
||
1665 | $table, |
||
1666 | $params, |
||
1667 | [' iid = ?' => [$id]] |
||
1668 | ); |
||
1669 | } |
||
1670 | |||
1671 | /** |
||
1672 | * @param int $id |
||
1673 | */ |
||
1674 | public static function deleteIcon($id) |
||
1675 | { |
||
1676 | $table = Database::get_course_table(TABLE_TOOL_LIST); |
||
1677 | $tool = self::getTool($id); |
||
1678 | |||
1679 | if ($tool && !empty($tool['custom_icon'])) { |
||
1680 | $file = self::getCustomSysIconPath().$tool['custom_icon']; |
||
1681 | $fileInfo = pathinfo($file); |
||
1682 | $fileGray = $fileInfo['filename'].'_na.'.$fileInfo['extension']; |
||
1683 | $fileGray = self::getCustomSysIconPath().$fileGray; |
||
1684 | |||
1685 | if (file_exists($file) && is_file($file)) { |
||
1686 | if (Security::check_abs_path($file, self::getCustomSysIconPath())) { |
||
1687 | unlink($file); |
||
1688 | } |
||
1689 | } |
||
1690 | |||
1691 | if (file_exists($fileGray) && is_file($fileGray)) { |
||
1692 | if (Security::check_abs_path($fileGray, self::getCustomSysIconPath())) { |
||
1693 | unlink($fileGray); |
||
1694 | } |
||
1695 | } |
||
1696 | |||
1697 | $params = [ |
||
1698 | 'custom_icon' => '', |
||
1699 | ]; |
||
1700 | |||
1701 | Database::update( |
||
1702 | $table, |
||
1703 | $params, |
||
1704 | [' iid = ?' => [$id]] |
||
1705 | ); |
||
1706 | } |
||
1707 | } |
||
1708 | |||
1709 | /** |
||
1710 | * @return array |
||
1711 | */ |
||
1712 | public static function getCourseAdminBlocks() |
||
1713 | { |
||
1714 | $blocks = []; |
||
1715 | $my_list = self::get_tools_category(TOOL_AUTHORING); |
||
1716 | |||
1717 | $blocks[] = [ |
||
1718 | 'title' => get_lang('Authoring'), |
||
1719 | 'class' => 'course-tools-author', |
||
1720 | 'content' => self::show_tools_category($my_list), |
||
1721 | ]; |
||
1722 | |||
1723 | $list1 = self::get_tools_category(TOOL_INTERACTION); |
||
1724 | $list2 = self::get_tools_category(TOOL_COURSE_PLUGIN); |
||
1725 | $my_list = array_merge($list1, $list2); |
||
1726 | |||
1727 | $blocks[] = [ |
||
1728 | 'title' => get_lang('Interaction'), |
||
1729 | 'class' => 'course-tools-interaction', |
||
1730 | 'content' => self::show_tools_category($my_list), |
||
1731 | ]; |
||
1732 | |||
1733 | $my_list = self::get_tools_category(TOOL_ADMIN_PLATFORM); |
||
1734 | |||
1735 | $blocks[] = [ |
||
1736 | 'title' => get_lang('Administration'), |
||
1737 | 'class' => 'course-tools-administration', |
||
1738 | 'content' => self::show_tools_category($my_list), |
||
1739 | ]; |
||
1740 | |||
1741 | return $blocks; |
||
1742 | } |
||
1743 | |||
1744 | /** |
||
1745 | * @return array |
||
1746 | */ |
||
1747 | public static function getCoachBlocks() |
||
1748 | { |
||
1749 | $blocks = []; |
||
1750 | $blocks[] = [ |
||
1751 | 'content' => self::show_tools_category(self::get_tools_category(TOOL_STUDENT_VIEW)), |
||
1752 | ]; |
||
1753 | |||
1754 | $sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers'); |
||
1755 | if ($sessionsCopy === 'true') { |
||
1756 | // Adding only maintenance for coaches. |
||
1757 | $myList = self::get_tools_category(TOOL_ADMIN_PLATFORM); |
||
1758 | $onlyMaintenanceList = []; |
||
1759 | foreach ($myList as $item) { |
||
1760 | if ($item['name'] === 'course_maintenance') { |
||
1761 | $item['link'] = 'course_info/maintenance_coach.php'; |
||
1762 | $onlyMaintenanceList[] = $item; |
||
1763 | } |
||
1764 | } |
||
1765 | |||
1766 | $blocks[] = [ |
||
1767 | 'title' => get_lang('Administration'), |
||
1768 | 'content' => self::show_tools_category($onlyMaintenanceList), |
||
1769 | ]; |
||
1770 | } |
||
1771 | |||
1772 | return $blocks; |
||
1773 | } |
||
1774 | |||
1775 | /** |
||
1776 | * @return array |
||
1777 | */ |
||
1778 | public static function getStudentBlocks() |
||
1779 | { |
||
1780 | $blocks = []; |
||
1781 | $tools = self::get_tools_category(TOOL_STUDENT_VIEW); |
||
1782 | $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( |
||
1783 | api_get_user_id(), |
||
1784 | api_get_course_info() |
||
1785 | ); |
||
1786 | |||
1787 | // Force user icon for DRH |
||
1788 | if ($isDrhOfCourse) { |
||
1789 | $addUserTool = true; |
||
1790 | foreach ($tools as $tool) { |
||
1791 | if ($tool['name'] === 'user') { |
||
1792 | $addUserTool = false; |
||
1793 | break; |
||
1794 | } |
||
1795 | } |
||
1796 | |||
1797 | if ($addUserTool) { |
||
1798 | $tools[] = [ |
||
1799 | 'c_id' => api_get_course_int_id(), |
||
1800 | 'name' => 'user', |
||
1801 | 'link' => 'user/user.php', |
||
1802 | 'image' => 'members.gif', |
||
1803 | 'visibility' => '1', |
||
1804 | 'admin' => '0', |
||
1805 | 'address' => 'squaregrey.gif', |
||
1806 | 'added_tool' => '0', |
||
1807 | 'target' => '_self', |
||
1808 | 'category' => 'interaction', |
||
1809 | 'session_id' => api_get_session_id(), |
||
1810 | ]; |
||
1811 | } |
||
1812 | } |
||
1813 | |||
1814 | if (count($tools) > 0) { |
||
1815 | $blocks[] = ['content' => self::show_tools_category($tools)]; |
||
1816 | } |
||
1817 | |||
1818 | if ($isDrhOfCourse) { |
||
1819 | $drhTool = self::get_tools_category(TOOL_DRH); |
||
1820 | $blocks[] = ['content' => self::show_tools_category($drhTool)]; |
||
1821 | } |
||
1822 | |||
1823 | return $blocks; |
||
1824 | } |
||
1825 | |||
1826 | /** |
||
1827 | * @return array |
||
1828 | */ |
||
1829 | public static function getUserBlocks() |
||
1830 | { |
||
1831 | $sessionId = api_get_session_id(); |
||
1832 | // Start of tools for CourseAdmins (teachers/tutors) |
||
1833 | if ($sessionId === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) { |
||
1834 | $blocks = self::getCourseAdminBlocks(); |
||
1835 | } elseif (api_is_coach()) { |
||
1836 | $blocks = self::getCoachBlocks(); |
||
1837 | } else { |
||
1838 | $blocks = self::getStudentBlocks(); |
||
1839 | } |
||
1840 | |||
1841 | return $blocks; |
||
1842 | } |
||
1843 | |||
1844 | /** |
||
1845 | * @param string $toolName |
||
1846 | * @param int $courseId |
||
1847 | * @param int $sessionId Optional. |
||
1848 | * |
||
1849 | * @return bool |
||
1850 | */ |
||
1851 | public static function getToolVisibility($toolName, $courseId, $sessionId = 0) |
||
1852 | { |
||
1853 | $allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session'); |
||
1854 | |||
1855 | $toolLink = self::getToolLinks($toolName); |
||
1856 | |||
1857 | $em = Database::getManager(); |
||
1858 | $toolRepo = $em->getRepository('ChamiloCourseBundle:CTool'); |
||
1859 | |||
1860 | /** @var CTool $tool */ |
||
1861 | $tool = $toolRepo->findOneBy(['cId' => $courseId, 'sessionId' => 0, 'link' => $toolLink]); |
||
1862 | |||
1863 | if ($allowEditionInSession && $sessionId) { |
||
1864 | $tool = $toolRepo->findOneBy( |
||
1865 | ['cId' => $courseId, 'sessionId' => $sessionId, 'link' => $toolLink] |
||
1866 | ); |
||
1867 | } |
||
1868 | |||
1869 | if ($tool) { |
||
1870 | $visibility = $tool->getVisibility(); |
||
1871 | } |
||
1872 | |||
1873 | return $visibility; |
||
1874 | } |
||
1875 | |||
1876 | /** |
||
1877 | * Get the tools links or one by name defined. |
||
1878 | * |
||
1879 | * @param $tool Optional |
||
1880 | * |
||
1881 | * @return string|string[] |
||
1882 | */ |
||
1883 | public static function getToolLinks($tool = null) |
||
1884 | { |
||
1885 | $toolsLinks = [ |
||
1886 | TOOL_DOCUMENT => 'document/document.php', |
||
1887 | TOOL_CALENDAR_EVENT => 'calendar/agenda.php', |
||
1888 | TOOL_LINK => 'link/link.php', |
||
1889 | TOOL_COURSE_DESCRIPTION => 'course_description/index.php', |
||
1890 | TOOL_LEARNPATH => 'lp/lp_controller.php', |
||
1891 | TOOL_ANNOUNCEMENT => 'announcements/announcements.php', |
||
1892 | TOOL_FORUM => 'forum/index.php', |
||
1893 | TOOL_DROPBOX => 'dropbox/index.php', |
||
1894 | TOOL_QUIZ => 'exercise/exercise.php', |
||
1895 | TOOL_USER => 'user/user.php', |
||
1896 | TOOL_GROUP => 'group/group.php', |
||
1897 | TOOL_BLOGS => 'blog/blog_admin.php', |
||
1898 | TOOL_CHAT => 'chat/chat.php', |
||
1899 | TOOL_STUDENTPUBLICATION => 'work/work.php', |
||
1900 | TOOL_TRACKING => 'tracking/courseLog.php', |
||
1901 | TOOL_COURSE_SETTING => 'course_info/infocours.php', |
||
1902 | TOOL_PORTFOLIO => 'portfolio/index.php', |
||
1903 | TOOL_COURSE_MAINTENANCE => 'course_info/maintenance.php', |
||
1904 | TOOL_SURVEY => 'survey/survey_list.php', |
||
1905 | TOOL_WIKI => 'wiki/index.php', |
||
1906 | TOOL_GLOSSARY => 'glossary/index.php', |
||
1907 | TOOL_GRADEBOOK => 'gradebook/index.php', |
||
1908 | TOOL_NOTEBOOK => 'notebook/index.php', |
||
1909 | TOOL_ATTENDANCE => 'attendance/index.php', |
||
1910 | TOOL_COURSE_PROGRESS => 'course_progress/index.php', |
||
1911 | ]; |
||
1912 | |||
1913 | if (!empty($tool) && isset($toolsLinks['tool'])) { |
||
1914 | return $toolsLinks['tool']; |
||
1915 | } |
||
1916 | |||
1917 | return $toolsLinks; |
||
1918 | } |
||
1919 | |||
1920 | /** |
||
1921 | * Filter tool icons. Only show if $patronKey is = :teacher |
||
1922 | * Example dataIcons[i]['name']: parameter titleIcons1:teacher || titleIcons2 || titleIcons3:teacher. |
||
1923 | * |
||
1924 | * @param array $dataIcons array Reference to icons |
||
1925 | * @param string $courseToolCategory Current tools category |
||
1926 | * |
||
1927 | * @return array |
||
1928 | */ |
||
1929 | private static function filterPluginTools($dataIcons, $courseToolCategory) |
||
1930 | { |
||
1931 | $patronKey = ':teacher'; |
||
1932 | |||
1933 | if ($courseToolCategory == TOOL_STUDENT_VIEW) { |
||
1934 | //Fix only coach can see external pages - see #8236 - icpna |
||
1935 | if (api_is_coach()) { |
||
1936 | foreach ($dataIcons as $index => $array) { |
||
1937 | if (isset($array['name'])) { |
||
1938 | $dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']); |
||
1939 | } |
||
1940 | } |
||
1941 | |||
1942 | return $dataIcons; |
||
1943 | } |
||
1944 | |||
1945 | $flagOrder = false; |
||
1946 | |||
1947 | foreach ($dataIcons as $index => $array) { |
||
1948 | if (!isset($array['name'])) { |
||
1949 | continue; |
||
1950 | } |
||
1951 | |||
1952 | $pos = strpos($array['name'], $patronKey); |
||
1953 | |||
1954 | if ($pos !== false) { |
||
1955 | unset($dataIcons[$index]); |
||
1956 | $flagOrder = true; |
||
1957 | } |
||
1958 | } |
||
1959 | |||
1960 | if ($flagOrder) { |
||
1961 | return array_values($dataIcons); |
||
1962 | } |
||
1963 | |||
1964 | return $dataIcons; |
||
1965 | } |
||
1966 | |||
1967 | // clean patronKey of name icons |
||
1968 | foreach ($dataIcons as $index => $array) { |
||
1969 | if (isset($array['name'])) { |
||
1970 | $dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']); |
||
1971 | } |
||
1972 | } |
||
1973 | |||
1974 | return $dataIcons; |
||
1975 | } |
||
1976 | |||
1977 | /** |
||
1978 | * Find the tool icon when homepage_view is activity_big. |
||
1979 | * |
||
1980 | * @param int $iconSize |
||
1981 | * @param bool $generateId |
||
1982 | * |
||
1983 | * @return string |
||
1984 | */ |
||
1985 | private static function getToolIcon(array $item, $iconSize, $generateId = true) |
||
1986 | { |
||
1987 | $image = str_replace('.gif', '.png', $item['tool']['image']); |
||
1988 | $toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null; |
||
1989 | |||
1990 | if (isset($item['tool']['custom_image'])) { |
||
1991 | return Display::img( |
||
1992 | $item['tool']['custom_image'], |
||
1993 | $item['name'], |
||
1994 | ['id' => 'toolimage_'.$toolIid] |
||
1995 | ); |
||
1996 | } |
||
1997 | |||
1998 | if (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) { |
||
1999 | $customIcon = $item['tool']['custom_icon']; |
||
2000 | |||
2001 | if ($item['tool']['visibility'] == '0') { |
||
2002 | $customIcon = self::getDisableIcon($item['tool']['custom_icon']); |
||
2003 | } |
||
2004 | |||
2005 | return Display::img( |
||
2006 | self::getCustomWebIconPath().$customIcon, |
||
2007 | $item['name'], |
||
2008 | ['id' => 'toolimage_'.$toolIid] |
||
2009 | ); |
||
2010 | } |
||
2011 | |||
2012 | $id = ''; |
||
2013 | if ($generateId) { |
||
2014 | $id = 'toolimage_'.$toolIid; |
||
2015 | } |
||
2016 | |||
2017 | return Display::return_icon( |
||
2018 | $image, |
||
2019 | $item['name'], |
||
2020 | ['id' => $id], |
||
2021 | $iconSize, |
||
2022 | false |
||
2023 | ); |
||
2024 | } |
||
2025 | } |
||
2026 |