*
* @var array
*/
- private $_cache = array();
+ protected $_cache = array();
/**
* HTTP client object.
*
* @var Horde_Http_Client
*/
- private $_client;
+ protected $_client;
/**
* A list of DAV support levels.
*
* @var array
*/
- private $_davSupport;
+ protected $_davSupport;
+
+ /**
+ * The Horde_Perms permissions mask matching the CalDAV ACL.
+ *
+ * @var integer
+ */
+ protected $_permission;
/**
* Selects a calendar as the currently opened calendar.
if ($component->getType() == 'vEvent') {
$event = new Kronolith_Event_Ical($this);
$event->status = Kronolith::STATUS_FREE;
+ $event->permission = $this->_permission;
$event->fromiCalendar($component);
// Force string so JSON encoding is consistent across drivers.
$event->id = $id ? $id : 'ical' . $i;
$xml->writeAttribute('xmlns', 'DAV:');
$xml->startElement('prop');
$xml->writeElement('resourcetype');
+ $xml->writeElement('current-user-privilege-set');
$xml->endDocument();
list(, $properties) = $this->_request('PROPFIND', $url, $xml,
array('Depth' => 0));
throw new Kronolith_Exception(_("The remote server URL does not point to a CalDAV directory."));
}
+ /* Read ACLs. */
+ if ($properties->response->propstat->prop->{'current-user-privilege-set'}) {
+ foreach ($properties->response->propstat->prop->{'current-user-privilege-set'}->privilege as $privilege) {
+ if ($privilege->all) {
+ $this->_permission = Horde_Perms::ALL;
+ break;
+ } elseif ($privilege->read) {
+ /* GET access. */
+ $this->_permission |= Horde_Perms::SHOW;
+ $this->_permission |= Horde_Perms::READ;
+ } elseif ($privilege->write || $privilege->{'write-content'}) {
+ /* PUT access. */
+ $this->_permission |= Horde_Perms::EDIT;
+ } elseif ($privilege->unbind) {
+ /* DELETE access. */
+ $this->_permission |= Horde_Perms::DELETE;
+ }
+ }
+ }
+
return true;
}
public $calendarType = 'remote';
/**
+ * The Horde_Perms permissions mask matching the CalDAV ACL of this event's
+ * calendar.
+ *
+ * @var integer
+ */
+ public $permission;
+
+ /**
* Imports a backend specific event object.
*
* @param Horde_Icalendar_Vevent Backend specific event object that this
/**
* Encapsulates permissions checking.
*
+ * $user is being ignored.
+ *
* @param integer $permission The permission to check for.
* @param string $user The user to check permissions for.
*
*/
public function hasPermission($permission, $user = null)
{
+ if (!is_null($this->permission)) {
+ return $this->permission & $permission;
+ }
+
switch ($permission) {
case Horde_Perms::SHOW:
case Horde_Perms::READ: