source: github/program/steps/mail/addcontact.inc @ 30233b8

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 30233b8 was 30233b8, checked in by thomascube <thomas@…>, 8 years ago

Minor bugfixes and correction of confusing License notfications

  • Property mode set to 100644
File size: 2.4 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/mail/addcontact.inc                                     |
6 |                                                                       |
7 | This file is part of the RoundCube Webmail client                     |
8 | Copyright (C) 2005, RoundCube Dev. - Switzerland                      |
9 | Licensed under the GNU GPL                                            |
10 |                                                                       |
11 | PURPOSE:                                                              |
12 |   Add the submitted contact to the users address book                 |
13 |                                                                       |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
16 +-----------------------------------------------------------------------+
17
18 $Id$
19
20*/
21
22$REMOTE_REQUEST = TRUE;
23
24if ($_GET['_address'])
25  {
26  $contact_arr = $IMAP->decode_address_list($_GET['_address']);
27  if (sizeof($contact_arr))
28    {
29    $contact = $contact_arr[1];
30
31    if ($contact['mailto'])
32      $sql_result = $DB->query(sprintf("SELECT 1 FROM %s
33                                        WHERE  user_id=%d
34                                        AND    email='%s'
35                                        AND    del!='1'",
36                                       get_table_name('contacts'),
37                                       $_SESSION['user_id'],
38                                       $contact['mailto']));
39
40    // contact entry with this mail address exists
41    if ($sql_result && $DB->num_rows($sql_result))
42      $existing_contact = TRUE;
43
44    else if ($contact['mailto'])
45      {
46      $DB->query(sprintf("INSERT INTO %s
47                          (user_id, name, email)
48                          VALUES (%d, '%s', '%s')",
49                         get_table_name('contacts'),
50                         $_SESSION['user_id'],
51                         $contact['name'],
52                         $contact['mailto']));
53
54      $added = $DB->insert_id();
55      }
56    }
57
58  if ($added)
59    $commands = show_message('addedsuccessfully', 'confirmation');
60  else if ($existing_contact)
61    $commands = show_message('contactexists', 'warning');
62  }
63
64
65if (!$commands)
66  $commands = show_message('errorsavingcontact', 'warning');
67
68rcube_remote_response($commands); 
69exit;
70?>
Note: See TracBrowser for help on using the repository browser.