summaryrefslogtreecommitdiff
path: root/program/steps/addressbook/copy.inc
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-09-30 13:24:33 +0000
committeralecpl <alec@alec.pl>2010-09-30 13:24:33 +0000
commitce92ba767a9557daf7f18be94882dd7e6f4591fb (patch)
treef018b3c42d2d452948bc240c3d9aa8a7aaff08a3 /program/steps/addressbook/copy.inc
parent66c674cc5716364cd6b450d8398b0a26aba0a2ae (diff)
- Plugin API: improved 'abort' flag handling, added 'result' item in some hooks: group_*, contact_*, identity_* (#1486914)
Diffstat (limited to 'program/steps/addressbook/copy.inc')
-rw-r--r--program/steps/addressbook/copy.inc32
1 files changed, 18 insertions, 14 deletions
diff --git a/program/steps/addressbook/copy.inc b/program/steps/addressbook/copy.inc
index a37e93211..8a8379078 100644
--- a/program/steps/addressbook/copy.inc
+++ b/program/steps/addressbook/copy.inc
@@ -37,29 +37,31 @@ if ($cid && preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid) &
$ids = array();
foreach ($arr_cids as $cid) {
- $plugin = $RCMAIL->plugins->exec_hook('contact_create', array(
- 'record' => $CONTACTS->get_record($cid, true),
- 'source' => $target,
- 'group' => $target_group,
- ));
- $a_record = $plugin['record'];
+ $a_record = $CONTACTS->get_record($cid, true);
- if (!$plugin['abort']) {
- // check if contact exists, if so, we'll need it's ID
- $result = $TARGET->search('email', $a_record['email'], true, true);
+ // check if contact exists, if so, we'll need it's ID
+ $result = $TARGET->search('email', $a_record['email'], true, true);
+
+ // insert contact record
+ if (!$result->count) {
+ $plugin = $RCMAIL->plugins->exec_hook('contact_create', array(
+ 'record' => $a_record, 'source' => $target, 'group' => $target_group));
- // insert contact record
- if (!$result->count) {
+ if (!$plugin['abort']) {
if ($insert_id = $TARGET->insert($a_record, false)) {
$ids[] = $insert_id;
$success++;
}
}
- else {
- $record = $result->first();
- $ids[] = $record['ID'];
+ else if ($plugin['result']) {
+ $ids = array_merge($ids, $plugin['result']);
+ $success++;
}
}
+ else {
+ $record = $result->first();
+ $ids[] = $record['ID'];
+ }
}
// assign to group
@@ -79,6 +81,8 @@ if ($cid && preg_match('/^[a-zA-Z0-9\+\/=_-]+(,[a-zA-Z0-9\+\/=_-]+)*$/', $cid) &
if (($cnt = $TARGET->add_to_group($target_group, $plugin['ids'])) && $cnt > $success)
$success = $cnt;
}
+ else if ($plugin['result'])
+ $success = $plugin['result'];
}
}