diff --git a/importexport/importexport_cli.php b/importexport/importexport_cli.php index 749a65aaba..5ef8b520d4 100755 --- a/importexport/importexport_cli.php +++ b/importexport/importexport_cli.php @@ -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' ); diff --git a/importexport/inc/class.arrayxml.inc.php b/importexport/inc/class.importexport_arrayxml.inc.php similarity index 95% rename from importexport/inc/class.arrayxml.inc.php rename to importexport/inc/class.importexport_arrayxml.inc.php index 08bad351ed..cd7386d5fd 100644 --- a/importexport/inc/class.arrayxml.inc.php +++ b/importexport/inc/class.importexport_arrayxml.inc.php @@ -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; } } -?> \ No newline at end of file +?> diff --git a/importexport/inc/class.importexport_definition.inc.php b/importexport/inc/class.importexport_definition.inc.php index 48e1ed8f86..25dc86bc29 100644 --- a/importexport/inc/class.importexport_definition.inc.php +++ b/importexport/inc/class.importexport_definition.inc.php @@ -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()); } diff --git a/importexport/inc/class.importexport_definitions_bo.inc.php b/importexport/inc/class.importexport_definitions_bo.inc.php index 9c02fb8108..a22ede75b1 100644 --- a/importexport/inc/class.importexport_definitions_bo.inc.php +++ b/importexport/inc/class.importexport_definitions_bo.inc.php @@ -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'); } diff --git a/importexport/inc/class.importexport_definitions_ui.inc.php b/importexport/inc/class.importexport_definitions_ui.inc.php index 1d39c03590..dec2db1119 100644 --- a/importexport/inc/class.importexport_definitions_ui.inc.php +++ b/importexport/inc/class.importexport_definitions_ui.inc.php @@ -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")) diff --git a/importexport/inc/class.importexport_export_csv.inc.php b/importexport/inc/class.importexport_export_csv.inc.php index b097a51c29..6a6c8d5124 100644 --- a/importexport/inc/class.importexport_export_csv.inc.php +++ b/importexport/inc/class.importexport_export_csv.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 */ diff --git a/importexport/inc/class.importexport_export_ui.inc.php b/importexport/inc/class.importexport_export_ui.inc.php index 4086dbf759..b99e9a17de 100644 --- a/importexport/inc/class.importexport_export_ui.inc.php +++ b/importexport/inc/class.importexport_export_ui.inc.php @@ -10,9 +10,6 @@ * @version $Id$ */ -require_once(EGW_INCLUDE_ROOT. '/etemplate/inc/class.etemplate.inc.php'); - - /** * userinterface for exports * diff --git a/importexport/inc/class.importexport_helper_functions.inc.php b/importexport/inc/class.importexport_helper_functions.inc.php index c4e94e1b7b..2e6c3c6607 100755 --- a/importexport/inc/class.importexport_helper_functions.inc.php +++ b/importexport/inc/class.importexport_helper_functions.inc.php @@ -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( => array( => array( => ))) */ 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 ?>