root/c3crm/sugarcrm/trunk/menu.php
Revision 1244 (by jianting, 05/10/06 11:27:59) |
---|
<?php $GLOBALS['sugarEntry'] = true; if(empty($GLOBALS['sugarEntry'])) die('Not A Valid Entry Point'); /********************************************************************************* * The contents of this file are subject to the SugarCRM Public License Version * 1.1.3 ("License"); You may not use this file except in compliance with the * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * All copies of the Covered Code must include on each user interface screen: * (i) the "Powered by SugarCRM" logo and * (ii) the SugarCRM copyright notice * in the same form as they appear in the distribution. See full license for * requirements. * * The Original Code is: SugarCRM Open Source * The Initial Developer of the Original Code is SugarCRM, Inc. * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.; * All Rights Reserved. * Contributor(s): ______________________________________. ********************************************************************************/ /********************************************************************************* * $Id: header.php,v 1.8.4.1 2006/01/08 04:36:06 majed Exp $ * Description: Contains a variety of utility functions used to display UI * components such as form headers and footers. Intended to be modified on a per * theme basis. ********************************************************************************/ require_once('XTemplate/xtpl.php'); require_once("data/Tracker.php"); require_once("include/utils.php"); require_once('include/modules.php'); require_once("config.php"); require_once ('log4php/LoggerManager.php'); require_once ('modules/ACL/ACLController.php'); require_once("include/database/PearDatabase.php"); require_once('modules/Tabgroups/Tabgroup.php'); require_once('modules/Users/User.php'); global $sugar_config; global $app_strings; global $current_user; $GLOBALS['log'] = LoggerManager::getLogger('Home'); if (!empty($sugar_config['session_dir'])) { session_save_path($sugar_config['session_dir']); } session_start(); $user_unique_key = (isset($_SESSION['unique_key'])) ? $_SESSION['unique_key'] : ""; $server_unique_key = (isset($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : ""; if ($user_unique_key != $server_unique_key) { session_destroy(); header("Location: login.php"); exit(); } if(!isset($_SESSION['authenticated_user_id'])) { // TODO change this to a translated string. session_destroy(); die("An active session is required to export content"); } // load the logger $current_user = new User(); $result = $current_user->retrieve($_SESSION['authenticated_user_id']); if($result == null) { session_destroy(); die("An active session is required to export content"); } if(isset($_SESSION['authenticated_user_theme']) && $_SESSION['authenticated_user_theme'] != '') { $theme = $_SESSION['authenticated_user_theme']; } else { $theme = $sugar_config['default_theme']; } /* if(empty($theme)) { $theme = "SugarLite"; } */ $GLOBALS['log']->debug('Current theme is: '.$theme); if(isset($_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != '') { $current_language = $_SESSION['authenticated_user_language']; } else { $current_language = $sugar_config['default_language']; } $GLOBALS['log']->debug('current_language is: '.$current_language); //set module and application string arrays based upon selected language $app_strings = return_application_language($current_language); $app_list_strings = return_app_list_strings_language($current_language); require_once("include/globalControlLinks.php"); $theme_path="themes/".$theme."/"; $image_path=$theme_path."images/"; $default_charset = $sugar_config['default_charset']; $xtpl=new XTemplate ($theme_path."menu.html"); $xtpl->assign("APP", $app_strings); if(isset($app_strings['LBL_CHARSET'])) { $xtpl->assign("LBL_CHARSET", $app_strings['LBL_CHARSET']); } else { $xtpl->assign("LBL_CHARSET", $default_charset); } $xtpl->assign("THEME", $theme); $xtpl->assign("IMAGE_PATH", $image_path); $xtpl->assign("CURRENT_USER", $current_user->first_name." ".$current_user->last_name); $modListHeader = $moduleList; if(isset($current_user->id)) { $modListHeader = query_module_access_list($current_user); } $modListHeader = get_val_array($modListHeader); $modListHeaderClone = $modListHeader; $tabgroupSeed = new Tabgroup(); $groups = $tabgroupSeed->getUserTabgroups($current_user->id); $tg_id_name = array(); $current_tg = ""; //for the first time. get the default app if(!empty($groups)){ if(!isset($_REQUEST["tabgroup"])){ //login for the first time if(!isset($_SESSION["tabgroup"])){ if(is_admin($current_user)){ $tg = $groups[0]; $current_tg = $tg->id; }else{ foreach($groups as $tg){ $tg_id_name[$tg->id] = $tg->name; if($tg->is_default == true){ $current_tg = $tg->id; } } if($current_tg == ""){ $tg = $groups[0]; $current_tg = $tg->id; //no default application is assigned. } } $_SESSION["tabgroup"] = $current_tg; }else{ $current_tg = $_SESSION["tabgroup"]; } }else{ $current_tg = $_REQUEST["tabgroup"]; $_SESSION["tabgroup"] = $current_tg; } $tabgroupSeed = new Tabgroup(); $tg = $tabgroupSeed->retrieve($current_tg); if(isset($tg->group_def) && !empty($tg->group_def)){ $modListHeaderClone = array_intersect_assoc($tg->group_def, $modListHeaderClone); } }else{ $current_tg = ""; } if(isset($_REQUEST["tabgroup"])) { $current_tg = $_REQUEST["tabgroup"]; } else { $current_tg = ""; } $tg = $tabgroupSeed->retrieve($current_tg); if(isset($tg->group_def) && !empty($tg->group_def)){ $modListHeaderClone = array_intersect_assoc($tg->group_def, $modListHeaderClone); } if(is_admin($current_user)) { $modListHeaderClone["Administration"] = "Administration"; } //print_r($modListHeaderClone); /* $application_modules = array(); $application_modules[] = "Contacts"; $application_modules[] = "Accounts"; $application_modules[] = "Leads"; $application_modules[] = "Opportunities"; $application_modules[] = "Products"; $application_modules[] = "Quotes"; */ foreach($modListHeaderClone as $key => $module_item) { $module_label = $app_list_strings['moduleList'][$module_item]; global $mod_strings; //global $app_strings; $xtpl->assign("MODULENAME", $module_item); $xtpl->assign("MODULE_LABEL", $module_label); $mod_strings = return_module_language($current_language, $module_item); include_once("modules/".$module_item."/Menu.php"); //global $module_menu; $count = 0; foreach($module_menu as $menu_item) { $subModuleCheck = 0; $subModuleCheckArray = array("Tasks", "Calls", "Meetings", "Notes","Prospects"); if(isset($menu_item[3])) { if(in_array($menu_item[3], $subModuleCheckArray) && (array_key_exists("Calendar", $modListHeader) || array_key_exists("Activities", $modListHeader))) $subModuleCheck = 1; } if(!isset($menu_item[3])|| !isset($modListHeader) || (isset($menu_item[3]) && (key_exists($menu_item[3],$modListHeader) || $subModuleCheck))){ if($count == 0 && substr_count($menu_item[0],"&action=index") > 0) { $first_url = $menu_item[0]; $count ++; } $after_this = current($module_menu); if ($menu_item[1] != 'Deleted Items') { $xtpl->assign("URL", $menu_item[0]); $xtpl->assign("LABEL", $menu_item[1]); $xtpl->assign("SC_MODULE_NAME", $menu_item[2]); $xtpl->assign("SC_IMAGE", get_image($image_path.$menu_item[2],"alt='".$menu_item[1]."' border='0' align='absmiddle'")); if (empty($after_this)) $xtpl->assign("SEPARATOR", ""); else $xtpl->assign("SEPARATOR", "</br>"); } else { $xtpl->assign("DELETED_ITEMS_URL", $menu_item[0]); $xtpl->assign("DELETED_ITEMS_LABEL", $menu_item[1]); } $xtpl->parse("main.menu.sub_menu.sub_menu_item"); } if(substr_count($menu_item[0],"&action=index") > 0 && substr_count($menu_item[0],"Calendar") < 1 && substr_count($menu_item[0],"Home") < 1 && substr_count($menu_item[0],"Dashboard") < 1 && substr_count($menu_item[0],"Administration") < 1) { $menu_item[0] .= "&show_deleted=1"; $recycle_menu[] = $menu_item; } } if(isset($recycle_menu)) { foreach($recycle_menu as $recycle_menu_item) { $xtpl->assign("URL", $recycle_menu_item[0]); $xtpl->assign("LABEL", $recycle_menu_item[1].$app_strings['LBL_RECYCLE']); $xtpl->assign("SC_MODULE_NAME", $recycle_menu_item[2]); $xtpl->assign("SC_IMAGE", get_image($image_path.$recycle_menu_item[2],"alt='".$recycle_menu_item[1]."' border='0' align='absmiddle'")); //$xtpl->assign("SEPARATOR", ""); $xtpl->assign("SEPARATOR", "</br>"); $xtpl->parse("main.menu.sub_menu.sub_menu_item"); } unset($recycle_menu); } unset($module_menu); $xtpl->parse("main.menu.sub_menu"); if(isset($first_url) && !empty($first_url)) { $xtpl->assign("FIRST_URL", $first_url); } $xtpl->parse("main.menu"); } if (isset($_REQUEST['query_string'])) $xtpl->assign("SEARCH", $_REQUEST['query_string']); $xtpl->parse("main"); $xtpl->out("main"); ?>
Note: See TracBrowser for help on using the browser.