b5cc7493321fb19a05c230b980efe20993cf4bd6
[atutor.git] / docs / include / lib / menu_pages.php
1 <?php
2 /************************************************************************/
3 /* ATutor                                                                                                                               */
4 /************************************************************************/
5 /* Copyright (c) 2002-2010                                              */
6 /* Inclusive Design Institute                                           */
7 /* http://atutor.ca                                                     */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12 // $Id$
13 if (!defined('AT_INCLUDE_PATH')) { exit; }
14 global $_config;
15 global $_pages;
16 global $system_courses;
17
18 /*
19         5 sections: public, my_start_page, course, admin, home
20 */
21 if (isset($_pages[AT_NAV_ADMIN])) {
22     array_unshift($_pages[AT_NAV_ADMIN], 'admin/index.php');
23 }
24
25 if($_config['allow_browse'] && $_config['just_social'] != "1") {
26 if($_SESSION['valid_user']){
27     $browse_tab = "users/browse.php";
28 }else{
29     $browse_tab = "browse.php";
30 }
31 }
32 if($_config['allow_registration']) {
33     $reg_tab = "registration.php";
34 }
35
36 if($_config['just_social']) {
37
38     $_pages[AT_NAV_START]  = array_merge(array('users/profile.php', 'users/preferences.php'), (isset($_pages[AT_NAV_START]) ? (array) $_pages[AT_NAV_START] : array()));
39
40 }else {
41
42     $_pages[AT_NAV_START]  = array_merge(array('users/index.php' , $browse_tab, 'users/profile.php', 'users/preferences.php'), (isset($_pages[AT_NAV_START]) ? (array) $_pages[AT_NAV_START] : array()));
43
44 }
45 $_pages[AT_NAV_PUBLIC] = array_merge(array('login.php',$reg_tab,$browse_tab), (isset($_pages[AT_NAV_PUBLIC]) ? $_pages[AT_NAV_PUBLIC] : array()));
46
47
48 //$_pages[AT_NAV_START]  = array_merge(array($my_tab , 'users/profile.php', 'users/preferences.php'), (isset($_pages[AT_NAV_START]) ? (array) $_pages[AT_NAV_START] : array()));
49 //The following line is needed to add MyCourses to the main nav tabs, but other adaptations are needed to have this function properly
50 //$_pages[AT_NAV_COURSE] = array('users/index.php','index.php');
51 $_pages[AT_NAV_COURSE] = array('index.php');
52 $_pages[AT_NAV_HOME]   = array();
53
54 if (isset($_SESSION['course_id']) && $_SESSION['course_id'] > 0) {
55     $main_links = $home_links = $side_menu = array();
56
57     if ($system_courses[$_SESSION['course_id']]['main_links']) {
58         $main_links = explode('|', $system_courses[$_SESSION['course_id']]['main_links']);
59         foreach ($main_links as $link) {
60             if (isset($_pages[$link])) {
61                 $_pages[$link]['parent'] = AT_NAV_COURSE;
62             }
63         }
64         $_pages[AT_NAV_COURSE] = array_merge($_pages[AT_NAV_COURSE], $main_links);
65     }
66
67     if ($system_courses[$_SESSION['course_id']]['home_links']) {
68         $home_links = explode('|', $system_courses[$_SESSION['course_id']]['home_links']);
69         foreach ($home_links as $link) {
70             if (isset($_pages[$link])) {
71                 $_pages[AT_NAV_HOME][] = $link;
72             }
73         }
74     }
75
76     if (authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)) {
77         $_pages[AT_NAV_COURSE][] = 'tools/index.php';
78     } else if ($_SESSION['privileges']) {
79
80         /**
81          * the loop and all this module priv checking is done to hide the Manage tab
82          * when this student has privileges, but no items linked from the Manage tab.
83          * Example: the File Storage privilege does not have a Manage tab item.
84          * In the best case it stops after the first found link.
85          * In the worst case it goes through all the modules and doesn't find a link.
86          */
87             $module_list = $moduleFactory->getModules(AT_MODULE_STATUS_ENABLED, 0, TRUE);
88             $keys = array_keys($module_list);
89
90             foreach ($keys as $module_name) {
91                 $module =& $module_list[$module_name];
92                 if ($module->getPrivilege() && authenticate($module->getPrivilege(), AT_PRIV_RETURN) && ($module->getChildPage('tools/index.php'))) {
93                     $_pages[AT_NAV_COURSE][] = 'tools/index.php';
94                     break;
95                 }
96             }
97         }
98 } else if (isset($_SESSION['course_id']) && $_SESSION['course_id'] == -1) {
99         /* admin pages */
100         $_pages['admin/index.php']['title_var'] = 'admin_home';
101         $_pages['admin/index.php']['parent']    = AT_NAV_ADMIN;
102         $_pages['admin/index.php']['guide']     = 'admin/?p=configuration.php';
103         $_pages['admin/index.php']['children'] = array_merge(array('mods/_core/users/admins/my_edit.php', 'mods/_core/users/admins/my_password.php'), isset($_pages['mods/_core/users/index.php']['children']) ?  $_pages['admin/index.php']['children'] : array());
104
105         $_pages['mods/_core/users/admins/my_edit.php']['title_var'] = 'my_account';
106         $_pages['mods/_core/users/admins/my_edit.php']['parent']    = 'admin/index.php';
107         $_pages['mods/_core/users/admins/my_edit.php']['guide']     = 'admin/?p=my_account.php';
108
109         $_pages['mods/_core/users/admins/my_password.php']['title_var'] = 'change_password';
110         $_pages['mods/_core/users/admins/my_password.php']['parent']    = 'admin/index.php';
111
112         if (admin_authenticate(AT_ADMIN_PRIV_ADMIN, AT_PRIV_RETURN)) {
113         //hide system preference from non-super admins
114             $_pages[AT_NAV_ADMIN][] = 'admin/config_edit.php';
115
116             $_pages['admin/config_edit.php']['title_var'] = 'system_preferences';
117             $_pages['admin/config_edit.php']['parent']    = AT_NAV_ADMIN;
118             $_pages['admin/config_edit.php']['guide']     = 'admin/?p=system_preferences.php';
119             $_pages['admin/config_edit.php']['children']  = array_merge((array) $_pages['admin/config_edit.php']['children'], array('admin/error_logging.php','mods/_standard/social/index_admin.php'));
120         }
121         $_pages['admin/fix_content.php']['title_var'] = 'fix_content_ordering';
122         $_pages['admin/fix_content.php']['parent']    = 'admin/index.php';
123
124         $_pages['admin/error_logging.php']['title_var'] = 'error_logging';
125         $_pages['admin/error_logging.php']['parent']    = 'admin/config_edit.php';
126         $_pages['admin/error_logging.php']['guide']     = 'admin/?p=error_logging.php';
127         $_pages['admin/error_logging.php']['children']  = array_merge(array('admin/error_logging_bundle.php', 'admin/error_logging_reset.php'), isset($_pages['admin/error_logging.php']['children']) ? $_pages['admin/error_logging.php']['children'] : array());
128
129         $_pages['admin/error_logging_reset.php']['title_var'] = 'reset_log';
130         $_pages['admin/error_logging_reset.php']['parent']    = 'admin/error_logging.php';
131
132         $_pages['admin/error_logging_bundle.php']['title_var'] = 'report_errors';
133         $_pages['admin/error_logging_bundle.php']['parent']    = 'admin/error_logging.php';
134
135         $_pages['admin/error_logging_details.php']['title_var'] = 'viewing_profile_bugs';
136         $_pages['admin/error_logging_details.php']['parent']    = 'admin/error_logging.php';
137
138         $_pages['admin/error_logging_view.php']['title_var'] = 'viewing_errors';
139         $_pages['admin/error_logging_view.php']['parent']    = 'admin/error_logging_details.php';
140
141         if (admin_authenticate(AT_ADMIN_PRIV_ADMIN, TRUE)) {
142         // hide modules from non-super admins
143             $_pages['admin/cron_config.php']['title_var'] = 'cron_config';
144             $_pages['admin/cron_config.php']['parent']    = 'admin/config_edit.php';
145             $_pages['admin/cron_config.php']['guide']     = 'admin/?p=cron_setup.php';
146             $_pages['admin/config_edit.php']['children']  = array_merge((array) $_pages['admin/config_edit.php']['children'], array('admin/cron_config.php'));
147         }
148     }
149
150 /* global pages */
151 $_pages['about.php']['title_var']  = 'about_atutor';
152
153 $_pages['404.php']['title_var']  = '404';
154
155 $_pages['help/index.php']['title_var']  = 'help';
156 $_pages['help/index.php']['children'] = array_merge(array('help/accessibility.php', 'help/contact_support.php'), isset($_pages['help/index.php']['children']) ? $_pages['help/index.php']['children'] : array());
157
158 $_pages['help/accessibility.php']['title_var']  = 'accessibility';
159 $_pages['help/accessibility.php']['parent'] = 'help/index.php';
160
161 $_pages['help/contact_support.php']['title_var']  = 'contact_support';
162 $_pages['help/contact_support.php']['parent'] = 'help/index.php';
163
164
165 $_pages['contact_instructor.php']['title_var']  = 'contact_instructor';
166
167 /* public pages */
168
169 $_pages['registration.php']['title_var'] = 'register';
170 $_pages['registration.php']['parent']    = AT_NAV_PUBLIC;
171 $_pages['registration.php']['children']  = isset($_pages['browse.php']['children']) ? $_pages['browse.php']['children'] : array();
172 $_pages['registration.php']['guide']     = 'general/?p=register.php';
173
174 $_pages['browse.php']['title_var'] = 'browse_courses';
175 $_pages['browse.php']['parent']    = AT_NAV_PUBLIC;
176 $_pages['browse.php']['children']  = isset($_pages['browse.php']['children']) ? $_pages['browse.php']['children'] : array();
177 $_pages['browse.php']['guide']     = 'general/?p=browse_courses.php';
178
179 $_pages['login.php']['title_var'] = 'login';
180 $_pages['login.php']['parent']    = AT_NAV_PUBLIC;
181 $_pages['login.php']['children']  = array_merge(array('password_reminder.php'), isset($_pages['login.php']['children']) ? $_pages['login.php']['children'] : array());
182 $_pages['login.php']['guide']     = 'general/?p=login.php';
183
184 $_pages['confirm.php']['title_var'] = 'confirm';
185 $_pages['confirm.php']['parent']    = AT_NAV_PUBLIC;
186
187 $_pages['password_reminder.php']['title_var'] = 'password_reminder';
188 $_pages['password_reminder.php']['parent']    = 'login.php';
189 $_pages['password_reminder.php']['guide']     = 'general/?p=password_reminder.php';
190
191 $_pages['logout.php']['title_var'] = 'logout';
192 $_pages['logout.php']['parent']    = AT_NAV_PUBLIC;
193
194 /* my start page pages */
195 $_pages['users/index.php']['title_var'] = 'my_courses';
196 $_pages['users/index.php']['parent']    = AT_NAV_START;
197 $_pages['users/index.php']['guide']     = 'general/?p=my_courses.php';
198 if (isset($_SESSION['member_id']) && $_SESSION['member_id'] && (!isset($_SESSION['course_id']) || !$_SESSION['course_id'])) {
199         //$_pages['users/index.php']['children']  = array_merge(array('mods/_core/courses/users/create_course.php'), isset($_pages['users/index.php']['children']) ? $_pages['users/index.php']['children'] : array());
200 }
201         $_pages['users/browse.php']['title_var'] = 'browse_courses';
202         //$_pages['users/browse.php']['parent']    = 'users/index.php';
203         $_pages['users/browse.php']['parent']    = AT_NAV_START;
204         $_pages['users/browse.php']['guide']     = 'general/?p=browse_courses.php';
205
206
207 if (isset($_SESSION['member_id']) && get_instructor_status() === TRUE)  
208 {
209         $_pages['mods/_core/courses/users/create_course.php']['title_var'] = 'create_course';
210 $_pages['mods/_core/courses/users/create_course.php']['parent']    = 'users/index.php';
211 $_pages['mods/_core/courses/users/create_course.php']['guide']    = 'instructor/?p=creating_courses.php';
212 $_pages['users/index.php']['children']  = array_merge(array('mods/_core/courses/users/create_course.php'), isset($_pages['users/index.php']['children']) ? $_pages['users/index.php']['children'] : array());
213
214 }
215 else if (isset($_SESSION['member_id']) && ALLOW_INSTRUCTOR_REQUESTS)
216 {
217
218           $_pages['mods/_core/courses/users/create_course.php']['title_var'] = 'request_instructor_priv';
219 $_pages['mods/_core/courses/users/create_course.php']['parent']    = 'users/index.php';
220 $_pages['mods/_core/courses/users/create_course.php']['guide']    = 'instructor/?p=creating_courses.php';
221 $_pages['users/index.php']['children']  = array_merge(array('mods/_core/courses/users/create_course.php'), isset($_pages['users/index.php']['children']) ? $_pages['users/index.php']['children'] : array());
222
223 }
224
225 $_pages['users/private_enroll.php']['title_var'] = 'enroll';
226 $_pages['users/private_enroll.php']['parent']    = 'users/index.php';
227
228 $_pages['users/remove_course.php']['title_var'] = 'unenroll';
229 $_pages['users/remove_course.php']['parent']    = 'users/index.php';
230
231 $_pages['mods/_standard/profile_pictures/profile_picture.php']['title_var']    = 'picture';
232
233 $_pages['users/profile.php']['title_var']    = 'profile';
234 $_pages['users/profile.php']['parent']   = AT_NAV_START;
235 $_pages['users/profile.php']['guide']     = 'general/?p=profile.php';
236 //$_pages['users/profile.php']['children']  = array_merge(array('users/password_change.php', 'users/email_change.php','mods/_standard/profile_pictures/profile_picture.php'), (array) $_pages['users/profile.php']['children']);
237 $_pages['users/profile.php']['children']  = array_merge(array('users/password_change.php', 'users/email_change.php','mods/_standard/profile_pictures/profile_picture.php'), (array) $_pages['users/profile.php']['children']);
238
239 $_pages['users/password_change.php']['title_var'] = 'change_password';
240 $_pages['users/password_change.php']['parent']    = 'users/profile.php';
241 //$_pages['users/password_change.php']['guide']    = 'instructor/?p=creating_courses.php';
242
243 $_pages['users/email_change.php']['title_var'] = 'change_email';
244 $_pages['users/email_change.php']['parent']    = 'users/profile.php';
245
246 $_pages['users/preferences.php']['title_var']  = 'preferences';
247 $_pages['users/preferences.php']['parent'] = AT_NAV_START;
248 $_pages['users/preferences.php']['guide']  = 'general/?p=preferences.php';
249
250 $_pages['users/pref_wizard/index.php']['title_var']  = 'preferences';
251 $_pages['users/pref_wizard/index.php']['parent'] = AT_NAV_START;
252
253 $_pages['enroll.php']['title_var']  = 'enroll';
254 $_pages['enroll.php']['parent'] = 'users/browse.php';
255
256 /* course pages */
257 $_pages['index.php']['title_var']  = 'course_home';
258 $_pages['index.php']['parent'] = AT_NAV_COURSE;
259
260 /* instructor pages: */
261 $_pages['tools/index.php']['title_var'] = 'manage';
262 $_pages['tools/index.php']['parent']    = AT_NAV_COURSE;
263
264 $_pages['inbox/index.php']['title_var'] = 'inbox';
265 $_pages['inbox/index.php']['children']  = array_merge(array('inbox/sent_messages.php', 'inbox/send_message.php', 'inbox/export.php'), isset($_pages['inbox/index.php']['children']) ? $_pages['inbox/index.php']['children'] : array());
266
267 $_pages['inbox/sent_messages.php']['title_var'] = 'sent_messages';
268 $_pages['inbox/sent_messages.php']['parent']    = 'inbox/index.php';
269
270 $_pages['inbox/send_message.php']['title_var'] = 'send_message';
271 $_pages['inbox/send_message.php']['parent']    = 'inbox/index.php';
272
273 $_pages['inbox/export.php']['title_var'] = 'export';
274 $_pages['inbox/export.php']['parent']    = 'inbox/index.php';
275
276 $_pages['profile.php']['title_var'] = 'profile';
277 $_pages['profile.php']['parent']    = 'index.php';
278
279 /**
280  * Iterate $_pages, distribute the "avail_in_mobile" setting on the parent page to all its child pages
281  * as long as it's not initially set on the child page.
282  * @param $this_page - string, the page location used as a key in $_pages
283  */ 
284 function distribute_avail_in_mobile($this_page) {
285         global $_pages;
286         // return in the cases:
287         // 1. the given page is not defined in $_pages 
288         // 2. it does not have any child
289         // 3. the given page does not have "avail_in_mobile" setting defined
290         if (!isset($_pages[$this_page]) || !isset($_pages[$this_page]["avail_in_mobile"]) || 
291             !isset($_pages[$this_page]['children']) || !is_array($_pages[$this_page]['children'])) {
292         return;
293         }
294         
295         foreach ($_pages[$this_page]['children'] as $child_page) {
296                 // Initial "avail_in_mobile" setting on the child page wins over the one fromt the parent
297                 if (!isset($_pages[$child_page])) {
298                         continue;
299                 } else {
300                         if (!isset($_pages[$child_page]["avail_in_mobile"])) {
301                                 $_pages[$child_page]["avail_in_mobile"] = $_pages[$this_page]["avail_in_mobile"];
302                         }
303                         distribute_avail_in_mobile($child_page);
304                 }
305         }
306 }
307
308 // The page can be turned on/off in mobile themes by adjusting page setting "avail_in_mobile" in module.php
309 // Here is to populate this setting to child pages.
310 if (is_mobile_device()) {
311         foreach ($_pages as $page => $garbage) {
312                 distribute_avail_in_mobile($page);
313         }
314 }
315
316 $current_page = substr($_SERVER['PHP_SELF'], strlen($_base_path));
317
318 function get_num_new_messages() {
319     global $db;
320     static $num_messages;
321
322     if (isset($num_messages)) {
323         return $num_messages;
324     }
325     $sql    = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."messages WHERE to_member_id=$_SESSION[member_id] AND new=1";
326     $result = mysql_query($sql, $db);
327     $row    = mysql_fetch_assoc($result);
328     $num_messages = $row['cnt'];
329
330     return $num_messages;
331 }
332
333 /**
334  *  Check the page availability
335  *  The page is unavailable if it's accessed by mobile device and the setting "avail_in_mobile" is set to false
336  *  @param      $this_page - string, the page location used as a key in $_pages 
337  */
338 function page_available($this_page) {
339         global $_pages;
340         if (is_mobile_device() && isset($_pages[$this_page]["avail_in_mobile"]) && !$_pages[$this_page]["avail_in_mobile"]) {
341                 return false;
342         } else {
343                 return isset($_pages[$this_page]);
344         }
345 }
346
347 //TODO****************BOLOGNA*******************REMOVE ME**********************/
348 function get_main_navigation($current_page) {
349     global $_pages, $_base_path, $_tool;
350
351     $parent_page = $_pages[$current_page]['parent'];
352     $_top_level_pages = array();
353
354     $tool_file= $table = '';
355
356     if (isset($parent_page) && defined($parent_page)) {
357         foreach($_pages[$parent_page] as $page) {
358                 if (page_available($page)) {
359                 if (isset($_pages[$page]['title'])) {
360                     $_page_title = $_pages[$page]['title'];
361                 } else {
362                     $_page_title = _AT($_pages[$page]['title_var']);
363                 }
364
365                 if(isset($_tool[$_pages[$page]['title_var']])){                 //viene prelevato il file nel caso in cui lo strumento sia valodo per essere inserito nella toolbar in fase di editing dei conenuti del corso
366                     $tool_file = $_tool[$_pages[$page]['title_var']]['file'];
367                     $table = $_tool[$_pages[$page]['title_var']]['table'];
368                 } else {
369                                         $tool_file = '';
370                                         $table = '';
371                                 }
372
373                 $_top_level_pages[] = array('url' => $_base_path . url_rewrite($page), 'title' => $_page_title, 'img' => $_base_path.$_pages[$page]['img'], 'tool_file' => $tool_file, 'table' => $table);
374             }
375         }
376     } else if (isset($parent_page)) {
377             return get_main_navigation($parent_page);
378         }
379
380     return $_top_level_pages;
381 }
382
383 function get_current_main_page($current_page) {
384     global $_pages, $_base_path;
385     $parent_page = $_pages[$current_page]['parent'];
386
387     if (isset($parent_page) && defined($parent_page)) {
388         return $_base_path . url_rewrite($current_page);
389     } else if (isset($parent_page)) {
390             return get_current_main_page($parent_page);
391         }
392 }
393
394 function get_sub_navigation($current_page) {
395     global $_pages, $_base_path;
396
397     if (isset($current_page) && defined($current_page)) {
398     // reached the top
399         return array();
400     } else if (isset($_pages[$current_page]['children']) && page_available($current_page)) {
401                 if (isset($_pages[$current_page]['title'])) {
402                 $_page_title = $_pages[$current_page]['title'];
403             } else {
404                 $_page_title = _AT($_pages[$current_page]['title_var']);
405             }
406
407             $_sub_level_pages[] = array('url' => $_base_path . $current_page, 'title' => $_page_title);
408             foreach ($_pages[$current_page]['children'] as $child) {
409                 if (!page_available($child)) continue;
410                 
411                 if (isset($_pages[$child]['title'])) {
412                     $_page_title = $_pages[$child]['title'];
413                 } else {
414                     $_page_title = _AT($_pages[$child]['title_var']);
415                 }
416
417                 $_sub_level_pages[] = array('url' => $_base_path . $child, 'title' => $_page_title, 'has_children' => isset($_pages[$child]['children']));
418             }
419         } else if (isset($_pages[$current_page]['parent'])) {
420             // no children
421
422                 $parent_page = $_pages[$current_page]['parent'];
423                 return get_sub_navigation($parent_page);
424             }
425
426     return $_sub_level_pages;
427 }
428
429 function get_current_sub_navigation_page($current_page) {
430     global $_pages, $_base_path;
431     
432     if (!page_available($current_page)) return;
433     
434     $parent_page = $_pages[$current_page]['parent'];
435
436     if (isset($parent_page) && defined($parent_page)) {
437         return $_base_path . $current_page;
438     } else {
439         return $_base_path . $current_page;
440     }
441 }
442
443 function get_path($current_page) {
444     global $_pages, $_base_path;
445
446     $path = array();
447     
448     if (!page_available($current_page)){
449         return $path;
450     }
451      
452     $parent_page = $_pages[$current_page]['parent'];
453
454     if (isset($_pages[$current_page]['title'])) {
455         $_page_title = $_pages[$current_page]['title'];
456     } else {
457         $_page_title = _AT($_pages[$current_page]['title_var']);
458     }
459
460     if (isset($parent_page) && defined($parent_page)) {
461         $path[] = array('url' => $_base_path . url_rewrite($current_page), 'title' => $_page_title);
462         return $path;
463     } else if (isset($parent_page)) {
464             $path[] = array('url' => $_base_path . url_rewrite($current_page), 'title' => $_page_title);
465             $path = array_merge((array) $path, get_path($parent_page));
466         } else {
467             $path[] = array('url' => $_base_path . url_rewrite($current_page), 'title' => $_page_title);
468         }
469
470     return $path;
471 }
472
473 //TODO****************BOLOGNA*********************REMOVE ME*****************/
474 function get_home_navigation($home_array='') {
475     global $_pages, $_list, $_base_path, $_tool;
476
477     // set default home_array to course index navigation array
478     if (!is_array($home_array)) $home_array = $_pages[AT_NAV_HOME];
479
480     $home_links = array();
481     foreach ($home_array as $child) {                                           //esecuzione del ciclo fin quando non saranno terminati i moduli presenti nella home-page del corso
482         if (page_available($child)) {
483         // initialization
484             $title = $icon = $sub_file = $image = $text = $tool_file = $table ='';
485
486             if (isset($_pages[$child]['title'])) {                              //viene prelevato il titolo che dovr� poi essere utilizzato nella visualizzazione
487                 $title = $_pages[$child]['title'];
488             } else {
489                 $title = _AT($_pages[$child]['title_var']);
490             }
491             if(isset($_pages[$child]['icon'])) {                                //si controlla se è presente l'icona inserita nel modulo di rifrimento. si ricorda che l'icona � inserita solo per i moduli che prevedono possibili sottocontenuti.
492                 $icon = $_base_path.$_pages[$child]['icon'];                    //in caso positivo viene prelevata e inserita in una variabile di appoggio che poi sar� a sua volta inserita all'interno dell'array finale home_links[]
493             } 
494             if(isset($_pages[$child]['text'])) {                         //nel caso in cui non sia presente un' icona associata si controlla se � stato settata il testo (per moduli privi di sottocontenuti).
495                 $text = $_pages[$child]['text'];                                //il testo viene inserito in una variabile d'appoggio e successivamente nell'array.
496             }
497
498             if (isset($_list[$_pages[$child]['title_var']]))                    //viene prelevato il path del file che dovr� poi essere richiamato nella visualizzazione dei sottocontenuti. solo i moduli che prevedono sottocontenuti avranno un file di riferimento.
499                 $sub_file = $_list[$_pages[$child]['title_var']]['file'];
500
501              if(isset($_tool[$_pages[$child]['title_var']])){                    //viene prelevato il file nel caso in cui lo strumento sia valido per essere inserito nella toolbar in fase di editing dei conenuti del corso
502                 $tool_file = $_tool[$_pages[$child]['title_var']]['file'];
503                 $table = $_tool[$_pages[$child]['title_var']]['table'];
504              }
505
506             $real_image_in_theme = AT_INCLUDE_PATH.'../themes/'.$_SESSION['prefs']['PREF_THEME'].'/'.$_pages[$child]['img'];
507             $image_in_theme = $_base_path.'themes/'.$_SESSION['prefs']['PREF_THEME'].'/'.$_pages[$child]['img'];
508
509             // look for images in theme folder. If not exists, use images relative to ATutor root folder
510             if (file_exists($real_image_in_theme))
511                 $image = $image_in_theme;
512             else
513                 $image = $_base_path.$_pages[$child]['img'];
514
515             // inclusion of all data necessary for displaying the modules on the home-page. Set by default to check the visible because the modules will be loaded all visible in the home.
516             $home_links[] = array('url' => $_base_path . url_rewrite($child), 'title' => $title, 'img' => $image, 'icon' => $icon, 'text' => $text, 'sub_file' => $sub_file, 'tool_file' => $tool_file, 'table' => $table);
517         }
518     }
519     return $home_links;
520 }
521
522 ?>