This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/core/auth_generate_admin_menu.inc.php

151 lines
4.5 KiB
PHP
Raw Normal View History

<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
2009-08-03 04:10:16 +00:00
*
* Originally authored by Tony Landis, AgileBill LLC
*
* Recent modifications by Deon George
*
* @author Deon George <deonATleenooksDOTnet>
* @copyright 2009 Deon George
* @link http://osb.leenooks.net
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
2009-08-03 04:10:16 +00:00
* @author Tony Landis <tony@agileco.com>
* @package AgileBill
* @subpackage Menu
*/
/**
* The main AgileBill Admin Menu Method
*
* @package AgileBill
2009-08-03 04:10:16 +00:00
* @subpackage Menu
*/
2009-08-03 04:10:16 +00:00
function auth_generate_admin_menu($menu_obj) {
global $C_translate,$smarty,$C_list;
$menu_obj->auth_update();
2009-08-03 04:10:16 +00:00
$i = 1;
$js = '';
$arr = $menu_obj->module;
$arr2 = $menu_obj->module;
2009-08-03 04:10:16 +00:00
# Loop through the modules
while (list($module,$val) = each($arr)) {
if (! empty($val[2])) {
if ($val[1] == $val[0] || empty($val[0]) || empty($val[1])) {
$module_name = $C_translate->translate('menu',$module,'','menutitle');
$parent = $val[0];
$module_id = $val[0];
2009-08-03 04:10:16 +00:00
$module_arr[$i]['name'] = $module_name;
$module_arr[$i]['module'] = $module;
# Loop through the methods
while (list($method,$meth_arr) = each($arr[$module])) {
if (gettype($meth_arr) == 'array' && ! empty($meth_arr[1])) {
$method_name = $C_translate->translate($method,$module,'','methodtitle');
if(empty($meth_arr[2]))
$page = $module.':'.$method;
else
2009-08-03 04:10:16 +00:00
$page = htmlspecialchars(str_replace('%%',$module,$meth_arr[2]));
2009-08-03 04:10:16 +00:00
$module_arr[$i]['methods'][] = array('name'=>$method_name,'page'=>$page);
}
}
2009-08-03 04:10:16 +00:00
# Loop through the sub-modules:
reset($arr2);
2009-08-03 04:10:16 +00:00
$ii = 0;
while (list($module,$val) = each ($arr2)) {
if (! empty($val[2])) {
if ($val[1] == $parent && $module_id != $val[0]) {
$module_name = $C_translate->translate('menu',$module,'','menutitle');
$module_arr[$i]["sub_name"][$ii] = $module_name;
# Loop through the methods
while (list($method,$meth_arr) = each($arr2[$module])) {
if (gettype($meth_arr) == 'array' && ! empty($meth_arr[1])) {
$method_name = $C_translate->translate($method,$module,'','methodtitle');
if(empty($meth_arr[2]))
$page = $module.':'.$method;
else
$page = htmlspecialchars(str_replace('%%',$module,$meth_arr[2]));
$module_arr[$i]['sub_methods'][$ii][] = array('name'=>$method_name,'page'=>$page);
}
}
2009-08-03 04:10:16 +00:00
$ii++;
}
}
2009-08-03 04:10:16 +00:00
}
2009-08-03 04:10:16 +00:00
$i++;
}
}
}
2009-08-03 04:10:16 +00:00
# Generate the main modules:
$js = '';
2009-01-05 02:21:21 +00:00
$js .= ".|Overview|javascript:openUrl('?_page=core:admin');\n";
$js .= ".|Exit Administration|javascript:exitAdmin();\n";
2009-08-03 04:10:16 +00:00
for ($i=1; $i<=count($module_arr); $i++) {
$name = $module_arr[$i]['name'];
$js .= ".|{$name}\n";
2009-08-03 04:10:16 +00:00
# Generate the main methods:
for ($ii=0; $ii<count($module_arr[$i]['methods']); $ii++) {
$name = $module_arr[$i]['methods'][$ii]['name'];
2009-08-03 04:10:16 +00:00
$page = $module_arr[$i]['methods'][$ii]['page'];
2009-01-05 02:21:21 +00:00
$js .= "..|{$name}|javascript:openUrl('?_page={$page}')\n";
}
2009-08-03 04:10:16 +00:00
# Generate the sub modules:
for ($ii=0; $ii<count(@$module_arr[$i]['sub_name']); $ii++) {
$name = $module_arr[$i]['sub_name'][$ii];
2009-01-05 02:21:21 +00:00
$js .= "..|{$name}|#\n";
2009-08-03 04:10:16 +00:00
# Generate the sub methods:
for ($iii=0; $iii<count($module_arr[$i]['sub_methods'][$ii]); $iii++) {
$name = $module_arr[$i]['sub_methods'][$ii][$iii]['name'];
$page = $module_arr[$i]['sub_methods'][$ii][$iii]['page'];
2009-01-05 02:21:21 +00:00
$js .= "...|{$name}|javascript:openUrl('?_page={$page}')\n";
}
}
2009-08-03 04:10:16 +00:00
}
2009-08-03 04:10:16 +00:00
# Set the dates for the quicksearch
$smarty->assign('today_start',$C_list->date(mktime(0,0,0,date('m'),date('d'),date('Y'))));
$smarty->assign('week_start',$C_list->date(mktime(0,0,0,date('m'),date('d')-7,date('Y'))));
$smarty->assign('month_start',$C_list->date(mktime(0,0,0,date('m'),1,date('Y'))));
# Generate the menu
2009-08-03 04:10:16 +00:00
require_once(PATH_INCLUDES.'phplayers/PHPLIB.php');
require_once(PATH_INCLUDES.'phplayers/layersmenu-common.inc.php');
require_once(PATH_INCLUDES.'phplayers/treemenu.inc.php');
2009-08-03 04:10:16 +00:00
# Unstoppable agileco logo ;)
echo '<img src="themes/default/images/logo-small.png" alt="Logo" style="border: 0; position: absolute; top: 8px; left: 45px;"/>';
$mnu = new TreeMenu();
$mnu->setMenuStructureString($js);
2009-08-03 04:10:16 +00:00
$mnu->setIconsize(16,16);
$mnu->parseStructureForMenu('treemenu1');
2009-08-03 04:10:16 +00:00
$mnu->setTreemenuTheme('kde_');
return $mnu->newTreeMenu('treemenu1');
}
2009-01-05 02:21:21 +00:00
?>