From 6fd71e3ed49aa71aa90e4cfd9bfeda4b48a1ab47 Mon Sep 17 00:00:00 2001 From: alecpl Date: Mon, 4 May 2009 06:53:56 +0000 Subject: - more addressbooks hooks (#1485829) --- program/steps/addressbook/copy.inc | 11 ++++++++--- program/steps/addressbook/import.inc | 24 +++++++++++++----------- program/steps/mail/addcontact.inc | 2 +- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'program') diff --git a/program/steps/addressbook/copy.inc b/program/steps/addressbook/copy.inc index 268903bf5..db407497e 100644 --- a/program/steps/addressbook/copy.inc +++ b/program/steps/addressbook/copy.inc @@ -26,8 +26,13 @@ if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && strlen($t $success = false; $TARGET = $RCMAIL->get_address_book($target); - if ($TARGET && $TARGET->ready && !$TARGET->readonly) - $success = $TARGET->insert($CONTACTS->search($CONTACTS->primary_key, $cid), true); + 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); + } if (empty($success)) $OUTPUT->show_message('copyerror', 'error'); @@ -41,4 +46,4 @@ if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && strlen($t // send response $OUTPUT->send(); -?> \ No newline at end of file +?> diff --git a/program/steps/addressbook/import.inc b/program/steps/addressbook/import.inc index 8140a8526..1d5b00e1a 100644 --- a/program/steps/addressbook/import.inc +++ b/program/steps/addressbook/import.inc @@ -75,18 +75,18 @@ function rcmail_import_buttons($attrib) { global $IMPORT_STATS, $OUTPUT; - $attrib += array('type' => "input"); + $attrib += array('type' => 'input'); unset($attrib['name']); if (is_object($IMPORT_STATS)) { $attrib['class'] = trim($attrib['class'] . ' mainaction'); - $out = $OUTPUT->button(array('command' => "list", 'label' => "done") + $attrib); + $out = $OUTPUT->button(array('command' => 'list', 'label' => 'done') + $attrib); } else { - $out = $OUTPUT->button(array('command' => "list", 'label' => "cancel") + $attrib); + $out = $OUTPUT->button(array('command' => 'list', 'label' => 'cancel') + $attrib); $out .= ' '; $attrib['class'] = trim($attrib['class'] . ' mainaction'); - $out .= $OUTPUT->button(array('command' => "import", 'label' => "import") + $attrib); + $out .= $OUTPUT->button(array('command' => 'import', 'label' => 'import') + $attrib); } return $out; @@ -142,19 +142,22 @@ if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name' } } - $success = $CONTACTS->insert(array( + $a_record = array( 'name' => $vcard->displayname, 'firstname' => $vcard->firstname, 'surname' => $vcard->surname, 'email' => $email, 'vcard' => $vcard->export(), - )); + ); - if ($success) { + $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $a_record, 'source' => null)); + $a_record = $plugin['record']; + + // insert record and send response + if (!$plugin['abort'] && ($success = $CONTACTS->insert($a_record))) { $IMPORT_STATS->inserted++; $IMPORT_STATS->names[] = $vcard->displayname; - } - else { + } else { $IMPORT_STATS->errors++; } } @@ -165,8 +168,7 @@ if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name' else if ($err = $_FILES['_file']['error']) { if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { $OUTPUT->show_message('filesizeerror', 'error', array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))); - } - else { + } else { $OUTPUT->show_message('fileuploaderror', 'error'); } } diff --git a/program/steps/mail/addcontact.inc b/program/steps/mail/addcontact.inc index 6ae0eec65..5f8c6d14d 100644 --- a/program/steps/mail/addcontact.inc +++ b/program/steps/mail/addcontact.inc @@ -43,7 +43,7 @@ if (!empty($_POST['_address']) && is_object($CONTACTS)) $OUTPUT->show_message('contactexists', 'warning'); else { - $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $contact, 'source' => get_input_value('_source', RCUBE_INPUT_GPC))); + $plugin = $RCMAIL->plugins->exec_hook('create_contact', array('record' => $contact, 'source' => null)); $contact = $plugin['record']; if (!$plugin['abort'] && ($done = $CONTACTS->insert($contact))) -- cgit v1.2.3