mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
WIP vidoteach/smallpart REST API
This commit is contained in:
parent
7ec41f1ca0
commit
972a05bd56
@ -2067,7 +2067,7 @@ class CalDAV extends HTTP_WebDAV_Server
|
||||
if (is_bool($status)) $status = $status ? '204 No Content' : '400 Something went wrong';
|
||||
|
||||
// check/handle Prefer: return-representation
|
||||
if ($status[0] === '2' || $status === true)
|
||||
if (((string)$status)[0] === '2' || $status === true)
|
||||
{
|
||||
// we can NOT use 204 No content (forbids a body) with return=representation, therefore we need to use 200 Ok instead!
|
||||
if ($handler->check_return_representation($options, $id, $user) && (int)$status == 204)
|
||||
|
@ -156,7 +156,7 @@ abstract class Handler
|
||||
abstract function propfind($path,&$options,&$files,$user);
|
||||
|
||||
/**
|
||||
* Propfind callback, if interator is used
|
||||
* Propfind callback, if iterator is used
|
||||
*
|
||||
* @param string $path
|
||||
* @param array &$filter
|
||||
@ -381,8 +381,13 @@ abstract class Handler
|
||||
//error_log(__METHOD__."(, $id, $user) start ".function_backtrace());
|
||||
if (isset($_SERVER['HTTP_PREFER']) && in_array('return=representation', preg_split('/, ?/', $_SERVER['HTTP_PREFER'])))
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST')
|
||||
// fix path for POST request to collection
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST')
|
||||
{
|
||||
if (!empty($this->new_id))
|
||||
{
|
||||
$options['path'] = rtrim($options['path'], '/').'/'.$this->new_id;
|
||||
}
|
||||
header('Content-Location: '.Api\Framework::getUrl($this->caldav->base_uri.$options['path']));
|
||||
}
|
||||
|
||||
@ -390,7 +395,14 @@ abstract class Handler
|
||||
unset($_SERVER['HTTP_IF_MATCH']);
|
||||
unset($_SERVER['HTTP_IF_NONE_MATCH']);
|
||||
|
||||
if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data']))
|
||||
// add "Accept: application/json" for JSON and set request-method to GET
|
||||
if (empty($_SERVER['HTTP_ACCEPT']) && Api\CalDAV::isJSON())
|
||||
{
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json';
|
||||
}
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
||||
if (($ret = $this->get($options, $id ?: $this->new_id, $user)) && !empty($options['data']))
|
||||
{
|
||||
if (!$this->caldav->use_compression()) header('Content-Length: '.$this->caldav->bytes($options['data']));
|
||||
header('Content-Type: '.$options['mimetype']);
|
||||
|
@ -436,4 +436,18 @@ class JsBase
|
||||
throw new JsParseException("Error parsing $type attribute '$name': ". $e->getMessage(), 422, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a DateTime value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string|null $timezone
|
||||
* @param bool $showWithoutTime true: return H:i set to 00:00
|
||||
* @return Api\DateTime
|
||||
* @throws Api\Exception
|
||||
*/
|
||||
protected static function parseDateTime(string $value, ?string $timezone=null, bool $showWithoutTime=false)
|
||||
{
|
||||
return new Api\DateTime($value, !empty($timezone) ? new \DateTimeZone($timezone) : null);
|
||||
}
|
||||
}
|
@ -571,20 +571,6 @@ class JsCalendar extends JsBase
|
||||
return $duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a DateTime value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string|null $timezone
|
||||
* @param bool $showWithoutTime true: return H:i set to 00:00
|
||||
* @return Api\DateTime
|
||||
* @throws Api\Exception
|
||||
*/
|
||||
protected static function parseDateTime(string $value, ?string $timezone=null, bool $showWithoutTime=false)
|
||||
{
|
||||
return new Api\DateTime($value, !empty($timezone) ? new \DateTimeZone($timezone) : null);
|
||||
}
|
||||
|
||||
protected static function parseStartDuration(array $data)
|
||||
{
|
||||
$parsed = [];
|
||||
|
Loading…
Reference in New Issue
Block a user