Aleksander Machniak
2016-05-22 77b5d7ee304a688a2eb115ce04b460b43c0dd700
commit | author | age
fa9819 1 #!/usr/bin/env php
TB 2 <?php
3 /*
4  +-----------------------------------------------------------------------+
f23ef1 5  | bin/moduserprefs.sh                                                   |
fa9819 6  |                                                                       |
TB 7  | This file is part of the Roundcube Webmail client                     |
e76208 8  | Copyright (C) 2012-2015, The Roundcube Dev Team                       |
fa9819 9  |                                                                       |
TB 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  |   Bulk-change settings stored in user preferences                     |
16  +-----------------------------------------------------------------------+
17  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
18  +-----------------------------------------------------------------------+
19 */
20
0ea079 21 define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
fa9819 22
TB 23 require_once INSTALL_PATH.'program/include/clisetup.php';
24
25 function print_usage()
26 {
8042e1 27     print "Usage: moduserprefs.sh [options] pref-name [pref-value]\n";
AM 28     print "Options:\n";
29     print "    --user=user-id User ID in local database\n";
30     print "    --config=path  Location of additional configuration file\n";
31     print "    --delete       Unset the given preference\n";
32     print "    --type=type    Pref-value type: int, bool, string\n";
fa9819 33 }
TB 34
35
36 // get arguments
8042e1 37 $args = rcube_utils::get_opt(array(
AM 38         'u' => 'user',
39         'd' => 'delete',
40         't' => 'type',
41         'c' => 'config',
42 ));
fa9819 43
TB 44 if ($_SERVER['argv'][1] == 'help') {
8042e1 45     print_usage();
AM 46     exit;
fa9819 47 }
TB 48 else if (empty($args[0]) || (!isset($args[1]) && !$args['delete'])) {
8042e1 49     print "Missing required parameters.\n";
AM 50     print_usage();
51     exit;
fa9819 52 }
TB 53
54 $pref_name  = trim($args[0]);
55 $pref_value = $args['delete'] ? null : trim($args[1]);
56
8042e1 57 if ($pref_value === null) {
AM 58     $args['type'] = null;
59 }
60
61 if ($args['config']) {
62     $rcube = rcube::get_instance();
63     $rcube->config->load_from_file($args['config']);
64 }
65
66 rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], $args['type']);
fa9819 67
TB 68 ?>