(no commit message)
[atutor.git] / 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', 'mods/_core/modules/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
144             $_pages['mods/_core/modules/index.php']['title_var'] = 'modules';
145             $_pages['mods/_core/modules/index.php']['parent']    = AT_NAV_ADMIN;
146             $_pages['mods/_core/modules/index.php']['guide']     = 'admin/?p=modules.php';
147             $_pages['mods/_core/modules/index.php']['children']  = array('mods/_core/modules/install_modules.php');
148
149             $_pages['mods/_core/modules/details.php']['title_var'] = 'details';
150             $_pages['mods/_core/modules/details.php']['parent']    = 'mods/_core/modules/index.php';
151
152             $_pages['mods/_core/modules/module_uninstall_step_1.php']['title_var'] = 'module_uninstall';
153             $_pages['mods/_core/modules/module_uninstall_step_1.php']['parent']    = 'mods/_core/modules/index.php';
154
155             $_pages['mods/_core/modules/module_uninstall_step_2.php']['title_var'] = 'module_uninstall';
156             $_pages['mods/_core/modules/module_uninstall_step_2.php']['parent']    = 'mods/_core/modules/index.php';
157
158             $_pages['mods/_core/modules/module_uninstall_step_3.php']['title_var'] = 'module_uninstall';
159             $_pages['mods/_core/modules/module_uninstall_step_3.php']['parent']    = 'mods/_core/modules/index.php';
160
161             $_pages['mods/_core/modules/install_modules.php']['title_var'] = 'install_modules';
162             $_pages['mods/_core/modules/install_modules.php']['parent']    = 'mods/_core/modules/index.php';
163             $_pages['mods/_core/modules/install_modules.php']['guide']     = 'admin/?p=modules.php';
164
165             $_pages['mods/_core/modules/version_history.php']['title_var'] = 'version_history';
166             $_pages['mods/_core/modules/version_history.php']['parent']    = 'mods/_core/modules/install_modules.php';
167
168             $_pages['mods/_core/modules/module_install_step_1.php']['title_var'] = 'details';
169             $_pages['mods/_core/modules/module_install_step_1.php']['parent']    = 'mods/_core/modules/install_modules.php';
170
171             $_pages['mods/_core/modules/module_install_step_2.php']['title_var'] = 'details';
172             $_pages['mods/_core/modules/module_install_step_2.php']['parent']    = 'mods/_core/modules/install_modules.php';
173
174             $_pages['mods/_core/modules/module_install_step_3.php']['title_var'] = 'details';
175             $_pages['mods/_core/modules/module_install_step_3.php']['parent']    = 'mods/_core/modules/install_modules.php';
176
177             $_pages['mods/_core/modules/confirm.php']['title_var'] = 'confirm';
178             $_pages['mods/_core/modules/confirm.php']['parent']    = 'mods/_core/modules/add_new.php';
179
180             $_pages['admin/cron_config.php']['title_var'] = 'cron_config';
181             $_pages['admin/cron_config.php']['parent']    = 'admin/config_edit.php';
182             $_pages['admin/cron_config.php']['guide']     = 'admin/?p=cron_setup.php';
183             $_pages['admin/config_edit.php']['children']  = array_merge((array) $_pages['admin/config_edit.php']['children'], array('admin/cron_config.php'));
184 /*
185             $_pages['admin/auto_enroll.php']['title_var'] = 'auto_enroll';
186             $_pages['admin/auto_enroll.php']['parent']    = 'admin/config_edit.php';
187             $_pages['admin/auto_enroll.php']['guide']     = 'admin/?p=auto_enroll.php';
188             $_pages['admin/auto_enroll.php']['children']  = array_merge(array('admin/auto_enroll_edit.php'));
189             $_pages['admin/config_edit.php']['children']  = array_merge((array) $_pages['admin/config_edit.php']['children'], array('admin/auto_enroll.php'));
190
191             $_pages['admin/auto_enroll_edit.php']['title_var'] = 'auto_enroll_edit';
192             $_pages['admin/auto_enroll_edit.php']['parent']    = 'admin/auto_enroll.php';
193             $_pages['admin/auto_enroll_edit.php']['guide']     = 'admin/?p=auto_enroll.php';
194
195             $_pages['admin/auto_enroll_delete.php']['title_var'] = 'auto_enroll_delete';
196             $_pages['admin/auto_enroll_delete.php']['parent']    = 'admin/auto_enroll.php';
197 */
198         }
199     }
200
201 /* global pages */
202 $_pages['about.php']['title_var']  = 'about_atutor';
203
204 $_pages['404.php']['title_var']  = '404';
205
206 $_pages['help/index.php']['title_var']  = 'help';
207 $_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());
208
209 $_pages['help/accessibility.php']['title_var']  = 'accessibility';
210 $_pages['help/accessibility.php']['parent'] = 'help/index.php';
211
212 $_pages['help/contact_support.php']['title_var']  = 'contact_support';
213 $_pages['help/contact_support.php']['parent'] = 'help/index.php';
214
215
216 $_pages['contact_instructor.php']['title_var']  = 'contact_instructor';
217
218 /* public pages */
219
220 $_pages['registration.php']['title_var'] = 'register';
221 $_pages['registration.php']['parent']    = AT_NAV_PUBLIC;
222 $_pages['registration.php']['children']  = isset($_pages['browse.php']['children']) ? $_pages['browse.php']['children'] : array();
223 $_pages['registration.php']['guide']     = 'general/?p=register.php';
224
225 $_pages['browse.php']['title_var'] = 'browse_courses';
226 $_pages['browse.php']['parent']    = AT_NAV_PUBLIC;
227 $_pages['browse.php']['children']  = isset($_pages['browse.php']['children']) ? $_pages['browse.php']['children'] : array();
228 $_pages['browse.php']['guide']     = 'general/?p=browse_courses.php';
229
230 $_pages['login.php']['title_var'] = 'login';
231 $_pages['login.php']['parent']    = AT_NAV_PUBLIC;
232 $_pages['login.php']['children']  = array_merge(array('password_reminder.php'), isset($_pages['login.php']['children']) ? $_pages['login.php']['children'] : array());
233 $_pages['login.php']['guide']     = 'general/?p=login.php';
234
235 $_pages['confirm.php']['title_var'] = 'confirm';
236 $_pages['confirm.php']['parent']    = AT_NAV_PUBLIC;
237
238 $_pages['password_reminder.php']['title_var'] = 'password_reminder';
239 $_pages['password_reminder.php']['parent']    = 'login.php';
240 $_pages['password_reminder.php']['guide']     = 'general/?p=password_reminder.php';
241
242 $_pages['logout.php']['title_var'] = 'logout';
243 $_pages['logout.php']['parent']    = AT_NAV_PUBLIC;
244
245 /* my start page pages */
246 $_pages['users/index.php']['title_var'] = 'my_courses';
247 $_pages['users/index.php']['parent']    = AT_NAV_START;
248 $_pages['users/index.php']['guide']     = 'general/?p=my_courses.php';
249 if (isset($_SESSION['member_id']) && $_SESSION['member_id'] && (!isset($_SESSION['course_id']) || !$_SESSION['course_id'])) {
250         //$_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());
251 }
252         $_pages['users/browse.php']['title_var'] = 'browse_courses';
253         //$_pages['users/browse.php']['parent']    = 'users/index.php';
254         $_pages['users/browse.php']['parent']    = AT_NAV_START;
255         $_pages['users/browse.php']['guide']     = 'general/?p=browse_courses.php';
256
257
258 if (isset($_SESSION['member_id']) && get_instructor_status() === TRUE)  
259 {
260         $_pages['mods/_core/courses/users/create_course.php']['title_var'] = 'create_course';
261 $_pages['mods/_core/courses/users/create_course.php']['parent']    = 'users/index.php';
262 $_pages['mods/_core/courses/users/create_course.php']['guide']    = 'instructor/?p=creating_courses.php';
263 $_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());
264
265 }
266 else if (isset($_SESSION['member_id']) && ALLOW_INSTRUCTOR_REQUESTS)
267 {
268
269           $_pages['mods/_core/courses/users/create_course.php']['title_var'] = 'request_instructor_priv';
270 $_pages['mods/_core/courses/users/create_course.php']['parent']    = 'users/index.php';
271 $_pages['mods/_core/courses/users/create_course.php']['guide']    = 'instructor/?p=creating_courses.php';
272 $_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());
273
274 }
275
276 $_pages['users/private_enroll.php']['title_var'] = 'enroll';
277 $_pages['users/private_enroll.php']['parent']    = 'users/index.php';
278
279 $_pages['users/remove_course.php']['title_var'] = 'unenroll';
280 $_pages['users/remove_course.php']['parent']    = 'users/index.php';
281
282 $_pages['mods/_standard/profile_pictures/profile_picture.php']['title_var']    = 'picture';
283
284 $_pages['users/profile.php']['title_var']    = 'profile';
285 $_pages['users/profile.php']['parent']   = AT_NAV_START;
286 $_pages['users/profile.php']['guide']     = 'general/?p=profile.php';
287 //$_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']);
288 $_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']);
289
290 $_pages['users/password_change.php']['title_var'] = 'change_password';
291 $_pages['users/password_change.php']['parent']    = 'users/profile.php';
292 //$_pages['users/password_change.php']['guide']    = 'instructor/?p=creating_courses.php';
293
294 $_pages['users/email_change.php']['title_var'] = 'change_email';
295 $_pages['users/email_change.php']['parent']    = 'users/profile.php';
296
297 $_pages['users/preferences.php']['title_var']  = 'preferences';
298 $_pages['users/preferences.php']['parent'] = AT_NAV_START;
299 $_pages['users/preferences.php']['guide']  = 'general/?p=preferences.php';
300
301 $_pages['users/pref_wizard/index.php']['title_var']  = 'preferences';
302 $_pages['users/pref_wizard/index.php']['parent'] = AT_NAV_START;
303
304
305
306 /* course pages */
307 $_pages['index.php']['title_var']  = 'course_home';
308 $_pages['index.php']['parent'] = AT_NAV_COURSE;
309
310 $_pages['enroll.php']['title_var']  = 'enroll';
311 $_pages['enroll.php']['parent'] = AT_NAV_COURSE;
312
313 /* instructor pages: */
314 $_pages['tools/index.php']['title_var'] = 'manage';
315 $_pages['tools/index.php']['parent']    = AT_NAV_COURSE;
316
317 $_pages['inbox/index.php']['title_var'] = 'inbox';
318 $_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());
319
320 $_pages['inbox/sent_messages.php']['title_var'] = 'sent_messages';
321 $_pages['inbox/sent_messages.php']['parent']    = 'inbox/index.php';
322
323 $_pages['inbox/send_message.php']['title_var'] = 'send_message';
324 $_pages['inbox/send_message.php']['parent']    = 'inbox/index.php';
325
326 $_pages['inbox/export.php']['title_var'] = 'export';
327 $_pages['inbox/export.php']['parent']    = 'inbox/index.php';
328
329 $_pages['profile.php']['title_var'] = 'profile';
330 $_pages['profile.php']['parent']    = 'index.php';
331
332
333 $current_page = substr($_SERVER['PHP_SELF'], strlen($_base_path));
334
335 function get_num_new_messages() {
336     global $db;
337     static $num_messages;
338
339     if (isset($num_messages)) {
340         return $num_messages;
341     }
342     $sql    = "SELECT COUNT(*) AS cnt FROM ".TABLE_PREFIX."messages WHERE to_member_id=$_SESSION[member_id] AND new=1";
343     $result = mysql_query($sql, $db);
344     $row    = mysql_fetch_assoc($result);
345     $num_messages = $row['cnt'];
346
347     return $num_messages;
348 }
349
350 //TODO****************BOLOGNA*******************REMOVE ME**********************/
351 function get_main_navigation($current_page) {
352     global $_pages, $_base_path, $_tool;
353
354     $parent_page = $_pages[$current_page]['parent'];
355     $_top_level_pages = array();
356
357     $tool_file= $table = '';
358
359     if (isset($parent_page) && defined($parent_page)) {
360         foreach($_pages[$parent_page] as $page) {
361             if (isset($_pages[$page])) {
362                 if (isset($_pages[$page]['title'])) {
363                     $_page_title = $_pages[$page]['title'];
364                 } else {
365                     $_page_title = _AT($_pages[$page]['title_var']);
366                 }
367
368                 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
369                     $tool_file = $_tool[$_pages[$page]['title_var']]['file'];
370                     $table = $_tool[$_pages[$page]['title_var']]['table'];
371                 } else {
372                                         $tool_file = '';
373                                         $table = '';
374                                 }
375
376                 $_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);
377             }
378         }
379     } else if (isset($parent_page)) {
380             return get_main_navigation($parent_page);
381         }
382
383     return $_top_level_pages;
384 }
385
386 function get_current_main_page($current_page) {
387     global $_pages, $_base_path;
388     $parent_page = $_pages[$current_page]['parent'];
389
390     if (isset($parent_page) && defined($parent_page)) {
391         return $_base_path . url_rewrite($current_page);
392     } else if (isset($parent_page)) {
393             return get_current_main_page($parent_page);
394         }
395 }
396
397 function get_sub_navigation($current_page) {
398     global $_pages, $_base_path;
399
400     if (isset($current_page) && defined($current_page)) {
401     // reached the top
402         return array();
403     } else if (isset($_pages[$current_page]['children'])) {
404             if (isset($_pages[$current_page]['title'])) {
405                 $_page_title = $_pages[$current_page]['title'];
406             } else {
407                 $_page_title = _AT($_pages[$current_page]['title_var']);
408             }
409
410             $_sub_level_pages[] = array('url' => $_base_path . $current_page, 'title' => $_page_title);
411             foreach ($_pages[$current_page]['children'] as $child) {
412
413                 if (isset($_pages[$child]['title'])) {
414                     $_page_title = $_pages[$child]['title'];
415                 } else {
416                     $_page_title = _AT($_pages[$child]['title_var']);
417                 }
418
419                 $_sub_level_pages[] = array('url' => $_base_path . $child, 'title' => $_page_title, 'has_children' => isset($_pages[$child]['children']));
420             }
421         } else if (isset($_pages[$current_page]['parent'])) {
422             // no children
423
424                 $parent_page = $_pages[$current_page]['parent'];
425                 return get_sub_navigation($parent_page);
426             }
427
428     return $_sub_level_pages;
429 }
430
431 function get_current_sub_navigation_page($current_page) {
432     global $_pages, $_base_path;
433     $parent_page = $_pages[$current_page]['parent'];
434
435     if (isset($parent_page) && defined($parent_page)) {
436         return $_base_path . $current_page;
437     } else {
438         return $_base_path . $current_page;
439     }
440 }
441
442 function get_path($current_page) {
443     global $_pages, $_base_path;
444
445     $parent_page = $_pages[$current_page]['parent'];
446
447     if (isset($_pages[$current_page]['title'])) {
448         $_page_title = $_pages[$current_page]['title'];
449     } else {
450         $_page_title = _AT($_pages[$current_page]['title_var']);
451     }
452
453     if (isset($parent_page) && defined($parent_page)) {
454         $path[] = array('url' => $_base_path . url_rewrite($current_page), 'title' => $_page_title);
455         return $path;
456     } else if (isset($parent_page)) {
457             $path[] = array('url' => $_base_path . url_rewrite($current_page), 'title' => $_page_title);
458             $path = array_merge((array) $path, get_path($parent_page));
459         } else {
460             $path[] = array('url' => $_base_path . url_rewrite($current_page), 'title' => $_page_title);
461         }
462
463     return $path;
464 }
465
466 //TODO****************BOLOGNA*********************REMOVE ME*****************/
467 function get_home_navigation($home_array='') {
468     global $_pages, $_list, $_base_path, $_tool;
469
470     // set default home_array to course index navigation array
471     if (!is_array($home_array)) $home_array = $_pages[AT_NAV_HOME];
472
473     $home_links = array();
474     foreach ($home_array as $child) {                                           //esecuzione del ciclo fin quando non saranno terminati i moduli presenti nella home-page del corso
475         if (isset($_pages[$child])) {
476         // initialization
477             $title = $icon = $sub_file = $image = $text = $tool_file = $table ='';
478
479             if (isset($_pages[$child]['title'])) {                              //viene prelevato il titolo che dovr� poi essere utilizzato nella visualizzazione
480                 $title = $_pages[$child]['title'];
481             } else {
482                 $title = _AT($_pages[$child]['title_var']);
483             }
484             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.
485                 $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[]
486             } 
487             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).
488                 $text = $_pages[$child]['text'];                                //il testo viene inserito in una variabile d'appoggio e successivamente nell'array.
489             }
490
491             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.
492                 $sub_file = $_list[$_pages[$child]['title_var']]['file'];
493
494              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
495                 $tool_file = $_tool[$_pages[$child]['title_var']]['file'];
496                 $table = $_tool[$_pages[$child]['title_var']]['table'];
497              }
498
499             $real_image_in_theme = AT_INCLUDE_PATH.'../themes/'.$_SESSION['prefs']['PREF_THEME'].'/'.$_pages[$child]['img'];
500             $image_in_theme = $_base_path.'themes/'.$_SESSION['prefs']['PREF_THEME'].'/'.$_pages[$child]['img'];
501
502             // look for images in theme folder. If not exists, use images relative to ATutor root folder
503             if (file_exists($real_image_in_theme))
504                 $image = $image_in_theme;
505             else
506                 $image = $_base_path.$_pages[$child]['img'];
507
508             // 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.
509             $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);
510         }
511     }
512     return $home_links;
513 }
514
515 ?>