comparison bin/moduserprefs.sh @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
1 #!/usr/bin/env php
2 <?php
3 /*
4 +-----------------------------------------------------------------------+
5 | bin/moduserprefs.sh |
6 | |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2012-2015, 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 | Bulk-change settings stored in user preferences |
16 +-----------------------------------------------------------------------+
17 | Author: Thomas Bruederli <roundcube@gmail.com> |
18 +-----------------------------------------------------------------------+
19 */
20
21 define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
22
23 require_once INSTALL_PATH.'program/include/clisetup.php';
24
25 function print_usage()
26 {
27 print "Usage: moduserprefs.sh [options] pref-name [pref-value]\n";
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";
33 }
34
35
36 // get arguments
37 $args = rcube_utils::get_opt(array(
38 'u' => 'user',
39 'd' => 'delete:bool',
40 't' => 'type',
41 'c' => 'config',
42 ));
43
44 if ($_SERVER['argv'][1] == 'help') {
45 print_usage();
46 exit;
47 }
48 else if (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) {
49 print "Missing required parameters.\n";
50 print_usage();
51 exit;
52 }
53
54 $pref_name = trim($args[0]);
55 $pref_value = $args['delete'] ? null : trim($args[1]);
56
57 if ($pref_value === null) {
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']);
67
68 ?>