Fix bug that ignored 'stop' in import condition, default definition

This commit is contained in:
Nathan Gray 2012-05-29 14:37:19 +00:00
parent 57be9157d5
commit de8bc4771c
2 changed files with 7 additions and 18 deletions

View File

@ -148,7 +148,7 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
$contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
$_definition->plugin_options['contact_owner'] : $this->user; $_definition->plugin_options['contact_owner'] : $this->user;
// Import into importer's personal addressbook // Import into importer's personal addressbook
if($contact_owner == 'personal') if($contact_owner == 'personal')
{ {
$contact_owner = $this->user; $contact_owner = $this->user;
} }
@ -190,12 +190,13 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
// Also handle categories in their own field // Also handle categories in their own field
$more_categories = array(); $more_categories = array();
foreach($_definition->plugin_options['field_mapping'] as $number => $field_name) { foreach($_definition->plugin_options['field_mapping'] as $number => $field_name) {
if(substr($field_name,0,3) != 'cat' || !$record[$field_name] || $field_name == 'cat_id') continue; if(!array_key_exists($field_name, $record) ||
substr($field_name,0,3) != 'cat' || !$record[$field_name] || $field_name == 'cat_id') continue;
list($cat, $cat_id) = explode('-', $field_name); list($cat, $cat_id) = explode('-', $field_name);
if(is_numeric($record[$field_name]) && $record[$field_name] != 1) { if(is_numeric($record[$field_name]) && $record[$field_name] != 1) {
// Column has a single category ID // Column has a single category ID
$more_categories[] = $record[$field_name]; $more_categories[] = $record[$field_name];
} elseif($record[$field_name] == '1' || } elseif($record[$field_name] == '1' ||
(!is_numeric($record[$field_name]) && strtolower($record[$field_name]) == strtolower(lang('Yes')))) { (!is_numeric($record[$field_name]) && strtolower($record[$field_name]) == strtolower(lang('Yes')))) {
// Each category got its own column. '1' is the database value, lang('yes') is the human value // Each category got its own column. '1' is the database value, lang('yes') is the human value
$more_categories[] = $cat_id; $more_categories[] = $cat_id;
@ -229,7 +230,7 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
if ($condition['string']=='account_id') $searchcondition['owner']=0; if ($condition['string']=='account_id') $searchcondition['owner']=0;
$contacts = $this->bocontacts->search( $contacts = $this->bocontacts->search(
//array( $condition['string'] => $record[$condition['string']],), //array( $condition['string'] => $record[$condition['string']],),
'', '',
$_definition->plugin_options['update_cats'] == 'add' ? false : true, $_definition->plugin_options['update_cats'] == 'add' ? false : true,
'', '', '', false, 'AND', false, '', '', '', false, 'AND', false,
$searchcondition $searchcondition
@ -258,7 +259,7 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
die('condition / action not supported!!!'); die('condition / action not supported!!!');
break; break;
} }
if ($action['last']) break; if ($action['stop']) break;
} }
} else { } else {
// unconditional insert // unconditional insert

View File

@ -240,25 +240,13 @@
<entry type="string" name="stop">1</entry> <entry type="string" name="stop">1</entry>
</entry> </entry>
</entry> </entry>
<entry type="array" name="1">
<entry type="string" name="string">id</entry>
<entry type="string" name="type">exists</entry>
<entry type="array" name="true">
<entry type="string" name="action">update</entry>
<entry type="string" name="stop">1</entry>
</entry>
<entry type="array" name="false">
<entry type="string" name="action">insert</entry>
<entry type="string" name="stop">1</entry>
</entry>
</entry>
</entry> </entry>
<entry type="string" name="owner_from_csv">1</entry> <entry type="string" name="owner_from_csv">1</entry>
<entry type="string" name="contact_owner">personal</entry> <entry type="string" name="contact_owner">personal</entry>
<entry type="string" name="change_owner">0</entry> <entry type="string" name="change_owner">0</entry>
<entry type="string" name="convert">1</entry> <entry type="string" name="convert">1</entry>
</entry> </entry>
<entry type="string" name="modified">2012-05-15 16:46:54</entry> <entry type="string" name="modified">2012-05-29 16:00:00</entry>
</entry> </entry>
</entry> </entry>
</entry> </entry>