0012216: Caldav Directory calendars not found
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 23 Sep 2016 08:51:18 +0000 (10:51 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 27 Sep 2016 12:45:38 +0000 (14:45 +0200)
* don't forget the braces in ternary operator!

see https://en.wikipedia.org/wiki/%3F:#PHP

https://forge.tine20.org/view.php?id=12216

Change-Id: I39051782a06c233c2d54d423bf8d208b081e4afc
Reviewed-on: http://gerrit.tine20.com/customers/3609
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Tinebase/WebDav/RootTest.php
tine20/Tinebase/WebDav/Collection/AbstractContainerTree.php

index 02a0380..e9731a0 100644 (file)
@@ -147,4 +147,14 @@ class Tinebase_WebDav_RootTest extends TestCase
         
         return $this->_webdavTree;
     }
+
+    /**
+     * @see 0012216: Caldav Directory calendars not found
+     */
+    public function testCalendarRoot()
+    {
+        $calendarRoot = new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT, true);
+        $children = $calendarRoot->getChildren();
+        $this->assertTrue(count($children) > 0 && $children[0] instanceof Calendar_Frontend_WebDAV);
+    }
 }
index 058d812..a2bcafc 100644 (file)
@@ -268,7 +268,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
      *
      * @return \Sabre\DAV\INode[]
      */
-    function getChildren()
+    public function getChildren()
     {
         $children = array();
         
@@ -280,7 +280,11 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                 
                 if ($this->_hasPersonalFolders) {
                     $children[] = $this->getChild(
-                        $this->_useIdAsName ? Tinebase_Core::getUser()->contact_id : $this->_useLoginAsFolderName() ? Tinebase_Core::getUser()->accountLoginName : Tinebase_Core::getUser()->accountDisplayName
+                        $this->_useIdAsName ?
+                            Tinebase_Core::getUser()->contact_id :
+                            ($this->_useLoginAsFolderName() ?
+                                Tinebase_Core::getUser()->accountLoginName :
+                                Tinebase_Core::getUser()->accountDisplayName)
                     );
                     
                     $otherUsers = Tinebase_Container::getInstance()->getOtherUsers(Tinebase_Core::getUser(), $this->_getApplicationName(), array(
@@ -291,7 +295,9 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                     foreach ($otherUsers as $user) {
                         if ($user->contact_id && $user->visibility === Tinebase_Model_User::VISIBILITY_DISPLAYED) {
                             try {
-                                $folderId = $this->_useIdAsName ? $user->contact_id : $this->_useLoginAsFolderName() ? $user->accountLoginName : $user->accountDisplayName;
+                                $folderId = $this->_useIdAsName ?
+                                    $user->contact_id :
+                                    ($this->_useLoginAsFolderName() ? $user->accountLoginName : $user->accountDisplayName);
 
                                 $children[] = $this->getChild($folderId);
                             } catch (\Sabre\DAV\Exception\NotFound $sdavenf) {
@@ -536,7 +542,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
                             $user = $this->_getUser(Tinebase_Helper::array_value(1, $this->_getPathParts()));
                             $contact = Addressbook_Controller_Contact::getInstance()->get($user->contact_id);
                         } catch (Tinebase_Exception_NotFound $tenf) {
-                            continue;
+                            continue 2;
                         }
                         
                         $response[$property] = $contact->n_fileas;
@@ -742,7 +748,7 @@ abstract class Tinebase_WebDav_Collection_AbstractContainerTree extends \Sabre\D
 
     protected function _getUser($_id)
     {
-        $classCacheId = ($this->_useIdAsName ? 'contact_id' : $this->_useLoginAsFolderName() ? 'accountLoginName' : 'accountDisplayName') . $_id;
+        $classCacheId = ($this->_useIdAsName ? 'contact_id' : ($this->_useLoginAsFolderName() ? 'accountLoginName' : 'accountDisplayName')) . $_id;
 
         if (isset(self::$_classCache[__FUNCTION__][$classCacheId])) {
             return self::$_classCache[__FUNCTION__][$classCacheId];