alecpl
2008-05-08 ed5ed98bea879a801c11c66589395452b9b8087b
program/steps/mail/addcontact.inc
@@ -19,13 +19,23 @@
*/
require_once('include/rcube_contacts.inc');
$done = false;
if (!empty($_POST['_address']))
{
  $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
  $CONTACTS = array();
  if (strtolower($CONFIG['address_book_type']) == 'ldap') {
    // Use the first writable LDAP address book.
    foreach ($CONFIG["ldap_public"] as $id => $prop) {
      if ($prop["writable"]) {
        $CONTACTS = new rcube_ldap($prop);
        break;
      } // end if
    } // end foreach
  } // end if
  else {
    $CONTACTS = new rcube_contacts($DB, $_SESSION['user_id']);
  } // end else
  $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_POST, true), 1, false);
  
  if (!empty($contact_arr[1]['mailto']))
@@ -40,7 +50,7 @@
      $contact['name'] = ucfirst(preg_replace('/[\.\-]/', ' ', substr($contact['email'], 0, strpos($contact['email'], '@'))));
    // check for existing contacts
    $existing = $CONTACTS->search('email', $contact['email'], false);
    $existing = $CONTACTS->search('email', $contact['email'], true, false);
    if ($done = $existing->count)
      $OUTPUT->show_message('contactexists', 'warning');
    else if ($done = $CONTACTS->insert($contact))
@@ -52,4 +62,4 @@
  $OUTPUT->show_message('errorsavingcontact', 'warning');
$OUTPUT->send();
?>
?>