Page MenuHomePhorge

No OneTemporary

Size
11 KB
Referenced Files
None
Subscribers
None
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
@@ -1,44 +1,49 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/steps/addressbook/copy.inc |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2007, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Copy a contact record from one direcotry to another |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id: copy.inc 471 2007-02-09 21:25:50Z thomasb $
*/
$cid = get_input_value('_cid', RCUBE_INPUT_POST);
$target = get_input_value('_to', RCUBE_INPUT_POST);
if ($cid && preg_match('/^[a-z0-9\-_=]+(,[a-z0-9\-_=]+)*$/i', $cid) && strlen($target) && $target != $source)
{
$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');
else
$OUTPUT->show_message('copysuccess', 'notice', array('nr' => count($success)));
// close connection to second address directory
$TARGET->close();
}
// 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
@@ -1,185 +1,187 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/steps/addressbook/import.inc |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2008-2009, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Import contacts from a vCard or CSV file |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id: $
*/
/**
* Handler function to display the import/upload form
*/
function rcmail_import_form($attrib)
{
global $RCMAIL, $OUTPUT;
$attrib += array('id' => "rcmImportForm");
$upload = new html_inputfield(array('type' => 'file', 'name' => '_file', 'id' => 'rcmimportfile', 'size' => 40));
$form = html::p(null, html::label('rcmimportfile', rcube_label('importfromfile')) . html::br() . $upload->show());
$check_replace = new html_checkbox(array('name' => '_replace', 'value' => 1, 'id' => 'rcmimportreplace'));
$form .= html::p(null, $check_replace->show(get_input_value('_replace', RCUBE_INPUT_GPC)) .
html::label('rcmimportreplace', rcube_label('importreplace')));
$OUTPUT->add_label('selectimportfile','importwait');
$OUTPUT->add_gui_object('importform', $attrib['id']);
$out = html::p(null, Q(rcube_label('importtext'), 'show'));
$out .= $OUTPUT->form_tag(array(
'action' => $RCMAIL->url('import'),
'method' => 'post',
'enctype' => 'multipart/form-data') + $attrib,
$form);
return $out;
}
/**
* Render the confirmation page for the import process
*/
function rcmail_import_confirm($attrib)
{
global $IMPORT_STATS;
$vars = get_object_vars($IMPORT_STATS);
$vars['names'] = join(', ', array_map('Q', $IMPORT_STATS->names));
return html::p($attrib, Q(rcube_label(array(
'name' => 'importconfirm',
'nr' => $IMORT_STATS->inserted,
'vars' => $vars,
)), 'show'));
}
/**
* Create navigation buttons for the current import step
*/
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 .= '&nbsp;';
$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;
}
/** The import process **/
$importstep = 'rcmail_import_form';
if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name'])) {
$replace = (bool)get_input_value('_replace', RCUBE_INPUT_GPC);
$CONTACTS = $RCMAIL->get_address_book(null, true);
// let rcube_vcard do the hard work :-)
$vcards = rcube_vcard::import(file_get_contents($_FILES['_file']['tmp_name']));
// no vcards detected
if (!count($vcards)) {
$OUTPUT->show_message('importerror', 'error');
}
else if ($CONTACTS->readonly) {
$OUTPUT->show_message('addresswriterror', 'error');
}
else {
$IMPORT_STATS = new stdClass;
$IMPORT_STATS->names = array();
$IMPORT_STATS->count = count($vcards);
$IMPORT_STATS->inserted = $IMPORT_STATS->skipped = $IMPORT_STATS->nomail = $IMPORT_STATS->errors = 0;
if ($replace)
$CONTACTS->delete_all();
foreach ($vcards as $vcard) {
$email = $vcard->email[0];
// skip entries without an e-mail address
if (empty($email)) {
$IMPORT_STATS->nomail++;
continue;
}
if (!$replace) {
// compare e-mail address
$existing = $CONTACTS->search('email', $email, false, false);
if (!$existing->count) { // compare display name
$existing = $CONTACTS->search('name', $vcard->displayname, false, false);
}
if ($existing->count) {
$IMPORT_STATS->skipped++;
continue;
}
}
- $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++;
}
}
$importstep = 'rcmail_import_confirm';
}
}
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');
}
}
$OUTPUT->set_pagetitle(rcube_label('importcontacts'));
$OUTPUT->add_handlers(array(
'importstep' => $importstep,
'importnav' => 'rcmail_import_buttons',
));
// render page
$OUTPUT->send('importcontacts');
?>
\ No newline at end of file
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
@@ -1,59 +1,59 @@
<?php
/*
+-----------------------------------------------------------------------+
| program/steps/mail/addcontact.inc |
| |
| This file is part of the RoundCube Webmail client |
| Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
| Add the submitted contact to the users address book |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
$Id$
*/
$done = false;
$CONTACTS = $RCMAIL->get_address_book(null, true);
if (!empty($_POST['_address']) && is_object($CONTACTS))
{
$contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_POST, true), 1, false);
if (!empty($contact_arr[1]['mailto']))
{
$contact = array(
'email' => $contact_arr[1]['mailto'],
'name' => $contact_arr[1]['name']
);
// use email address part for name
if (empty($contact['name']) || $contact['name'] == $contact['email'])
$contact['name'] = ucfirst(preg_replace('/[\.\-]/', ' ', substr($contact['email'], 0, strpos($contact['email'], '@'))));
// check for existing contacts
$existing = $CONTACTS->search('email', $contact['email'], true, false);
if ($done = $existing->count)
$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)))
$OUTPUT->show_message('addedsuccessfully', 'confirmation');
}
}
}
if (!$done)
$OUTPUT->show_message('errorsavingcontact', 'warning');
$OUTPUT->send();
?>

File Metadata

Mime Type
text/x-diff
Expires
Thu, Dec 18, 1:29 PM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
418854
Default Alt Text
(11 KB)

Event Timeline