mirror of
https://github.com/YunoHost-Apps/z-push_ynh.git
synced 2024-09-03 18:05:58 +02:00
Update to latest sources
This commit is contained in:
parent
2f643f9c53
commit
957871fe54
7 changed files with 198 additions and 14 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
106
sources/include/z_syslog.php
Normal file
106
sources/include/z_syslog.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright 2015 Leon van Kammen / Coder of Salvation. All rights reserved.
|
||||
* Modifications 2015 - Francisco Miguel Biete
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Leon van Kammen / Coder of Salvation AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Leon van Kammen / Coder of Salvation OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of Leon van Kammen / Coder of Salvation
|
||||
*/
|
||||
|
||||
class ZSyslog {
|
||||
private static $hostname = false;
|
||||
private static $port = 514;
|
||||
private static $program = "[z-push]";
|
||||
|
||||
/**
|
||||
* Initializes the logging
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public static function Initialize() {
|
||||
if (defined('LOG_SYSLOG_HOST'))
|
||||
self::$hostname = LOG_SYSLOG_HOST;
|
||||
if (defined('LOG_SYSLOG_PORT'))
|
||||
self::$port = LOG_SYSLOG_PORT;
|
||||
if (defined('LOG_SYSLOG_PROGRAM'))
|
||||
self::$program = LOG_SYSLOG_PROGRAM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message in the syslog facility.
|
||||
*
|
||||
* @params int $zlog_level Z-Push LogLevel
|
||||
* @params string $message
|
||||
*
|
||||
* @access public
|
||||
* @return boolean
|
||||
*/
|
||||
public static function send($zlog_level, $message) {
|
||||
$level = self::zlogLevel2SyslogLevel($zlog_level);
|
||||
if ($level === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::$hostname === false) {
|
||||
return syslog($level, $message);
|
||||
}
|
||||
else {
|
||||
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
||||
$facility = 1; // user level
|
||||
$pri = ($facility*8) + $level; // multiplying the Facility number by 8 + adding the level
|
||||
foreach (explode("\n", $message) as $line) {
|
||||
if (strlen(trim($line)) > 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;
|
||||
}
|
||||
}
|
||||
}
|
38
sources/testing/samples/meeting_request_rim.txt
Normal file
38
sources/testing/samples/meeting_request_rim.txt
Normal file
|
@ -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
|
33
sources/testing/testing-imap_meeting_tzid.php
Normal file
33
sources/testing/testing-imap_meeting_tzid.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
define('LOGLEVEL', LOGLEVEL_DEBUG);
|
||||
define('LOGUSERLEVEL', LOGLEVEL_DEVICEID);
|
||||
|
||||
date_default_timezone_set('Europe/Madrid');
|
||||
|
||||
$body = file_get_contents('testing/samples/meeting_request.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));
|
||||
|
||||
|
||||
$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));
|
8
sources/vendor/composer/ClassLoader.php
vendored
8
sources/vendor/composer/ClassLoader.php
vendored
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Add table
Reference in a new issue