Commit 7b0d5004 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge branch 'develop' of https://stash.z-hub.io/scm/zp/z-push into...

Merge branch 'develop' of https://stash.z-hub.io/scm/zp/z-push into bugfix/ZP-805-update-class-constructors
parents 76595fff 19824533
...@@ -550,18 +550,21 @@ class ImportChangesICS implements IImportChanges { ...@@ -550,18 +550,21 @@ class ImportChangesICS implements IImportChanges {
// Get the entryid of the message we're moving // Get the entryid of the message we're moving
$entryid = mapi_msgstore_entryidfromsourcekey($this->store, $this->folderid, hex2bin($sk)); $entryid = mapi_msgstore_entryidfromsourcekey($this->store, $this->folderid, hex2bin($sk));
if(!$entryid) $srcmessage = false;
throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to resolve source message id", $sk, $newfolder), SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID);
if ($entryid) {
//open the source message //open the source message
$srcmessage = mapi_msgstore_openentry($this->store, $entryid); $srcmessage = mapi_msgstore_openentry($this->store, $entryid);
if (!$srcmessage) { }
if(!$entryid || !$srcmessage) {
$code = SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID; $code = SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID;
// if we move to the trash and the source message is not found, we can also just tell the mobile that we successfully moved to avoid errors (ZP-624) // if we move to the trash and the source message is not found, we can also just tell the mobile that we successfully moved to avoid errors (ZP-624)
if ($newfolder == ZPush::GetBackend()->GetWasteBasket()) { if ($newfolder == ZPush::GetBackend()->GetWasteBasket()) {
$code = SYNC_MOVEITEMSSTATUS_SUCCESS; $code = SYNC_MOVEITEMSSTATUS_SUCCESS;
} }
throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to open source message: 0x%X", $sk, $newfolder, mapi_last_hresult()), $code); $errorCase = !$entryid ? "resolve source message id" : "open source message";
throw new StatusException(sprintf("ImportChangesICS->ImportMessageMove('%s','%s'): Error, unable to %s: 0x%X", $sk, $newfolder, $errorCase, mapi_last_hresult()), $code);
} }
// check if the source message is in the current syncinterval // check if the source message is in the current syncinterval
......
...@@ -337,23 +337,34 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -337,23 +337,34 @@ class BackendKopano implements IBackend, ISearchProvider {
*/ */
public function GetHierarchy() { public function GetHierarchy() {
$folders = array(); $folders = array();
$importer = false;
$mapiprovider = new MAPIProvider($this->session, $this->store); $mapiprovider = new MAPIProvider($this->session, $this->store);
$rootfolder = mapi_msgstore_openentry($this->store); $rootfolder = mapi_msgstore_openentry($this->store);
$rootfolderprops = mapi_getprops($rootfolder, array(PR_SOURCE_KEY)); $rootfolderprops = mapi_getprops($rootfolder, array(PR_SOURCE_KEY));
$rootfoldersourcekey = bin2hex($rootfolderprops[PR_SOURCE_KEY]);
$hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH); $hierarchy = mapi_folder_gethierarchytable($rootfolder, CONVENIENT_DEPTH);
$rows = mapi_table_queryallrows($hierarchy, array(PR_ENTRYID)); $rows = mapi_table_queryallrows($hierarchy, array(PR_DISPLAY_NAME, PR_PARENT_ENTRYID, PR_ENTRYID, PR_SOURCE_KEY, PR_PARENT_SOURCE_KEY, PR_CONTAINER_CLASS, PR_ATTR_HIDDEN, PR_EXTENDED_FOLDER_FLAGS, PR_FOLDER_TYPE));
foreach ($rows as $row) { foreach ($rows as $row) {
$mapifolder = mapi_msgstore_openentry($this->store, $row[PR_ENTRYID]); // do not display hidden and search folders
$folder = $mapiprovider->GetFolder($mapifolder); if ((isset($row[PR_ATTR_HIDDEN]) && $row[PR_ATTR_HIDDEN]) ||
(isset($row[PR_FOLDER_TYPE]) && $row[PR_FOLDER_TYPE] == FOLDER_SEARCH) ||
if (isset($folder->parentid) && $folder->parentid != $rootfoldersourcekey) (isset($row[PR_PARENT_SOURCE_KEY]) && $row[PR_PARENT_SOURCE_KEY] == $rootfolderprops[PR_SOURCE_KEY]) ) {
continue;
}
$folder = $mapiprovider->GetFolder($row);
if ($folder) {
$folders[] = $folder; $folders[] = $folder;
} }
}
// reloop the folders to make sure all parentids are mapped correctly
$dm = ZPush::GetDeviceManager();
foreach ($folders as $folder) {
if ($folder->parentid !== "0") {
$folder->parentid = $dm->GetFolderIdForBackendId($folder->parentid);
}
}
return $folders; return $folders;
} }
......
...@@ -155,7 +155,7 @@ class PHPWrapper { ...@@ -155,7 +155,7 @@ class PHPWrapper {
else $message->flags = $flags; else $message->flags = $flags;
$this->importer->ImportMessageChange($this->prefix.bin2hex($sourcekey), $message); $this->importer->ImportMessageChange($this->prefix.bin2hex($sourcekey), $message);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageChange(): change for :'%s'", $this->prefix.bin2hex($sourcekey))); ZLog::Write(LOGLEVEL_DEBUG, sprintf("PHPWrapper->ImportMessageChange(): change for: '%s'", $this->prefix.bin2hex($sourcekey)));
// Tell MAPI it doesn't need to do anything itself, as we've done all the work already. // Tell MAPI it doesn't need to do anything itself, as we've done all the work already.
return SYNC_E_IGNORE; return SYNC_E_IGNORE;
......
...@@ -313,6 +313,8 @@ ...@@ -313,6 +313,8 @@
define('KOE_CAPABILITY_OOFTIMES', true); define('KOE_CAPABILITY_OOFTIMES', true);
// Notes support // Notes support
define('KOE_CAPABILITY_NOTES', true); define('KOE_CAPABILITY_NOTES', true);
// Shared folder support
define('KOE_CAPABILITY_SHAREDFOLDER', true);
// To synchronize the GAB KOE, the GAB store and folderid need to be specified. // To synchronize the GAB KOE, the GAB store and folderid need to be specified.
// Use the gab-sync script to generate this data. The name needs to // Use the gab-sync script to generate this data. The name needs to
......
...@@ -108,6 +108,10 @@ include_once(ZPUSH_CONFIG); ...@@ -108,6 +108,10 @@ include_once(ZPUSH_CONFIG);
// Do the actual request // Do the actual request
header(ZPush::GetServerHeader()); header(ZPush::GetServerHeader());
if (RequestProcessor::isUserAuthenticated()) {
header("X-Z-Push-Version: ". @constant('ZPUSH_VERSION'));
}
// announce the supported AS versions (if not already sent to device) // announce the supported AS versions (if not already sent to device)
if (ZPush::GetDeviceManager()->AnnounceASVersion()) { if (ZPush::GetDeviceManager()->AnnounceASVersion()) {
$versions = ZPush::GetSupportedProtocolVersions(true); $versions = ZPush::GetSupportedProtocolVersions(true);
...@@ -232,7 +236,7 @@ include_once(ZPUSH_CONFIG); ...@@ -232,7 +236,7 @@ include_once(ZPUSH_CONFIG);
ZLog::Write(LOGLEVEL_INFO, ZLog::Write(LOGLEVEL_INFO,
sprintf("cmd='%s' memory='%s/%s' time='%ss' devType='%s' devId='%s' getUser='%s' from='%s' version='%s' method='%s' httpcode='%s'", sprintf("cmd='%s' memory='%s/%s' time='%ss' devType='%s' devId='%s' getUser='%s' from='%s' version='%s' method='%s' httpcode='%s'",
Request::GetCommand(), Utils::FormatBytes(memory_get_peak_usage(false)), Utils::FormatBytes(memory_get_peak_usage(true)), Request::GetCommand(), Utils::FormatBytes(memory_get_peak_usage(false)), Utils::FormatBytes(memory_get_peak_usage(true)),
number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2, ',', '.'), number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2),
Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod(), http_response_code() )); Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod(), http_response_code() ));
ZLog::Write(LOGLEVEL_DEBUG, "-------- End"); ZLog::Write(LOGLEVEL_DEBUG, "-------- End");
......
...@@ -710,7 +710,7 @@ class ASDevice extends StateObject { ...@@ -710,7 +710,7 @@ class ASDevice extends StateObject {
$this->backend2folderidCache[$backendid] = $newHash; $this->backend2folderidCache[$backendid] = $newHash;
return $newHash; return $newHash;
} }
ZLog::Write(LOGLEVEL_WARN, sprintf("ASDevice->GetFolderIdForBackendId(): no valid condition found for determining folderid for backendid '%s'. Returning as is!", Utils::PrintAsString($backendid))); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ASDevice->GetFolderIdForBackendId(): no valid condition found for determining folderid for backendid '%s'. Returning as is!", Utils::PrintAsString($backendid)));
return $backendid; return $backendid;
} }
......
...@@ -53,6 +53,7 @@ class Streamer implements Serializable { ...@@ -53,6 +53,7 @@ class Streamer implements Serializable {
const STREAMER_TYPE = 3; const STREAMER_TYPE = 3;
const STREAMER_PROP = 4; const STREAMER_PROP = 4;
const STREAMER_RONOTIFY = 5; const STREAMER_RONOTIFY = 5;
const STREAMER_VALUEMAP = 20;
const STREAMER_TYPE_DATE = 1; const STREAMER_TYPE_DATE = 1;
const STREAMER_TYPE_HEX = 2; const STREAMER_TYPE_HEX = 2;
const STREAMER_TYPE_DATE_DASHES = 3; const STREAMER_TYPE_DATE_DASHES = 3;
......
...@@ -176,8 +176,13 @@ if (!defined('E_DEPRECATED')) define(E_DEPRECATED, 8192); ...@@ -176,8 +176,13 @@ if (!defined('E_DEPRECATED')) define(E_DEPRECATED, 8192);
// TODO review error handler // TODO review error handler
function zpush_error_handler($errno, $errstr, $errfile, $errline, $errcontext) { function zpush_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
$bt = debug_backtrace(); if (defined('LOG_ERROR_MASK')) $errno &= LOG_ERROR_MASK;
switch ($errno) { switch ($errno) {
case 0:
// logging disabled by LOG_ERROR_MASK
break;
case E_DEPRECATED: case E_DEPRECATED:
// do not handle this message // do not handle this message
break; break;
...@@ -191,6 +196,7 @@ function zpush_error_handler($errno, $errstr, $errfile, $errline, $errcontext) { ...@@ -191,6 +196,7 @@ function zpush_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
break; break;
default: default:
$bt = debug_backtrace();
ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ". (count($bt)-1) . " steps"); ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ". (count($bt)-1) . " steps");
for($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) { for($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) {
$file = $line = "unknown"; $file = $line = "unknown";
......
...@@ -97,6 +97,7 @@ class ZPush { ...@@ -97,6 +97,7 @@ class ZPush {
// Webservice commands // Webservice commands
const COMMAND_WEBSERVICE_DEVICE = -100; const COMMAND_WEBSERVICE_DEVICE = -100;
const COMMAND_WEBSERVICE_USERS = -101; const COMMAND_WEBSERVICE_USERS = -101;
const COMMAND_WEBSERVICE_INFO = -102;
// Latest supported State version // Latest supported State version
const STATE_VERSION = IStateMachine::STATEVERSION_02; const STATE_VERSION = IStateMachine::STATEVERSION_02;
...@@ -145,6 +146,7 @@ class ZPush { ...@@ -145,6 +146,7 @@ class ZPush {
self::COMMAND_WEBSERVICE_DEVICE => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND), self::COMMAND_WEBSERVICE_DEVICE => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND),
self::COMMAND_WEBSERVICE_USERS => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND), self::COMMAND_WEBSERVICE_USERS => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND),
self::COMMAND_WEBSERVICE_INFO => array(self::REQUESTHANDLER => "Webservice", self::PLAININPUT, self::NOACTIVESYNCCOMMAND, self::WEBSERVICECOMMAND),
); );
...@@ -366,6 +368,9 @@ class ZPush { ...@@ -366,6 +368,9 @@ class ZPush {
if (!defined('KOE_CAPABILITY_NOTES')) { if (!defined('KOE_CAPABILITY_NOTES')) {
define('KOE_CAPABILITY_NOTES', false); define('KOE_CAPABILITY_NOTES', false);
} }
if (!defined('KOE_CAPABILITY_SHAREDFOLDER')) {
define('KOE_CAPABILITY_SHAREDFOLDER', false);
}
if (!defined('KOE_GAB_FOLDERID')) { if (!defined('KOE_GAB_FOLDERID')) {
define('KOE_GAB_FOLDERID', ''); define('KOE_GAB_FOLDERID', '');
} }
...@@ -577,6 +582,8 @@ class ZPush { ...@@ -577,6 +582,8 @@ class ZPush {
static public function GetBackend() { static public function GetBackend() {
// if the backend is not yet loaded, load backend drivers and instantiate it // if the backend is not yet loaded, load backend drivers and instantiate it
if (!isset(ZPush::$backend)) { if (!isset(ZPush::$backend)) {
$isIbar = false;
// Initialize our backend // Initialize our backend
$ourBackend = @constant('BACKEND_PROVIDER'); $ourBackend = @constant('BACKEND_PROVIDER');
...@@ -594,12 +601,19 @@ class ZPush { ...@@ -594,12 +601,19 @@ class ZPush {
} }
elseif (!class_exists($ourBackend)) { elseif (!class_exists($ourBackend)) {
spl_autoload_register('\ZPush::IncludeBackend'); spl_autoload_register('\ZPush::IncludeBackend');
$isIbar = true;
ZLog::Write(LOGLEVEL_DEBUG, "ZPush::GetBackend(): autoload register ZPush::IncludeBackend");
} }
if (class_exists($ourBackend)) if (class_exists($ourBackend))
ZPush::$backend = new $ourBackend(); ZPush::$backend = new $ourBackend();
else else
throw new FatalMisconfigurationException(sprintf("Backend provider '%s' can not be loaded. Check configuration!", $ourBackend)); throw new FatalMisconfigurationException(sprintf("Backend provider '%s' can not be loaded. Check configuration!", $ourBackend));
if ($isIbar) {
spl_autoload_unregister('\ZPush::IncludeBackend');
ZLog::Write(LOGLEVEL_DEBUG, "ZPush::GetBackend(): autoload unregister ZPush::IncludeBackend");
}
} }
return ZPush::$backend; return ZPush::$backend;
} }
......
...@@ -189,10 +189,17 @@ class DiffState implements IChanges { ...@@ -189,10 +189,17 @@ class DiffState implements IChanges {
$changes[] = $change; $changes[] = $change;
} }
// @see https://jira.z-hub.io/browse/ZP-955
if (isset($old_item['mod']) && isset($item['mod'])) {
if ($old_item['mod'] != $item['mod']) { if ($old_item['mod'] != $item['mod']) {
$change["type"] = "change"; $change["type"] = "change";
$changes[] = $change; $changes[] = $change;
} }
}
else if (isset($old_item['mod']) || isset($item['mod'])) {
$change["type"] = "change";
$changes[] = $change;
}
// unset in $old, so $old contains only the deleted items // unset in $old, so $old contains only the deleted items
unset($old[$id]); unset($old[$id]);
......
...@@ -63,8 +63,9 @@ class Settings extends RequestProcessor { ...@@ -63,8 +63,9 @@ class Settings extends RequestProcessor {
if(KOE_CAPABILITY_RECEIVEFLAGS) $cap[] = "receiveflags"; if(KOE_CAPABILITY_RECEIVEFLAGS) $cap[] = "receiveflags";
if(KOE_CAPABILITY_SENDFLAGS) $cap[] = "sendflags"; if(KOE_CAPABILITY_SENDFLAGS) $cap[] = "sendflags";
if(KOE_CAPABILITY_OOFTIMES) $cap[] = "ooftime"; if(KOE_CAPABILITY_OOFTIMES) $cap[] = "ooftime";
else if(KOE_CAPABILITY_OOF) $cap[] = "oof"; // 'ooftime' superseeds 'oof'. If 'ooftime' is set, 'oof' should not be defined. elseif(KOE_CAPABILITY_OOF) $cap[] = "oof"; // 'ooftime' superseeds 'oof'. If 'ooftime' is set, 'oof' should not be defined.
if(KOE_CAPABILITY_NOTES) $cap[] = "notes"; if(KOE_CAPABILITY_NOTES) $cap[] = "notes";
if(KOE_CAPABILITY_SHAREDFOLDER) $cap[] = "sharedfolder";
self::$specialHeaders = array(); self::$specialHeaders = array();
self::$specialHeaders[] = "X-Push-Capabilities: ". implode(",",$cap); self::$specialHeaders[] = "X-Push-Capabilities: ". implode(",",$cap);
......
...@@ -123,7 +123,11 @@ class SyncAppointment extends SyncObject { ...@@ -123,7 +123,11 @@ class SyncAppointment extends SyncObject {
// 3 = Confident // 3 = Confident
SYNC_POOMCAL_SENSITIVITY => array ( self::STREAMER_VAR => "sensitivity", SYNC_POOMCAL_SENSITIVITY => array ( self::STREAMER_VAR => "sensitivity",
self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) ), self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) ),
self::STREAMER_RONOTIFY => true), self::STREAMER_RONOTIFY => true,
self::STREAMER_VALUEMAP => array( 0 => "Normal",
1 => "Personal",
2 => "Private",
3 => "Confident")),
// Busystatus values // Busystatus values
// 0 = Free // 0 = Free
...@@ -134,11 +138,18 @@ class SyncAppointment extends SyncObject { ...@@ -134,11 +138,18 @@ class SyncAppointment extends SyncObject {
SYNC_POOMCAL_BUSYSTATUS => array ( self::STREAMER_VAR => "busystatus", SYNC_POOMCAL_BUSYSTATUS => array ( self::STREAMER_VAR => "busystatus",
self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO,
self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,4) ), self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,4) ),
self::STREAMER_RONOTIFY => true), self::STREAMER_RONOTIFY => true,
self::STREAMER_VALUEMAP => array( 0 => "Free",
1 => "Tentative",
2 => "Busy",
3 => "Out of office",
4 => "Working Elsewhere")),
SYNC_POOMCAL_ALLDAYEVENT => array ( self::STREAMER_VAR => "alldayevent", SYNC_POOMCAL_ALLDAYEVENT => array ( self::STREAMER_VAR => "alldayevent",
self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO), self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO),
self::STREAMER_RONOTIFY => true), self::STREAMER_RONOTIFY => true,
self::STREAMER_VALUEMAP => array( 0 => "No",
1 => "Yes")),
SYNC_POOMCAL_REMINDER => array ( self::STREAMER_VAR => "reminder", SYNC_POOMCAL_REMINDER => array ( self::STREAMER_VAR => "reminder",
self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1), self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1),
...@@ -158,7 +169,16 @@ class SyncAppointment extends SyncObject { ...@@ -158,7 +169,16 @@ class SyncAppointment extends SyncObject {
// 15 = as 7 // 15 = as 7
SYNC_POOMCAL_MEETINGSTATUS => array ( self::STREAMER_VAR => "meetingstatus", SYNC_POOMCAL_MEETINGSTATUS => array ( self::STREAMER_VAR => "meetingstatus",
self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,3,5,7,9,11,13,15) ), self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,3,5,7,9,11,13,15) ),
self::STREAMER_RONOTIFY => true), self::STREAMER_RONOTIFY => true,
self::STREAMER_VALUEMAP => array( 0 => "Not a meeting",
1 => "Meeting",
3 => "Meeting received",
5 => "Meeting canceled",
7 => "Meeting canceled and received",
9 => "Meeting",
11 => "Meeting received",
13 => "Meeting canceled",
15 => "Meeting canceled and received",)),
SYNC_POOMCAL_ATTENDEES => array ( self::STREAMER_VAR => "attendees", SYNC_POOMCAL_ATTENDEES => array ( self::STREAMER_VAR => "attendees",
self::STREAMER_TYPE => "SyncAttendee", self::STREAMER_TYPE => "SyncAttendee",
......
...@@ -126,7 +126,9 @@ class SyncMail extends SyncObject { ...@@ -126,7 +126,9 @@ class SyncMail extends SyncObject {
SYNC_POOMMAIL_READ => array ( self::STREAMER_VAR => "read", SYNC_POOMMAIL_READ => array ( self::STREAMER_VAR => "read",
self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) ), self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) ),
self::STREAMER_RONOTIFY => true), self::STREAMER_RONOTIFY => true,
self::STREAMER_VALUEMAP => array( 0 => "No",
1 => "Yes")),
SYNC_POOMMAIL_ATTACHMENTS => array ( self::STREAMER_VAR => "attachments", SYNC_POOMMAIL_ATTACHMENTS => array ( self::STREAMER_VAR => "attachments",
self::STREAMER_TYPE => "SyncAttachment", self::STREAMER_TYPE => "SyncAttachment",
......
...@@ -246,18 +246,20 @@ abstract class SyncObject extends Streamer { ...@@ -246,18 +246,20 @@ abstract class SyncObject extends Streamer {
$out[$keyprefix.$val] = Utils::GetFormattedTime($this->$val); $out[$keyprefix.$val] = Utils::GetFormattedTime($this->$val);
} }
else { else {
$out[$keyprefix.$val] = (isset($this->$val) && strlen($this->$val) ? $out[$keyprefix.$val] = (strlen($this->$val) ?
Utils::GetFormattedTime($this->$val):"undefined") ." - ". $odoName .": ". Utils::GetFormattedTime($this->$val):"undefined") ." - ". $odoName .": ".
(isset($odo->$val) && strlen($odo->$val) ? Utils::GetFormattedTime($odo->$val) : "undefined"); (strlen($odo->$val) ? Utils::GetFormattedTime($odo->$val) : "undefined");
} }
} }
// else just compare their values // else just compare their values and print human friendly if necessary
else { else {
if($this->$val == $odo->$val) { if($this->$val == $odo->$val) {
$out[$keyprefix.$val] = $this->$val; $out[$keyprefix.$val] = $this->GetNameFromPropertyValue($v, $this->$val);
} }
else { else {
$out[$keyprefix.$val] = (isset($this->$val) && $this->$val ? $this->$val:"undefined") ." - ". $odoName .": ". (isset($odo->$val) && $odo->$val ? $odo->$val:"undefined"); $out[$keyprefix.$val] = (strlen($this->$val) ? $this->GetNameFromPropertyValue($v, $this->$val) : "undefined") .
" - ". $odoName .": ".
(strlen($odo->$val) ? $odo->GetNameFromPropertyValue($v, $odo->$val) : "undefined");
} }
} }
} }
...@@ -272,7 +274,7 @@ abstract class SyncObject extends Streamer { ...@@ -272,7 +274,7 @@ abstract class SyncObject extends Streamer {
else { else {
if($this->$val == $odo->$val) { if($this->$val == $odo->$val) {
if (! ($this instanceof SyncRecurrence)) { if (! ($this instanceof SyncRecurrence)) {
$out[$keyprefix.$val] = $this->$val; $out[$keyprefix.$val] = ($this->GetNameFromPropertyValue($v, $this->$val));
} }
} }
else { else {
...@@ -280,7 +282,9 @@ abstract class SyncObject extends Streamer { ...@@ -280,7 +282,9 @@ abstract class SyncObject extends Streamer {
$out["Recurrence"] = "Recurrence changed"; $out["Recurrence"] = "Recurrence changed";
} }
else { else {
$out[$keyprefix.$val] = (strlen($this->$val) ? $this->$val:"undefined") ." - ". $odoName .": ". (strlen($odo->$val) ? $odo->$val:"undefined"); $out[$keyprefix.$val] = (strlen($this->$val) ? $this->GetNameFromPropertyValue($v, $this->$val) : "undefined") .
" - ". $odoName .": ".
(strlen($odo->$val) ? ($odo->GetNameFromPropertyValue($v, $odo->$val)) : "undefined");
} }
} }
} }
...@@ -291,7 +295,8 @@ abstract class SyncObject extends Streamer { ...@@ -291,7 +295,8 @@ abstract class SyncObject extends Streamer {
// Otherwise it's a ghosted property and the device didn't send it, so we don't have to care about that case. // Otherwise it's a ghosted property and the device didn't send it, so we don't have to care about that case.
if (in_array($k, $supportedFields)) { if (in_array($k, $supportedFields)) {
if ((is_scalar($this->$val) && strlen($this->$val)) || (!is_scalar($this->$val) && !empty($this->$val))) { if ((is_scalar($this->$val) && strlen($this->$val)) || (!is_scalar($this->$val) && !empty($this->$val))) {
$out[$keyprefix.$val] = (is_array($this->$val) ? implode(",", $this->$val) : $this->$val) . " - " . $odoName .": value completely removed"; $out[$keyprefix.$val] = (is_array($this->$val) ? implode(",", $this->$val) : $this->GetNameFromPropertyValue($v, $this->$val)) .
" - " . $odoName .": value completely removed";
} }
} }
// there is no data sent for SyncMail, so just output its values // there is no data sent for SyncMail, so just output its values
...@@ -300,7 +305,7 @@ abstract class SyncObject extends Streamer { ...@@ -300,7 +305,7 @@ abstract class SyncObject extends Streamer {
$out[$keyprefix.$val] = Utils::GetFormattedTime($this->$val); $out[$keyprefix.$val] = Utils::GetFormattedTime($this->$val);
} }
else { else {
$out[$keyprefix.$val] = $this->$val; $out[$keyprefix.$val] = $this->GetNameFromPropertyValue($v, $this->$val);
} }
} }
} }
...@@ -314,7 +319,7 @@ abstract class SyncObject extends Streamer { ...@@ -314,7 +319,7 @@ abstract class SyncObject extends Streamer {
$out[$keyprefix.$val] = "Not set - " . $odoName . ": an exception was added"; $out[$keyprefix.$val] = "Not set - " . $odoName . ": an exception was added";
} }
else { else {
$out[$keyprefix.$val] = "Not set - " . $odoName . ": " . $odo->$val . " (value added)"; $out[$keyprefix.$val] = "Not set - " . $odoName . ": " . $odo->GetNameFromPropertyValue($v, $odo->$val) . " (value added)";
} }
} }
else if (isset($v[self::STREAMER_ARRAY])) { else if (isset($v[self::STREAMER_ARRAY])) {
...@@ -322,7 +327,7 @@ abstract class SyncObject extends Streamer { ...@@ -322,7 +327,7 @@ abstract class SyncObject extends Streamer {
$out[$keyprefix.$val] = "Not set - ". $odoName .": ". implode(", ", $odo->$val) . " (value added)"; $out[$keyprefix.$val] = "Not set - ". $odoName .": ". implode(", ", $odo->$val) . " (value added)";
} }
else { else {
$out[$keyprefix.$val] = "Not set - " . $odoName . ": " . $odo->$val . " (value added)"; $out[$keyprefix.$val] = "Not set - " . $odoName . ": " . $odo->GetNameFromPropertyValue($v, $odo->$val) . " (value added)";
} }
} }
} }
...@@ -376,6 +381,19 @@ abstract class SyncObject extends Streamer { ...@@ -376,6 +381,19 @@ abstract class SyncObject extends Streamer {
return $this->unsetVars; return $this->unsetVars;
} }
/**
* Removes not necessary data from the object
*
* @access public
* @return boolean
*/
public function StripData() {
if (isset($this->unsetVars)) {
unset($this->unsetVars);
}
return parent::StripData();
}
/** /**
* Method checks if the object has the minimum of required parameters * Method checks if the object has the minimum of required parameters
* and fullfills semantic dependencies * and fullfills semantic dependencies
...@@ -587,4 +605,20 @@ abstract class SyncObject extends Streamer { ...@@ -587,4 +605,20 @@ abstract class SyncObject extends Streamer {
return true; return true;
} }
/**
* Returns human friendly property name from its value if a mapping is available.
*
* @param array $v
* @param mixed $val
*
* @access public
* @return mixed
*/
public function GetNameFromPropertyValue($v, $val) {
if (isset($v[self::STREAMER_VALUEMAP][$val])) {
return $v[self::STREAMER_VALUEMAP][$val];
}
return $val;
}
} }
...@@ -209,13 +209,14 @@ class Utils { ...@@ -209,13 +209,14 @@ class Utils {
ZLog::Write(LOGLEVEL_DEBUG, "FILEAS_ORDER not defined. Add it to your config.php."); ZLog::Write(LOGLEVEL_DEBUG, "FILEAS_ORDER not defined. Add it to your config.php.");
return null; return null;
} }
/** /**
* Checks if the PHP-MAPI extension is available and in a requested version * Checks if the PHP-MAPI extension is available and in a requested version.
* *
* @param string $version the version to be checked ("6.30.10-18495", parts or build number) * @param string $version the version to be checked ("6.30.10-18495", parts or build number)
* *
* @access public * @access public
* @return boolean installed version is superior to the checked strin * @return boolean installed version is superior to the checked string
*/ */
static public function CheckMapiExtVersion($version = "") { static public function CheckMapiExtVersion($version = "") {
// compare build number if requested // compare build number if requested
...@@ -236,8 +237,7 @@ class Utils { ...@@ -236,8 +237,7 @@ class Utils {
} }
/** /**
* Parses and returns an ecoded vCal-Uid from an * Parses and returns an ecoded vCal-Uid from an OL compatible GlobalObjectID.
* OL compatible GlobalObjectID
* *
* @param string $olUid an OL compatible GlobalObjectID * @param string $olUid an OL compatible GlobalObjectID
* *
...@@ -660,6 +660,7 @@ class Utils { ...@@ -660,6 +660,7 @@ class Utils {
// Webservice commands // Webservice commands
case ZPush::COMMAND_WEBSERVICE_DEVICE: return 'WebserviceDevice'; case ZPush::COMMAND_WEBSERVICE_DEVICE: return 'WebserviceDevice';
case ZPush::COMMAND_WEBSERVICE_USERS: return 'WebserviceUsers'; case ZPush::COMMAND_WEBSERVICE_USERS: return 'WebserviceUsers';
case ZPush::COMMAND_WEBSERVICE_INFO: return 'WebserviceInfo';
} }
return false; return false;
} }
...@@ -704,6 +705,7 @@ class Utils { ...@@ -704,6 +705,7 @@ class Utils {
// Webservice commands // Webservice commands
case 'WebserviceDevice': return ZPush::COMMAND_WEBSERVICE_DEVICE; case 'WebserviceDevice': return ZPush::COMMAND_WEBSERVICE_DEVICE;
case 'WebserviceUsers': return ZPush::COMMAND_WEBSERVICE_USERS; case 'WebserviceUsers': return ZPush::COMMAND_WEBSERVICE_USERS;
case 'WebserviceInfo': return ZPush::COMMAND_WEBSERVICE_INFO;
} }
return false; return false;
} }
......
...@@ -108,7 +108,13 @@ class ZPushAdmin { ...@@ -108,7 +108,13 @@ class ZPushAdmin {
// load all collections of device also loading states and loading hierarchy, but not checking permissions // load all collections of device also loading states and loading hierarchy, but not checking permissions
$sc->LoadAllCollections(true, true, false, true); $sc->LoadAllCollections(true, true, false, true);
}
catch (StateInvalidException $sive) {
ZLog::Write(LOGLEVEL_WARN, sprintf("ZPushAdmin::GetDeviceDetails(): device '%s' of user '%s' has invalid states. Please sync to solve this issue.", $devid, $user));
$device->SetDeviceError("Invalid states. Please force synchronization!");
}
if ($sc) {
if ($sc->GetLastSyncTime()) if ($sc->GetLastSyncTime())
$device->SetLastSyncTime($sc->GetLastSyncTime()); $device->SetLastSyncTime($sc->GetLastSyncTime());
...@@ -131,11 +137,6 @@ class ZPushAdmin { ...@@ -131,11 +137,6 @@ class ZPushAdmin {
} }
} }
} }
catch (StateInvalidException $sive) {
ZLog::Write(LOGLEVEL_WARN, sprintf("ZPushAdmin::GetDeviceDetails(): device '%s' of user '%s' has invalid states. Please sync to solve this issue.", $devid, $user));
$device->SetDeviceError("Invalid states. Please force synchronization!");
}
return $device; return $device;
} }
catch (StateNotFoundException $e) { catch (StateNotFoundException $e) {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* Created : 29.12.2011 * Created : 29.12.2011
* *
* Copyright 2007 - 2013 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -69,9 +69,13 @@ class Webservice { ...@@ -69,9 +69,13 @@ class Webservice {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceDevice service", $commandCode));
$this->server->setClass("WebserviceDevice"); $this->server->setClass("WebserviceDevice");
} }
// the webservice command is handled by its class // the webservice command is handled by its class
if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) { else if ($commandCode == ZPush::COMMAND_WEBSERVICE_INFO) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Webservice::HandleWebservice('%s'): executing WebserviceInfo service", $commandCode));
$this->server->setClass("WebserviceInfo");
}
// the webservice command is handled by its class
else if ($commandCode == ZPush::COMMAND_WEBSERVICE_USERS) {
if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true) if (!defined("ALLOW_WEBSERVICE_USERS_ACCESS") || ALLOW_WEBSERVICE_USERS_ACCESS !== true)
throw new HTTPReturnCodeException("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS", 403); throw new HTTPReturnCodeException("Access to the WebserviceUsers service is disabled in configuration. Enable setting ALLOW_WEBSERVICE_USERS_ACCESS", 403);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* Created : 23.12.2011 * Created : 23.12.2011
* *
* Copyright 2007 - 2015 Zarafa Deutschland GmbH * Copyright 2007 - 2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -42,7 +42,6 @@ ...@@ -42,7 +42,6 @@
* *
* Consult LICENSE file for details * Consult LICENSE file for details
************************************************/ ************************************************/
include ('lib/utils/zpushadmin.php');
class WebserviceDevice { class WebserviceDevice {
......
<?php
/***********************************************
* File : webserviceinfo.php
* Project : Z-Push
* Descr : Provides general information for an authenticated
* user.
*
* Created : 17.06.2016
*
* Copyright 2016 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation with the following additional
* term according to sec. 7:
*
* According to sec. 7 of the GNU Affero General Public License, version 3,
* the terms of the AGPL are supplemented with the following terms:
*
* "Zarafa" is a registered trademark of Zarafa B.V.
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
* The licensing of the Program under the AGPL does not imply a trademark license.
* Therefore any rights, title and interest in our trademarks remain entirely with us.
*
* However, if you propagate an unmodified version of the Program you are
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
* Furthermore you may use our trademarks where it is necessary to indicate
* the intended purpose of a product or service provided you use it in accordance
* with honest practices in industrial or commercial matters.
* If you want to propagate modified versions of the Program under the name "Z-Push",
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
class WebserviceInfo {
/**
* Returns a list of folders of the Request::GetGETUser().
* If the user has not enough permissions an empty result is returned.
*
* @access public
* @return array
*/
public function ListUserFolders() {
$user = Request::GetGETUser();
$output = array();
$hasRights = ZPush::GetBackend()->Setup($user);
ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceInfo::ListUserFolders(): permissions to open store '%s': %s", $user, Utils::PrintAsString($hasRights)));
$folders = ZPush::GetBackend()->GetHierarchy();
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d folders", count($folders)), true);
foreach ($folders as $folder) {
$folder->StripData();
unset($folder->Store, $folder->flags, $folder->content, $folder->NoBackendFolder, $folder->ReadOnly);
$output[] = $folder;
}
return $output;
}
}
...@@ -176,6 +176,7 @@ return array( ...@@ -176,6 +176,7 @@ return array(
'WBXMLException' => $baseDir . '/lib/exceptions/wbxmlexception.php', 'WBXMLException' => $baseDir . '/lib/exceptions/wbxmlexception.php',
'Webservice' => $baseDir . '/lib/webservice/webservice.php', 'Webservice' => $baseDir . '/lib/webservice/webservice.php',
'WebserviceDevice' => $baseDir . '/lib/webservice/webservicedevice.php', 'WebserviceDevice' => $baseDir . '/lib/webservice/webservicedevice.php',
'WebserviceInfo' => $baseDir . '/lib/webservice/webserviceinfo.php',
'WebserviceUsers' => $baseDir . '/lib/webservice/webserviceusers.php', 'WebserviceUsers' => $baseDir . '/lib/webservice/webserviceusers.php',
'ZLog' => $baseDir . '/lib/core/zlog.php', 'ZLog' => $baseDir . '/lib/core/zlog.php',
'ZPush' => $baseDir . '/lib/core/zpush.php', 'ZPush' => $baseDir . '/lib/core/zpush.php',
......
...@@ -183,6 +183,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -183,6 +183,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f
'WBXMLException' => __DIR__ . '/../..' . '/lib/exceptions/wbxmlexception.php', 'WBXMLException' => __DIR__ . '/../..' . '/lib/exceptions/wbxmlexception.php',
'Webservice' => __DIR__ . '/../..' . '/lib/webservice/webservice.php', 'Webservice' => __DIR__ . '/../..' . '/lib/webservice/webservice.php',
'WebserviceDevice' => __DIR__ . '/../..' . '/lib/webservice/webservicedevice.php', 'WebserviceDevice' => __DIR__ . '/../..' . '/lib/webservice/webservicedevice.php',
'WebserviceInfo' => __DIR__ . '/../..' . '/lib/webservice/webserviceinfo.php',
'WebserviceUsers' => __DIR__ . '/../..' . '/lib/webservice/webserviceusers.php', 'WebserviceUsers' => __DIR__ . '/../..' . '/lib/webservice/webserviceusers.php',
'ZLog' => __DIR__ . '/../..' . '/lib/core/zlog.php', 'ZLog' => __DIR__ . '/../..' . '/lib/core/zlog.php',
'ZPush' => __DIR__ . '/../..' . '/lib/core/zpush.php', 'ZPush' => __DIR__ . '/../..' . '/lib/core/zpush.php',
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* *
* Created : 18.05.2015 * Created : 18.05.2015
* *
* Copyright 2015 Zarafa Deutschland GmbH * Copyright 2015-2016 Zarafa Deutschland GmbH
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3, * it under the terms of the GNU Affero General Public License, version 3,
...@@ -42,9 +42,10 @@ ...@@ -42,9 +42,10 @@
************************************************/ ************************************************/
if (count($argv) < 2) { if (count($argv) < 2) {
die("\tUsage: printwbmxl.php WBXML-INPUT-HERE\n\n"); die("\tUsage: printwbmxl.php WBXML-INPUT-HERE or PATH-TO-FILE\n\n");
} }
$wbxml64 = $argv[1]; $wbxml64 = is_file($argv[1]) ? realpath($argv[1]) : $argv[1];
chdir(__DIR__);
// include the stuff we need // include the stuff we need
include_once('../../src/lib/utils/stringstreamwrapper.php'); include_once('../../src/lib/utils/stringstreamwrapper.php');
...@@ -71,7 +72,7 @@ class ZLog { ...@@ -71,7 +72,7 @@ class ZLog {
} }
// setup // setup
$wxbml = StringStreamWrapper::Open($wbxml64); $wxbml = is_file($wbxml64) ? fopen($wbxml64, 'r+') : StringStreamWrapper::Open($wbxml64);
$base64filter = stream_filter_append($wxbml, 'convert.base64-decode'); $base64filter = stream_filter_append($wxbml, 'convert.base64-decode');
$decoder = new WBXMLDecoder($wxbml); $decoder = new WBXMLDecoder($wxbml);
if (! $decoder->IsWBXML()) { if (! $decoder->IsWBXML()) {
......
...@@ -88,6 +88,7 @@ class GabSyncCLI { ...@@ -88,6 +88,7 @@ class GabSyncCLI {
static private $syncWorker; static private $syncWorker;
static private $command; static private $command;
static private $uniqueId = false; static private $uniqueId = false;
static private $targetGab = false;
static private $errormessage; static private $errormessage;
/** /**
...@@ -101,6 +102,7 @@ class GabSyncCLI { ...@@ -101,6 +102,7 @@ class GabSyncCLI {
"\tgab-sync.php -a ACTION [options]" .PHP_EOL.PHP_EOL. "\tgab-sync.php -a ACTION [options]" .PHP_EOL.PHP_EOL.
"Parameters:" .PHP_EOL. "Parameters:" .PHP_EOL.
"\t-a simulate | sync | sync-one | clear-all | delete-all" .PHP_EOL. "\t-a simulate | sync | sync-one | clear-all | delete-all" .PHP_EOL.
"\t[-t] TARGET-GAB\t\t Target GAB to execute the action / unique-id on. Optional, if not set, executed on all or default gab." .PHP_EOL.
"\t[-u] UNIQUE-ID" .PHP_EOL.PHP_EOL. "\t[-u] UNIQUE-ID" .PHP_EOL.PHP_EOL.
"Actions:" .PHP_EOL. "Actions:" .PHP_EOL.
"\tsimulate\t\t Simulates the GAB synchronization and prints out statistics and configuration suggestions." .PHP_EOL. "\tsimulate\t\t Simulates the GAB synchronization and prints out statistics and configuration suggestions." .PHP_EOL.
...@@ -120,7 +122,7 @@ class GabSyncCLI { ...@@ -120,7 +122,7 @@ class GabSyncCLI {
static public function SetupSyncWorker() { static public function SetupSyncWorker() {
$file = "lib/" .strtolower(SYNCWORKER).".php"; $file = "lib/" .strtolower(SYNCWORKER).".php";
@include_once($file); include_once($file);
if (!class_exists(SYNCWORKER)) { if (!class_exists(SYNCWORKER)) {
self::$errormessage = "SyncWorker file loaded, but class '".SYNCWORKER."' can not be found. Check your configuration or implementation."; self::$errormessage = "SyncWorker file loaded, but class '".SYNCWORKER."' can not be found. Check your configuration or implementation.";
...@@ -157,7 +159,7 @@ class GabSyncCLI { ...@@ -157,7 +159,7 @@ class GabSyncCLI {
if (self::$errormessage) if (self::$errormessage)
return; return;
$options = getopt("u:a:"); $options = getopt("u:a:t:");
// get 'unique-id' // get 'unique-id'
if (isset($options['u']) && !empty($options['u'])) if (isset($options['u']) && !empty($options['u']))
...@@ -165,6 +167,12 @@ class GabSyncCLI { ...@@ -165,6 +167,12 @@ class GabSyncCLI {
else if (isset($options['unique-id']) && !empty($options['unique-id'])) else if (isset($options['unique-id']) && !empty($options['unique-id']))
self::$uniqueId = strtolower(trim($options['unique-id'])); self::$uniqueId = strtolower(trim($options['unique-id']));
// get 'target-gab'
if (isset($options['t']) && !empty($options['t']))
self::$targetGab = strtolower(trim($options['t']));
else if (isset($options['target-gab']) && !empty($options['target-gab']))
self::$targetGab = strtolower(trim($options['target-gab']));
// get 'action' // get 'action'
$action = false; $action = false;
if (isset($options['a']) && !empty($options['a'])) if (isset($options['a']) && !empty($options['a']))
...@@ -240,31 +248,31 @@ class GabSyncCLI { ...@@ -240,31 +248,31 @@ class GabSyncCLI {
echo PHP_EOL; echo PHP_EOL;
switch(self::$command) { switch(self::$command) {
case self::COMMAND_SIMULATE: case self::COMMAND_SIMULATE:
self::$syncWorker->Simulate(); self::$syncWorker->Simulate(self::$targetGab);
break; break;
case self::COMMAND_SYNC: case self::COMMAND_SYNC:
self::$syncWorker->Sync(); self::$syncWorker->Sync(self::$targetGab);
break; break;
case self::COMMAND_SYNC_ONE: case self::COMMAND_SYNC_ONE:
self::$syncWorker->SyncOne(self::$uniqueId); self::$syncWorker->SyncOne(self::$uniqueId, self::$targetGab);
break; break;
case self::COMMAND_CLEARALL: case self::COMMAND_CLEARALL:
echo "Are you sure you want to remove all chunks and data from the public folder. ALL GAB data will be removed from ALL KOE instances [y/N]: "; echo "Are you sure you want to remove all chunks and data from the hidden GAB folder. ALL GAB data will be removed from ALL KOE instances [y/N]: ";
$confirm = strtolower(trim(fgets(STDIN))); $confirm = strtolower(trim(fgets(STDIN)));
if ( $confirm === 'y' || $confirm === 'yes') if ( $confirm === 'y' || $confirm === 'yes')
self::$syncWorker->ClearAll(); self::$syncWorker->ClearAll(self::$targetGab);
else else
echo "Aborted!".PHP_EOL; echo "Aborted!".PHP_EOL;
break; break;
case self::COMMAND_DELETEALL: case self::COMMAND_DELETEALL:
echo "Are you sure you want to remove all chunks and data from the public folder and delete it? ALL GAB data will be removed from ALL KOE instances [y/N]: "; echo "Are you sure you want to remove all chunks and data from the hidden GAB folder and delete it? ALL GAB data will be removed from ALL KOE instances [y/N]: ";
$confirm = strtolower(trim(fgets(STDIN))); $confirm = strtolower(trim(fgets(STDIN)));
if ( $confirm === 'y' || $confirm === 'yes') if ( $confirm === 'y' || $confirm === 'yes')
self::$syncWorker->DeleteAll(); self::$syncWorker->DeleteAll(self::$targetGab);
else else
echo "Aborted!".PHP_EOL; echo "Aborted!".PHP_EOL;
break; break;
......
This diff is collapsed.
This diff is collapsed.
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