Esempio n. 1
0
 /**
  * contructor
  * 
  * @param  string|Tinebase_Model_Application  $_application  the current application
  * @param  string                             $_container    the current path
  */
 public function __construct(Tinebase_Model_Container $_container, $_useIdAsName = false)
 {
     parent::__construct($_container, $_useIdAsName);
     $this->_path = '/' . $this->_application->getId() . '/folders/' . $this->_container->type . '/';
     if ($this->_container->type == Tinebase_Model_Container::TYPE_SHARED) {
         $this->_path .= $this->_container->getId();
     } else {
         $this->_path .= Tinebase_Core::getUser()->accountId . '/' . $this->_container->getId();
     }
 }
 /**
  * contructor
  * 
  * @param  string|Tinebase_Model_Application  $_application  the current application
  * @param  string                             $_container    the current path
  */
 public function __construct(Tinebase_Model_Container $_container, $_useIdAsName = false)
 {
     parent::__construct($_container, $_useIdAsName);
     $this->_path = Tinebase_FileSystem::getInstance()->getContainerPath($this->_container);
     // make sure filesystem path exists
     try {
         Tinebase_FileSystem::getInstance()->stat($this->_path);
     } catch (Tinebase_Exception_NotFound $tenf) {
         Tinebase_FileSystem::getInstance()->mkdir($this->_path);
     }
 }
 /**
  * returns the changes happened since the provided syncToken which is the content sequence
  *
  * @param string $syncToken
  * @return array
  */
 public function getChanges($syncToken)
 {
     $result = parent::getChanges($syncToken);
     $newResult = array();
     $backend = Calendar_Controller_Event::getInstance()->getBackend();
     foreach ($result as $action => $value) {
         if (!is_array($value)) {
             $newResult[$action] = $value;
             continue;
         }
         $uids = $backend->getUidOfBaseEvents(array_keys($value));
         $newResult[$action] = array();
         foreach ($uids as $row) {
             $newResult[$action][$row[0]] = $row[0] . $this->_suffix;
         }
     }
     return $newResult;
 }
 /**
  * Returns the list of properties
  *
  * @param array $requestedProperties
  * @return array
  */
 public function getProperties($requestedProperties)
 {
     $ctags = Tinebase_Container::getInstance()->getContentSequence($this->_container);
     $properties = array('{http://calendarserver.org/ns/}getctag' => $ctags, 'id' => $this->_container->getId(), 'uri' => $this->_useIdAsName == true ? $this->_container->getId() : $this->_container->name, '{DAV:}resource-id' => 'urn:uuid:' . $this->_container->getId(), '{DAV:}owner' => new Sabre\DAVACL\Property\Principal(Sabre\DAVACL\Property\Principal::HREF, 'principals/users/' . Tinebase_Core::getUser()->contact_id), '{DAV:}displayname' => $this->_container->name, '{http://apple.com/ns/ical/}calendar-color' => empty($this->_container->color) ? '#000000' : $this->_container->color, '{' . Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')), '{' . Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-data' => new Sabre\CalDAV\Property\SupportedCalendarData(), '{' . Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-description' => 'Calendar ' . $this->_container->name, '{' . Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => Tinebase_WebDav_Container_Abstract::getCalendarVTimezone($this->_application));
     if (!empty(Tinebase_Core::getUser()->accountEmailAddress)) {
         $properties['{' . Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-user-address-set'] = new Sabre\DAV\Property\HrefList(array('mailto:' . Tinebase_Core::getUser()->accountEmailAddress), false);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . print_r($properties, true));
     }
     $response = array();
     foreach ($requestedProperties as $prop) {
         if (isset($properties[$prop])) {
             $response[$prop] = $properties[$prop];
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . print_r($response, true));
     }
     return $response;
 }
 /**
  * test Tinebase_WebDav_Container_Abstract::getCalendarVTimezone
  */
 public function testGetCalendarVTimezone()
 {
     $vTimezone = Tinebase_WebDav_Container_Abstract::getCalendarVTimezone('Calendar');
     $this->assertContains('PRODID:-//tine20.org//Tine 2.0 Calendar', $vTimezone);
     $vTimezone = Tinebase_WebDav_Container_Abstract::getCalendarVTimezone(Tinebase_Application::getInstance()->getApplicationByName('Calendar'));
     $this->assertContains('PRODID:-//tine20.org//Tine 2.0 Calendar', $vTimezone);
 }
 /**
  * Returns the list of properties
  *
  * @param array $requestedProperties
  * @return array
  */
 public function getProperties($requestedProperties)
 {
     $properties = array('{http://calendarserver.org/ns/}getctag' => round(time() / 60), 'id' => 'schedule-inbox', 'uri' => 'schedule-inbox', '{DAV:}resource-id' => 'urn:uuid:schedule-inbox', '{DAV:}owner' => new \Sabre\DAVACL\Property\Principal(Sabre\DAVACL\Property\Principal::HREF, 'principals/users/' . $this->_user->contact_id), '{DAV:}displayname' => 'Schedule Inbox', '{http://apple.com/ns/ical/}calendar-color' => '#666666', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Property\SupportedCalendarComponentSet(array('VEVENT')), '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-data' => new \Sabre\CalDAV\Property\SupportedCalendarData(), '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-description' => 'Calendar schedule inbox', '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-timezone' => Tinebase_WebDav_Container_Abstract::getCalendarVTimezone('Calendar'));
     $defaultCalendarId = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $this->_user->getId());
     if (!empty($defaultCalendarId)) {
         $properties['{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}schedule-default-calendar-URL'] = new \Sabre\DAV\Property\Href('calendars/' . $this->_user->contact_id . '/' . $defaultCalendarId);
     }
     if (!empty(Tinebase_Core::getUser()->accountEmailAddress)) {
         $properties['{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}calendar-user-address-set'] = new \Sabre\DAV\Property\HrefList(array('mailto:' . Tinebase_Core::getUser()->accountEmailAddress), false);
     }
     $response = array();
     foreach ($requestedProperties as $prop) {
         if (isset($properties[$prop])) {
             $response[$prop] = $properties[$prop];
         }
     }
     return $response;
 }