]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Home/sitemap.php
Release 6.5.0
[Github/sugarcrm.git] / modules / Home / sitemap.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 $sm = sm_build_array();
39 $sm_smarty = new Sugar_Smarty();
40
41 global $sugar_config;
42 if(isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '')
43 {
44     $current_language = $_SESSION['authenticated_user_language'];
45 }
46 else
47 {
48     $current_language = $sugar_config['default_language'];
49 }
50
51 $mod_strings = return_module_language($current_language, 'Home');
52 $sm_smarty->assign('CLOSE', isset($mod_strings['LBL_CLOSE_SITEMAP']) ? $mod_strings['LBL_CLOSE_SITEMAP'] : '');
53
54 // get the list_strings in order for module friendly name display.
55 $app_list_strings = return_app_list_strings_language($current_language);
56
57 foreach ($sm as $mod_dir_name => $links)
58 {
59     $module_friendly_name = $app_list_strings['moduleList'][$mod_dir_name];
60     $temphtml = "";
61     $temphtml .= '<h4><a href="javascript:window.location=\'index.php?module='.$mod_dir_name.'&action=index\'">' . $module_friendly_name .'</a></h4><ul class=\'noBullet\'>';
62
63     foreach ($links as $name => $href)
64     {
65         $temphtml .= '<li class=\'noBullet\'><a href="javascript:window.location=\''. $href .'\'">' . $name . ' ' . '</a></li>';
66     }
67
68     $temphtml .= '</ul>';
69     $sm_smarty->assign(strtoupper($mod_dir_name), $temphtml);
70 }
71
72 // Specify the sitemap template to use; allow developers to override this with a custom one to add/remove modules
73 // from the list
74 $tpl = 'modules/Home/sitemap.tpl';
75 if ( sugar_is_file('custom/modules/Home/sitemap.tpl') ) {
76     $tpl = 'custom/modules/Home/sitemap.tpl';
77 }
78 echo $sm_smarty->fetch($tpl);
79
80 function sm_build_array()
81 {
82     //if the sitemap array is already stored, then pass it back
83     if (isset($_SESSION['SM_ARRAY']) && !empty($_SESSION['SM_ARRAY'])){
84         return $_SESSION['SM_ARRAY'];   
85     }   
86
87
88     include("include/modules.php");
89         global $sugar_config,$mod_strings;
90
91
92         // Need to set up mod_strings when we iterate through module menus.
93     $orig_modstrings = array();
94     if(!empty($mod_strings))
95     {
96      $orig_modstrings = $mod_strings;
97     }
98     if(isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '')
99     {
100         $current_language = $_SESSION['authenticated_user_language'];
101     }
102     else
103     {
104         $current_language = $sugar_config['default_language'];
105     }
106         $exclude= array();              // in case you want to exclude any.
107     $mstr_array = array();
108
109         global $modListHeader;
110         if(!isset($modListHeader))
111         {
112                 global $current_user;
113                 if(isset($current_user))
114                 {
115                         $modListHeader = query_module_access_list($current_user);
116                 }
117         }
118
119     foreach($modListHeader as $key=>$val)
120     {
121         if(!empty($exclusion_array) && in_array($val,$exclude ))
122         {
123            continue;
124         }
125         else
126         {
127                     if (file_exists('modules/'.$val.'/Menu.php'))
128                     {
129                 $mod_strings = return_module_language($current_language, $val);
130                 $module_menu = array();
131                 include('modules/'.$val.'/Menu.php');
132
133                 $tmp_menu_items = array();
134                 foreach($module_menu as $menu)
135                 {
136                         if(isset($menu[0]) && !empty($menu[0]) && isset($menu[1]) && !empty($menu[1]) && trim($menu[0]) !='#')
137                         {
138                         $tmp_menu_items[$menu[1]] =$menu[0];
139                     }
140                 }
141                 $mstr_array[$val] = $tmp_menu_items;
142             }
143         }
144     }
145
146         //reset the modstrings to current module
147         $mod_strings = $orig_modstrings ;
148     //store master array into session variable
149     $_SESSION['SM_ARRAY'] = $mstr_array; 
150         return $mstr_array;
151 }