adding "regular" import/export functions (import & export) to preferences: allows to use them without being admin

This commit is contained in:
Ralf Becker 2010-07-07 17:11:10 +00:00
parent 82e8bdbd9e
commit f3017cdeba
2 changed files with 6 additions and 69 deletions

View File

@ -16,22 +16,12 @@ if (!defined('IMPORTEXPORT_APP'))
class importexport_admin_prefs_sidebox_hooks
{
var $config = array();
function importexport_admin_prefs_sidebox_hooks()
{
$config =& CreateObject('phpgwapi.config',IMPORTEXPORT_APP);
$config->read_repository();
$this->config =& $config->config_data;
unset($config);
}
function all_hooks($args)
static function all_hooks($args)
{
$appname = IMPORTEXPORT_APP;
$location = is_array($args) ? $args['location'] : $args;
if ($location == 'sidebox_menu')
if ($GLOBALS['egw_info']['user']['apps']['preferences'] && $location != 'admin')
{
$file = array(
'Import'=> array(
@ -47,23 +37,13 @@ class importexport_admin_prefs_sidebox_hooks
'icon' => 'export'
),
);
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);
display_sidebox($appname,lang($appname),$file);
}
}
@ -88,45 +68,4 @@ class importexport_admin_prefs_sidebox_hooks
}
}
}
/**
* 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',IMPORTEXPORT_APP))
{
return;
}
$GLOBALS['egw']->session->appsession('default_prefs_set',IMPORTEXPORT_APP,'set');
$default_prefs =& $GLOBALS['egw']->preferences->default[IMPORTEXPORT_APP];
$defaults = array(
);
foreach($defaults as $var => $default)
{
if (!isset($default_prefs[$var]) || $default_prefs[$var] === '')
{
$GLOBALS['egw']->preferences->add(IMPORTEXPORT_APP,$var,$default,'default');
$need_save = True;
}
}
if ($need_save)
{
$GLOBALS['egw']->preferences->save_repository(False,'default');
}
}
}

View File

@ -26,11 +26,9 @@ $setup_info['importexport']['note'] =
'';
/* The hooks this app includes, needed for hooks registration */
//$setup_info['importexport']['hooks']['preferences'] = 'importexport'.'.admin_prefs_sidebox_hooks.all_hooks';
//$setup_info['importexport']['hooks']['settings'] = 'importexport'.'.admin_prefs_sidebox_hooks.settings';
$setup_info['importexport']['hooks']['admin'] = 'importexport'.'.importexport_admin_prefs_sidebox_hooks.all_hooks';
$setup_info['importexport']['hooks']['sidebox_menu'] = 'importexport'.'.importexport_admin_prefs_sidebox_hooks.all_hooks';
//$setup_info['importexport']['hooks']['search_link'] = 'importexport'.'.bomyterra.search_link';
$setup_info['importexport']['hooks']['preferences'] =
$setup_info['importexport']['hooks']['admin'] =
$setup_info['importexport']['hooks']['sidebox_menu'] = 'importexport_admin_prefs_sidebox_hooks::all_hooks';
/* Dependencies for this app to work */
$setup_info['importexport']['depends'][] = array(