4 +-----------------------------------------------------------------------+
5 | program/steps/mail/addcontact.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Add the submitted contact to the users address book |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: addcontact.inc 160 2006-03-03 16:36:22Z roundcube $
22 $REMOTE_REQUEST = TRUE;
24 if (!empty($_GET['_address']))
26 $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_GET, TRUE));
27 if (sizeof($contact_arr))
29 $contact = $contact_arr[1];
31 if ($contact['mailto'])
32 $sql_result = $DB->query("SELECT 1 FROM ".get_table_name('contacts')."
36 $_SESSION['user_id'],$contact['mailto']);
38 // contact entry with this mail address exists
39 if ($sql_result && $DB->num_rows($sql_result))
40 $existing_contact = TRUE;
42 else if ($contact['mailto'])
44 $DB->query("INSERT INTO ".get_table_name('contacts')."
45 (user_id, changed, del, name, email)
46 VALUES (?, now(), 0, ?, ?)",
51 $added = $DB->insert_id(get_sequence_name('contacts'));
56 $commands = show_message('addedsuccessfully', 'confirmation');
57 else if ($existing_contact)
58 $commands = show_message('contactexists', 'warning');
63 $commands = show_message('errorsavingcontact', 'warning');
65 rcube_remote_response($commands);