mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 12:51:52 +02:00
imrpove dry-run and cli
This commit is contained in:
parent
c1a2bd342f
commit
f75ab71d98
@ -13,11 +13,13 @@
|
|||||||
$path_to_egroupware = realpath(dirname(__FILE__).'/..');
|
$path_to_egroupware = realpath(dirname(__FILE__).'/..');
|
||||||
|
|
||||||
$usage = "usage:
|
$usage = "usage:
|
||||||
--definition <name of definition>
|
--definition <name of definition> Name of definition
|
||||||
--file <name of file>
|
--file <name of file> File to import / for export
|
||||||
--user <eGW username>
|
--user <eGW username> eGroupWare username for action
|
||||||
--password <password for user>
|
--password <password for user> users password
|
||||||
--domain <domain name> \n";
|
--domain <domain name> eGroupWare domain
|
||||||
|
--dry-run no real action, just console output
|
||||||
|
\n";
|
||||||
|
|
||||||
if (php_sapi_name() != 'cli') {
|
if (php_sapi_name() != 'cli') {
|
||||||
die('This script only runs form command line');
|
die('This script only runs form command line');
|
||||||
@ -49,7 +51,8 @@
|
|||||||
'file=',
|
'file=',
|
||||||
'user=',
|
'user=',
|
||||||
'password=',
|
'password=',
|
||||||
'domain='
|
'domain=',
|
||||||
|
'dry-run',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert the arguments to options - check for the first argument
|
// Convert the arguments to options - check for the first argument
|
||||||
@ -66,6 +69,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$domain = 'default';
|
$domain = 'default';
|
||||||
|
$dryrun = false;
|
||||||
foreach ($options[0] as $option) {
|
foreach ($options[0] as $option) {
|
||||||
switch ($option[0]) {
|
switch ($option[0]) {
|
||||||
case '--file' :
|
case '--file' :
|
||||||
@ -83,6 +87,9 @@
|
|||||||
case '--password' :
|
case '--password' :
|
||||||
$password = $option[1];
|
$password = $option[1];
|
||||||
break;
|
break;
|
||||||
|
case '--dry-run' :
|
||||||
|
$dryrun = true;
|
||||||
|
break;
|
||||||
default :
|
default :
|
||||||
fwrite (STDERR,$usage."\n");
|
fwrite (STDERR,$usage."\n");
|
||||||
exit(INVALID_OPTION);
|
exit(INVALID_OPTION);
|
||||||
@ -131,19 +138,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
require_once('inc/class.definition.inc.php');
|
require_once('inc/class.definition.inc.php');
|
||||||
try {
|
|
||||||
$definition = new definition($definition);
|
$definition = new definition($definition);
|
||||||
}
|
if( $definition->get_identifier() < 1 ) {
|
||||||
catch (Exception $e) {
|
fwrite(STDERR,"importexport_cli: Definition not found! \n");
|
||||||
fwrite(STDERR,"importexport_cli: ". $e->getMessage(). "\n");
|
|
||||||
exit(INVALID_OPTION);
|
exit(INVALID_OPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['egw_info']['flags']['currentapp'] = $definition->application;
|
$GLOBALS['egw_info']['flags']['currentapp'] = $definition->application;
|
||||||
|
|
||||||
|
$definition->plugin_options['dry_run'] = $dryrun;
|
||||||
|
$type = $definition->type;
|
||||||
|
|
||||||
|
|
||||||
require_once("$path_to_egroupware/$definition->application/importexport/class.$definition->plugin.inc.php");
|
require_once("$path_to_egroupware/$definition->application/importexport/class.$definition->plugin.inc.php");
|
||||||
$po = new $definition->plugin;
|
$po = new $definition->plugin;
|
||||||
$type = $definition->type;
|
|
||||||
|
|
||||||
$resource = fopen( $file, 'r' );
|
$resource = fopen( $file, 'r' );
|
||||||
$po->$type( $resource, $definition );
|
$po->$type( $resource, $definition );
|
||||||
|
@ -54,22 +54,6 @@ class bodefinitions {
|
|||||||
return $this->definitions;
|
return $this->definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* reads a definition from database
|
|
||||||
*
|
|
||||||
* @deprecated see class.definition.inc.php
|
|
||||||
* @param mixed &$definition
|
|
||||||
* @return bool success or not
|
|
||||||
*/
|
|
||||||
public function read(&$definition) {
|
|
||||||
if(is_int($definition)) $definition = array('definition_id' => $definition);
|
|
||||||
elseif(is_string($definition)) $definition = array('name' => $definition);
|
|
||||||
if(!$definition = $this->so_sql->read($definition)) return false;
|
|
||||||
$definition += (array)unserialize($definition['plugin_options']);
|
|
||||||
unset($definition['plugin_options']);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deletes a defintion
|
* deletes a defintion
|
||||||
*
|
*
|
||||||
|
@ -217,7 +217,7 @@ class definition implements iface_egw_record {
|
|||||||
/**
|
/**
|
||||||
* gets identifier of this record
|
* gets identifier of this record
|
||||||
*
|
*
|
||||||
* @return string identifier of this record
|
* @return int identifier of this record
|
||||||
*/
|
*/
|
||||||
public function get_identifier() {
|
public function get_identifier() {
|
||||||
return $this->definition['definition_id'];
|
return $this->definition['definition_id'];
|
||||||
|
@ -209,6 +209,7 @@ class import_csv implements iface_import_record { //, Iterator {
|
|||||||
$record = $this->record;
|
$record = $this->record;
|
||||||
$this->record = array();
|
$this->record = array();
|
||||||
foreach ($this->mapping as $cvs_idx => $new_idx) {
|
foreach ($this->mapping as $cvs_idx => $new_idx) {
|
||||||
|
if( $new_idx == '' ) continue;
|
||||||
$this->record[$new_idx] = $record[$cvs_idx];
|
$this->record[$new_idx] = $record[$cvs_idx];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user