forked from stwa/google_addressbook
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsync-cli.sh
More file actions
executable file
·44 lines (36 loc) · 1.63 KB
/
Copy pathsync-cli.sh
File metadata and controls
executable file
·44 lines (36 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env php
<?php
/*
+-----------------------------------------------------------------------+
| sync-cli.sh |
| |
| Licensed under the GNU General Public License version 3 |
| |
| PURPOSE: |
| Sync your google addressbook via cli. |
+-----------------------------------------------------------------------+
| Author: Stefan Wagner <stw@cannycode.de> |
+-----------------------------------------------------------------------+
*/
define('INSTALL_PATH', realpath(__DIR__ . '/../..') . '/');
require_once INSTALL_PATH . 'program/include/clisetup.php';
require_once(__DIR__ . '/google_addressbook_functions.php');
ini_set('memory_limit', -1);
// 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");
}
$sql_result = $db->query("SELECT * FROM " . $db->table_name('users'));
while ($sql_result && ($sql_arr = $db->fetch_assoc($sql_result))) {
echo "Syncing contacts for user " . $sql_arr['username'] . "... ";
$user = new rcube_user($sql_arr['user_id'], $sql_arr);
if (google_addressbook_functions::is_enabled($user)) {
$res = google_addressbook_functions::google_sync_contacts($user);
echo $res['message'] . "\n";
} else {
echo "disabled.\n";
}
}