Fix handling of --delete argument in moduserprefs.sh script (#5296)

pull/5303/head
Aleksander Machniak 9 years ago
parent f466899d8d
commit d61d33a12a

@ -20,6 +20,7 @@ CHANGELOG Roundcube Webmail
- Fix bug where "no body" alert could be displayed when sending mailvelope email - Fix bug where "no body" alert could be displayed when sending mailvelope email
- Enigma: Fix keys import from inside of an encrypted message (#5285) - Enigma: Fix keys import from inside of an encrypted message (#5285)
- Fix searching by email address in contacts with multiple addresses (#5291) - Fix searching by email address in contacts with multiple addresses (#5291)
- Fix handling of --delete argument in moduserprefs.sh script (#5296)
RELEASE 1.2.0 RELEASE 1.2.0
------------- -------------

@ -36,7 +36,7 @@ function print_usage()
// get arguments // get arguments
$args = rcube_utils::get_opt(array( $args = rcube_utils::get_opt(array(
'u' => 'user', 'u' => 'user',
'd' => 'delete', 'd' => 'delete:bool',
't' => 'type', 't' => 'type',
'c' => 'config', 'c' => 'config',
)); ));
@ -45,7 +45,7 @@ if ($_SERVER['argv'][1] == 'help') {
print_usage(); print_usage();
exit; exit;
} }
else if (empty($args[0]) || (!isset($args[1]) && !$args['delete'])) { else if (empty($args[0]) || (empty($args[1]) && empty($args['delete']))) {
print "Missing required parameters.\n"; print "Missing required parameters.\n";
print_usage(); print_usage();
exit; exit;

@ -24,7 +24,7 @@ define('INSTALL_PATH', realpath(__DIR__ . '/..') . '/' );
require_once INSTALL_PATH . 'program/include/clisetup.php'; require_once INSTALL_PATH . 'program/include/clisetup.php';
// get arguments // get arguments
$opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept')); $opts = rcube_utils::get_opt(array('v' => 'version', 'y' => 'accept:bool'));
// ask user if no version is specified // ask user if no version is specified
if (!$opts['version']) { if (!$opts['version']) {

@ -976,6 +976,16 @@ class rcube_utils
public static function get_opt($aliases = array()) public static function get_opt($aliases = array())
{ {
$args = array(); $args = array();
$bool = array();
// find boolean (no value) options
foreach ($aliases as $key => $alias) {
if ($pos = strpos($alias, ':')) {
$aliases[$key] = substr($alias, 0, $pos);
$bool[] = $key;
$bool[] = $aliases[$key];
}
}
for ($i=1; $i < count($_SERVER['argv']); $i++) { for ($i=1; $i < count($_SERVER['argv']); $i++) {
$arg = $_SERVER['argv'][$i]; $arg = $_SERVER['argv'][$i];
@ -985,10 +995,14 @@ class rcube_utils
if ($arg[0] == '-') { if ($arg[0] == '-') {
$key = preg_replace('/^-+/', '', $arg); $key = preg_replace('/^-+/', '', $arg);
$sp = strpos($arg, '='); $sp = strpos($arg, '=');
if ($sp > 0) { if ($sp > 0) {
$key = substr($key, 0, $sp - 2); $key = substr($key, 0, $sp - 2);
$value = substr($arg, $sp+1); $value = substr($arg, $sp+1);
} }
else if (in_array($key, $bool)) {
$value = true;
}
else if (strlen($_SERVER['argv'][$i+1]) && $_SERVER['argv'][$i+1][0] != '-') { else if (strlen($_SERVER['argv'][$i+1]) && $_SERVER['argv'][$i+1][0] != '-') {
$value = $_SERVER['argv'][++$i]; $value = $_SERVER['argv'][++$i];
} }

Loading…
Cancel
Save