alecpl
2012-04-14 9870dac30de1b8d1bdeab57af3eeb7c89b21ef76
commit | author | age
3e2637 1 #!/usr/bin/env php
T 2 <?php
3 /*
4
5  +-----------------------------------------------------------------------+
6  | bin/indexcontacts.sh                                                  |
7  |                                                                       |
8  | This file is part of the Roundcube Webmail client                     |
9  | Copyright (C) 2011, The Roundcube Dev Team                            |
7fe381 10  |                                                                       |
T 11  | Licensed under the GNU General Public License version 3 or            |
12  | any later version with exceptions for skins & plugins.                |
13  | See the README file for a full license statement.                     |
3e2637 14  |                                                                       |
T 15  | PURPOSE:                                                              |
16  |   Update the fulltext index for all contacts of the internal          |
17  |   address book.                                                       |
18  +-----------------------------------------------------------------------+
19  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
20  +-----------------------------------------------------------------------+
21
22  $Id$
23
24 */
25
26 define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
27
28 require_once INSTALL_PATH.'program/include/clisetup.php';
4aafd9 29 ini_set('memory_limit', -1);
3e2637 30
T 31 // connect to DB
32 $RCMAIL = rcmail::get_instance();
33
34 $db = $RCMAIL->get_dbh();
35 $db->db_connect('w');
36
37 if (!$db->is_connected() || $db->is_error())
38     die("No DB connection\n");
39
40 // iterate over all users
9556e0 41 $sql_result = $db->query("SELECT user_id FROM " . $RCMAIL->config->get('db_table_users', 'users')." WHERE 1=1");
3e2637 42 while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) {
T 43     echo "Indexing contacts for user " . $sql_arr['user_id'] . "...";
44     
45     $contacts = new rcube_contacts($db, $sql_arr['user_id']);
46     $contacts->set_pagesize(9999);
47     
48     $result = $contacts->list_records();
49     while ($result->count && ($row = $result->next())) {
50         unset($row['words']);
51         $contacts->update($row['ID'], $row);
52     }
4aafd9 53
3e2637 54     echo "done.\n";
T 55 }
56
57 ?>