source: github/program/steps/mail/addcontact.inc @ 949dea5

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

Improved reading of POST and GET values

  • Property mode set to 100644
File size: 2.3 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 (!empty($_GET['_address']))
25  {
26  $contact_arr = $IMAP->decode_address_list(get_input_value('_address', RCUBE_INPUT_GET, TRUE));
27  if (sizeof($contact_arr))
28    {
29    $contact = $contact_arr[1];
30
31    if ($contact['mailto'])
32      $sql_result = $DB->query("SELECT 1 FROM ".get_table_name('contacts')."
33                                WHERE  user_id=?
34                                AND    email=?
35                                AND    del<>1",
36                                $_SESSION['user_id'],$contact['mailto']);
37
38    // contact entry with this mail address exists
39    if ($sql_result && $DB->num_rows($sql_result))
40      $existing_contact = TRUE;
41
42    else if ($contact['mailto'])
43      {
44      $DB->query("INSERT INTO ".get_table_name('contacts')."
45                  (user_id, changed, del, name, email)
46                  VALUES (?, now(), 0, ?, ?)",
47                  $_SESSION['user_id'],
48                  $contact['name'],
49                  $contact['mailto']);
50
51      $added = $DB->insert_id(get_sequence_name('contacts'));
52      }
53    }
54
55  if ($added)
56    $commands = show_message('addedsuccessfully', 'confirmation');
57  else if ($existing_contact)
58    $commands = show_message('contactexists', 'warning');
59  }
60
61
62if (!$commands)
63  $commands = show_message('errorsavingcontact', 'warning');
64
65rcube_remote_response($commands); 
66exit;
67?>
Note: See TracBrowser for help on using the repository browser.