Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
fix(#225): Regression; map usernames in BackendCombined
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Miguel Biete <fbiete@gmail.com>
<fmbiete@gmail.com>
  • Loading branch information
fmbiete committed Aug 21, 2015
1 parent ba30c3e commit 9b1fc35
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions z-push-admin.php
Expand Up @@ -106,6 +106,7 @@ class ZPushAdminCLI {
static private $device = false;
static private $type = false;
static private $backend = false;
static private $mappedUsername = false;
static private $errormessage;

/**
Expand All @@ -120,6 +121,7 @@ static public function UsageInstructions() {
"Parameters:\n\t-a list/wipe/remove/resync/clearloop/fixstates/map/unmap\n" .
"\t[-u] username\n" .
"\t[-d] deviceid\n" .
"\t[-m] mappedUsername\n" .
"\t[-b] backend\n\n" .
"Actions:\n" .
"\tlist\t\t\t\t Lists all devices and synchronized users\n" .
Expand All @@ -140,7 +142,7 @@ static public function UsageInstructions() {
"\tclearloop\t\t\t Clears system wide loop detection data\n" .
"\tclearloop -d DEVICE -u USER\t Clears all loop detection data of a device DEVICE and an optional user USER\n" .
"\tfixstates\t\t\t Checks the states for integrity and fixes potential issues\n" .
"\tmap -u USER -b BACKEND -t USER2\t Maps USER for BACKEND to username USER2 (when using 'combined' backend)\n" .
"\tmap -u USER -b BACKEND -m USER2\t Maps USER for BACKEND to username USER2 (when using 'combined' backend)\n" .
"\tunmap -u USER -b BACKEND\t Removes the mapping for USER and BACKEND (when using 'combined' backend)\n" .
"\n";
}
Expand Down Expand Up @@ -169,7 +171,7 @@ static public function CheckOptions() {
if (self::$errormessage)
return;

$options = getopt("u:d:a:t:b:");
$options = getopt("u:d:a:t:b:m:");

// get 'user'
if (isset($options['u']) && !empty($options['u']))
Expand Down Expand Up @@ -217,6 +219,12 @@ static public function CheckOptions() {
elseif (isset($options['backend']) && !empty($options['backend']))
self::$backend = strtolower(trim($options['backend']));

// get 'map'
if (isset($options['m']) && !empty($options['m']))
self::$mappedUsername = trim($options['m']);
elseif (isset($options['mappedUsername']) && !empty($options['mappedUsername']))
self::$mappedUsername = trim($options['mappedUsername']);

// get a command for the requested action
switch ($action) {
// list data
Expand Down Expand Up @@ -285,7 +293,7 @@ static public function CheckOptions() {

// map users for 'combined' backend
case "map":
if (self::$user === false || self::$backend === false || self::$type === false)
if (self::$user === false || self::$backend === false || self::$mappedUsername === false)
self::$errormessage = "Not possible to map. User, backend and target user must be specified.";
else
self::$command = self::COMMAND_MAP;
Expand Down Expand Up @@ -700,7 +708,7 @@ static private function CommandFixStates() {
* @access private
*/
static private function CommandMap() {
if (ZPushAdmin::AddUsernameMapping(self::$user, self::$backend, self::$type))
if (ZPushAdmin::AddUsernameMapping(self::$user, self::$backend, self::$mappedUsername))
printf("Successfully mapped username.\n");
else
echo ZLog::GetLastMessage(LOGLEVEL_ERROR) . "\n";
Expand Down

0 comments on commit 9b1fc35

Please sign in to comment.