removes error reporting when checking for app webdav frontends
[tine20] / tine20 / Tinebase / WebDav / Root.php
1 <?php
2 /**
3  * Tine 2.0
4  *
5  * @package     Tinebase
6  * @subpackage  WebDAV
7  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
8  * @author      Lars Kneschke <l.kneschke@metaways.de>
9  * @copyright   Copyright (c) 2011-2014 Metaways Infosystems GmbH (http://www.metaways.de)
10  */
11
12 /**
13  * root of tree for the WebDAV frontend
14  *
15  * This class handles the root of the WebDAV tree
16  *
17  * @package     Tinebase
18  * @subpackage  WebDAV
19  */
20 class Tinebase_WebDav_Root extends \Sabre\DAV\SimpleCollection
21 {
22     public function __construct()
23     {
24         parent::__construct('root', array(
25             new \Sabre\DAV\SimpleCollection('principals', array(
26                 new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_USERS),
27                 new Tinebase_WebDav_PrincipalCollection(new Tinebase_WebDav_PrincipalBackend(), Tinebase_WebDav_PrincipalBackend::PREFIX_GROUPS)
28             ))
29         ));
30         
31         if (Tinebase_Core::getUser()->hasRight('Calendar', Tinebase_Acl_Rights::RUN)) {
32             $this->addChild(
33                 new Calendar_Frontend_WebDAV(\Sabre\CalDAV\Plugin::CALENDAR_ROOT, true)
34             );
35         }
36        
37         if (Tinebase_Core::getUser()->hasRight('Tasks', Tinebase_Acl_Rights::RUN)) {
38             $this->addChild(
39                 new Tasks_Frontend_WebDAV('tasks', true)
40             );
41         }
42
43         if (Tinebase_Core::getUser()->hasRight('Addressbook', Tinebase_Acl_Rights::RUN)) {
44             $this->addChild(
45                 new Addressbook_Frontend_WebDAV(\Sabre\CardDAV\Plugin::ADDRESSBOOK_ROOT, true)
46             );
47         }
48         
49         // main entry point for ownCloud 
50         if (Tinebase_Core::getUser()->hasRight('Filemanager', Tinebase_Acl_Rights::RUN)) {
51             $this->addChild(
52                 new \Sabre\DAV\SimpleCollection(
53                     'remote.php', 
54                     array(new Filemanager_Frontend_WebDAV('webdav'))
55                 )
56             );
57         }
58         
59         // webdav tree
60         $webDAVCollection = new \Sabre\DAV\SimpleCollection('webdav');
61         
62         foreach (Tinebase_Core::getUser()->getApplications() as $application) {
63             $applicationClass = $application->name . '_Frontend_WebDAV';
64             if (@class_exists($applicationClass)) {
65                 $webDAVCollection->addChild(new $applicationClass($application->name));
66             }
67         }
68         
69         $this->addChild($webDAVCollection);
70     }
71 }