mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
* InfoLog CSV import: do not notify a 2nd time when primary link get set (UI does not do it either)
fixed wired formatting of 8 space instead of tab and removed xmlrpc like call by introducing new parameter value 2=only update modifier
This commit is contained in:
parent
f467572bd4
commit
cbc87ce197
@ -699,7 +699,7 @@ class infolog_bo
|
|||||||
*
|
*
|
||||||
* @param array &$values values to write
|
* @param array &$values values to write
|
||||||
* @param boolean $check_defaults=true check and set certain defaults
|
* @param boolean $check_defaults=true check and set certain defaults
|
||||||
* @param boolean $touch_modified=true touch the modification data and sets the modiefier's user-id
|
* @param boolean|int $touch_modified=true touch the modification date and sets the modifier's user-id, 2: only modifier
|
||||||
* @param boolean $user2server=true conversion between user- and server-time necessary
|
* @param boolean $user2server=true conversion between user- and server-time necessary
|
||||||
* @param boolean $skip_notification=false true = do NOT send notification, false (default) = send notifications
|
* @param boolean $skip_notification=false true = do NOT send notification, false (default) = send notifications
|
||||||
* @param boolean $throw_exception=false Throw an exception (if required fields are not set)
|
* @param boolean $throw_exception=false Throw an exception (if required fields are not set)
|
||||||
@ -874,7 +874,7 @@ class infolog_bo
|
|||||||
$this->time2time($values);
|
$this->time2time($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($touch_modified || !$values['info_datemodified'])
|
if ($touch_modified && $touch_modified !== 2 || !$values['info_datemodified'])
|
||||||
{
|
{
|
||||||
// Should only an entry be updated which includes the original modification date?
|
// Should only an entry be updated which includes the original modification date?
|
||||||
// Used in the web-GUI to check against a modification by an other user while editing the entry.
|
// Used in the web-GUI to check against a modification by an other user while editing the entry.
|
||||||
|
@ -67,12 +67,14 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
private $definition;
|
private $definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var business object
|
* @var infolog_bo
|
||||||
*/
|
*/
|
||||||
private $boinfolog;
|
private $boinfolog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For figuring out if a record has changed
|
* For figuring out if a record has changed
|
||||||
|
*
|
||||||
|
* @var infolog_tracking::
|
||||||
*/
|
*/
|
||||||
protected $tracking;
|
protected $tracking;
|
||||||
|
|
||||||
@ -97,9 +99,9 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
protected $errors = array();
|
protected $errors = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of actions, and how many times that action was taken
|
* List of actions, and how many times that action was taken
|
||||||
*/
|
*/
|
||||||
protected $results = array();
|
protected $results = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* imports entries according to given definition object.
|
* imports entries according to given definition object.
|
||||||
@ -213,14 +215,14 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
|
|
||||||
// Special values
|
// Special values
|
||||||
if ($record['addressbook'] && !is_numeric($record['addressbook']))
|
if ($record['addressbook'] && !is_numeric($record['addressbook']))
|
||||||
{
|
{
|
||||||
list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
|
list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
|
||||||
$record['addressbook'] = self::addr_id($lastname,$firstname,$org_name);
|
$record['addressbook'] = self::addr_id($lastname,$firstname,$org_name);
|
||||||
}
|
}
|
||||||
if ($record['projectmanager'] && !is_numeric($record['projectmanager']))
|
if ($record['projectmanager'] && !is_numeric($record['projectmanager']))
|
||||||
{
|
{
|
||||||
$record['projectmanager'] = self::project_id($record['projectmanager']);
|
$record['projectmanager'] = self::project_id($record['projectmanager']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $_definition->plugin_options['conditions'] )
|
if ( $_definition->plugin_options['conditions'] )
|
||||||
{
|
{
|
||||||
@ -324,9 +326,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
$this->results[$_action]++;
|
$this->results[$_action]++;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Fake an XMLRPC call to avoid failing modification date check
|
$result = $this->boinfolog->write( $_data, true, 2); // 2 = dont touch modification date
|
||||||
$GLOBALS['server']->last_method = '~fake it~';
|
|
||||||
$result = $this->boinfolog->write( $_data, true, true);
|
|
||||||
if(!$result) {
|
if(!$result) {
|
||||||
$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
|
$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
|
||||||
$GLOBALS['egw']->accounts->id2name($_data['info_owner']),
|
$GLOBALS['egw']->accounts->id2name($_data['info_owner']),
|
||||||
@ -370,7 +370,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
'info_id' => $id,
|
'info_id' => $id,
|
||||||
'info_link_id' => $link_id,
|
'info_link_id' => $link_id,
|
||||||
);
|
);
|
||||||
$this->boinfolog->write($to_write);
|
$this->boinfolog->write($to_write,False,false,true,true); // last true = no notifications, as no real change
|
||||||
$info_link_id = $link_id;
|
$info_link_id = $link_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,40 +431,40 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns warnings that were encountered during importing
|
* Returns warnings that were encountered during importing
|
||||||
* Maximum of one warning message per record, but you can append if you need to
|
* Maximum of one warning message per record, but you can append if you need to
|
||||||
*
|
*
|
||||||
* @return Array (
|
* @return Array (
|
||||||
* record_# => warning message
|
* record_# => warning message
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function get_warnings() {
|
public function get_warnings() {
|
||||||
return $this->warnings;
|
return $this->warnings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns errors that were encountered during importing
|
* Returns errors that were encountered during importing
|
||||||
* Maximum of one error message per record, but you can append if you need to
|
* Maximum of one error message per record, but you can append if you need to
|
||||||
*
|
*
|
||||||
* @return Array (
|
* @return Array (
|
||||||
* record_# => error message
|
* record_# => error message
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function get_errors() {
|
public function get_errors() {
|
||||||
return $this->errors;
|
return $this->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of actions taken, and the number of records for that action.
|
* Returns a list of actions taken, and the number of records for that action.
|
||||||
* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
|
* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
|
||||||
*
|
*
|
||||||
* @return Array (
|
* @return Array (
|
||||||
* action => record count
|
* action => record count
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function get_results() {
|
public function get_results() {
|
||||||
return $this->results;
|
return $this->results;
|
||||||
}
|
}
|
||||||
// end of iface_export_plugin
|
// end of iface_export_plugin
|
||||||
|
|
||||||
// Extra conversion functions - must be static
|
// Extra conversion functions - must be static
|
||||||
@ -483,7 +483,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
{
|
{
|
||||||
$contacts =& CreateObject('phpgwapi.contacts');
|
$contacts =& CreateObject('phpgwapi.contacts');
|
||||||
}
|
}
|
||||||
if (!is_null($org_name)) // org_name given?
|
if (!is_null($org_name)) // org_name given?
|
||||||
{
|
{
|
||||||
$org_name = trim($org_name);
|
$org_name = trim($org_name);
|
||||||
$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
|
$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
|
||||||
@ -529,7 +529,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
* Get the primary key for an entry based on a custom field
|
* Get the primary key for an entry based on a custom field
|
||||||
* Returns key, so regular linking can take over
|
* Returns key, so regular linking can take over
|
||||||
*/
|
*/
|
||||||
protected function link_by_cf($record_num, $app, $fieldname, $value)
|
protected function link_by_cf($record_num, $app, $fieldname, $value)
|
||||||
{
|
{
|
||||||
$app_id = false;
|
$app_id = false;
|
||||||
|
|
||||||
@ -554,7 +554,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
|
|
||||||
// Couldn't find field, give an error - something's wrong
|
// Couldn't find field, give an error - something's wrong
|
||||||
if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
|
if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
|
||||||
$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
|
$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
|
||||||
$custom_field, lang($app));
|
$custom_field, lang($app));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -565,12 +565,12 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
{
|
{
|
||||||
$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
|
$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
|
||||||
$result = egw_link::query($app, '', $options);
|
$result = egw_link::query($app, '', $options);
|
||||||
|
|
||||||
// Only one allowed
|
// Only one allowed
|
||||||
if(count($result) != 1)
|
if(count($result) != 1)
|
||||||
{
|
{
|
||||||
$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
|
$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
|
||||||
lang('Unable to link to %3 by custom field "%1": "%4". %2 matches.',
|
lang('Unable to link to %3 by custom field "%1": "%4". %2 matches.',
|
||||||
$custom_field, count($result), lang($app), $options['filter'][0]
|
$custom_field, count($result), lang($app), $options['filter'][0]
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
@ -581,4 +581,3 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
|||||||
return $app_id;
|
return $app_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user