Add --config and --type options to moduserprefs.sh script (#1490051)

pull/278/head
Aleksander Machniak 9 years ago
parent 86e97e8d50
commit 8042e13af6

@ -1,6 +1,7 @@
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

@ -24,28 +24,45 @@ require_once INSTALL_PATH.'program/include/clisetup.php';
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 "--delete Unset the given preference\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();
exit;
print_usage();
exit;
}
else if (empty($args[0]) || (!isset($args[1]) && !$args['delete'])) {
print "Missing required parameters.\n";
print_usage();
exit;
print "Missing required parameters.\n";
print_usage();
exit;
}
$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']);
?>

@ -327,8 +327,9 @@ class rcmail_utils
* @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();
@ -339,6 +340,15 @@ class rcmail_utils
$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");

Loading…
Cancel
Save