mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
Import export dialog - Add suggestion for admin to take a backup before importing
- Add links to add new or edit definition (subject to access rules) if an exception happens (column mis-match, import plugin error)
This commit is contained in:
parent
29e52fc727
commit
6615964c39
@ -47,7 +47,7 @@ class importexport_definitions_bo {
|
||||
$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
|
||||
$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
|
||||
$sql .= ' (';
|
||||
$read = array('all');
|
||||
$read = array();
|
||||
foreach($this_membership as $id)
|
||||
{
|
||||
$read[] = 'allowed_users '.
|
||||
|
@ -63,9 +63,9 @@
|
||||
$sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024);
|
||||
$required = $options['charset'] == 'user' || !$options['charset'] ? $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'] : $options['charset'];
|
||||
$encoding = mb_detect_encoding($sample,$required,true);
|
||||
if($encoding && $required != $encoding)
|
||||
if($encoding && strtoupper($required) != strtoupper($encoding))
|
||||
{
|
||||
$this->message = lang("Encoding mismatch. Expected %1 file, you uploaded %2.\n",
|
||||
$this->message = lang("Encoding mismatch. Expected %1 file, you uploaded %2.<br />\n",
|
||||
$required,
|
||||
$encoding
|
||||
);
|
||||
@ -105,28 +105,61 @@
|
||||
if(!$content['dry-run']) $GLOBALS['egw']->js->set_onload("window.opener.egw_refresh('{$this->message}','$appname');");
|
||||
$total_processed = 0;
|
||||
foreach($plugin->get_results() as $action => $a_count) {
|
||||
$this->message .= "\n" . lang($action) . ": $a_count";
|
||||
$this->message .= "<br />\n" . lang($action) . ": $a_count";
|
||||
$total_processed += $a_count;
|
||||
}
|
||||
if(count($plugin->get_warnings())) {
|
||||
$this->message .= "\n".lang('Warnings').':';
|
||||
$this->message .= "<br />\n".lang('Warnings').':';
|
||||
foreach($plugin->get_warnings() as $record => $message) {
|
||||
$this->message .= "\n$record: $message";
|
||||
}
|
||||
}
|
||||
if(count($plugin->get_errors())) {
|
||||
$this->message .= "\n".lang('Problems during import:');
|
||||
$this->message .= "<br />\n".lang('Problems during import:');
|
||||
foreach($plugin->get_errors() as $record => $message) {
|
||||
$this->message .= "\n$record: $message";
|
||||
$this->message .= "<br />\n$record: $message";
|
||||
}
|
||||
if($count != $total_processed) $this->message .= "\n".lang('Some records may not have been imported');
|
||||
if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->message = $e->getMessage();
|
||||
|
||||
// Add links for new / edit definition
|
||||
$config = config::read('importexport');
|
||||
if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions'])
|
||||
{
|
||||
// New definition
|
||||
$add_link = egw::link('/index.php',array(
|
||||
'menuaction' => 'importexport.importexport_definitions_ui.edit'
|
||||
));
|
||||
$this->message .= "<br />\n" . lang('Create a <a href="%1">new definition</a> for this file.', $add_link);
|
||||
|
||||
// Edit selected definition, if allowed
|
||||
if($definition_obj->owner == $GLOBALS['egw_info']['user']['account_id'] ||
|
||||
!$definition_obj->owner && $GLOBALS['egw_info']['user']['apps']['admin'])
|
||||
{
|
||||
$edit_link = egw::link('/index.php',array(
|
||||
'menuaction' => 'importexport.importexport_definitions_ui.edit',
|
||||
'definition' => $definition
|
||||
));
|
||||
$this->message .= "<br />\n" . lang('<a href="%1">Edit definition %2</a>',
|
||||
$edit_link, $definition_obj->name );
|
||||
}
|
||||
} elseif($content['cancel']) {
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif($content['cancel'])
|
||||
{
|
||||
$GLOBALS['egw']->js->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',
|
||||
array('menuaction' => 'admin.admin_db_backup.index')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : '');
|
||||
$data['definition'] = $definition;
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* EGroupware - eTemplates for Application importexport
|
||||
* http://www.egroupware.org
|
||||
* generated by soetemplate::dump4setup() 2012-06-20 11:32
|
||||
* generated by soetemplate::dump4setup() 2012-09-05 11:26
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package importexport
|
||||
@ -93,7 +93,7 @@ $templ_data[] = array('name' => 'importexport.export_dialog.selection_tab','temp
|
||||
|
||||
$templ_data[] = array('name' => 'importexport.import_definition','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:92:"Import definitions (Attension: Existing definitions with equal names will be overwritten!!!)";}}i:2;a:1:{s:1:"A";a:2:{s:4:"type";s:4:"file";s:4:"name";s:11:"import_file";}}i:3;a:1:{s:1:"A";a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:6:"update";s:5:"label";s:26:"Update default-definitions";}}}}s:4:"rows";i:3;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1306253183',);
|
||||
|
||||
$templ_data[] = array('name' => 'importexport.import_dialog','template' => '','lang' => '','group' => '0','version' => '1.9.002','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:1:{s:2:"h1";s:10:",!@message";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:7:"message";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:7:"appname";s:8:"onchange";s:87:"xajax_doXMLHTTP(\'importexport.importexport_import_ui.ajax_get_definitions\',this.value);";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Import definition";}s:1:"B";a:2:{s:4:"type";s:6:"select";s:4:"name";s:10:"definition";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Delimiter";}s:1:"B";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";s:7:"no_lang";s:1:"1";i:1;a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:9:"delimiter";s:8:"onchange";s:163:"var _this = jQuery(this); var text = _this.parent().parent().find(\'input\'); if(_this.val() ==\'other\') {text.val(\'\');text.show(); text.focus();} else {text.hide();}";}i:2;a:4:{s:4:"type";s:4:"text";s:4:"name";s:15:"other_delimiter";s:4:"size";s:3:"2,1";s:4:"span";s:5:",hide";}}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:28:"Please select file to import";}s:1:"B";a:2:{s:4:"type";s:4:"file";s:4:"name";s:4:"file";}}i:6;a:2:{s:1:"A";a:5:{s:4:"type";s:3:"box";s:4:"span";s:11:"all,preview";s:8:"readonly";s:1:"1";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:4:"html";s:4:"name";s:7:"preview";s:8:"readonly";s:1:"1";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:7;a:2:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";}i:3;a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"dry-run";s:5:"label";s:9:"Test only";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;}}','size' => '','style' => '.hide input {
|
||||
$templ_data[] = array('name' => 'importexport.import_dialog','template' => '','lang' => '','group' => '0','version' => '1.9.003','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:8:{i:0;a:1:{s:2:"h1";s:10:",!@message";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:4:"html";s:4:"span";s:11:"all,message";s:4:"name";s:7:"message";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:7:"appname";s:8:"onchange";s:87:"xajax_doXMLHTTP(\'importexport.importexport_import_ui.ajax_get_definitions\',this.value);";}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:17:"Import definition";}s:1:"B";a:2:{s:4:"type";s:6:"select";s:4:"name";s:10:"definition";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:9:"Delimiter";}s:1:"B";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";s:7:"no_lang";s:1:"1";i:1;a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:9:"delimiter";s:8:"onchange";s:163:"var _this = jQuery(this); var text = _this.parent().parent().find(\'input\'); if(_this.val() ==\'other\') {text.val(\'\');text.show(); text.focus();} else {text.hide();}";}i:2;a:4:{s:4:"type";s:4:"text";s:4:"name";s:15:"other_delimiter";s:4:"size";s:3:"2,1";s:4:"span";s:5:",hide";}}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:28:"Please select file to import";}s:1:"B";a:2:{s:4:"type";s:4:"file";s:4:"name";s:4:"file";}}i:6;a:2:{s:1:"A";a:5:{s:4:"type";s:3:"box";s:4:"span";s:11:"all,preview";s:8:"readonly";s:1:"1";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:4:"html";s:4:"name";s:7:"preview";s:8:"readonly";s:1:"1";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:7;a:2:{s:1:"A";a:6:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";s:4:"span";s:3:"all";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Import";s:4:"name";s:6:"import";}i:2;a:3:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";}i:3;a:4:{s:4:"type";s:8:"checkbox";s:4:"name";s:7:"dry-run";s:5:"label";s:9:"Test only";s:5:"align";s:5:"right";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:7;s:4:"cols";i:2;}}','size' => '','style' => '.hide input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ display: none;
|
||||
}
|
||||
.preview tr{
|
||||
vertical-align: top;
|
||||
}','modified' => '1324337858',);
|
||||
}','modified' => '1346865956',);
|
||||
|
||||
$templ_data[] = array('name' => 'importexport.schedule_edit','template' => '','lang' => '','group' => '0','version' => '1.9.003','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:12:{i:0;a:3:{s:2:"h1";s:10:",!@message";s:2:"c7";s:4:"help";s:2:"h8";s:17:",@no_delete_files";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:11:"all,message";s:4:"name";s:7:"message";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Type";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:4:"type";s:8:"onchange";i:1;}}i:3;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Application";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:7:"appname";s:8:"onchange";s:137:"xajax_doXMLHTTP(\'importexport.importexport_schedule_ui.ajax_get_plugins\', document.getElementById(form::name(\'type\')).value, this.value);";}}i:4;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Plugin";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:4:"name";s:6:"plugin";s:4:"size";s:9:"Select...";s:8:"onchange";s:144:"xajax_doXMLHTTP(\'importexport.importexport_schedule_ui.ajax_get_definitions\', document.getElementById(form::name(\'appname\')).value, this.value);";}}i:5;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:10:"Definition";}s:1:"B";a:3:{s:4:"type";s:6:"select";s:4:"name";s:10:"definition";s:4:"size";s:9:"Select...";}}i:6;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Target";}s:1:"B";a:3:{s:4:"type";s:4:"text";s:4:"size";s:2:"50";s:4:"name";s:6:"target";}}i:7;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:3:"all";s:5:"label";s:83:"Target examples: vfs://default/home/user/export.csv or http://server.net/prices.csv";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:8;a:2:{s:1:"A";a:4:{s:4:"type";s:8:"checkbox";s:5:"label";s:25:"Delete files after import";s:4:"name";s:12:"delete_files";s:4:"span";s:3:"all";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:9;a:2:{s:1:"A";a:7:{s:4:"type";s:4:"grid";s:4:"data";a:4:{i:0;a:1:{s:2:"c1";s:2:"th";}i:1;a:6:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Year";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:5:"Month";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:3:"Day";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Day of week";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:4:"Hour";}s:1:"F";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Minute";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"year";s:4:"size";s:1:"5";}s:1:"B";a:3:{s:4:"type";s:4:"text";s:4:"name";s:5:"month";s:4:"size";s:1:"5";}s:1:"C";a:3:{s:4:"type";s:4:"text";s:4:"name";s:3:"day";s:4:"size";s:1:"5";}s:1:"D";a:4:{s:4:"type";s:4:"text";s:4:"name";s:3:"dow";s:5:"align";s:6:"center";s:4:"size";s:1:"5";}s:1:"E";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"hour";s:4:"size";s:1:"5";}s:1:"F";a:3:{s:4:"type";s:4:"text";s:4:"name";s:3:"min";s:4:"size";s:1:"5";}}i:3;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:1:"3";s:5:"label";s:11:"(* for all)";}s:1:"B";a:1:{s:4:"type";s:5:"label";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:2:{s:4:"type";s:5:"label";s:5:"label";s:12:"(0-6, 0=Sun)";}s:1:"E";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"(0-23)";}s:1:"F";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:3;s:4:"cols";i:6;s:4:"name";s:8:"schedule";s:4:"span";s:3:"all";s:7:"options";a:0:{}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:10;a:2:{s:1:"A";a:5:{s:4:"type";s:9:"date-time";s:4:"span";s:11:"all,message";s:5:"label";s:46:"Schedule times are server time! Currently %s.";s:4:"name";s:12:"current_time";s:8:"readonly";s:1:"1";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:11;a:2:{s:1:"A";a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"2";s:4:"span";s:3:"all";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:4:"save";}i:2;a:4:{s:4:"type";s:6:"button";s:4:"name";s:6:"cancel";s:5:"label";s:6:"Cancel";s:7:"onclick";s:13:"self.close();";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:11;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1323130226',);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user