Move importexport to new API

This commit is contained in:
Nathan Gray 2016-05-09 22:49:20 +00:00
parent de89542712
commit 7e7f045343
19 changed files with 232 additions and 339 deletions

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
$path_to_egroupware = realpath(dirname(__FILE__).'/..');
$usage = "usage:
@ -148,7 +150,7 @@ $po = new $definition->plugin;
$resource = fopen( $file, 'r' );
$po->$type( $resource, $definition );
common::egw_exit();
exit();
function import_export_access(&$account)
{

View File

@ -9,6 +9,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
if (!defined('IMPORTEXPORT_APP'))
{
define('IMPORTEXPORT_APP','importexport');
@ -32,27 +35,27 @@ class importexport_admin_prefs_sidebox_hooks
array(
'text' => 'Import',
'link' => "javascript:egw_openWindowCentered2('".
egw::link('/index.php','menuaction=importexport.importexport_import_ui.import_dialog',false).
Egw::link('/index.php','menuaction=importexport.importexport_import_ui.import_dialog',false).
"','_blank',850,440,'yes')",
'icon' => 'import'
),
);
$export_limit = bo_merge::getExportLimit($appname);
$export_limit = Api\Storage\Merge::getExportLimit($appname);
//error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit);
if(bo_merge::is_export_limit_excepted() || $export_limit !== 'no')
if(Api\Storage\Merge::is_export_limit_excepted() || $export_limit !== 'no')
{
$file[] = array(
'text' => 'Export',
'link' => "javascript:egw_openWindowCentered2('".
egw::link('/index.php','menuaction=importexport.importexport_export_ui.export_dialog',false).
Egw::link('/index.php','menuaction=importexport.importexport_export_ui.export_dialog',false).
"','_blank',850,440,'yes')",
'icon' => 'export'
);
}
$config = config::read($appname);
$config = Api\Config::read($appname);
if($config['users_create_definitions'])
{
$file['Define imports|exports'] = egw::link('/index.php',array(
$file['Define imports|exports'] = Egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_definitions_ui.index',
'ajax' => 'true'
),$GLOBALS['egw_info']['user']['apps']['admin'] ? 'admin' : 'preferences');
@ -63,13 +66,13 @@ 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'),
'Import definitions' => egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.import_definition'),
'Define imports|exports' => egw::link('/index.php',array(
'Site Configuration' => Egw::link('/index.php','menuaction=importexport.importexport_definitions_ui.site_config'),
'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',
'ajax' => 'true'
)),
'Schedule' => egw::link('/index.php', array(
'Schedule' => Egw::link('/index.php', array(
'menuaction' => 'importexport.importexport_schedule_ui.index'
)),
);
@ -92,12 +95,12 @@ class importexport_admin_prefs_sidebox_hooks
if($GLOBALS['egw_info']['flags']['no_importexport'] === true) return array();
$appname = $GLOBALS['egw_info']['flags']['currentapp'];
$cache = egw_cache::getCache(egw_cache::SESSION, 'importexport', 'sidebox_links');
$cache = Api\Cache::getCache(Api\Cache::SESSION, 'importexport', 'sidebox_links');
if(!$cache[$appname] && $GLOBALS['egw_info']['user']['apps']['importexport']) {
$cache[$appname]['import'] = importexport_helper_functions::has_definitions($appname, 'import');
$cache[$appname]['export'] = importexport_helper_functions::has_definitions($appname, 'export');
egw_cache::setCache(egw_cache::SESSION, 'importexport', 'sidebox_links', $cache);
Api\Cache::setCache(Api\Cache::SESSION, 'importexport', 'sidebox_links', $cache);
}
// Add in import / export, if available
@ -106,7 +109,7 @@ class importexport_admin_prefs_sidebox_hooks
if($cache[$appname]['import'])
{
$file['Import CSV'] = array('link' => "javascript:egw_openWindowCentered2('".
egw::link('/index.php',array(
Egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_import_ui.import_dialog',
'appname'=>$appname
),false)."','_blank',850,440,'yes')",
@ -118,12 +121,12 @@ class importexport_admin_prefs_sidebox_hooks
$file['Import CSV']['link'] = '';
}
}
$export_limit = bo_merge::getExportLimit($appname);
$export_limit = Api\Storage\Merge::getExportLimit($appname);
//error_log(__METHOD__.__LINE__.' app:'.$appname.' limit:'.$export_limit);
if ((bo_merge::is_export_limit_excepted() || bo_merge::hasExportLimit($export_limit,'ISALLOWED')) && $cache[$appname]['export'])
if ((Api\Storage\Merge::is_export_limit_excepted() || Api\Storage\Merge::hasExportLimit($export_limit,'ISALLOWED')) && $cache[$appname]['export'])
{
$file['Export CSV'] = array('link' => "javascript:egw_openWindowCentered2('".
egw::link('/index.php',array(
Egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_export_ui.export_dialog',
'appname'=>$appname
),false)."','_blank',850,440,'yes')",
@ -136,12 +139,12 @@ class importexport_admin_prefs_sidebox_hooks
}
}
$config = config::read('importexport');
$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
)
{
$file['Define imports|exports'] = egw::link('/index.php',array(
$file['Define imports|exports'] = Egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_definitions_ui.index',
'application' => $appname,
'ajax' => 'true'

View File

@ -8,6 +8,8 @@
* @author Nathan Gray
*/
use EGroupware\Api;
use EGroupware\Api\Link;
/**
* A basic CSV import plugin.
@ -355,7 +357,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
}
else if($type == 'search')
{
$result = egw_link::query($app, $app_id);
$result = Link::query($app, $app_id);
do
{
$app_id = key($result);
@ -369,7 +371,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
// Searching, take first result
if(!is_numeric($app_id))
{
$result = egw_link::query($app, $app_id);
$result = Link::query($app, $app_id);
do
{
$app_id = key($result);
@ -385,7 +387,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
}
if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id))
{
$link_id = egw_link::link($this->definition->application,$id,$app,$app_id);
$link_id = Link::link($this->definition->application,$id,$app,$app_id);
}
}
}
@ -426,7 +428,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
if($fields[$field]) $label = $fields[$field];
}
} catch (Exception $e) {
translation::add_app($definition->application);
Api\Translation::add_app($definition->application);
foreach($labels as $field => &$label) {
$label = lang($label);
}
@ -443,7 +445,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
}
$this->preview_records = array();
return html::table($rows);
return Api\Html::table($rows);
}
/**
@ -533,7 +535,7 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
// Find matching entry
if($app && $custom_field && $value)
{
$cfs = config::get_customfields($app);
$cfs = Api\Storage\Customfields::get($app);
// Error if no custom fields, probably something wrong in definition
if(!$cfs[$custom_field])
{
@ -557,10 +559,10 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
error_log("Searching for $custom_field = $value");
// Search
if(egw_link::get_registry($app, 'query'))
if(Link::get_registry($app, 'query'))
{
$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
$result = egw_link::query($app, '', $options);
$result = Link::query($app, '', $options);
// Only one allowed
if($record->get_identifier())

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* class definition
*
@ -38,7 +40,7 @@ class importexport_definition implements importexport_iface_egw_record {
);
/**
* @var so_sql holds so_sql object
* @var so_sql holds Api\Storage\Base object
*/
private $so_sql;
@ -64,7 +66,7 @@ class importexport_definition implements importexport_iface_egw_record {
* @param string $_identifier
*/
public function __construct( $_identifier='' ) {
$this->so_sql = new so_sql(self::_appname ,self::_defintion_talbe);
$this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe);
$this->user = $GLOBALS['egw_info']['user']['user_id'];
$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
// compability to string identifiers
@ -282,7 +284,7 @@ class importexport_definition implements importexport_iface_egw_record {
$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
$this->so_sql->data['modified'] = time();
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());
throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier());
}
return $this->definition['definition_id'];
@ -342,7 +344,7 @@ class importexport_definition implements importexport_iface_egw_record {
throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
}
if(!$this->so_sql->delete()) {
throw('Error: so_sql was not able to delete definition: '.$this->get_identifier());
throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier());
}
}

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/** bo to define {im|ex}ports
*
* @todo make this class an egw_record_pool!
@ -20,7 +22,7 @@ class importexport_definitions_bo {
const _defintion_table = 'egw_importexport_definitions';
/**
* @var so_sql holds so_sql
* @var so_sql holds Api\Storage\Base
*/
private $so_sql;
@ -31,7 +33,7 @@ class importexport_definitions_bo {
public function __construct($_query=false, $ignore_acl = false)
{
$this->so_sql = new so_sql(self::_appname, self::_defintion_table );
$this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table );
if ($_query) {
$definitions = $this->so_sql->search($_query, false);
foreach ((array)$definitions as $definition) {
@ -170,7 +172,7 @@ class importexport_definitions_bo {
{
$export_data = array('metainfo' => array(
'type' => 'importexport definitions',
'charset' => translation::charset(),
'charset' => Api\Translation::charset(),
'entries' => count($keys),
));
@ -224,10 +226,10 @@ class importexport_definitions_bo {
unset ( $data );
// convert charset into internal used charset
$definitions = translation::convert(
$definitions = Api\Translation::convert(
$definitions,
$metainfo['charset'],
translation::charset()
Api\Translation::charset()
);
// Avoid warning if no definitions found
@ -273,7 +275,7 @@ class importexport_definitions_bo {
public static function export_from_import(importexport_definition $import)
{
// Only operates on import definitions
if($import->type != 'import') throw new egw_exception_wrong_parameter('Only import definitions');
if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions');
// Find export plugin
$plugin = str_replace('import', 'export',$import->plugin);

View File

@ -10,6 +10,12 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Acl;
use EGroupware\Api\Etemplate;
/**
* Userinterface to define {im|ex}ports
*
@ -57,11 +63,11 @@ class importexport_definitions_ui
{
// we cant deal with notice and warnings, as we are on ajax!
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
$GLOBALS['egw']->translation->add_app(self::_appname);
Api\Translation::add_app(self::_appname);
$GLOBALS['egw_info']['flags']['currentapp'] = self::_appname;
$this->etpl = new etemplate_new();
$this->clock = html::image(self::_appname,'clock');
$this->etpl = new Etemplate();
$this->clock = Api\Html::image(self::_appname,'clock');
$this->steps = array(
'wizard_step10' => lang('Choose an application'),
'wizard_step20' => lang('Choose a plugin'),
@ -88,8 +94,8 @@ class importexport_definitions_ui
} else {
// Filter private definitions
$filter['owner'] = $GLOBALS['egw_info']['user']['account_id'];
$config = config::read('phpgwapi');
if($config['export_limit'] == 'no' && !bo_merge::is_export_limit_excepted()) {
$config = Api\Config::read('phpgwapi');
if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) {
$filter['type'] = 'import';
}
}
@ -105,7 +111,7 @@ class importexport_definitions_ui
elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false)
{
$selected = $content['nm']['rows']['selected'];
if(count($selected) < 1 || !is_array($selected)) common::egw_exit();
if(count($selected) < 1 || !is_array($selected)) exit();
switch ($button)
{
case 'delete_selected' :
@ -174,9 +180,9 @@ class importexport_definitions_ui
);
if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application'];
}
if(egw_session::appsession('index', 'importexport'))
if(Api\Cache::getSession('importexport', 'index'))
{
$content['nm'] = array_merge($content['nm'], egw_session::appsession('index', 'importexport'));
$content['nm'] = array_merge($content['nm'], Api\Cache::getSession('importexport', 'index'));
}
$content['nm']['actions'] = $this->get_actions();
$sel_options = array(
@ -197,7 +203,7 @@ class importexport_definitions_ui
}
if($msg) $content['msg'] = $msg;
$etpl = new etemplate_new(self::_appname.'.definition_index');
$etpl = new Etemplate(self::_appname.'.definition_index');
return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv );
}
@ -312,7 +318,7 @@ class importexport_definitions_ui
if ($use_all)
{
// get the whole selection
$old_query = $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'importexport');
$old_query = $query = is_array($session_name) ? $session_name : Api\Cache::getSession('importexport', $session_name);
@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
$query['num_rows'] = -1; // all
@ -326,7 +332,7 @@ class importexport_definitions_ui
if(!is_array($session_name))
{
// Restore old query
egw_session::appsession($session_name, 'importexport',$old_query);
Api\Cache::setSession('importexport', $session_name, $old_query);
}
}
@ -340,12 +346,12 @@ class importexport_definitions_ui
// There's probably a way to do this in just JS, all the info should be there...
foreach($selected as $id) {
$definition = $bodefinitions->read((int)$id);
$link = egw::link('/index.php', array(
$link = Egw::link('/index.php', array(
'menuaction' => 'importexport.importexport_'.$definition['type'].'_ui.'.$definition['type'].'_dialog',
'appname' => $definition['application'],
'definition' => $definition['name']
));
egw_framework::set_onload("egw_openWindowCentered2('$link','_blank',850,440,'yes');");
Framework::set_onload("egw_openWindowCentered2('$link','_blank',850,440,'yes');");
}
break;
case 'allowed':
@ -377,7 +383,7 @@ class importexport_definitions_ui
header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment; filename="'.$name.'"');
echo $bodefinitions->export($selected);
common::egw_exit();
exit();
break;
case 'copy':
@ -438,7 +444,7 @@ class importexport_definitions_ui
public function get_rows(&$query, &$rows, &$readonlys) {
$rows = array();
egw_session::appsession('index','importexport',$query);
Api\Cache::setSession('importexport', 'index', $query);
// Special handling for allowed users 'private'
if($query['col_filter']['allowed_users'] == 'private')
@ -528,7 +534,7 @@ class importexport_definitions_ui
$wizard_plugin = $content['plugin'];
}
// App translations
if($content['application']) translation::add_app($content['application']);
if($content['application']) Api\Translation::add_app($content['application']);
$this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin;
@ -716,7 +722,7 @@ class importexport_definitions_ui
} elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) {
$content['type'] = 'export';
} else {
throw new egw_exception('Invalid plugin');
throw new Api\Exception('Invalid plugin');
}
return $this->get_step($content['step'],1);
case 'previous' :
@ -732,7 +738,7 @@ class importexport_definitions_ui
else
{
$content['text'] = $this->steps['wizard_step20'];
$config = config::read('phpgwapi');
$config = Api\Config::read('phpgwapi');
foreach ($this->plugins[$content['application']] as $type => $plugins) {
if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue;
foreach($plugins as $plugin => $name) {
@ -771,7 +777,7 @@ class importexport_definitions_ui
$suggestions = array(
$content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'],
$content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'],
$content['name'] .'-'. egw_time::to('now', true),
$content['name'] .'-'. Api\DateTime::to('now', true),
//$content['name'] .'-'. rand(0,100),
);
foreach($suggestions as $key => $suggestion) {
@ -824,7 +830,7 @@ class importexport_definitions_ui
{
if($this->can_edit($content))
{
$content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', EGW_ACL_READ,'importexport') ?
$content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ,'importexport') ?
($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) :
null;
$content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',',$content['allowed_users']));
@ -854,7 +860,7 @@ class importexport_definitions_ui
$content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']);
$content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) && $content['allowed_users'][0] == 'all' ||
$content['allowed_users'] == 'all';
if(!$GLOBALS['egw']->acl->check('share_definition', EGW_ACL_READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin'])
if(!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin'])
{
$content['allowed_users'] = array();
$readonlys['allowed_users'] = true;
@ -897,8 +903,8 @@ class importexport_definitions_ui
$bodefinitions->save($content);
// This message is displayed if browser cant close window
$content['msg'] = lang('ImportExport wizard finished successfully!');
egw_framework::refresh_opener('','importexport');
egw_framework::window_close();
Framework::refresh_opener('','importexport');
Framework::window_close();
return 'importexport.wizard_close';
}
@ -961,7 +967,7 @@ class importexport_definitions_ui
{
if(!$GLOBALS['egw_info']['user']['apps']['admin'])
{
egw::redirect_link('/home');
Egw::redirect_link('/home');
}
if($content['save'])
{
@ -973,25 +979,25 @@ class importexport_definitions_ui
foreach($content['share_definition'] as $group)
{
$GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,EGW_ACL_READ);
$GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,Acl::READ);
}
unset($content['share_definition']);
// Other config
// Other Api\Config
foreach($content as $key=>$value)
{
config::save_value($key, $value, 'importexport');
Api\Config::save_value($key, $value, 'importexport');
}
} elseif (isset($content['cancel'])) {
$GLOBALS['egw']->redirect_link('/admin/index.php');
}
$data = config::read(self::_appname);
$data['share_definition'] = $GLOBALS['egw']->acl->get_ids_for_location('share_definition', EGW_ACL_READ, self::_appname);
$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($GLOBALS['egw']->translation->get_installed_charsets() as $charset => $label)
foreach(Api\Translation::get_installed_charsets() as $charset => $label)
{
unset($sel_options['import_charsets'][strtoupper($charset)]);
}

View File

@ -10,6 +10,10 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Acl;
/**
* class export_csv
* This an record exporter.
@ -40,7 +44,7 @@ class importexport_export_csv implements importexport_iface_export_record
protected $record_array = array();
/**
* @var translation holds (charset) translation object
* @var translation holds (charset) Api\Translation object
*/
protected $translation;
@ -96,7 +100,7 @@ class importexport_export_csv implements importexport_iface_export_record
*/
public function __construct( $_stream, array $_options ) {
if (!is_object($GLOBALS['egw']->translation)) {
$GLOBALS['egw']->translation = new translation();
$GLOBALS['egw']->translation = new Api\Translation();
}
$this->translation = &$GLOBALS['egw']->translation;
$this->handle = $_stream;
@ -106,10 +110,10 @@ class importexport_export_csv implements importexport_iface_export_record
$this->csv_options = array_merge( $this->csv_options, $_options );
}
//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
if(!bo_merge::is_export_limit_excepted()) {
$this->export_limit = bo_merge::getExportLimit($_options['appname']);
if(!Api\Storage\Merge::is_export_limit_excepted()) {
$this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']);
//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
if($this->export_limit == 'no') throw new egw_exception_no_permission_admin('Export disabled');
if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled');
}
}
@ -124,7 +128,7 @@ class importexport_export_csv implements importexport_iface_export_record
}
if($_mapping['all_custom_fields']) {
// Field value is the appname, so we can pull the fields
$custom = config::get_customfields($_mapping['all_custom_fields']);
$custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']);
unset($_mapping['all_custom_fields']);
foreach($custom as $field => $info) {
$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
@ -179,7 +183,7 @@ class importexport_export_csv implements importexport_iface_export_record
if(substr($label,-1) == '*') $label = substr($label,0,-1);
}
} catch (Exception $e) {
translation::add_app($appname);
Api\Translation::add_app($appname);
foreach($this->mapping as $field => &$label) {
$label = lang($label);
}
@ -236,7 +240,7 @@ class importexport_export_csv implements importexport_iface_export_record
if(!$appname) return;
$fields = array();
$custom = config::get_customfields($appname);
$custom = Api\Storage\Customfields::get($appname);
foreach($custom as $name => $c_field) {
$name = '#' . $name;
switch($c_field['type']) {
@ -258,7 +262,7 @@ class importexport_export_csv implements importexport_iface_export_record
case 'select':
if (count($c_field['values']) == 1 && isset($c_field['values']['@']))
{
$c_field['values'] = egw_customfields::get_options_from_file($c_field['values']['@']);
$c_field['values'] = Api\Storage\Customfields::get_options_from_file($c_field['values']['@']);
}
$fields['select'][] = $name;
$selects[$name] = $c_field['values'];
@ -333,12 +337,12 @@ class importexport_export_csv implements importexport_iface_export_record
foreach((array)$fields['links'] as $name) {
if($record->$name) {
if(is_numeric($record->$name) && !$links[$name]) {
$link = egw_link::get_link($record->$name);
$link = Link::get_link($record->$name);
$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
}
if($links[$name]) {
$record->$name = egw_link::title($links[$name], $record->$name);
$record->$name = Link::title($links[$name], $record->$name);
}
}
else
@ -352,11 +356,11 @@ class importexport_export_csv implements importexport_iface_export_record
if(is_array($record->$name)) {
$names = array();
foreach($record->$name as $_name) {
$names[] = common::grab_owner_name($_name);
$names[] = Api\Accounts::username($_name);
}
$record->$name = implode(', ', $names);
} else {
$record->$name = common::grab_owner_name($record->$name);
$record->$name = Api\Accounts::username($record->$name);
}
}
else
@ -409,14 +413,14 @@ class importexport_export_csv implements importexport_iface_export_record
}
static $cat_object;
if(is_null($cat_object)) $cat_object = new categories(false,$appname);
if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname);
foreach((array)$fields['select-cat'] as $name) {
if($record->$name) {
$cats = array();
$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
foreach($ids as $n => $cat_id) {
if ($cat_id && $cat_object->check_perms(EGW_ACL_READ,$cat_id))
if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id))
{
$cats[] = $cat_object->id2name($cat_id);
}

View File

@ -10,6 +10,10 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Etemplate;
/**
* userinterface for exports
*
@ -32,8 +36,8 @@ class importexport_export_ui {
private $export_plugins;
public function __construct() {
egw_framework::validate_file('.','export_dialog','importexport');
egw_framework::validate_file('.','importexport','importexport');
Framework::includeJS('.','export_dialog','importexport');
Framework::includeJS('.','importexport','importexport');
$this->user = $GLOBALS['egw_info']['user']['user_id'];
$this->export_plugins = importexport_helper_functions::get_plugins('all','export');
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
@ -46,7 +50,7 @@ class importexport_export_ui {
$readonlys = array();
$preserv = array();
$et = new etemplate_new(self::_appname. '.export_dialog');
$et = new Etemplate(self::_appname. '.export_dialog');
$_appname = $_content['appname'] ? $_content['appname'] : $_GET['appname'];
$_definition = $_content['definition'] ? $_content['definition'] : $_GET['definition'];
$_plugin = $_content['plugin'] ? $_content['plugin'] : $_GET['plugin'];
@ -56,8 +60,8 @@ class importexport_export_ui {
if($_GET['selection'] || $_content['selection_passed']) $content['selection_passed'] = $preserv['selection_passed'] = true;
// Check global setting
if(!bo_merge::is_export_limit_excepted()) {
$export_limit = bo_merge::getExportLimit($_appname);
if(!Api\Storage\Merge::is_export_limit_excepted()) {
$export_limit = Api\Storage\Merge::getExportLimit($_appname);
if($export_limit == 'no') {
die(lang('Admin disabled exporting'));
}
@ -245,7 +249,7 @@ class importexport_export_ui {
if($_content['preview'] || $_content['export'])
{
//error_log(__LINE__.__FILE__.'$_content: '.print_r($_content,true));
$response = egw_json_response::get();
$response = Api\Json\Response::get();
if ($_content['definition'] == 'expert') {
$definition = new importexport_definition();
@ -287,13 +291,13 @@ class importexport_export_ui {
}
if(is_array($value) && array_key_exists('from', $value) && $value['from'])
{
$filter[$key]['from'] = egw_time::to($value['from'],'ts');
$filter[$key]['from'] = Api\DateTime::to($value['from'],'ts');
}
// If user selects an end date, they most likely want entries including that date
if(is_array($value) && array_key_exists('to',$value) && $value['to'] )
{
// Adjust time to 23:59:59
$filter[$key]['to'] = new egw_time($value['to']);
$filter[$key]['to'] = new Api\DateTime($value['to']);
$filter[$key]['to']->setTime(23,59,59);
$filter[$key]['to'] = $filter[$key]['to']->format('ts');
}
@ -316,7 +320,7 @@ class importexport_export_ui {
$tmpfname = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'export');
$file = fopen($tmpfname, "w+");
if (! $charset = $definition->plugin_options['charset']) {
$charset = $GLOBALS['egw']->translation->charset();
$charset = Api\Translation::charset();
}
if($charset == 'user')
{
@ -338,7 +342,7 @@ class importexport_export_ui {
}
// Store charset to use in header
egw_cache::setSession('importexport', $tmpfname, $charset, 100);
Api\Cache::setSession('importexport', $tmpfname, $charset, 100);
if($_content['export'] == 'pressed') {
fclose($file);
@ -357,7 +361,7 @@ class importexport_export_ui {
$link_query['filename'] = $plugin_filename;
}
$response->redirect( $GLOBALS['egw']->link('/index.php',$link_query),true);
egw_framework::window_close();
Framework::window_close();
return;
}
elseif($_content['preview'] == 'pressed') {
@ -378,9 +382,9 @@ class importexport_export_ui {
unlink($tmpfname);
// Convert back to system charset for display
$preview = $GLOBALS['egw']->translation->convert( $preview,
$preview = Api\Translation::convert( $preview,
$charset,
$GLOBALS['egw']->translation->charset()
Api\Translation::charset()
);
$preview = "<div class='header'>".lang('Preview') . "<span class='count'>".(int)$record_count."</span></div>".$preview;
@ -432,7 +436,7 @@ class importexport_export_ui {
public function ajax_get_definition_description($_definition) {
$_response = egw_json_response::get();
$_response = Api\Json\Response::get();
$description = '';
if ($_definition)
{
@ -446,7 +450,7 @@ class importexport_export_ui {
}
public function ajax_get_plugin_description($_plugin) {
$_respone = egw_json_response::get();
$_respone = Api\Json\Response::get();
$plugin_object = new $_plugin;
if (is_a($plugin_object, 'importexport_iface_export_plugin')) {
@ -477,9 +481,9 @@ class importexport_export_ui {
$file = fopen($tmpfname,'rb');
// Get charset
$charset = egw_cache::getSession('importexport', $tmpfname);
$charset = Api\Cache::getSession('importexport', $tmpfname);
html::content_header($nicefname.'.'.$_GET['_suffix'],
Api\Header\Content::type($nicefname.'.'.$_GET['_suffix'],
($_GET['_type'] ? $_GET['_type'] : 'application/text') . ($charset ? '; charset='.$charset : ''),
filesize($tmpfname));
fpassthru($file);
@ -487,6 +491,6 @@ class importexport_export_ui {
unlink($tmpfname);
// Try to avoid any extra finishing output
common::egw_exit();
exit();
}
} // end class uiexport

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* class importexport_helper_functions (only static methods)
* use importexport_helper_functions::method
@ -223,7 +225,7 @@ class importexport_helper_functions {
public static function cat_id2name( $_cat_ids ) {
$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
foreach ( $cat_ids as $cat_id ) {
$cat_names[] = categories::id2name( (int)$cat_id );
$cat_names[] = Api\Categories::id2name( (int)$cat_id );
}
return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
} // end of member function category_id2name
@ -237,7 +239,7 @@ class importexport_helper_functions {
* @return mixed comma seperated list or array with cat_ids
*/
public static function cat_name2id( $_cat_names, $parent = 0 ) {
$cats = new categories(); // uses current user and app (egw_info[flags][currentapp])
$cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp])
$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
foreach ( $cat_names as $cat_name ) {
@ -422,7 +424,7 @@ 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(
$plugins = Api\Cache::getTree(
__CLASS__,
'plugins',
array('importexport_helper_functions','_get_plugins'),
@ -432,7 +434,7 @@ class importexport_helper_functions {
$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
$types = $_type == 'all' ? array('import','export') : (array)$_type;
// Testing: comment out egw_cache call, use this
// Testing: comment out Api\Cache call, use this
//$plugins = self::_get_plugins($appnames, $types);
foreach($plugins as $appname => $_types) {
if(!in_array($appname, $appnames)) unset($plugins[$appname]);
@ -479,7 +481,7 @@ class importexport_helper_functions {
}
$d->close();
$config = config::read('importexport');
$config = Api\Config::read('importexport');
if($config['update'] == 'auto') {
self::load_defaults($appname);
}
@ -537,7 +539,7 @@ class importexport_helper_functions {
* @return boolean
*/
public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
$definitions = egw_cache::getSession(
$definitions = Api\Cache::getSession(
__CLASS__,
'has_definitions',
array('importexport_helper_functions','_has_definitions'),
@ -559,7 +561,7 @@ class importexport_helper_functions {
return count($definitions[$appname]) > 0;
}
// egw_cache needs this public
// Api\Cache needs this public
public static function _has_definitions(Array $appnames, Array $types) {
$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
$list = array();
@ -636,7 +638,7 @@ class importexport_helper_functions {
}
}
// Add custom fields
$custom = config::get_customfields($app_name);
$custom = Api\Storage\Customfields::get($app_name);
foreach($custom as $field_name => $settings)
{
$settings['name'] = '#'.$field_name;

View File

@ -10,9 +10,12 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
/**
* class importexport_iface_egw_record
* This a the abstract interface of an egw record.
* This a the abstract interface of an Egw record.
* A record is e.g. a single address or or single event.
* The idea behind is that we can have metaoperation over differnt apps by
* having a common interface.

View File

@ -11,6 +11,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Link;
/**
* class import_csv
* This a an abstract implementation of interface iface_import_record
@ -156,7 +159,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
return false;
}
$this->current_position++;
$this->record = $GLOBALS['egw']->translation->convert($csv_data, $this->csv_charset);
$this->record = Api\Translation::convert($csv_data, $this->csv_charset);
break;
case 'previous' :
@ -268,7 +271,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
if($appname) {
// Load translations
translation::add_app($appname);
Api\Translation::add_app($appname);
if(!self::$cf_parse_cache[$appname]) {
$c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods);
@ -319,7 +322,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
// Text - search for a matching record
if(!is_numeric($record[$name]))
{
$results = egw_link::query($links[$name], $record[$name]);
$results = Link::query($links[$name], $record[$name]);
if(count($results) >= 1)
{
// More than 1 result. Check for exact match
@ -389,36 +392,36 @@ class importexport_import_csv implements importexport_iface_import_record { //,
// Need to handle format first
if($format == 1)
{
$formatted = egw_time::createFromFormat(
'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat,
$formatted = Api\DateTime::createFromFormat(
'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat,
$record[$name],
egw_time::$user_timezone
Api\DateTime::$user_timezone
);
if(!$formatted && $errors = egw_time::getLastErrors())
if(!$formatted && $errors = Api\DateTime::getLastErrors())
{
// Try again, without time
$formatted = egw_time::createFromFormat(
'!'.egw_time::$user_dateformat,
$formatted = Api\DateTime::createFromFormat(
'!'.Api\DateTime::$user_dateformat,
trim($record[$name]),
egw_time::$user_timezone
Api\DateTime::$user_timezone
);
if(!$formatted && $errors = egw_time::getLastErrors())
if(!$formatted && $errors = Api\DateTime::getLastErrors())
{
// Try again, anything goes
try {
$formatted = new egw_time($record[$name]);
$formatted = new Api\DateTime($record[$name]);
} catch (Exception $e) {
$warnings[] = $name.': ' . $e->getMessage() . "\n" .
'Format: '.'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat;
'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat;
continue;
}
$errors = egw_time::getLastErrors();
$errors = Api\DateTime::getLastErrors();
foreach($errors['errors'] as $char => $msg)
{
$warnings[] = "$name: [$char] $msg\n".
'Format: '.'!'.egw_time::$user_dateformat . ' ' .egw_time::$user_timeformat;
'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat;
}
}
}
@ -426,7 +429,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
{
$record[$name] = $formatted->getTimestamp();
// Timestamp is apparently in server time, but apps will do the same conversion
$record[$name] = egw_time::server2user($record[$name],'ts');
$record[$name] = Api\DateTime::server2user($record[$name],'ts');
}
}
@ -447,13 +450,13 @@ class importexport_import_csv implements importexport_iface_import_record { //,
// Need to handle format first
if($format == 1)
{
$formatted = egw_time::createFromFormat('!'.egw_time::$user_dateformat, $record[$name]);
if($formatted && $errors = egw_time::getLastErrors() && $errors['error_count'] == 0)
$formatted = Api\DateTime::createFromFormat('!'.Api\DateTime::$user_dateformat, $record[$name]);
if($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0)
{
$record[$name] = $formatted->getTimestamp();
}
}
$record[$name] = egw_time::server2user($record[$name],'ts');
$record[$name] = Api\DateTime::server2user($record[$name],'ts');
if(is_array(self::$cf_parse_cache[$appname][0]['date']) &&
in_array($name, self::$cf_parse_cache[$appname][0]['date'])) {
// Custom fields stored in a particular format (from customfields_widget)
@ -484,7 +487,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
if($appname) {
$GLOBALS['egw_info']['flags']['currentapp'] = $appname;
}
$categories = new categories('',$appname);
$categories = new Api\Categories('',$appname);
foreach((array)$fields['select-cat'] as $name) {
if($record[$name]) {
// Only parse name if it needs it

View File

@ -10,6 +10,10 @@
* @version $Id: class.importexport_import_ui.inc.php 27222 2009-06-08 16:21:14Z ralfbecker $
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Etemplate;
/**
* userinterface for imports
@ -44,14 +48,14 @@
$definition = $_GET['definition'] ? $_GET['definition'] : $content['definition'];
// We use some inline js in preview results if it fails
egw_framework::csp_script_src_attrs("unsafe-inline");
Api\Header\ContentSecurityPolicy::add('script-src', "unsafe-inline");
$template = new etemplate_new('importexport.import_dialog');
$template = new Etemplate('importexport.import_dialog');
// Load application's translations
if($appname)
{
translation::add_app($appname);
Api\Translation::add_app($appname);
}
if($content['import'] && $definition) {
try {
@ -81,7 +85,7 @@
$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
}
$required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
$encoding = translation::detect_encoding($sample, $required);
$encoding = Api\Translation::detect_encoding($sample, $required);
if($encoding && strtoupper($required) != strtoupper($encoding))
{
$this->message = lang("Encoding mismatch. Expected %1 file, you uploaded %2.<br />\n",
@ -100,7 +104,7 @@
if($file)
{
$cachefile = new egw_cache_files(array());
$dst_file = $cachefile->filename(egw_cache::keys(egw_cache::INSTANCE, 'importexport',
$dst_file = $cachefile->filename(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true);
// Keep file
if($dst_file)
@ -155,7 +159,7 @@
// Refresh opening window
if(!$content['dry-run'])
{
egw_framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname);
}
$total_processed = 0;
foreach($plugin->get_results() as $action => $a_count) {
@ -177,7 +181,7 @@
}
if ($dst_file && $content['file']['tmp_name'] == $dst_file) {
// Remove file
$cachefile->delete(egw_cache::keys(egw_cache::INSTANCE, 'importexport',
$cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport',
'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id'])));
unset($dst_file);
}
@ -188,12 +192,12 @@
}
elseif($content['cancel'])
{
$GLOBALS['egw']->js->set_onload('window.close();');
egw_framework::set_onload('window.close();');
}
elseif ($GLOBALS['egw_info']['user']['apps']['admin'])
{
$this->message .= lang('You may want to <a href="%1" target="_new">backup</a> first.',
egw::link('/index.php',
Egw::link('/index.php',
array('menuaction' => 'admin.admin_db_backup.index')
)
);
@ -212,7 +216,7 @@
$sel_options = self::get_select_options($data);
$data['message'] = $this->message;
egw_framework::validate_file('.','importexport','importexport');
Framework::includeJS('.','importexport','importexport');
if($_GET['appname']) $readonlys['appname'] = true;
@ -292,7 +296,7 @@
* @param importexport_iface_import_plugin $plugin Instance of plugin to be used
* @param resource $stream
* @param importexport_definition $definition
* @return String HTML fragment illustrating how the data will be understood by egw
* @return String HTML fragment illustrating how the data will be understood by Egw
*/
protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj)
{
@ -317,7 +321,7 @@
$rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data;
if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--;
}
$preview = html::table($rows);
$preview = Api\Html::table($rows);
rewind($stream);
}
else
@ -371,7 +375,7 @@
$data = fgetcsv($file, 8000, $options['fieldsep']);
rewind($file);
$data = translation::convert($data,$charset);
$data = Api\Translation::convert($data,$charset);
$ok = true;
if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields'])))
@ -402,8 +406,8 @@
continue;
}
// Check column headers, taking into account different translations - make sure no *
$lang_defn = mb_strtoupper(translation::translate($options['csv_fields'][$index],false,''));
$lang_file = mb_strtoupper(translation::translate($header,false,''));
$lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index],false,''));
$lang_file = mb_strtoupper(Api\Translation::translate($header,false,''));
if($lang_defn == $lang_file ||
$lang_defn == mb_strtoupper($header) ||
@ -413,9 +417,9 @@
continue;
}
// Try to go back to translation message ID for a match
$file_message_id = translation::get_message_id($header, $definition->application);
$defn_message_id = translation::get_message_id($options['csv_fields'][$index], $definition->application);
// Try to go back to Api\Translation message ID for a match
$file_message_id = Api\Translation::get_message_id($header, $definition->application);
$defn_message_id = Api\Translation::get_message_id($options['csv_fields'][$index], $definition->application);
if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id)
{
@ -432,12 +436,12 @@
if(!$ok || count($message) != $message_count)
{
// Add links for new / edit definition
$config = config::read('importexport');
$config = Api\Config::read('importexport');
if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
{
$actions = '';
// New definition
$add_link = egw::link('/index.php',array(
$add_link = Egw::link('/index.php',array(
'menuaction' => 'importexport.importexport_definitions_ui.edit',
'application' => $definition->application,
'plugin' => $definition->plugin,
@ -445,7 +449,7 @@
'step' => 'wizard_step21'
));
$add_link = "
javascript:this.window.location = '" . egw::link('/index.php', array(
javascript:this.window.location = '" . Egw::link('/index.php', array(
'menuaction' => 'importexport.importexport_import_ui.import_dialog',
// Don't set appname, or user won't be able to select & see their new definition
//'appname' => $definition->application,
@ -470,7 +474,7 @@
$GLOBALS['egw']->session->appsession('csvfile','',$dst_file);
$edit_link['step'] = 'wizard_step30';
}
$edit_link = egw::link('/index.php',$edit_link);
$edit_link = Egw::link('/index.php',$edit_link);
$edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')";
$actions[] = lang('Edit definition <a href="%1">%2</a> to match your file',
$edit_link, $definition->name );

View File

@ -10,6 +10,10 @@
* @version $Id: class.importexport_import_ui.inc.php 27222 2009-06-08 16:21:14Z ralfbecker $
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Vfs;
use EGroupware\Api\Etemplate;
/**
* userinterface for admins to schedule imports or exports using async services
@ -26,7 +30,7 @@
protected static $template;
public function __construct() {
$this->template = new etemplate_new();
$this->template = new Etemplate();
}
public function index($content = array()) {
@ -68,9 +72,9 @@
}
$data['scheduled'][] = array_merge($async['data'], array(
'id' => urlencode($id),
'next' => egw_time::server2user($async['next']),
'next' => Api\DateTime::server2user($async['next']),
'times' => str_replace("\n", '', print_r($async['times'], true)),
'last_run' => $async['data']['last_run'] ? egw_time::server2user($async['data']['last_run']) : ''
'last_run' => $async['data']['last_run'] ? Api\DateTime::server2user($async['data']['last_run']) : ''
));
}
array_unshift($data['scheduled'], false);
@ -85,7 +89,7 @@
public function edit($content = array()) {
$id = $_GET['id'] ? urldecode($_GET['id']) : $content['id'];
$definition_id = $_GET['definition'];
$async = new asyncservice();
$async = new Api\Asyncservice();
unset($content['id']);
@ -112,8 +116,8 @@
$content
);
if($result) {
egw_framework::refresh_opener('', 'admin',$id,'update','admin');
egw_framework::window_close();
Framework::refresh_opener('', 'admin',$id,'update','admin');
Framework::window_close();
} else {
$data['message'] = lang('Unable to schedule');
unset($id);
@ -159,7 +163,7 @@
$data['current_time'] = time();
$sel_options = self::get_select_options($data);
egw_framework::validate_file('.','importexport','importexport');
Framework::includeJS('.','importexport','importexport');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Schedule import / export');
$this->template->read('importexport.schedule_edit');
@ -304,11 +308,11 @@
if($scheme == '' || $scheme == 'file') {
return 'Direct file access not allowed';
}
if($scheme == EGroupware\Api\Vfs::SCHEME && !in_array(EGroupware\Api\Vfs::SCHEME, stream_get_wrappers())) {
stream_wrapper_register(EGroupware\Api\Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL);
if($scheme == EGroupware\Vfs::SCHEME && !in_array(EGroupware\Vfs::SCHEME, stream_get_wrappers())) {
stream_wrapper_register(EGroupware\Vfs::SCHEME, 'vfs_stream_wrapper', STREAM_IS_URL);
}
if ($data['type'] == 'import' && ($scheme == EGroupware\Api\Vfs::SCHEME && !egw_vfs::is_readable($data['target'])))
if ($data['type'] == 'import' && ($scheme == EGroupware\Vfs::SCHEME && !Vfs::is_readable($data['target'])))
{
return lang('%1 is not readable',$data['target']);
}
@ -621,7 +625,7 @@
if($data['warnings'])
{
$contents .= lang($data['type']) . ' ' . lang('Warnings') . ' ' . egw_time::to() . ':';
$contents .= lang($data['type']) . ' ' . lang('Warnings') . ' ' . Api\DateTime::to() . ':';
foreach($data['warnings'] as $target => $message)
{
$contents .= "\n". (is_numeric($target) ? '' : $target."\n");
@ -631,7 +635,7 @@
}
if($data['errors'])
{
$contents .= lang($data['type']) . ' ' . lang('Errors') . ' ' . egw_time::to() . ':';
$contents .= lang($data['type']) . ' ' . lang('Errors') . ' ' . Api\DateTime::to() . ':';
foreach($data['errors'] as $target => $errors)
{
$contents .= "\n". (is_numeric($target) ? '' : $target."\n");

View File

@ -6,6 +6,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Etemplate;
/**
* Extend custom fields and make an general advanced filter
*
@ -21,7 +24,7 @@
*
* Most text fields are ignored.
*/
class importexport_widget_filter extends etemplate_widget_transformer
class importexport_widget_filter extends Etemplate\Widget\Transformer
{
protected static $prefix = '';
@ -98,7 +101,7 @@ class importexport_widget_filter extends etemplate_widget_transformer
// and used as such. All unknown values will be used for selection, not passed through to the query
if (isset($field['values']['@']))
{
$options['values'] = egw_customfields::get_options_from_file($field['values']['@']);
$options['values'] = Api\Storage\Customfields::get_options_from_file($field['values']['@']);
unset($field['values']['@']);
} else {
$options['values'] = array_diff_key($field['values'], array_flip(ajax_select_widget::$known_options));
@ -113,7 +116,7 @@ class importexport_widget_filter extends etemplate_widget_transformer
{
if (count($field['values']) == 1 && isset($field['values']['@']))
{
$field['values'] = egw_customfields::get_options_from_file($field['values']['@']);
$field['values'] = Api\Storage\Customfields::get_options_from_file($field['values']['@']);
}
foreach((array)$field['values'] as $key => $val)
{
@ -182,4 +185,4 @@ class importexport_widget_filter extends etemplate_widget_transformer
}
}
// Register, or it won't be found
\EGroupware\Api\Etemplate\Widget::registerWidget('importexport_widget_filter', array('filter'));
Etemplate\Widget::registerWidget('importexport_widget_filter', array('filter'));

View File

@ -15,6 +15,8 @@
* @author Nathan Gray
*/
use EGroupware\Api;
class importexport_wizard_basic_export_csv
{
@ -63,7 +65,7 @@ class importexport_wizard_basic_export_csv
);
list($appname, $part2) = explode('_', get_class($this));
if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= '_'.$part2; // Handle apps with _ in the name
translation::add_app($appname);
Api\Translation::add_app($appname);
}
/**
@ -202,13 +204,13 @@ class importexport_wizard_basic_export_csv
1 => lang('Field names'),
'label' => lang('Field labels')
);
$sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+
$sel_options['charset'] = Api\Translation::get_installed_charsets()+
array(
'user' => lang('User preference'),
);
// Add in extra allowed charsets
$config = config::read('importexport');
$config = Api\Config::read('importexport');
$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
if($extra_charsets)
{

View File

@ -15,6 +15,8 @@
* @author Nathan Gray
*/
use EGroupware\Api;
class importexport_wizard_basic_import_csv
{
@ -98,7 +100,7 @@ class importexport_wizard_basic_import_csv
$content['step'] = 'wizard_step30';
$preserv = $content;
unset ($preserv['button']);
//$GLOBALS['egw']->js->set_onload("xajax_eT_wrapper_init();");
return $this->step_templates[$content['step']];
}
@ -131,8 +133,8 @@ class importexport_wizard_basic_import_csv
// Remove & forget file
unlink($GLOBALS['egw']->session->appsession('csvfile',$content['application']));
egw_cache::setSession($content['application'], 'csvfile', '');
$content['csv_fields'] = translation::convert($data,$content['charset']);
Api\Cache::setSession($content['application'], 'csvfile', '');
$content['csv_fields'] = Api\Translation::convert($data,$content['charset']);
// Reset field mapping for new file
$content['field_mapping'] = array();
@ -151,10 +153,10 @@ class importexport_wizard_basic_import_csv
}
// Check english also
if($GLOBALS['egw_info']['user']['preferences']['common']['lang'] != 'en' && !isset($english[$field_name])) {
$msg_id = translation::get_message_id($field_name, $content['application']);
$msg_id = Api\Translation::get_message_id($field_name, $content['application']);
}
if($msg_id) {
$english[$field_name] = translation::read('en', $content['application'], $msg_id);
$english[$field_name] = Api\Translation::read('en', $content['application'], $msg_id);
} else {
$english[$field_name] = false;
}
@ -229,13 +231,13 @@ class importexport_wizard_basic_import_csv
$content['convert'] = 1;
}
$sel_options['charset'] = $GLOBALS['egw']->translation->get_installed_charsets()+
$sel_options['charset'] = Api\Translation::get_installed_charsets()+
array(
'user' => lang('User preference'),
);
// Add in extra allowed charsets
$config = config::read('importexport');
$config = Api\Config::read('importexport');
$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
if($extra_charsets)
{

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@
*/
$setup_info['importexport']['name'] = 'importexport';
$setup_info['importexport']['version'] = '14.1';
$setup_info['importexport']['version'] = '16.1';
$setup_info['importexport']['app_order'] = 2;
$setup_info['importexport']['enable'] = 2;
$setup_info['importexport']['tables'] = array('egw_importexport_definitions');
@ -36,12 +36,8 @@ $setup_info['importexport']['hooks']['etemplate2_register_widgets'] = 'importexp
/* Dependencies for this app to work */
$setup_info['importexport']['depends'][] = array(
'appname' => 'phpgwapi',
'versions' => Array('14.1')
);
$setup_info['importexport']['depends'][] = array(
'appname' => 'etemplate',
'versions' => Array('14.1')
'appname' => 'api',
'versions' => Array('16.1')
);
// installation checks for importexport

View File

@ -126,3 +126,7 @@ function importexport_upgrade1_9_004()
{
return $GLOBALS['setup_info']['importexport']['currentver'] = '14.1';
}
function importexport_upgrade14_1()
{
return $GLOBALS['setup_info']['importexport']['currentver'] = '16.1';
}