From 957871fe545847dc80c8bb12cd5ff6eb915d69ea Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 21 Aug 2015 23:55:45 +0100 Subject: [PATCH] Update to latest sources --- sources/backend/combined/combined.php | 9 +- sources/include/z_syslog.php | 106 ++++++++++++++++++ .../testing/samples/meeting_request_rim.txt | 38 +++++++ sources/testing/testing-imap_meeting_tzid.php | 33 ++++++ sources/vendor/composer/ClassLoader.php | 8 +- sources/vendor/composer/autoload_classmap.php | 2 +- sources/z-push-admin.php | 16 ++- 7 files changed, 198 insertions(+), 14 deletions(-) create mode 100644 sources/include/z_syslog.php create mode 100644 sources/testing/samples/meeting_request_rim.txt create mode 100644 sources/testing/testing-imap_meeting_tzid.php diff --git a/sources/backend/combined/combined.php b/sources/backend/combined/combined.php index 79e5605..c88e915 100644 --- a/sources/backend/combined/combined.php +++ b/sources/backend/combined/combined.php @@ -451,7 +451,7 @@ class BackendCombined extends Backend implements ISearchProvider { $backend = $this->GetBackend($folderid); if($backend === false) { - // if not backend is found we return true, we don't want this to never cause an error + // if not backend is found we return true, we don't want this to cause an error return true; } @@ -459,10 +459,9 @@ class BackendCombined extends Backend implements ISearchProvider { ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCombined->ChangesSinkInitialize('%s') is supported, initializing", $folderid)); return $backend->ChangesSinkInitialize($this->GetBackendFolder($folderid)); } - else { - // if the backend doesn't support ChangesSink, we also return true so we don't get an error - return true; - } + + // if the backend doesn't support ChangesSink, we also return true so we don't get an error + return true; } /** diff --git a/sources/include/z_syslog.php b/sources/include/z_syslog.php new file mode 100644 index 0000000..a599b6d --- /dev/null +++ b/sources/include/z_syslog.php @@ -0,0 +1,106 @@ + 0) { + $syslog_message = "<{$pri}>" . date('M d H:i:s ') . self::$program . ': ' . $line; + socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, self::$hostname, self::$port); + } + } + socket_close($sock); + } + + return true; + } + + /** + * Converts the ZLog level to SYSLOG level. + * + * @params int $loglevel Z-Push LogLevel + * + * @access private + * @return SYSLOG_LEVEL or false + */ + private static function zlogLevel2SyslogLevel($loglevel) { + switch($loglevel) { + case LOGLEVEL_OFF: return false; break; + case LOGLEVEL_FATAL: return LOG_ALERT; break; + case LOGLEVEL_ERROR: return LOG_ERR; break; + case LOGLEVEL_WARN: return LOG_WARNING; break; + case LOGLEVEL_INFO: return LOG_INFO; break; + case LOGLEVEL_DEBUG: return LOG_DEBUG; break; + case LOGLEVEL_WBXML: return LOG_DEBUG; break; + case LOGLEVEL_DEVICEID: return LOG_DEBUG; break; + case LOGLEVEL_WBXMLSTACK: return LOG_DEBUG; break; + } + } +} \ No newline at end of file diff --git a/sources/testing/samples/meeting_request_rim.txt b/sources/testing/samples/meeting_request_rim.txt new file mode 100644 index 0000000..245f4ad --- /dev/null +++ b/sources/testing/samples/meeting_request_rim.txt @@ -0,0 +1,38 @@ +BEGIN:VCALENDAR +PRODID:-//Research In Motion//RIM App//EN +VERSION:2.0 +CALSCALE:GREGORIAN +METHOD:REQUEST +BEGIN:VTIMEZONE +TZID:Europe/Dublin +BEGIN:STANDARD +DTSTART:20001029T020000 +RRULE:FREQ=3DYEARLY;BYDAY=3D4SU;BYMONTH=3D10 +TZNAME:GMT +TZOFFSETFROM:+0100 +TZOFFSETTO:+0000 +END:STANDARD +BEGIN:DAYLIGHT +DTSTART:20000326T010000 +RRULE:FREQ=3DYEARLY;BYDAY=3D4SU;BYMONTH=3D3 +TZNAME:IST +TZOFFSETFROM:+0000 +TZOFFSETTO:+0100 +END:DAYLIGHT +END:VTIMEZONE +BEGIN:VEVENT +ATTENDEE;RSVP=3DTRUE;ROLE=3DREQ-PARTICIPANT;CN=3Dmaxtest@mcgva.ovh;PARTSTAT= +=3DTENTATIVE +:mailto:user1@domain.tld +CREATED:20150814T163344Z +DTEND;TZID=3DEurope/Dublin:20150814T175000 +DTSTAMP:20150814T163344Z +DTSTART;TZID=3DEurope/Dublin:20150814T174500 +ORGANIZER:mailto:user2@domain.tld +SEQUENCE:0 +STATUS:CONFIRMED +SUMMARY:Test invitation +TRANSP:OPAQUE +UID:3af267ec-42a2-11e5-bfc0-574eadb945a2 +END:VEVENT +END:VCALENDAR \ No newline at end of file diff --git a/sources/testing/testing-imap_meeting_tzid.php b/sources/testing/testing-imap_meeting_tzid.php new file mode 100644 index 0000000..0918380 --- /dev/null +++ b/sources/testing/testing-imap_meeting_tzid.php @@ -0,0 +1,33 @@ +ParseFrom($body); + +$props = $ical->GetPropertiesByPath("VTIMEZONE/TZID"); +if (count($props) > 0) { + $tzid = $props[0]->Value(); + printf("TZID %s\n", $props[0]->Value()); +} +print_r(TimezoneUtil::GetFullTZFromTZName($tzid)); + + +$body = file_get_contents('testing/samples/meeting_request_rim.txt'); + +$ical = new iCalComponent(); +$ical->ParseFrom($body); + +$props = $ical->GetPropertiesByPath("VTIMEZONE/TZID"); +if (count($props) > 0) { + $tzid = $props[0]->Value(); + printf("TZID %s\n", $props[0]->Value()); +} +print_r(TimezoneUtil::GetFullTZFromTZName($tzid)); \ No newline at end of file diff --git a/sources/vendor/composer/ClassLoader.php b/sources/vendor/composer/ClassLoader.php index 4e05d3b..5e1469e 100644 --- a/sources/vendor/composer/ClassLoader.php +++ b/sources/vendor/composer/ClassLoader.php @@ -351,7 +351,7 @@ class ClassLoader foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { if (0 === strpos($class, $prefix)) { foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { return $file; } } @@ -361,7 +361,7 @@ class ClassLoader // PSR-4 fallback dirs foreach ($this->fallbackDirsPsr4 as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { return $file; } } @@ -380,7 +380,7 @@ class ClassLoader foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { foreach ($dirs as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } @@ -390,7 +390,7 @@ class ClassLoader // PSR-0 fallback dirs foreach ($this->fallbackDirsPsr0 as $dir) { - if (is_file($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { return $file; } } diff --git a/sources/vendor/composer/autoload_classmap.php b/sources/vendor/composer/autoload_classmap.php index 67716a6..dd8088f 100644 --- a/sources/vendor/composer/autoload_classmap.php +++ b/sources/vendor/composer/autoload_classmap.php @@ -146,7 +146,7 @@ return array( 'ZPushAdmin' => $baseDir . '/lib/utils/zpushadmin.php', 'ZPushAutodiscover' => $baseDir . '/autodiscover/autodiscover.php', 'ZPushException' => $baseDir . '/lib/exceptions/zpushexception.php', - 'ZSyslog' => $baseDir . '/lib/core/zsyslog.php', + 'ZSyslog' => $baseDir . '/include/z_syslog.php', 'carddav_backend' => $baseDir . '/include/z_carddav.php', 'iCalComponent' => $baseDir . '/include/iCalendar.php', 'iCalProp' => $baseDir . '/include/iCalendar.php', diff --git a/sources/z-push-admin.php b/sources/z-push-admin.php index a677e93..597aca9 100755 --- a/sources/z-push-admin.php +++ b/sources/z-push-admin.php @@ -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; /** @@ -120,6 +121,7 @@ class ZPushAdminCLI { "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" . @@ -140,7 +142,7 @@ class ZPushAdminCLI { "\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"; } @@ -169,7 +171,7 @@ class ZPushAdminCLI { 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'])) @@ -217,6 +219,12 @@ class ZPushAdminCLI { 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 @@ -285,7 +293,7 @@ class ZPushAdminCLI { // 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; @@ -700,7 +708,7 @@ class ZPushAdminCLI { * @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";