- if ($target != '0')
- $TARGET = new rcube_ldap($CONFIG['ldap_public'][$target]);
- else
- $TARGET = new rcube_contacts($DB, $_SESSION['user_id']);
-
- $success = false;
- if ($TARGET && $TARGET->ready && !$TARGET->readonly)
- $success = $TARGET->insert($CONTACTS->search($CONTACTS->primary_key, $cid), true);
+ $success = false;
+ $TARGET = $RCMAIL->get_address_book($target);
+
+ if ($TARGET && $TARGET->ready && !$TARGET->readonly) {
+ $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $CONTACTS->search($CONTACTS->primary_key, $cid), 'source' => $target));
+ $a_record = $plugin['record'];
+
+ if (!$plugin['abort'])
+ $success = $TARGET->insert($CONTACTS->search($a_record, true));
+ }