mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
using standard site-configuration plus some hooks
This commit is contained in:
parent
cf10e4af69
commit
030eb89f84
@ -184,10 +184,10 @@ class admin_config
|
|||||||
{
|
{
|
||||||
return (int)($a != $b); // necessary to kope with arrays
|
return (int)($a != $b); // necessary to kope with arrays
|
||||||
});
|
});
|
||||||
$removals = array_udiff_assoc($old, $c->config_data, function($a, $b)
|
$removals = array_diff(array_udiff_assoc($old, $c->config_data, function($a, $b)
|
||||||
{
|
{
|
||||||
return (int)($a != $b);
|
return (int)(!empty($a) && $a != $b);
|
||||||
});
|
}), array(null, ''));
|
||||||
$set = array_merge(array_fill_keys(array_keys($removals), null), $modifications);
|
$set = array_merge(array_fill_keys(array_keys($removals), null), $modifications);
|
||||||
$old = array_filter($old, function($key) use ($set)
|
$old = array_filter($old, function($key) use ($set)
|
||||||
{
|
{
|
||||||
@ -203,6 +203,12 @@ class admin_config
|
|||||||
{
|
{
|
||||||
$msg = lang('Nothing to save.');
|
$msg = lang('Nothing to save.');
|
||||||
}
|
}
|
||||||
|
if (!$errors)
|
||||||
|
{
|
||||||
|
// allow apps to hook into configuration dialog to eg. save some stuff outside configuration
|
||||||
|
$_content['location'] = 'config_after_save';
|
||||||
|
Api\Hooks::single($_content, $_appname);
|
||||||
|
}
|
||||||
if(!$errors && !$_content['apply'])
|
if(!$errors && !$_content['apply'])
|
||||||
{
|
{
|
||||||
Api\Framework::message($msg, 'success');
|
Api\Framework::message($msg, 'success');
|
||||||
|
@ -19,6 +19,7 @@ if (!defined('IMPORTEXPORT_APP'))
|
|||||||
|
|
||||||
class importexport_admin_prefs_sidebox_hooks
|
class importexport_admin_prefs_sidebox_hooks
|
||||||
{
|
{
|
||||||
|
const _appname = 'importexport';
|
||||||
|
|
||||||
public $public_functions = array(
|
public $public_functions = array(
|
||||||
'spreadsheet_list' => true
|
'spreadsheet_list' => true
|
||||||
@ -66,7 +67,7 @@ class importexport_admin_prefs_sidebox_hooks
|
|||||||
if ($GLOBALS['egw_info']['user']['apps']['admin'])
|
if ($GLOBALS['egw_info']['user']['apps']['admin'])
|
||||||
{
|
{
|
||||||
$file = Array(
|
$file = Array(
|
||||||
'Site Configuration' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.site_config'),
|
'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=importexport'),
|
||||||
'Import definitions' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'),
|
'Import definitions' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'),
|
||||||
'Define imports|exports' => Egw::link('/index.php',array(
|
'Define imports|exports' => Egw::link('/index.php',array(
|
||||||
'menuaction' => 'importexport.importexport_definitions_ui.index',
|
'menuaction' => 'importexport.importexport_definitions_ui.index',
|
||||||
@ -138,7 +139,7 @@ class importexport_admin_prefs_sidebox_hooks
|
|||||||
$file['Export CSV']['link'] = '';
|
$file['Export CSV']['link'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = Api\Config::read('importexport');
|
$config = Api\Config::read('importexport');
|
||||||
if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) &&
|
if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) &&
|
||||||
count(importexport_helper_functions::get_plugins($appname)) > 0
|
count(importexport_helper_functions::get_plugins($appname)) > 0
|
||||||
@ -152,7 +153,7 @@ class importexport_admin_prefs_sidebox_hooks
|
|||||||
}
|
}
|
||||||
if($file) display_sidebox($appname,lang('importexport'),$file);
|
if($file) display_sidebox($appname,lang('importexport'),$file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of custom widgets classes for etemplate2
|
* Returns a list of custom widgets classes for etemplate2
|
||||||
*/
|
*/
|
||||||
@ -160,4 +161,48 @@ class importexport_admin_prefs_sidebox_hooks
|
|||||||
{
|
{
|
||||||
return array('importexport_widget_filter');
|
return array('importexport_widget_filter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add stuff to admin >> site configuration
|
||||||
|
*
|
||||||
|
* @param array $config
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function config(array $config)
|
||||||
|
{
|
||||||
|
unset($config); // not used, but required by function signature
|
||||||
|
|
||||||
|
$ret = array(
|
||||||
|
'share_definition' => $GLOBALS['egw']->acl->get_ids_for_location('share_definition', Api\Acl::READ, self::_appname)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (function_exists('mb_list_encodings'))
|
||||||
|
{
|
||||||
|
$ret['sel_options']['import_charsets'] = array_combine(mb_list_encodings(), mb_list_encodings());
|
||||||
|
|
||||||
|
// Remove 'standard' encodings to prevent doubles
|
||||||
|
foreach(array_keys(Api\Translation::get_installed_charsets()) as $charset)
|
||||||
|
{
|
||||||
|
unset($ret['sel_options']['import_charsets'][strtoupper($charset)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save non-config stuff, after site-configuration is successful saved
|
||||||
|
*
|
||||||
|
* @param array $content
|
||||||
|
*/
|
||||||
|
public static function config_after_save(array $content)
|
||||||
|
{
|
||||||
|
// ACL
|
||||||
|
$GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition', false);
|
||||||
|
$GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition', false);
|
||||||
|
|
||||||
|
foreach($content['newsettings']['share_definition'] as $group)
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group, Api\Acl::READ);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -942,53 +942,4 @@ class importexport_definitions_ui
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Site configuration
|
|
||||||
*/
|
|
||||||
public function site_config($content = array())
|
|
||||||
{
|
|
||||||
if(!$GLOBALS['egw_info']['user']['apps']['admin'])
|
|
||||||
{
|
|
||||||
Egw::redirect_link('/home');
|
|
||||||
}
|
|
||||||
if($content['save'])
|
|
||||||
{
|
|
||||||
unset($content['save']);
|
|
||||||
|
|
||||||
// ACL
|
|
||||||
$GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition',false);
|
|
||||||
$GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition',false);
|
|
||||||
|
|
||||||
foreach($content['share_definition'] as $group)
|
|
||||||
{
|
|
||||||
$GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,Acl::READ);
|
|
||||||
}
|
|
||||||
unset($content['share_definition']);
|
|
||||||
|
|
||||||
// Other Api\Config
|
|
||||||
foreach($content as $key=>$value)
|
|
||||||
{
|
|
||||||
Api\Config::save_value($key, $value, 'importexport');
|
|
||||||
}
|
|
||||||
} elseif (isset($content['cancel'])) {
|
|
||||||
$GLOBALS['egw']->redirect_link('/admin/index.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = Api\Config::read(self::_appname);
|
|
||||||
$data['share_definition'] = $GLOBALS['egw']->acl->get_ids_for_location('share_definition', Acl::READ, self::_appname);
|
|
||||||
$sel_options['import_charsets'] = array_combine(mb_list_encodings(),mb_list_encodings());
|
|
||||||
|
|
||||||
// Remove 'standard' encodings to prevent doubles
|
|
||||||
foreach(Api\Translation::get_installed_charsets() as $charset => $label)
|
|
||||||
{
|
|
||||||
unset($sel_options['import_charsets'][strtoupper($charset)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!$data['update']) $data['update'] = 'request';
|
|
||||||
|
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname);
|
|
||||||
$etpl = new etemplate(self::_appname.'.config');
|
|
||||||
$etpl->exec(self::_appname.'.importexport_definitions_ui.site_config',$data,$sel_options,$readonlys,$preserv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ $setup_info['importexport']['hooks']['admin'] =
|
|||||||
$setup_info['importexport']['hooks']['sidebox_menu'] = 'importexport_admin_prefs_sidebox_hooks::all_hooks';
|
$setup_info['importexport']['hooks']['sidebox_menu'] = 'importexport_admin_prefs_sidebox_hooks::all_hooks';
|
||||||
$setup_info['importexport']['hooks']['sidebox_all'] = 'importexport_admin_prefs_sidebox_hooks::other_apps';
|
$setup_info['importexport']['hooks']['sidebox_all'] = 'importexport_admin_prefs_sidebox_hooks::other_apps';
|
||||||
$setup_info['importexport']['hooks']['etemplate2_register_widgets'] = 'importexport_admin_prefs_sidebox_hooks::widgets';
|
$setup_info['importexport']['hooks']['etemplate2_register_widgets'] = 'importexport_admin_prefs_sidebox_hooks::widgets';
|
||||||
|
$setup_info['importexport']['hooks']['config'] = 'importexport_admin_prefs_sidebox_hooks::config';
|
||||||
|
$setup_info['importexport']['hooks']['config_after_save'] = 'importexport_admin_prefs_sidebox_hooks::config_after_save';
|
||||||
|
|
||||||
/* Dependencies for this app to work */
|
/* Dependencies for this app to work */
|
||||||
$setup_info['importexport']['depends'][] = array(
|
$setup_info['importexport']['depends'][] = array(
|
||||||
|
@ -11,21 +11,15 @@
|
|||||||
<rows>
|
<rows>
|
||||||
<row>
|
<row>
|
||||||
<description value="Users allowed to create their own definitions"/>
|
<description value="Users allowed to create their own definitions"/>
|
||||||
<checkbox id="users_create_definitions"/>
|
<checkbox id="newsettings[users_create_definitions]"/>
|
||||||
</row>
|
</row>
|
||||||
<row valign="top">
|
<row valign="top">
|
||||||
<description value="Users allowed to share their own definitions"/>
|
<description value="Users allowed to share their own definitions"/>
|
||||||
<listbox type="select-account" id="share_definition" rows="5" options="both"/>
|
<listbox type="select-account" id="newsettings[share_definition]" rows="5" options="both"/>
|
||||||
</row>
|
</row>
|
||||||
<row valign="top">
|
<row valign="top">
|
||||||
<description value="Extra charsets for import / export"/>
|
<description value="Extra charsets for import / export"/>
|
||||||
<listbox id="import_charsets" rows="5"/>
|
<listbox id="newsettings[import_charsets]" rows="5"/>
|
||||||
</row>
|
|
||||||
<row>
|
|
||||||
<hbox span="all">
|
|
||||||
<button label="Save" id="save" span="all"/>
|
|
||||||
<button label="Cancel" id="cancel" span="all"/>
|
|
||||||
</hbox>
|
|
||||||
</row>
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
|
Loading…
Reference in New Issue
Block a user