diff --git a/admin/inc/class.admin_config.inc.php b/admin/inc/class.admin_config.inc.php index 879ce3438f..5325822f5f 100644 --- a/admin/inc/class.admin_config.inc.php +++ b/admin/inc/class.admin_config.inc.php @@ -184,10 +184,10 @@ class admin_config { 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); $old = array_filter($old, function($key) use ($set) { @@ -203,6 +203,12 @@ class admin_config { $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']) { Api\Framework::message($msg, 'success'); diff --git a/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php b/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php index 529dda6e73..eccd333783 100644 --- a/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php +++ b/importexport/inc/class.importexport_admin_prefs_sidebox_hooks.inc.php @@ -19,6 +19,7 @@ if (!defined('IMPORTEXPORT_APP')) class importexport_admin_prefs_sidebox_hooks { + const _appname = 'importexport'; public $public_functions = array( 'spreadsheet_list' => true @@ -66,7 +67,7 @@ class importexport_admin_prefs_sidebox_hooks if ($GLOBALS['egw_info']['user']['apps']['admin']) { $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'), 'Define imports|exports' => Egw::link('/index.php',array( 'menuaction' => 'importexport.importexport_definitions_ui.index', @@ -138,7 +139,7 @@ class importexport_admin_prefs_sidebox_hooks $file['Export CSV']['link'] = ''; } } - + $config = Api\Config::read('importexport'); if($appname != 'admin' && ($config['users_create_definitions'] || $GLOBALS['egw_info']['user']['apps']['admin']) && 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); } - + /** * Returns a list of custom widgets classes for etemplate2 */ @@ -160,4 +161,48 @@ class importexport_admin_prefs_sidebox_hooks { 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); + } + } } diff --git a/importexport/inc/class.importexport_definitions_ui.inc.php b/importexport/inc/class.importexport_definitions_ui.inc.php index 806699daaf..1c0e4b14b0 100644 --- a/importexport/inc/class.importexport_definitions_ui.inc.php +++ b/importexport/inc/class.importexport_definitions_ui.inc.php @@ -942,53 +942,4 @@ class importexport_definitions_ui } 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); - } } diff --git a/importexport/setup/setup.inc.php b/importexport/setup/setup.inc.php index 07b6a99217..67be7d140f 100644 --- a/importexport/setup/setup.inc.php +++ b/importexport/setup/setup.inc.php @@ -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_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']['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 */ $setup_info['importexport']['depends'][] = array( diff --git a/importexport/templates/default/config.xet b/importexport/templates/default/config.xet index 631d5d1be8..3739ea3b33 100644 --- a/importexport/templates/default/config.xet +++ b/importexport/templates/default/config.xet @@ -11,21 +11,15 @@ - + - + - - - - -