comparison bin/indexcontacts.sh @ 0:4681f974d28b

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:52:31 -0500
parents
children bf99236cc5cd
comparison
equal deleted inserted replaced
-1:000000000000 0:4681f974d28b
1 #!/usr/bin/env php
2 <?php
3 /*
4 +-----------------------------------------------------------------------+
5 | bin/indexcontacts.sh |
6 | |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2011, The Roundcube Dev Team |
9 | |
10 | Licensed under the GNU General Public License version 3 or |
11 | any later version with exceptions for skins & plugins. |
12 | See the README file for a full license statement. |
13 | |
14 | PURPOSE: |
15 | Update the fulltext index for all contacts of the internal |
16 | address book. |
17 +-----------------------------------------------------------------------+
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
19 +-----------------------------------------------------------------------+
20 */
21
22 define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
23
24 require_once INSTALL_PATH.'program/include/clisetup.php';
25 ini_set('memory_limit', -1);
26
27 // connect to DB
28 $RCMAIL = rcube::get_instance();
29
30 $db = $RCMAIL->get_dbh();
31 $db->db_connect('w');
32
33 if (!$db->is_connected() || $db->is_error()) {
34 rcube::raise_error("No DB connection", false, true);
35 }
36
37 // iterate over all users
38 $sql_result = $db->query("SELECT `user_id` FROM " . $db->table_name('users', true) . " ORDER BY `user_id`");
39 while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) {
40 echo "Indexing contacts for user " . $sql_arr['user_id'] . "...";
41
42 $contacts = new rcube_contacts($db, $sql_arr['user_id']);
43 $contacts->set_pagesize(9999);
44
45 $result = $contacts->list_records();
46 while ($result->count && ($row = $result->next())) {
47 unset($row['words']);
48 $contacts->update($row['ID'], $row);
49 }
50
51 echo "done.\n";
52 }
53
54 ?>