source: github/program/steps/addressbook/delete.inc @ d7cb774

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since d7cb774 was d7cb774, checked in by svncommit <devs@…>, 8 years ago

more pear/mdb2 integration

  • Property mode set to 100644
File size: 3.3 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/addressbook/delete.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 |   Delete the submitted contacts (CIDs) from 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['_cid'])
25  {
26  $DB->query("UPDATE ".get_table_name('contacts')."
27              SET    del='1'
28              WHERE  user_id=?
29              AND    contact_id IN (".$_GET['_cid'].")",
30              $_SESSION['user_id']);
31                     
32  $count = $DB->affected_rows();
33  if (!$count)
34    {
35    // send error message
36    exit;
37    }
38
39
40  // count contacts for this user
41  $sql_result = $DB->query("SELECT COUNT(contact_id) AS rows
42                            FROM ".get_table_name('contacts')."
43                            WHERE  del<>'1'
44                            AND    user_id=?",
45                            $_SESSION['user_id']);
46                                   
47  $sql_arr = $DB->fetch_assoc($sql_result);
48  $rowcount = $sql_arr['rows'];   
49
50  // update message count display
51  $pages = ceil($rowcount/$CONFIG['pagesize']);
52  $commands = sprintf("this.set_rowcount('%s');\n", rcmail_get_rowcount_text($rowcount));
53  $commands .= sprintf("this.set_env('pagecount', %d);\n", $pages);
54
55
56  // add new rows from next page (if any)
57  if ($_GET['_from']!='show' && $pages>1 && $_SESSION['page'] < $pages)
58    {
59    $start_row = ($_SESSION['page'] * $CONFIG['pagesize']) - $count;
60
61    // get contacts from DB
62    $sql_result = $DB->limitquery("SELECT * FROM ".get_table_name('contacts')."
63                                   WHERE  del<>'1'
64                                   AND    user_id=?
65                                   ORDER BY name",
66                                   $start_row,
67                                   $count,
68                                   $_SESSION['user_id']);
69                                     
70    $commands .= rcmail_js_contacts_list($sql_result);
71
72/*
73    // define list of cols to be displayed
74    $a_show_cols = array('name', 'email');
75   
76    while ($sql_arr = $DB->fetch_assoc($sql_result))
77      {
78      $a_row_cols = array();
79           
80      // format each col
81      foreach ($a_show_cols as $col)
82        {
83        $cont = rep_specialchars_output($sql_arr[$col]);
84        $a_row_cols[$col] = $cont;
85        }
86 
87      $commands .= sprintf("this.add_contact_row(%s, %s);\n",
88                           $sql_arr['contact_id'],
89                           array2js($a_row_cols));
90      }
91*/
92    }
93
94  // send response
95  rcube_remote_response($commands);
96  }
97
98exit;
99?>
Note: See TracBrowser for help on using the repository browser.