mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:18 +01:00
- Add blacklisting so plugin scan will skip certain files or directories
- Add caching to plugin scan, default is to rescan once a day - Remove lingering unneeded requires
This commit is contained in:
parent
c4ec7ad53f
commit
fb5a3e11a8
@ -137,8 +137,7 @@
|
||||
exit(INVALID_OPTION);
|
||||
}
|
||||
|
||||
require_once('inc/class.definition.inc.php');
|
||||
$definition = new definition($definition);
|
||||
$definition = new importexport_definition($definition);
|
||||
if( $definition->get_identifier() < 1 ) {
|
||||
fwrite(STDERR,"importexport_cli: Definition not found! \n");
|
||||
exit(INVALID_OPTION);
|
||||
@ -149,8 +148,6 @@
|
||||
$definition->plugin_options['dry_run'] = $dryrun;
|
||||
$type = $definition->type;
|
||||
|
||||
|
||||
require_once("$path_to_egroupware/$definition->application/importexport/class.$definition->plugin.inc.php");
|
||||
$po = new $definition->plugin;
|
||||
|
||||
$resource = fopen( $file, 'r' );
|
||||
|
@ -20,7 +20,7 @@
|
||||
* @todo deal with other types like objects
|
||||
* @static only namespace here
|
||||
*/
|
||||
class arrayxml {
|
||||
class importexport_arrayxml {
|
||||
|
||||
/**
|
||||
* converts a php array to an xml string
|
||||
@ -108,4 +108,4 @@ class arrayxml {
|
||||
return $xml_array;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
@ -10,9 +10,6 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.arrayxml.inc.php');
|
||||
require_once(EGW_INCLUDE_ROOT. '/etemplate/inc/class.so_sql.inc.php');
|
||||
|
||||
/**
|
||||
* class definition
|
||||
*
|
||||
@ -79,7 +76,7 @@ class importexport_definition implements importexport_iface_egw_record {
|
||||
if ( !( in_array( $this->user, $this->get_allowed_users() ) || $this->definition['owner'] == $this->user || $this->is_admin)) {
|
||||
throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
|
||||
}
|
||||
$options_data = arrayxml::xml2array( $this->definition['plugin_options'] );
|
||||
$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
|
||||
$this->definition['plugin_options'] = $options_data['root'];
|
||||
}
|
||||
}
|
||||
@ -236,7 +233,7 @@ class importexport_definition implements importexport_iface_egw_record {
|
||||
}
|
||||
|
||||
$this->so_sql->data = $this->definition;
|
||||
$this->so_sql->data['plugin_options'] = arrayxml::array2xml( $this->definition['plugin_options'] );
|
||||
$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
|
||||
if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
|
||||
throw new Exception('Error: so_sql was not able to save definition: '.$this->get_identifier());
|
||||
}
|
||||
|
@ -10,9 +10,6 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.arrayxml.inc.php');
|
||||
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
|
||||
|
||||
/** bo to define {im|ex}ports
|
||||
*
|
||||
* @todo make this class an egw_record_pool!
|
||||
@ -118,11 +115,11 @@ class importexport_definitions_bo {
|
||||
$definition = new importexport_definition( $definition_id );
|
||||
$export_data['definitions'][$definition->name] = $definition->get_record_array();
|
||||
$export_data['definitions'][$definition->name]['allowed_users'] =
|
||||
import_export_helper_functions::account_id2name(
|
||||
importexport_helper_functions::account_id2name(
|
||||
$export_data['definitions'][$definition->name]['allowed_users']
|
||||
);
|
||||
$export_data['definitions'][$definition->name]['owner'] =
|
||||
import_export_helper_functions::account_id2name(
|
||||
importexport_helper_functions::account_id2name(
|
||||
$export_data['definitions'][$definition->name]['owner']
|
||||
);
|
||||
unset($export_data['definitions'][$definition->name]['definition_id']);
|
||||
@ -130,7 +127,7 @@ class importexport_definitions_bo {
|
||||
}
|
||||
|
||||
|
||||
$xml = new arrayxml();
|
||||
$xml = new importexport_arrayxml();
|
||||
return $xml->array2xml($export_data, 'importExportDefinitions');
|
||||
}
|
||||
|
||||
|
@ -160,13 +160,8 @@ class importexport_definitions_ui
|
||||
$wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']);
|
||||
|
||||
// we need to deal with the wizard object if exists
|
||||
if (file_exists(EGW_SERVER_ROOT . '/'. $content['application'].'/importexport/class.wizzard_'. $content['plugin'].'.inc.php')) {
|
||||
error_log('Wizard has one z in english');
|
||||
}
|
||||
if (file_exists(EGW_SERVER_ROOT . '/'. $content['application'].'/importexport/class.wizard_'. $content['plugin'].'.inc.php'))
|
||||
{
|
||||
require_once(EGW_SERVER_ROOT . '/'. $content['application'].'/importexport/class.wizard_'. $content['plugin'].'.inc.php');
|
||||
$wizard_plugin = 'wizard_'.$content['plugin'];
|
||||
error_log('Deprecated location for importexport wizard. Please move it to app/inc/ and rename it to follow new conventions');
|
||||
}
|
||||
elseif (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php"))
|
||||
|
@ -10,8 +10,6 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once(EGW_INCLUDE_ROOT. '/phpgwapi/inc/class.translation.inc.php');
|
||||
|
||||
/**
|
||||
* class export_csv
|
||||
* This an record exporter.
|
||||
@ -97,7 +95,7 @@ class importexport_export_csv implements importexport_iface_export_record
|
||||
|
||||
/**
|
||||
* Sets conversion.
|
||||
* See import_export_helper_functions::conversion.
|
||||
* @see importexport_helper_functions::conversion.
|
||||
*
|
||||
* @param array $_conversion
|
||||
*/
|
||||
|
@ -10,9 +10,6 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once(EGW_INCLUDE_ROOT. '/etemplate/inc/class.etemplate.inc.php');
|
||||
|
||||
|
||||
/**
|
||||
* userinterface for exports
|
||||
*
|
||||
|
@ -11,11 +11,23 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* class import_export_helper_functions (only static methods)
|
||||
* use import_export_helper_functions::method
|
||||
* class importexport_helper_functions (only static methods)
|
||||
* use importexport_helper_functions::method
|
||||
*/
|
||||
class importexport_helper_functions {
|
||||
|
||||
// Plugins are scanned and cached for all instances using this source path
|
||||
const CACHE_EXPIRATION = 86400;
|
||||
|
||||
/**
|
||||
* Files known to cause problems, and will be skipped in a plugin scan
|
||||
* If you put appname => true, the whole app will be skipped.
|
||||
*/
|
||||
protected static $blacklist_files = array(
|
||||
'news_admin' => array(
|
||||
'class.news_admin_import.inc.php',
|
||||
),
|
||||
);
|
||||
/**
|
||||
* nothing to construct here, only static functions!
|
||||
*/
|
||||
@ -267,17 +279,40 @@ class importexport_helper_functions {
|
||||
* @return array(<appname> => array( <type> => array(<plugin> => <title>)))
|
||||
*/
|
||||
public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
|
||||
$plugins = egw_cache::getTree(
|
||||
__CLASS__,
|
||||
'plugins',
|
||||
array('importexport_helper_functions','_get_plugins'),
|
||||
array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
|
||||
self::CACHE_EXPIRATION
|
||||
);
|
||||
|
||||
$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
|
||||
$types = $_type == 'all' ? array('import','export') : (array)$_type;
|
||||
|
||||
foreach($plugins as $appname => $types) {
|
||||
if(!in_array($appname, $appnames)) unset($plugins['appname']);
|
||||
}
|
||||
foreach($plugins as $appname => $types) {
|
||||
$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
|
||||
}
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
protected static function _get_plugins(Array $appnames, Array $types) {
|
||||
$plugins = array();
|
||||
|
||||
foreach ($appnames as $appname) {
|
||||
if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
|
||||
|
||||
$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
|
||||
if(!is_dir($appdir) || !array_key_exists($appname, $GLOBALS['egw_info']['apps'])) continue;
|
||||
if(!is_dir($appdir)) continue;
|
||||
$d = dir($appdir);
|
||||
|
||||
// step through each file in appdir
|
||||
while (false !== ($entry = $d->read())) {
|
||||
// Blacklisted?
|
||||
if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue;
|
||||
|
||||
list( ,$classname, ,$extension) = explode('.',$entry);
|
||||
$file = $appdir. '/'. $entry;
|
||||
|
||||
@ -317,5 +352,5 @@ class importexport_helper_functions {
|
||||
public static function guess_filetype( $_file ) {
|
||||
|
||||
}
|
||||
} // end of import_export_helper_functions
|
||||
} // end of importexport_helper_functions
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user