Commit a8a83486 authored by Manfred Kutas's avatar Manfred Kutas

ZP-1192 List more details on shared folders with z-push-admin.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 44515e38
...@@ -93,6 +93,7 @@ class ZPushAdminCLI { ...@@ -93,6 +93,7 @@ class ZPushAdminCLI {
static private $type = false; static private $type = false;
static private $errormessage; static private $errormessage;
static private $daysold = false; static private $daysold = false;
static private $shared = false;
/** /**
* Returns usage instructions * Returns usage instructions
...@@ -104,6 +105,7 @@ class ZPushAdminCLI { ...@@ -104,6 +105,7 @@ class ZPushAdminCLI {
return "Usage:\n\tz-push-admin.php -a ACTION [options]\n\n" . return "Usage:\n\tz-push-admin.php -a ACTION [options]\n\n" .
"Parameters:\n\t-a list/lastsync/wipe/remove/resync/clearloop/fixstates\n\t[-u] username\n\t[-d] deviceid\n" . "Parameters:\n\t-a list/lastsync/wipe/remove/resync/clearloop/fixstates\n\t[-u] username\n\t[-d] deviceid\n" .
"\t[-t] type\tthe following types are available: '".self::TYPE_OPTION_EMAIL."', '".self::TYPE_OPTION_CALENDAR."', '".self::TYPE_OPTION_CONTACT."', '".self::TYPE_OPTION_TASK."', '".self::TYPE_OPTION_NOTE."', '".self::TYPE_OPTION_HIERARCHY."' of '".self::TYPE_OPTION_GAB."' (for KOE) or a folder id.\n" . "\t[-t] type\tthe following types are available: '".self::TYPE_OPTION_EMAIL."', '".self::TYPE_OPTION_CALENDAR."', '".self::TYPE_OPTION_CONTACT."', '".self::TYPE_OPTION_TASK."', '".self::TYPE_OPTION_NOTE."', '".self::TYPE_OPTION_HIERARCHY."' of '".self::TYPE_OPTION_GAB."' (for KOE) or a folder id.\n" .
"\t[--shared|-s] n\tshow detailed information about shared folders of a user in list.\n".
"\t[--days-old] n\tshow or remove profiles older than n days with lastsync or remove. n must be a positive integer.\n\n". "\t[--days-old] n\tshow or remove profiles older than n days with lastsync or remove. n must be a positive integer.\n\n".
"Actions:\n" . "Actions:\n" .
"\tlist\t\t\t\t\t Lists all devices and synchronized users\n" . "\tlist\t\t\t\t\t Lists all devices and synchronized users\n" .
...@@ -152,7 +154,7 @@ class ZPushAdminCLI { ...@@ -152,7 +154,7 @@ class ZPushAdminCLI {
if (self::$errormessage) if (self::$errormessage)
return; return;
$options = getopt("u:d:a:t:", array('user:', 'device:', 'action:', 'type:', 'days-old:', 'days-ago:')); $options = getopt("u:d:a:t:s", array('user:', 'device:', 'action:', 'type:', 'days-old:', 'days-ago:', 'shared'));
// get 'user' // get 'user'
if (isset($options['u']) && !empty($options['u'])) if (isset($options['u']) && !empty($options['u']))
...@@ -192,6 +194,10 @@ class ZPushAdminCLI { ...@@ -192,6 +194,10 @@ class ZPushAdminCLI {
self::$daysold = trim($options['days-old']); self::$daysold = trim($options['days-old']);
} }
if (isset($options['s']) || isset($options['shared'])) {
self::$shared = true;
}
// if type is set, it must be one of known types or a 44 or 48 byte long folder id // if type is set, it must be one of known types or a 44 or 48 byte long folder id
if (self::$type !== false) { if (self::$type !== false) {
if (self::$type !== self::TYPE_OPTION_EMAIL && if (self::$type !== self::TYPE_OPTION_EMAIL &&
...@@ -790,6 +796,13 @@ class ZPushAdminCLI { ...@@ -790,6 +796,13 @@ class ZPushAdminCLI {
return false; return false;
} }
echo "-----------------------------------------------------\n";
echo "DeviceId:\t\t$deviceId\n";
echo "Device type:\t\t". ($device->GetDeviceType() !== ASDevice::UNDEFINED ? $device->GetDeviceType() : "unknown") ."\n";
echo "UserAgent:\t\t".($device->GetDeviceUserAgent()!== ASDevice::UNDEFINED ? $device->GetDeviceUserAgent() : "unknown") ."\n";
// TODO implement $device->GetDeviceUserAgentHistory()
if (!self::$shared) {
// Gather some statistics about synchronized folders // Gather some statistics about synchronized folders
$folders = $device->GetAllFolderIds(); $folders = $device->GetAllFolderIds();
$synchedFolders = 0; $synchedFolders = 0;
...@@ -848,52 +861,6 @@ class ZPushAdminCLI { ...@@ -848,52 +861,6 @@ class ZPushAdminCLI {
} }
if (!$folderinfo) $folderinfo = "None available"; if (!$folderinfo) $folderinfo = "None available";
// additional folders
$addFolders = array();
$sharedFolders = $device->GetAdditionalFolders();
array_walk($sharedFolders, function (&$key) { $key["origin"] = 'Shared'; });
// $additionalFolders comes directly from the config
array_walk($additionalFolders, function (&$key) { $key["origin"] = 'Configured'; });
foreach(array_merge($additionalFolders,$sharedFolders) as $df) {
$df['additional'] = '';
$syncfolderid = $device->GetFolderIdForBackendId($df['folderid'], false, false, null);
switch($df['type']) {
case SYNC_FOLDER_TYPE_USER_APPOINTMENT:
if ($df['name'] == KOE_GAB_NAME) {
$gentype = "GAB";
}
else {
$gentype = "Calendar";
}
break;
case SYNC_FOLDER_TYPE_USER_CONTACT:
$gentype = "Contact";
break;
case SYNC_FOLDER_TYPE_USER_TASK:
$gentype = "Task";
break;
case SYNC_FOLDER_TYPE_USER_NOTE:
$gentype = "Note";
break;
default:
$gentype = "Email";
break;
}
if ($device->GetFolderType($syncfolderid) == SYNC_FOLDER_TYPE_UNKNOWN) {
$df['additional'] = "(KOE patching incomplete)";
}
$df['type'] = $gentype;
$df['synched'] = ($device->GetFolderUUID($syncfolderid)) ? 'Active' : 'Inactive (not yet synchronized or no permissions)';
$addFolders[] = $df;
}
$addFoldersTotal = !empty($addFolders) ? count($addFolders) : 'none';
echo "-----------------------------------------------------\n";
echo "DeviceId:\t\t$deviceId\n";
echo "Device type:\t\t". ($device->GetDeviceType() !== ASDevice::UNDEFINED ? $device->GetDeviceType() : "unknown") ."\n";
echo "UserAgent:\t\t".($device->GetDeviceUserAgent()!== ASDevice::UNDEFINED ? $device->GetDeviceUserAgent() : "unknown") ."\n";
// TODO implement $device->GetDeviceUserAgentHistory()
// device information transmitted during Settings command // device information transmitted during Settings command
if ($device->GetDeviceModel()) if ($device->GetDeviceModel())
echo "Device Model:\t\t". $device->GetDeviceModel(). "\n"; echo "Device Model:\t\t". $device->GetDeviceModel(). "\n";
...@@ -916,6 +883,7 @@ class ZPushAdminCLI { ...@@ -916,6 +883,7 @@ class ZPushAdminCLI {
echo "First sync:\t\t". strftime("%Y-%m-%d %H:%M", $device->GetFirstSyncTime()) ."\n"; echo "First sync:\t\t". strftime("%Y-%m-%d %H:%M", $device->GetFirstSyncTime()) ."\n";
echo "Last sync:\t\t". ($device->GetLastSyncTime() ? strftime("%Y-%m-%d %H:%M", $device->GetLastSyncTime()) : "never")."\n"; echo "Last sync:\t\t". ($device->GetLastSyncTime() ? strftime("%Y-%m-%d %H:%M", $device->GetLastSyncTime()) : "never")."\n";
$filterType = (defined('SYNC_FILTERTIME_MAX') && SYNC_FILTERTIME_MAX > SYNC_FILTERTYPE_ALL) ? SYNC_FILTERTIME_MAX : SYNC_FILTERTYPE_ALL; $filterType = (defined('SYNC_FILTERTIME_MAX') && SYNC_FILTERTIME_MAX > SYNC_FILTERTYPE_ALL) ? SYNC_FILTERTIME_MAX : SYNC_FILTERTYPE_ALL;
$maxDevice = $device->GetSyncFilterType(); $maxDevice = $device->GetSyncFilterType();
if ($maxDevice !== false && $maxDevice > SYNC_FILTERTYPE_ALL && ($filterType == SYNC_FILTERTYPE_ALL || $maxDevice < $filterType)) { if ($maxDevice !== false && $maxDevice > SYNC_FILTERTYPE_ALL && ($filterType == SYNC_FILTERTYPE_ALL || $maxDevice < $filterType)) {
...@@ -971,16 +939,79 @@ class ZPushAdminCLI { ...@@ -971,16 +939,79 @@ class ZPushAdminCLI {
} }
} }
} }
}
// additional folders
$addFolders = array();
$sharedFolders = $device->GetAdditionalFolders();
array_walk($sharedFolders, function (&$key) { $key["origin"] = 'Shared'; });
// $additionalFolders comes directly from the config
array_walk($additionalFolders, function (&$key) { $key["origin"] = 'Configured'; });
foreach(array_merge($additionalFolders,$sharedFolders) as $df) {
$df['additional'] = '';
$syncfolderid = $device->GetFolderIdForBackendId($df['folderid'], false, false, null);
switch($df['type']) {
case SYNC_FOLDER_TYPE_USER_APPOINTMENT:
if ($df['name'] == KOE_GAB_NAME) {
$gentype = "GAB";
}
else {
$gentype = "Calendar";
}
break;
case SYNC_FOLDER_TYPE_USER_CONTACT:
$gentype = "Contact";
break;
case SYNC_FOLDER_TYPE_USER_TASK:
$gentype = "Task";
break;
case SYNC_FOLDER_TYPE_USER_NOTE:
$gentype = "Note";
break;
default:
$gentype = "Email";
break;
}
if ($device->GetFolderType($syncfolderid) == SYNC_FOLDER_TYPE_UNKNOWN) {
$df['additional'] = "(KOE patching incomplete)";
}
$df['type'] = $gentype;
$df['synched'] = ($device->GetFolderUUID($syncfolderid)) ? 'Active' : 'Inactive (not yet synchronized or no permissions)';
$addFolders[] = $df;
}
$addFoldersTotal = !empty($addFolders) ? count($addFolders) : 'none';
echo "Additional Folders:\t$addFoldersTotal\n"; echo "Additional Folders:\t$addFoldersTotal\n";
if ($addFoldersTotal != 'none') {
if (!self::$shared) {
print("\tFolder name Store Type Origin Synched\n");
}
}
foreach ($addFolders as $folder) { foreach ($addFolders as $folder) {
// Configured folders are always under root
if (!isset($folder['parentid'])) $folder['parentid'] = '0';
if (!self::$shared) {
if (strlen($folder['store']) > 14) { if (strlen($folder['store']) > 14) {
$folder['store'] = substr($folder['store'], 0, 12) . ".."; $folder['store'] = substr($folder['store'], 0, 12) . "..";
} }
if (strlen($folder['name']) > 20) { if (strlen($folder['name']) > 30) {
$folder['name'] = substr($folder['name'], 0, 18) . ".."; $folder['name'] = substr($folder['name'], 0, 28) . "..";
}
printf("\t%s %s %s %s %s %s\n", str_pad($folder['name'], 30), str_pad($folder['store'], 14), str_pad($folder['type'], 8), str_pad($folder['origin'], 10), $folder['synched'], $folder['additional']);
}
else {
printf("\tFolder name:\t%s\n", $folder['name']);
printf("\tStore:\t\t%s\n", $folder['store']);
printf("\tType:\t\t%s\n", $folder['type']);
printf("\tOrigin:\t\t%s\n", $folder['origin']);
printf("\tFolder id:\t%s\n", $folder['folderid']);
printf("\tParent id:\t%s\n", $folder['parentid']);
printf("\tSynched:\t%s\n", $folder['synched']);
if (!empty($folder['additional'])) printf("\tAdditional:\t%s\n", $folder['additional']);
echo "\t------------------------\n";
} }
printf("\t%s %s %s %s %s %s\n", str_pad($folder['origin'], 10), str_pad($folder['type'], 8), str_pad($folder['store'], 14), str_pad($folder['name'], 20), $folder['synched'], $folder['additional']);
} }
if (!self::$shared) {
echo "Status:\t\t\t"; echo "Status:\t\t\t";
switch ($device->GetWipeStatus()) { switch ($device->GetWipeStatus()) {
case SYNC_PROVISION_RWSTATUS_OK: case SYNC_PROVISION_RWSTATUS_OK:
...@@ -999,11 +1030,11 @@ class ZPushAdminCLI { ...@@ -999,11 +1030,11 @@ class ZPushAdminCLI {
echo "Not available\n"; echo "Not available\n";
break; break;
} }
echo "WipeRequest on:\t\t". ($device->GetWipeRequestedOn() ? strftime("%Y-%m-%d %H:%M", $device->GetWipeRequestedOn()) : "not set")."\n"; echo "WipeRequest on:\t\t". ($device->GetWipeRequestedOn() ? strftime("%Y-%m-%d %H:%M", $device->GetWipeRequestedOn()) : "not set")."\n";
echo "WipeRequest by:\t\t". ($device->GetWipeRequestedBy() ? $device->GetWipeRequestedBy() : "not set")."\n"; echo "WipeRequest by:\t\t". ($device->GetWipeRequestedBy() ? $device->GetWipeRequestedBy() : "not set")."\n";
echo "Wiped on:\t\t". ($device->GetWipeActionOn() ? strftime("%Y-%m-%d %H:%M", $device->GetWipeActionOn()) : "not set")."\n"; echo "Wiped on:\t\t". ($device->GetWipeActionOn() ? strftime("%Y-%m-%d %H:%M", $device->GetWipeActionOn()) : "not set")."\n";
echo "Policy name:\t\t". ($device->GetPolicyName() ? $device->GetPolicyName() : ASDevice::DEFAULTPOLICYNAME)."\n"; echo "Policy name:\t\t". ($device->GetPolicyName() ? $device->GetPolicyName() : ASDevice::DEFAULTPOLICYNAME)."\n";
}
if ($device->GetKoeVersion()) { if ($device->GetKoeVersion()) {
echo "Kopano Outlook Extension:\n"; echo "Kopano Outlook Extension:\n";
...@@ -1026,7 +1057,7 @@ class ZPushAdminCLI { ...@@ -1026,7 +1057,7 @@ class ZPushAdminCLI {
if (!isset($device->ignoredmessages) || empty($device->ignoredmessages)) { if (!isset($device->ignoredmessages) || empty($device->ignoredmessages)) {
echo "No errors known\n"; echo "No errors known\n";
} }
else { elseif (!self::$shared) {
printf("%d messages need attention because they could not be synchronized\n", count($device->ignoredmessages)); printf("%d messages need attention because they could not be synchronized\n", count($device->ignoredmessages));
foreach ($device->ignoredmessages as $im) { foreach ($device->ignoredmessages as $im) {
$info = ""; $info = "";
...@@ -1048,6 +1079,9 @@ class ZPushAdminCLI { ...@@ -1048,6 +1079,9 @@ class ZPushAdminCLI {
echo "\n"; echo "\n";
} }
} }
else {
print("There are some messages which need attention because they could not be synchronized. Run z-push-admin without -s or --shared.\n");
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment