mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-07 00:48:55 +00:00
Set notifications of events; the actual notification routine is not yet implemented
This commit is contained in:
parent
62ec9bfa69
commit
8196f9b900
26 changed files with 324 additions and 212 deletions
|
@ -68,7 +68,7 @@ class Sabre_CalDAV_CalendarQueryParser {
|
|||
|
||||
$this->xpath = new DOMXPath($dom);
|
||||
$this->xpath->registerNameSpace('cal',Sabre_CalDAV_Plugin::NS_CALDAV);
|
||||
$this->xpath->registerNameSpace('dav','urn:DAV');
|
||||
$this->xpath->registerNameSpace('dav','DAV:');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -442,11 +442,11 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
public function calendarMultiGetReport($dom) {
|
||||
|
||||
$properties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild));
|
||||
$hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href');
|
||||
$hrefElems = $dom->getElementsByTagNameNS('DAV:','href');
|
||||
|
||||
$xpath = new DOMXPath($dom);
|
||||
$xpath->registerNameSpace('cal',Sabre_CalDAV_Plugin::NS_CALDAV);
|
||||
$xpath->registerNameSpace('dav','urn:DAV');
|
||||
$xpath->registerNameSpace('dav','DAV:');
|
||||
|
||||
$expand = $xpath->query('/cal:calendar-multiget/dav:prop/cal:calendar-data/cal:expand');
|
||||
if ($expand->length>0) {
|
||||
|
|
|
@ -269,7 +269,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin {
|
|||
|
||||
$properties = array_keys(Sabre_DAV_XMLUtil::parseProperties($dom->firstChild));
|
||||
|
||||
$hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href');
|
||||
$hrefElems = $dom->getElementsByTagNameNS('DAV:','href');
|
||||
$propertyList = array();
|
||||
|
||||
foreach($hrefElems as $elem) {
|
||||
|
|
|
@ -485,19 +485,17 @@ class Sabre_DAV_Client {
|
|||
*/
|
||||
public function parseMultiStatus($body) {
|
||||
|
||||
$body = Sabre_DAV_XMLUtil::convertDAVNamespace($body);
|
||||
|
||||
$responseXML = simplexml_load_string($body, null, LIBXML_NOBLANKS | LIBXML_NOCDATA);
|
||||
if ($responseXML===false) {
|
||||
throw new InvalidArgumentException('The passed data is not valid XML');
|
||||
}
|
||||
|
||||
$responseXML->registerXPathNamespace('d', 'urn:DAV');
|
||||
$responseXML->registerXPathNamespace('d', 'DAV:');
|
||||
|
||||
$propResult = array();
|
||||
|
||||
foreach($responseXML->xpath('d:response') as $response) {
|
||||
$response->registerXPathNamespace('d', 'urn:DAV');
|
||||
$response->registerXPathNamespace('d', 'DAV:');
|
||||
$href = $response->xpath('d:href');
|
||||
$href = (string)$href[0];
|
||||
|
||||
|
@ -505,7 +503,7 @@ class Sabre_DAV_Client {
|
|||
|
||||
foreach($response->xpath('d:propstat') as $propStat) {
|
||||
|
||||
$propStat->registerXPathNamespace('d', 'urn:DAV');
|
||||
$propStat->registerXPathNamespace('d', 'DAV:');
|
||||
$status = $propStat->xpath('d:status');
|
||||
list($httpVersion, $statusCode, $message) = explode(' ', (string)$status[0],3);
|
||||
|
||||
|
|
|
@ -1999,7 +1999,7 @@ class Sabre_DAV_Server {
|
|||
if (!$body) return array();
|
||||
|
||||
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($body);
|
||||
$elem = $dom->getElementsByTagNameNS('urn:DAV','propfind')->item(0);
|
||||
$elem = $dom->getElementsByTagNameNS('DAV:','propfind')->item(0);
|
||||
return array_keys(Sabre_DAV_XMLUtil::parseProperties($elem));
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,6 @@ class Sabre_DAV_XMLUtil {
|
|||
* {http://www.example.org}myelem
|
||||
*
|
||||
* This format is used throughout the SabreDAV sourcecode.
|
||||
* Elements encoded with the urn:DAV namespace will
|
||||
* be returned as if they were in the DAV: namespace. This is to avoid
|
||||
* compatibility problems.
|
||||
*
|
||||
* This function will return null if a nodetype other than an Element is passed.
|
||||
*
|
||||
|
@ -33,8 +30,7 @@ class Sabre_DAV_XMLUtil {
|
|||
|
||||
if ($dom->nodeType !== XML_ELEMENT_NODE) return null;
|
||||
|
||||
// Mapping back to the real namespace, in case it was dav
|
||||
if ($dom->namespaceURI=='urn:DAV') $ns = 'DAV:'; else $ns = $dom->namespaceURI;
|
||||
$ns = $dom->namespaceURI;
|
||||
|
||||
// Mapping to clark notation
|
||||
return '{' . $ns . '}' . $dom->localName;
|
||||
|
@ -64,29 +60,11 @@ class Sabre_DAV_XMLUtil {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method takes an XML document (as string) and converts all instances of the
|
||||
* DAV: namespace to urn:DAV
|
||||
*
|
||||
* This is unfortunately needed, because the DAV: namespace violates the xml namespaces
|
||||
* spec, and causes the DOM to throw errors
|
||||
*
|
||||
* @param string $xmlDocument
|
||||
* @return array|string|null
|
||||
*/
|
||||
static function convertDAVNamespace($xmlDocument) {
|
||||
|
||||
// This is used to map the DAV: namespace to urn:DAV. This is needed, because the DAV:
|
||||
// namespace is actually a violation of the XML namespaces specification, and will cause errors
|
||||
return preg_replace("/xmlns(:[A-Za-z0-9_]*)?=(\"|\')DAV:(\\2)/","xmlns\\1=\\2urn:DAV\\2",$xmlDocument);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method provides a generic way to load a DOMDocument for WebDAV use.
|
||||
*
|
||||
* This method throws a Sabre_DAV_Exception_BadRequest exception for any xml errors.
|
||||
* It does not preserve whitespace, and it converts the DAV: namespace to urn:DAV.
|
||||
* It does not preserve whitespace.
|
||||
*
|
||||
* @param string $xml
|
||||
* @throws Sabre_DAV_Exception_BadRequest
|
||||
|
@ -118,10 +96,11 @@ class Sabre_DAV_XMLUtil {
|
|||
libxml_clear_errors();
|
||||
|
||||
$dom = new DOMDocument();
|
||||
$dom->loadXML(self::convertDAVNamespace($xml),LIBXML_NOWARNING | LIBXML_NOERROR);
|
||||
|
||||
// We don't generally care about any whitespace
|
||||
$dom->preserveWhiteSpace = false;
|
||||
|
||||
$dom->loadXML($xml,LIBXML_NOWARNING | LIBXML_NOERROR);
|
||||
|
||||
if ($error = libxml_get_last_error()) {
|
||||
libxml_clear_errors();
|
||||
|
|
|
@ -88,11 +88,11 @@ class Sabre_DAVACL_Property_Acl extends Sabre_DAV_Property {
|
|||
static public function unserialize(DOMElement $dom) {
|
||||
|
||||
$privileges = array();
|
||||
$xaces = $dom->getElementsByTagNameNS('urn:DAV','ace');
|
||||
$xaces = $dom->getElementsByTagNameNS('DAV:','ace');
|
||||
for($ii=0; $ii < $xaces->length; $ii++) {
|
||||
|
||||
$xace = $xaces->item($ii);
|
||||
$principal = $xace->getElementsByTagNameNS('urn:DAV','principal');
|
||||
$principal = $xace->getElementsByTagNameNS('DAV:','principal');
|
||||
if ($principal->length !== 1) {
|
||||
throw new Sabre_DAV_Exception_BadRequest('Each {DAV:}ace element must have one {DAV:}principal element');
|
||||
}
|
||||
|
@ -116,17 +116,17 @@ class Sabre_DAVACL_Property_Acl extends Sabre_DAV_Property {
|
|||
|
||||
$protected = false;
|
||||
|
||||
if ($xace->getElementsByTagNameNS('urn:DAV','protected')->length > 0) {
|
||||
if ($xace->getElementsByTagNameNS('DAV:','protected')->length > 0) {
|
||||
$protected = true;
|
||||
}
|
||||
|
||||
$grants = $xace->getElementsByTagNameNS('urn:DAV','grant');
|
||||
$grants = $xace->getElementsByTagNameNS('DAV:','grant');
|
||||
if ($grants->length < 1) {
|
||||
throw new Sabre_DAV_Exception_NotImplemented('Every {DAV:}ace element must have a {DAV:}grant element. {DAV:}deny is not yet supported');
|
||||
}
|
||||
$grant = $grants->item(0);
|
||||
|
||||
$xprivs = $grant->getElementsByTagNameNS('urn:DAV','privilege');
|
||||
$xprivs = $grant->getElementsByTagNameNS('DAV:','privilege');
|
||||
for($jj=0; $jj<$xprivs->length; $jj++) {
|
||||
|
||||
$xpriv = $xprivs->item($jj);
|
||||
|
|
|
@ -30,7 +30,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
|
|||
public $children = array();
|
||||
|
||||
/**
|
||||
* If coponents are added to this map, they will be automatically mapped
|
||||
* If components are added to this map, they will be automatically mapped
|
||||
* to their respective classes, if parsed by the reader or constructed with
|
||||
* the 'create' method.
|
||||
*
|
||||
|
@ -94,40 +94,54 @@ class Sabre_VObject_Component extends Sabre_VObject_Element {
|
|||
*
|
||||
* This is solely used by the childrenSort method.
|
||||
*
|
||||
* A higher score means the item will be higher in the list
|
||||
* A higher score means the item will be lower in the list.
|
||||
* To avoid score collisions, each "score category" has a reasonable
|
||||
* space to accomodate elements. The $key is added to the $score to
|
||||
* preserve the original relative order of elements.
|
||||
*
|
||||
* @param Sabre_VObject_Node $n
|
||||
* @param int $key
|
||||
* @param Sabre_VObject $array
|
||||
* @return int
|
||||
*/
|
||||
$sortScore = function($n) {
|
||||
|
||||
if ($n instanceof Sabre_VObject_Component) {
|
||||
$sortScore = function($key, $array) {
|
||||
|
||||
if ($array[$key] instanceof Sabre_VObject_Component) {
|
||||
// We want to encode VTIMEZONE first, this is a personal
|
||||
// preference.
|
||||
if ($n->name === 'VTIMEZONE') {
|
||||
return 1;
|
||||
if ($array[$key]->name === 'VTIMEZONE') {
|
||||
$score=300000000;
|
||||
return $score+$key;
|
||||
} else {
|
||||
return 0;
|
||||
$score=400000000;
|
||||
return $score+$key;
|
||||
}
|
||||
} else {
|
||||
// Properties get encoded first
|
||||
// VCARD version 4.0 wants the VERSION property to appear first
|
||||
if ($n->name === 'VERSION') {
|
||||
return 3;
|
||||
} else {
|
||||
return 2;
|
||||
if ($array[$key] instanceof Sabre_VObject_Property) {
|
||||
if ($array[$key]->name === 'VERSION') {
|
||||
$score=100000000;
|
||||
return $score+$key;
|
||||
} else {
|
||||
// All other properties
|
||||
$score=200000000;
|
||||
return $score+$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
next($children);
|
||||
|
||||
};
|
||||
|
||||
usort($this->children, function($a, $b) use ($sortScore) {
|
||||
$tmp = $this->children;
|
||||
uksort($this->children, function($a, $b) use ($sortScore, $tmp) {
|
||||
|
||||
$sA = $sortScore($a);
|
||||
$sB = $sortScore($b);
|
||||
$sA = $sortScore($a, $tmp);
|
||||
$sB = $sortScore($b, $tmp);
|
||||
|
||||
if ($sA === $sB) return 0;
|
||||
|
||||
return ($sA > $sB) ? -1 : 1;
|
||||
return ($sA < $sB) ? -1 : 1;
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue