From 420cf9ad1d402fe97cae9a07be307af5fae102a3 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 16 Oct 2003 09:36:46 +0000 Subject: [PATCH] moved admin, preferences hook to one class, added a sidebox-menu --- .../class.admin_prefs_sidebox_hooks.inc.php | 74 +++++++++++++++++++ infolog/inc/hook_admin.inc.php | 28 +------ infolog/inc/hook_preferences.inc.php | 10 +-- infolog/setup/setup.inc.php | 6 +- 4 files changed, 83 insertions(+), 35 deletions(-) create mode 100644 infolog/inc/class.admin_prefs_sidebox_hooks.inc.php diff --git a/infolog/inc/class.admin_prefs_sidebox_hooks.inc.php b/infolog/inc/class.admin_prefs_sidebox_hooks.inc.php new file mode 100644 index 0000000000..f93038ce7e --- /dev/null +++ b/infolog/inc/class.admin_prefs_sidebox_hooks.inc.php @@ -0,0 +1,74 @@ + * + * ------------------------------------------------------- * + * This program is free software; you can redistribute it and/or modify it * + * under the terms of the GNU General Public License as published by the * + * Free Software Foundation; either version 2 of the License, or (at your * + * option) any later version. * + \**************************************************************************/ + + /* $Id$ */ + +class admin_prefs_sidebox_hooks +{ + function all_hooks($args) + { + $appname = 'infolog'; + $location = is_array($args) ? $args['location'] : $args; + //echo "

admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'

\n"; + + if ($location == 'sidebox_menu') + { + $file = array( + 'add' => $GLOBALS['phpgw']->link('/index.php',array( + 'menuaction' => 'infolog.uiinfolog.edit' )) + ); + display_sidebox($appname,$GLOBALS['phpgw_info']['apps']['infolog']['title'].' '.lang('Menu'),$file); + } + + if ($GLOBALS['phpgw_info']['user']['apps']['preferences'] && $location != 'admin') + { + $file = array( + 'Preferences' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname), + 'Grant Access' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname), + 'Edit Categories' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True') + ); + if ($location == 'preferences') + { + display_section($appname,$file); + } + else + { + display_sidebox($appname,lang('Preferences'),$file); + } + } + + if ($GLOBALS['phpgw_info']['user']['apps']['admin'] && $location != 'preferences') + { + $file = Array( + 'Site configuration' => $GLOBALS['phpgw']->link('/index.php',array( + 'menuaction' => 'infolog.uiinfolog.admin' )), + 'Global Categories' => $GLOBALS['phpgw']->link('/index.php',array( + 'menuaction' => 'admin.uicategories.index', + 'appname' => $appname, + 'global_cats'=> True)), + 'Custom fields, typ and status' => $GLOBALS['phpgw']->link('/index.php',array( + 'menuaction' => 'infolog.uicustomfields.edit')), + 'CSV-Import' => $GLOBALS['phpgw']->link('/infolog/csv_import.php') + ); + if ($location == 'admin') + { + display_section($appname,$file); + } + else + { + display_sidebox($appname,lang('Admin'),$file); + } + } + } +} + +?> diff --git a/infolog/inc/hook_admin.inc.php b/infolog/inc/hook_admin.inc.php index 42e6a8fcb7..c0b6ba21cf 100644 --- a/infolog/inc/hook_admin.inc.php +++ b/infolog/inc/hook_admin.inc.php @@ -10,28 +10,8 @@ \**************************************************************************/ /* $Id$ */ - { - $file = Array - ( - 'Site configuration' => $GLOBALS['phpgw']->link('/index.php',array( - 'menuaction' => 'infolog.uiinfolog.admin' )), - 'Global Categories' => $GLOBALS['phpgw']->link('/index.php',array( - 'menuaction' => 'admin.uicategories.index', - 'appname' => $appname, - 'global_cats'=> True)), - 'Custom fields, typ and status' => $GLOBALS['phpgw']->link('/index.php',array( - 'menuaction' => 'infolog.uicustomfields.edit')), - 'CSV-Import' => $GLOBALS['phpgw']->link('/infolog/csv_import.php') - ); - -//Do not modify below this line - if ($GLOBALS['phpgw']->common->public_functions['display_mainscreen']) - { - $GLOBALS['phpgw']->common->display_mainscreen($appname,$file); - } - else - { - display_section($appname,lang($appname),$file); // for .14/6 - } - } +{ + // for compatibility and convinience, can go soon + ExecMethod('infolog.admin_prefs_sidebox_hooks.all_hooks','admin'); +} ?> diff --git a/infolog/inc/hook_preferences.inc.php b/infolog/inc/hook_preferences.inc.php index a5241f9e05..ee9b485f88 100644 --- a/infolog/inc/hook_preferences.inc.php +++ b/infolog/inc/hook_preferences.inc.php @@ -13,14 +13,8 @@ /* $Id$ */ { -// Only Modify the $file and $title variables..... - $file = array( - 'Preferences' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname='.$appname), - 'Grant Access' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname), - 'Edit Categories' => $GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app=' . $appname . '&cats_level=True&global_cats=True') - ); -//Do not modify below this line - display_section($appname,lang($appname),$file); // leave 2. $appname for compatibilty with .14 + // for compatibility and convinience, can go soon + ExecMethod('infolog.admin_prefs_sidebox_hooks.all_hooks','preferences'); } ?> diff --git a/infolog/setup/setup.inc.php b/infolog/setup/setup.inc.php index dd1fc5056e..79218259cb 100755 --- a/infolog/setup/setup.inc.php +++ b/infolog/setup/setup.inc.php @@ -47,11 +47,10 @@ InfoLog page in our Wiki.'; /* The hooks this app includes, needed for hooks registration */ - $setup_info['infolog']['hooks'][] = 'preferences'; + $setup_info['infolog']['hooks']['preferences'] = 'infolog.admin_prefs_sidebox_hooks.all_hooks'; $setup_info['infolog']['hooks'][] = 'settings'; - $setup_info['infolog']['hooks'][] = 'admin'; + $setup_info['infolog']['hooks']['admin'] = 'infolog.admin_prefs_sidebox_hooks.all_hooks'; $setup_info['infolog']['hooks'][] = 'deleteaccount'; - $setup_info['infolog']['hooks'][] = 'about'; $setup_info['infolog']['hooks'][] = 'home'; $setup_info['infolog']['hooks']['addressbook_view'] = 'infolog.uiinfolog.hook_view'; $setup_info['infolog']['hooks']['projects_view'] = 'infolog.uiinfolog.hook_view'; @@ -59,6 +58,7 @@ $setup_info['infolog']['hooks']['infolog'] = 'infolog.uiinfolog.hook_view'; $setup_info['infolog']['hooks']['calendar_include_events'] = 'infolog.boinfolog.cal_to_include'; $setup_info['infolog']['hooks']['calendar_include_todos'] = 'infolog.boinfolog.cal_to_include'; + $setup_info['infolog']['hooks']['sidebox_menu'] = 'infolog.admin_prefs_sidebox_hooks.all_hooks'; /* Dependencies for this app to work */ $setup_info['infolog']['depends'][] = array(