mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
131 lines
4.0 KiB
PHP
131 lines
4.0 KiB
PHP
<?php
|
|
/**************************************************************************\
|
|
* eGroupWare - TimeSheet: Admin-, Preferences- and SideboxMenu-Hooks *
|
|
* http://www.eGroupWare.org *
|
|
* Written and (c) 2005 by Ralf Becker <RalfBecker@outdoor-training.de> *
|
|
* ------------------------------------------------------- *
|
|
* 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$ */
|
|
|
|
if (!defined('TIMESHEET_APP'))
|
|
{
|
|
define('TIMESHEET_APP','timesheet');
|
|
}
|
|
|
|
class ts_admin_prefs_sidebox_hooks
|
|
{
|
|
var $public_functions = array(
|
|
// 'check_set_default_prefs' => true,
|
|
);
|
|
var $config = array();
|
|
|
|
function pm_admin_prefs_sidebox_hooks()
|
|
{
|
|
$config =& CreateObject('phpgwapi.config',TIMESHEET_APP);
|
|
$config->read_repository();
|
|
$this->config =& $config->config_data;
|
|
unset($config);
|
|
}
|
|
|
|
/**
|
|
* hooks to build projectmanager's sidebox-menu plus the admin and preferences sections
|
|
*
|
|
* @param string/array $args hook args
|
|
*/
|
|
function all_hooks($args)
|
|
{
|
|
$appname = TIMESHEET_APP;
|
|
$location = is_array($args) ? $args['location'] : $args;
|
|
//echo "<p>ts_admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
|
|
|
|
if ($location == 'sidebox_menu')
|
|
{
|
|
$file = array(
|
|
);
|
|
display_sidebox($appname,$GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'),$file);
|
|
}
|
|
|
|
if ($GLOBALS['egw_info']['user']['apps']['preferences'] && $location != 'admin')
|
|
{
|
|
$file = array(
|
|
// 'Preferences' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uisettings.index&appname='.$appname),
|
|
'Grant Access' => $GLOBALS['egw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
|
|
'Edit Categories' => $GLOBALS['egw']->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['egw_info']['user']['apps']['admin'] && $location != 'preferences')
|
|
{
|
|
$file = Array(
|
|
// 'Site configuration' => $GLOBALS['egw']->link('/index.php','menuaction=projectmanager.admin.config'),
|
|
// 'Custom fields' => $GLOBALS['egw']->link('/index.php','menuaction=admin.customfields.edit&appname='.$appname),
|
|
'Global Categories' => $GLOBALS['egw']->link('/index.php',array(
|
|
'menuaction' => 'admin.uicategories.index',
|
|
'appname' => $appname,
|
|
'global_cats'=> True)),
|
|
);
|
|
if ($location == 'admin')
|
|
{
|
|
display_section($appname,$file);
|
|
}
|
|
else
|
|
{
|
|
display_sidebox($appname,lang('Admin'),$file);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* populates $GLOBALS['settings'] for the preferences
|
|
*/
|
|
function settings()
|
|
{
|
|
$this->check_set_default_prefs();
|
|
|
|
return true; // otherwise prefs say it cant find the file ;-)
|
|
}
|
|
|
|
/**
|
|
* Check if reasonable default preferences are set and set them if not
|
|
*
|
|
* It sets a flag in the app-session-data to be called only once per session
|
|
*/
|
|
function check_set_default_prefs()
|
|
{
|
|
if ($GLOBALS['egw']->session->appsession('default_prefs_set',TIMESHEET_APP))
|
|
{
|
|
return;
|
|
}
|
|
$GLOBALS['egw']->session->appsession('default_prefs_set',TIMESHEET_APP,'set');
|
|
|
|
$default_prefs =& $GLOBALS['egw']->preferences->default[TIMESHEET_APP];
|
|
|
|
$defaults = array(
|
|
);
|
|
foreach($defaults as $var => $default)
|
|
{
|
|
if (!isset($default_prefs[$var]) || $default_prefs[$var] === '')
|
|
{
|
|
$GLOBALS['egw']->preferences->add(TIMESHEET_APP,$var,$default,'default');
|
|
$need_save = True;
|
|
}
|
|
}
|
|
if ($need_save)
|
|
{
|
|
$GLOBALS['egw']->preferences->save_repository(False,'default');
|
|
}
|
|
}
|
|
} |