Skip to content

Commit 05fe610

Browse files
committed
Merge remote-tracking branch 'z-hub/develop' into develop
# Conflicts: # src/lib/request/find.php # src/vendor/composer/autoload_classmap.php # src/vendor/composer/autoload_static.php
2 parents d4b7866 + af25a21 commit 05fe610

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1909
-593
lines changed

config/nginx/z-push.conf

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,7 @@ server {
3232
include snippets/z-push-php.conf;
3333
}
3434

35-
location /AutoDiscover/AutoDiscover.xml {
36-
include snippets/z-push-autodiscover.conf;
37-
include snippets/z-push-php.conf;
38-
}
39-
location /Autodiscover/Autodiscover.xml {
40-
include snippets/z-push-autodiscover.conf;
41-
include snippets/z-push-php.conf;
42-
}
43-
location /autodiscover/autodiscover.xml {
35+
location ~* ^/AutoDiscover/AutoDiscover.xml$ {
4436
include snippets/z-push-autodiscover.conf;
4537
include snippets/z-push-php.conf;
4638
}

src/autodiscover/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* This is not always possible as the username might have a different
5252
* schema than email address. Configure this parameter to match your
5353
* username settings.
54-
* @see https://wiki.z-hub.io/display/ZP/Configuring+Z-Push+Autodiscover#ConfiguringZ-PushAutodiscover-Configuration
54+
* @see https://github.com/Z-Hub/Z-Push/wiki/Configuring-Z-Push-Autodiscover
5555
* @see https://jira.z-hub.io/browse/ZP-1209
5656
*
5757
* Possible values:

src/backend/caldav/caldav.php

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public function GetFolderList() {
125125
$folders = array();
126126
$calendars = $this->_caldav->FindCalendars();
127127
foreach ($calendars as $val) {
128+
if ($this->GetFolderIsIncluded($val->url) == false) {
129+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderList() Excluded folder '%s'", $val->url));
130+
continue;
131+
}
132+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderList() Included folder '%s'", $val->url));
133+
128134
$fpath = explode("/", $val->url, -1);
129135
if (is_array($fpath)) {
130136
$folderid = array_pop($fpath);
@@ -446,7 +452,7 @@ public function ResolveRecipients($resolveRecipients) {
446452
* @return string AS version constant
447453
*/
448454
public function GetSupportedASVersion() {
449-
return ZPush::ASV_14;
455+
return ZPush::ASV_161;
450456
}
451457

452458
/**
@@ -1289,7 +1295,7 @@ private function _ParseASEventToVEvent($data, $id, $tzid, $tzpar) {
12891295
break;
12901296
}
12911297
}
1292-
if (isset($data->reminder)) {
1298+
if (isset($data->reminder) && $data->reminder !== '') {
12931299
$valarm = new iCalComponent();
12941300
$valarm->SetType("VALARM");
12951301
$valarm->AddProperty("ACTION", "DISPLAY");
@@ -2199,5 +2205,68 @@ private function explodeUnescapedDelimiter($delimiter, $data, $escapeCharacter =
21992205

22002206
return $result;
22012207
}
2208+
2209+
/**
2210+
* Filter discovered calendar urls, by inclusion or exclusion.
2211+
* The default is to always include the calendar collection, unless either include or exclude is uncommented and configured.
2212+
* The calendar collection is included, either when the include filter is not configured, or when the include filter matches.
2213+
* The calendar collection is excluded, when the exclude filter is configured and it matches. Exclude always wins over include.
2214+
* The defined constants can either be a string or an array of multiple strings, to provide multiple filters.
2215+
*/
2216+
private function GetFolderIsIncluded($url) {
2217+
// Exist and retain original behaviour.
2218+
if ((defined('CALDAV_PATH_INCLUDE') == false) && (defined('CALDAV_PATH_EXCLUDE') == false)) {
2219+
return true;
2220+
}
2221+
if ($url === null) {
2222+
return true;
2223+
}
2224+
2225+
// Convert to array.
2226+
$includes = array();
2227+
if (defined('CALDAV_PATH_INCLUDE') == true) {
2228+
if (is_array(CALDAV_PATH_INCLUDE) == true) {
2229+
$includes = CALDAV_PATH_INCLUDE;
2230+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderIsIncluded() Include filter is an array with %s elements", count($includes)));
2231+
} else if (CALDAV_PATH_INCLUDE !== '') {
2232+
$includes = array(CALDAV_PATH_INCLUDE);
2233+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderIsIncluded() Include filter is a string '%s'", CALDAV_PATH_INCLUDE));
2234+
}
2235+
}
2236+
2237+
$excludes = array();
2238+
if (defined('CALDAV_PATH_EXCLUDE') == true) {
2239+
if (is_array(CALDAV_PATH_EXCLUDE) == true) {
2240+
$excludes = CALDAV_PATH_EXCLUDE;
2241+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderIsIncluded() Exclude filter is an array with %s elements", count($excludes)));
2242+
} else if (CALDAV_PATH_EXCLUDE !== '') {
2243+
$excludes = array(CALDAV_PATH_EXCLUDE);
2244+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderIsIncluded() Exclude filter is a string '%s'", CALDAV_PATH_EXCLUDE));
2245+
}
2246+
}
2247+
2248+
// Test for matches.
2249+
$foundOneInclude = (count($includes) == 0);
2250+
foreach ($includes as $include) {
2251+
if (fnmatch($include, $url) == true) {
2252+
$foundOneInclude = true;
2253+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderIsIncluded() Include filter '%s' matches '%s'", $include, $url));
2254+
break;
2255+
}
2256+
}
2257+
2258+
$foundNoExcludes = (count($excludes) == 0);
2259+
$foundOneExclude = false;
2260+
foreach ($excludes as $exclude) {
2261+
if (fnmatch($exclude, $url) == true) {
2262+
$foundOneExclude = true;
2263+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCalDAV::GetFolderIsIncluded() Exclude filter '%s' matches '%s'", $exclude, $url));
2264+
break;
2265+
}
2266+
}
2267+
$foundNoExcludes = ($foundOneExclude == false);
22022268

2269+
return (($foundOneInclude == true) && ($foundNoExcludes == true));
2270+
} // GetFolderIsIncluded
2271+
22032272
};

src/backend/caldav/config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,13 @@
5454
// Maximum period to sync.
5555
// Some servers don't support more than 10 years so you will need to change this
5656
define('CALDAV_MAX_SYNC_PERIOD', 2147483647);
57+
58+
// Filter discovered calendar urls, by inclusion or exclusion.
59+
// The default is to always include the calendar collection, unless either include or exclude is uncommented and configured.
60+
// The calendar collection is included, either when the include filter is not configured, or when the include filter matches.
61+
// The calendar collection is excluded, when the exclude filter is configured and it matches. Exclude always wins over include.
62+
// The defined constants can either be a string or an array of multiple strings, to provide multiple filters.
63+
// Exclude example: '*/archived-appointments/'
64+
// Include example: '*sync*'
65+
//define('CALDAV_PATH_INCLUDE', '');
66+
//define('CALDAV_PATH_EXCLUDE', '');

src/backend/carddav/carddav.php

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ public function ResolveRecipients($resolveRecipients) {
703703
* @return string AS version constant
704704
*/
705705
public function GetSupportedASVersion() {
706-
return ZPush::ASV_14;
706+
return ZPush::ASV_161;
707707
}
708708

709709

@@ -1328,8 +1328,13 @@ private function discoverAddressbooks() {
13281328
continue;
13291329
}
13301330
}
1331-
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::discoverAddressbooks() Found addressbook '%s'", urldecode($response->url)));
1332-
$this->addressbooks[] = urldecode($response->url);
1331+
1332+
if ($this->getAddressbookIsIncluded($response->url) == true) {
1333+
$this->addressbooks[] = urldecode($response->url);
1334+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::discoverAddressbooks() Included addressbook '%s'", urldecode($response->url)));
1335+
} else {
1336+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::discoverAddressbooks() Excluded addressbook '%s'", urldecode($response->url)));
1337+
}
13331338
}
13341339
unset($xml);
13351340
}
@@ -1462,4 +1467,68 @@ private function getAddressbookFromUrl($addressbookUrl) {
14621467
return $addressbookId;
14631468
}
14641469

1470+
1471+
/**
1472+
* Filter discovered addressbook urls, by inclusion or exclusion.
1473+
* The default is to always include the addressbook collection, unless either include or exclude is uncommented and configured.
1474+
* The addressbook collection is included, either when the include filter is not configured, or when the include filter matches.
1475+
* The addressbook collection is excluded, when the exclude filter is configured and it matches. Exclude always wins over include.
1476+
* The defined constants can either be a string or an array of multiple strings, to provide multiple filters.
1477+
*/
1478+
private function getAddressbookIsIncluded($url) {
1479+
// Exist and retain original behaviour.
1480+
if ((defined('CARDDAV_PATH_INCLUDE') == false) && (defined('CARDDAV_PATH_EXCLUDE') == false)) {
1481+
return true;
1482+
}
1483+
if ($url === null) {
1484+
return true;
1485+
}
1486+
1487+
// Convert to array.
1488+
$includes = array();
1489+
if (defined('CARDDAV_PATH_INCLUDE') == true) {
1490+
if (is_array(CARDDAV_PATH_INCLUDE) == true) {
1491+
$includes = CARDDAV_PATH_INCLUDE;
1492+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::getAddressbookIsIncluded() Include filter is an array with %s elements", count($includes)));
1493+
} else if (CARDDAV_PATH_INCLUDE !== '') {
1494+
$includes = array(CARDDAV_PATH_INCLUDE);
1495+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::getAddressbookIsIncluded() Include filter is a string '%s'", CARDDAV_PATH_INCLUDE));
1496+
}
1497+
}
1498+
1499+
$excludes = array();
1500+
if (defined('CARDDAV_PATH_EXCLUDE') == true) {
1501+
if (is_array(CARDDAV_PATH_EXCLUDE) == true) {
1502+
$excludes = CARDDAV_PATH_EXCLUDE;
1503+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::getAddressbookIsIncluded() Exclude filter is an array with %s elements", count($excludes)));
1504+
} else if (CARDDAV_PATH_EXCLUDE !== '') {
1505+
$excludes = array(CARDDAV_PATH_EXCLUDE);
1506+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::getAddressbookIsIncluded() Exclude filter is a string '%s'", CARDDAV_PATH_EXCLUDE));
1507+
}
1508+
}
1509+
1510+
// Test for matches.
1511+
$foundOneInclude = (count($includes) == 0);
1512+
foreach ($includes as $include) {
1513+
if (fnmatch($include, $url) == true) {
1514+
$foundOneInclude = true;
1515+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::getAddressbookIsIncluded() Include filter '%s' matches '%s'", $include, $url));
1516+
break;
1517+
}
1518+
}
1519+
1520+
$foundNoExcludes = (count($excludes) == 0);
1521+
$foundOneExclude = false;
1522+
foreach ($excludes as $exclude) {
1523+
if (fnmatch($exclude, $url) == true) {
1524+
$foundOneExclude = true;
1525+
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV::getAddressbookIsIncluded() Exclude filter '%s' matches '%s'", $exclude, $url));
1526+
break;
1527+
}
1528+
}
1529+
$foundNoExcludes = ($foundOneExclude == false);
1530+
1531+
return (($foundOneInclude == true) && ($foundNoExcludes == true));
1532+
} // getAddressbookIsIncluded
1533+
14651534
}

src/backend/carddav/config.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,13 @@
9393
// Davical needs it
9494
// SOGo official demo online needs it, but some SOGo installation don't need it, so test it
9595
define('CARDDAV_URL_VCARD_EXTENSION', '.vcf');
96+
97+
// Filter discovered addressbook urls, by inclusion or exclusion.
98+
// The default is to always include the addressbook collection, unless either include or exclude is uncommented and configured.
99+
// The addressbook collection is included, either when the include filter is not configured, or when the include filter matches.
100+
// The addressbook collection is excluded, when the exclude filter is configured and it matches. Exclude always wins over include.
101+
// The defined constants can either be a string or an array of multiple strings, to provide multiple filters.
102+
// Exclude example: '*/archived-addresses/'
103+
// Include example: '*sync*'
104+
//define('CARDDAV_PATH_INCLUDE', '');
105+
//define('CARDDAV_PATH_EXCLUDE', '');

src/backend/combined/combined.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ public function GetBackendId($folderid){
531531
* @return string AS version constant
532532
*/
533533
public function GetSupportedASVersion() {
534-
$version = ZPush::ASV_14;
534+
$version = ZPush::ASV_161;
535535
foreach ($this->backends as $i => $b) {
536536
$subversion = $this->backends[$i]->GetSupportedASVersion();
537537
if ($subversion < $version) {

0 commit comments

Comments
 (0)