Add --config and --type options to moduserprefs.sh script (#1490051)
| | |
| | | CHANGELOG Roundcube Webmail |
| | | =========================== |
| | | |
| | | - Add --config and --type options to moduserprefs.sh script (#1490051) |
| | | - Implemented memcache_debug and apc_debug options |
| | | - Installer: Remove system() function use (#1490139) |
| | | - Password plugin: Added 'kpasswd' driver by Peter Allgeyer |
| | |
| | | |
| | | function print_usage() |
| | | { |
| | | print "Usage: moduserprefs.sh [--user=user-id] pref-name [pref-value|--delete]\n"; |
| | | print "--user User ID in local database\n"; |
| | | print "Usage: moduserprefs.sh [options] pref-name [pref-value]\n"; |
| | | print "Options:\n"; |
| | | print " --user=user-id User ID in local database\n"; |
| | | print " --config=path Location of additional configuration file\n"; |
| | | print "--delete Unset the given preference\n"; |
| | | print " --type=type Pref-value type: int, bool, string\n"; |
| | | } |
| | | |
| | | |
| | | // get arguments |
| | | $args = rcube_utils::get_opt(array('u' => 'user', 'd' => 'delete')); |
| | | $args = rcube_utils::get_opt(array( |
| | | 'u' => 'user', |
| | | 'd' => 'delete', |
| | | 't' => 'type', |
| | | 'c' => 'config', |
| | | )); |
| | | |
| | | if ($_SERVER['argv'][1] == 'help') { |
| | | print_usage(); |
| | |
| | | $pref_name = trim($args[0]); |
| | | $pref_value = $args['delete'] ? null : trim($args[1]); |
| | | |
| | | rcmail_utils::mod_pref($pref_name, $pref_value, $args['user']); |
| | | if ($pref_value === null) { |
| | | $args['type'] = null; |
| | | } |
| | | |
| | | if ($args['config']) { |
| | | $rcube = rcube::get_instance(); |
| | | $rcube->config->load_from_file($args['config']); |
| | | } |
| | | |
| | | rcmail_utils::mod_pref($pref_name, $pref_value, $args['user'], $args['type']); |
| | | |
| | | ?> |
| | |
| | | * @param string Option name |
| | | * @param string Option value |
| | | * @param int Optional user identifier |
| | | * @param string Optional value type (bool, int, string) |
| | | */ |
| | | public static function mod_pref($name, $value, $userid = null) |
| | | public static function mod_pref($name, $value, $userid = null, $type = 'string') |
| | | { |
| | | $db = self::db(); |
| | | |
| | |
| | | $query = '1=1'; |
| | | } |
| | | |
| | | $type = strtolower($type); |
| | | |
| | | if ($type == 'bool' || $type == 'boolean') { |
| | | $value = rcube_utils::get_boolean($value); |
| | | } |
| | | else if ($type == 'int' || $type == 'integer') { |
| | | $value = (int) $value; |
| | | } |
| | | |
| | | // iterate over all users |
| | | $sql_result = $db->query("SELECT * FROM " . $db->table_name('users', true) . " WHERE $query"); |
| | | |