<?php
/* * *******************************************************************************
* TES is a Time and Expense Management program developed by
* Initechs, LLC. Copyright (C) 2009 - 2010 Initechs LLC.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY INITECHS, INITECHS DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact Initechs headquarters at 1841 Piedmont Road, Suite 301,
* Marietta, GA, USA. or at email address hide@address.com
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display od the "Initechs" logo.
* If the display of the logo is not reasonably feasible for technical reasons,
* the Appropriate Legal Notices must display the words "Powered by Initechs".
* ****************************************************************************** */
$basedir = dirname(__FILE__) . './..';
require_once("$basedir/baseclass/GetAuthorization.php");
require_once("$basedir/menu/menuconfig.php");
require_once("$basedir/systemconfig/controllerstructure.php");
class Menu {
public function buildMenu() {
global $menu_config_array;
global $config_array;
if (loggedInUserName() == null)
return ("Please login to the application to access your information.");
$menustr = '';
$menustr .= "\n<table id='frame' style='border:none; '>";
$menustr .= "\n<tr>";
$menustr .= "\n<td>";
$menustr .= "\n<ul id='navlist'>";
$auth = new userauthorization();
foreach ($menu_config_array as $module => $menu_array_detail) {
if ((isset($menu_array_detail['showOnMenu']))
and ($menu_array_detail['showOnMenu'] == 'noshow'))
continue;
if ($auth->isauthorized_module_level($module)) {
$active = (isset($_GET['module']) and ($_GET['module'] == $module)) ? "id='active'" : "";
if ((!isset($menu_array_detail['heading']))
or ($menu_array_detail['heading'] == ''))
$menu_array_detail['heading'] = $module;
$menuHeading = changeLiteral(ucfirst($menu_array_detail['heading']));
$actionStr = (isset($menu_array_detail['actions']['List'])) ? '&action=List' : '';
$addlGetParm = ($module == 'sysadmin') ? '&uid=1' : '';
$menustr .= "\n\t<li $active><a href=\"index.php?module=$module$actionStr$addlGetParm\">$menuHeading</a></li>";
}
}
$menustr .= "\n</ul>";
$menustr .= "\n</td>";
$menustr .= "\n</tr>";
if (!isset($_GET['module'])) {
$menustr .= "\n</table>";
return $menustr;
}
$menustr .= "\n<tr>";
$menustr .= "\n<td>";
$menustr .= "\n<ul id='navlist'>";
// Second line of the menu.
foreach ($menu_config_array[$_GET['module']]['actions'] as $action => $action_detail) {
if (isset($action_detail['showOnMenu'])
and ($action_detail['showOnMenu'] == 'noshow'))
continue;
if (isset($action_detail['showCondition'])) {
$show_condition = explode("=", $action_detail['showCondition'], 2);
if ((trim(strtolower($show_condition[0])) == 'action')
and (trim($show_condition[1]) != $_GET['action']))
continue;
}
if (isset($menu_config_array[$action])) { // Refer to another module
$urlModule = $action;
if (!$auth->isauthorized_module_level($action))
continue;
}
else {
if (isset($action_detail['module']))
$urlModule = $action_detail['module'];
else
$urlModule = $_GET['module'];
if (!$auth->isauthorized_module_action_level($urlModule, $action))
continue;
}
$urlAction = isset($menu_config_array[$action]) ? '&action=List' : "&action={$action}";
$addlGetParm = (($urlModule == 'sysadmin') and ($action == 'List')) ? '&uid=1' : '';
if ($_GET['action'] == $action) {
foreach ($_GET as $getKey => $getParm) {
if ($getKey != 'module'
and $getKey != 'action'
and $getParm != '')
$addlGetParm .= "&$getKey=$getParm";
}
}
$activeAction = (isset($_GET['action']) and $_GET['action'] == $action) ? "id='active'" : "";
$pgm = isset($config_array[$urlModule]['actions'][$action]['callProgram']) ? $config_array[$urlModule]['actions'][$action]['callProgram'] : 'index.php';
$heading = isset($action_detail['heading']) ? ucfirst($action_detail['heading']) : ucfirst($action);
$heading = changeLiteral($heading);
$menustr .= "\n\t<li $activeAction><a href=\"{$pgm}?module=$urlModule$urlAction$addlGetParm\">$heading</a></li>";
}
$menustr .= "\n</ul>";
$menustr .= "\n</td>";
$menustr .= "\n</tr>";
$menustr .= "\n</table>";
return $menustr;
}
}
?>