Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 9 May 2016 11:58:32 +0000 (13:58 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 9 May 2016 11:58:32 +0000 (13:58 +0200)
1  2 
tests/tine20/Calendar/Frontend/WebDAV/ContainerTest.php
tine20/Calendar/Frontend/WebDAV/Container.php

@@@ -53,10 -53,7 +53,10 @@@ class Calendar_Frontend_WebDAV_Containe
          )));
          
          Tinebase_Container::getInstance()->addGrants($this->objects['initialContainer'], Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, Tinebase_Core::getUser()->accountPrimaryGroup, array(Tinebase_Model_Grants::GRANT_READ));
 -        
 +
 +        // rw cal agent
 +        $_SERVER['HTTP_USER_AGENT'] = 'CalendarStore/5.0 (1127); iCal/5.0 (1535); Mac OS X/10.7.1 (11B26)';
 +
          // must be defined for Calendar/Frontend/WebDAV/Event.php
          $_SERVER['REQUEST_URI'] = 'foobar';
      }
       */
      public function testCreateFile()
      {
 -        $GLOBALS['_SERVER']['HTTP_USER_AGENT'] = 'FooBar User Agent';
 -        
          $vcalendarStream = $this->_getVCalendar(dirname(__FILE__) . '/../../Import/files/lightning.ics');
          
          $container = new Calendar_Frontend_WebDAV_Container($this->objects['initialContainer']);
          $container = new Calendar_Frontend_WebDAV_Container($this->objects['initialContainer']);
          
          $shares = $container->getShares();
-         
          $this->assertEquals(3, count($shares));
+         $this->assertEquals('urn:uuid:anyone', $shares[0]['href']);
+         $this->assertEquals('urn:uuid:' . Tinebase_Core::getUser()->contact_id, $shares[2]['href']);
      }
      
      /**
       */
      public function testGetSharesWithoutRights()
      {
 -        $jmcblack = array_value('jmcblack', Zend_Registry::get('personas'));
 +        $jmcblack = Tinebase_Helper::array_value('jmcblack', Zend_Registry::get('personas'));
          $jmcblacksCalId = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $jmcblack->getId());
          $jmcblacksCal = Tinebase_Container::getInstance()->get($jmcblacksCalId);
          
@@@ -32,9 -32,7 +32,9 @@@ class Calendar_Frontend_WebDAV_Containe
       * @var array
       */
      protected $_calendarQueryCache = null;
 -    
 +
 +
 +
      /**
       * (non-PHPdoc)
       * @see Sabre\DAV\Collection::getChild()
          
          return $children;
      }
 -    
 +
      /**
       * Returns the list of properties
       *
          
          $properties = array(
              '{http://calendarserver.org/ns/}getctag' => $ctags,
 +            '{DAV:}sync-token'  => Tinebase_WebDav_Plugin_SyncToken::SYNCTOKEN_PREFIX . $ctags,
              'id'                => $this->_container->getId(),
              'uri'               => $this->_useIdAsName == true ? $this->_container->getId() : $this->_container->name,
              '{DAV:}resource-id' => 'urn:uuid:' . $this->_container->getId(),
       */
      protected function _getMaxPeriodFrom()
      {
 +        //if the client does support sync tokens and the plugin Tinebase_WebDav_Plugin_SyncToken is active, allow to filter for all calendar events => return 100 years
 +        if (Calendar_Convert_Event_VCalendar_Factory::supportsSyncToken($_SERVER['HTTP_USER_AGENT'])) {
 +            return 100;
 +        }
          return Calendar_Config::getInstance()->get(Calendar_Config::MAX_FILTER_PERIOD_CALDAV, 2);
      }
      
      /**
       * (non-PHPdoc)
+      *
+      * changed href from URI format /path/to/targetid to urn:uuid:id format due to el capitano ical client
+      * see:
+      * https://service.metaways.net/Ticket/Display.html?id=145985
+      *
       * @see \Sabre\CalDAV\IShareableCalendar::getShares()
       */
      public function getShares()
              
              switch ($grant->account_type) {
                  case 'anyone':
-                     $href       = '/principals/groups/anyone';
+                     // was: '/principals/groups/anyone'
+                     $href       = 'urn:uuid:anyone';
                      $commonName = 'Anyone';
                      break;
                  
                      } catch (Tinebase_Exception_NotFound $tenf) {
                          continue;
                      }
-                      
-                     $href       = '/principals/groups/' . $list->list_id;
+                     // was: '/principals/groups/'
+                     $href       = 'urn:uuid:' . $list->list_id;
                      $commonName = $list->name;
                      
                      break;
                      
                  case 'user':
+                     if ((string)$this->_container->owner_id === (string)$grant->account_id) {
+                         continue;
+                     }
                      try {
                          $contact = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountId', $grant->account_id);
                      } catch (Tinebase_Exception_NotFound $tenf) {
                          continue;
                      }
-                      
-                     $href       = '/principals/users/' . $contact->contact_id;
+                     // was: '/principals/users/'
+                     $href       = 'urn:uuid:' . $contact->contact_id;
                      $commonName = $contact->accountDisplayName;
                      break;
              }
      {
          
      }
 +
 +    /**
 +     * indicates whether the concrete class supports sync-token
 +     *
 +     * @return bool
 +     */
 +    public function supportsSyncToken()
 +    {
 +        return true;
 +    }
  }