/usr/share/php/Horde/Dav/Calendar/Backend.php is in php-horde-dav 1.1.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | <?php
/**
* Copyright 2013-2015 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you
* did not receive this file, see http://www.horde.org/licenses/bsd.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package Dav
*/
use Sabre\DAV;
use Sabre\CalDAV\Backend;
/**
* The calendar and task list backend wrapper.
*
* @author Jan Schneider <jan@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/bsd BSD
* @package Dav
*/
class Horde_Dav_Calendar_Backend extends Backend\AbstractBackend
{
/**
* A registry object.
*
* @var Horde_Registry
*/
protected $_registry;
/**
* A storage object.
*
* @var Horde_Dav_Storage_Base
*/
protected $_storage;
/**
* List of available interfaces and the providing applications.
*
* @var array
*/
protected $_interfaces = array();
/**
* Constructor.
*
* @param Horde_Registry $registry A registry object.
* @param Horde_Dav_Storage_Base $storage A storage object.
*/
public function __construct(Horde_Registry $registry, Horde_Dav_Storage_Base $storage)
{
$this->_registry = $registry;
$this->_storage = $storage;
foreach (array('calendar', 'tasks') as $interface) {
try {
$application = $this->_registry->hasInterface($interface);
if ($application) {
$this->_interfaces[$interface] = $application;
}
} catch (Horde_Exception $e) {
}
}
}
/**
* Returns a list of calendars for a principal.
*
* @param string $principalUri
* @return array
*/
public function getCalendarsForUser($principalUri)
{
list($prefix, $user) = DAV\URLUtil::splitPath($principalUri);
if ($prefix != 'principals') {
throw new DAV\Exception\NotFound('Invalid principal prefix path ' . $prefix);
}
$collections = array();
foreach ($this->_interfaces as $interface) {
try {
$collections = array_merge(
$collections,
(array)$this->_registry->callAppMethod(
$interface,
'davGetCollections',
array('args' => array($user))
)
);
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
return $collections;
}
/**
* Creates a new calendar for a principal.
*
* If the creation was a success, an id must be returned that can be used to reference
* this calendar in other methods, such as updateCalendar.
*
* @param string $principalUri
* @param string $calendarUri
* @param array $properties
* @return void
*/
public function createCalendar($principalUri, $calendarUri, array $properties)
{
}
/**
* Delete a calendar and all it's objects
*
* @param mixed $calendarId
* @return void
*/
public function deleteCalendar($calendarId)
{
}
/**
* Returns all calendar objects within a calendar.
*
* @param mixed $calendarId
* @return array
*/
public function getCalendarObjects($calendarId)
{
try {
return $this->_registry->callAppMethod(
$this->_interface($calendarId),
'davGetObjects',
array('args' => array($calendarId))
);
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
/**
* Returns information from a single calendar object, based on it's object
* uri.
*
* @param mixed $calendarId
* @param string $objectUri
* @return array
*/
public function getCalendarObject($calendarId, $objectUri)
{
try {
return $this->_registry->callAppMethod(
$this->_interface($calendarId),
'davGetObject',
array('args' => array($calendarId, $objectUri))
);
} catch (Horde_Exception_NotFound $e) {
return null;
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
/**
* Creates a new calendar object.
*
* @param mixed $calendarId
* @param string $objectUri
* @param string $calendarData
* @return string|null
*/
public function createCalendarObject($calendarId, $objectUri, $calendarData)
{
$this->updateCalendarObject($calendarId, $objectUri, $calendarData);
}
/**
* Updates an existing calendarobject, based on it's uri.
*
* @param mixed $calendarId
* @param string $objectUri
* @param string $calendarData
* @return string|null
*/
public function updateCalendarObject($calendarId, $objectUri, $calendarData)
{
try {
return $this->_registry->callAppMethod(
$this->_interface($calendarId),
'davPutObject',
array('args' => array($calendarId, $objectUri, $calendarData))
);
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
/**
* Deletes an existing calendar object.
*
* @param mixed $calendarId
* @param string $objectUri
* @return void
*/
public function deleteCalendarObject($calendarId, $objectUri)
{
try {
return $this->_registry->callAppMethod(
$this->_interface($calendarId),
'davDeleteObject',
array('args' => array($calendarId, $objectUri))
);
} catch (Horde_Exception $e) {
throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
}
}
/**
* Returns the application that owns a certain calendar or task list.
*
* @param string $calendarId An external calendar or task list id.
*
* @return string The application that owns the calendar or task list.
* @throws Sabre\DAV\Exception if the application cannot be found.
*/
protected function _interface($calendarId)
{
$interface = $this->_storage->getCollectionInterface($calendarId);
if (!$interface || !isset($this->_interfaces[$interface])) {
throw new DAV\Exception(sprintf('No interface found for calendar %s', $calendarId));
}
return $this->_interfaces[$interface];
}
}
|