summaryrefslogtreecommitdiff
path: root/roundcubemail/bin
diff options
context:
space:
mode:
authorthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-02-14 20:46:48 +0000
committerthomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c>2011-02-14 20:46:48 +0000
commit1e1ad9ee81069a18c3bbe0101f405491d977b1bf (patch)
tree32dc1f66b2575ba9642696e5fbc4b311ade728cf /roundcubemail/bin
parent2e91bb700b0ea556d4780a4d80703f3ce8473391 (diff)
Fulltext search over contact fields. Attention: DATABASE SCHEMA CHANGED\!
git-svn-id: https://svn.roundcube.net/trunk@4541 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/bin')
-rwxr-xr-xroundcubemail/bin/indexcontacts.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/roundcubemail/bin/indexcontacts.sh b/roundcubemail/bin/indexcontacts.sh
new file mode 100755
index 000000000..ac20e0441
--- /dev/null
+++ b/roundcubemail/bin/indexcontacts.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env php
+<?php
+/*
+
+ +-----------------------------------------------------------------------+
+ | bin/indexcontacts.sh |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2011, The Roundcube Dev Team |
+ | Licensed under the GNU GPL |
+ | |
+ | PURPOSE: |
+ | Update the fulltext index for all contacts of the internal |
+ | address book. |
+ +-----------------------------------------------------------------------+
+ | Author: Thomas Bruederli <roundcube@gmail.com> |
+ +-----------------------------------------------------------------------+
+
+ $Id$
+
+*/
+
+define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
+
+require_once INSTALL_PATH.'program/include/clisetup.php';
+
+
+// connect to DB
+$RCMAIL = rcmail::get_instance();
+
+$db = $RCMAIL->get_dbh();
+$db->db_connect('w');
+
+if (!$db->is_connected() || $db->is_error())
+ die("No DB connection\n");
+
+// iterate over all users
+$sql_result = $db->query("SELECT user_id FROM " . $RCMAIL->config->get('db_table_users', 'users')." WHERE 1");
+while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) {
+ echo "Indexing contacts for user " . $sql_arr['user_id'] . "...";
+
+ $contacts = new rcube_contacts($db, $sql_arr['user_id']);
+ $contacts->set_pagesize(9999);
+
+ $result = $contacts->list_records();
+ while ($result->count && ($row = $result->next())) {
+ unset($row['words']);
+ $contacts->update($row['ID'], $row);
+ }
+
+ echo "done.\n";
+}
+
+?>