Blame view

sources/apps/contacts/appinfo/remote.php 2.71 KB
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
3
4
5
  <?php
  /**
   * ownCloud - Addressbook
   *
   * @author Jakob Sack
6d9380f96   Cédric Dupont   Update sources OC...
6
   * @author Thomas Tanghus
d1bafeea1   Kload   [fix] Upgrade to ...
7
   * @copyright 2011 Jakob Sack mail@jakobsack.de
6d9380f96   Cédric Dupont   Update sources OC...
8
   * @copyright 2011-2014 Thomas Tanghus (thomas@tanghus.net)
d1bafeea1   Kload   [fix] Upgrade to ...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
   * License as published by the Free Software Foundation; either
   * version 3 of the License, or any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
   *
   * You should have received a copy of the GNU Affero General Public
   * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
   *
   */
  
  OCP\App::checkAppEnabled('contacts');
6d9380f96   Cédric Dupont   Update sources OC...
26
  if (substr(OCP\Util::getRequestUri(), 0, strlen(OC_App::getAppWebPath('contacts').'/carddav.php'))
d1bafeea1   Kload   [fix] Upgrade to ...
27
28
29
30
31
32
  	=== OC_App::getAppWebPath('contacts').'/carddav.php'
  ) {
  	$baseuri = OC_App::getAppWebPath('contacts').'/carddav.php';
  }
  
  // only need authentication apps
6d9380f96   Cédric Dupont   Update sources OC...
33
  $RUNTIME_APPTYPES = array('authentication');
d1bafeea1   Kload   [fix] Upgrade to ...
34
35
36
37
38
39
40
41
  OC_App::loadApps($RUNTIME_APPTYPES);
  
  // Backends
  $authBackend = new OC_Connector_Sabre_Auth();
  $principalBackend = new OC_Connector_Sabre_Principal();
  
  $addressbookbackends = array();
  $addressbookbackends[] = new OCA\Contacts\Backend\Database(\OCP\User::getUser());
6d9380f96   Cédric Dupont   Update sources OC...
42
43
44
45
46
  $backends = array('local', 'shared');
  if (\OCP\Config::getAppValue('contacts', 'backend_ldap', "false") === "true") {
  	$backends[] = 'ldap';
  }
  $carddavBackend = new OCA\Contacts\CardDAV\Backend($backends);
d1bafeea1   Kload   [fix] Upgrade to ...
47
48
49
  $requestBackend = new OC_Connector_Sabre_Request();
  
  // Root nodes
6d9380f96   Cédric Dupont   Update sources OC...
50
  $principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
d1bafeea1   Kload   [fix] Upgrade to ...
51
52
53
54
55
56
57
58
  $principalCollection->disableListing = true; // Disable listing
  
  $addressBookRoot = new OCA\Contacts\CardDAV\AddressBookRoot($principalBackend, $carddavBackend);
  $addressBookRoot->disableListing = true; // Disable listing
  
  $nodes = array(
  	$principalCollection,
  	$addressBookRoot,
6d9380f96   Cédric Dupont   Update sources OC...
59
  );
d1bafeea1   Kload   [fix] Upgrade to ...
60
61
  
  // Fire up server
6d9380f96   Cédric Dupont   Update sources OC...
62
  $server = new \Sabre\DAV\Server($nodes);
d1bafeea1   Kload   [fix] Upgrade to ...
63
64
65
  $server->httpRequest = $requestBackend;
  $server->setBaseUri($baseuri);
  // Add plugins
6d9380f96   Cédric Dupont   Update sources OC...
66
  $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud'));
d1bafeea1   Kload   [fix] Upgrade to ...
67
  $server->addPlugin(new OCA\Contacts\CardDAV\Plugin());
6d9380f96   Cédric Dupont   Update sources OC...
68
69
70
71
  $server->addPlugin(new \Sabre\DAVACL\Plugin());
  $server->addPlugin(new \Sabre\DAV\Browser\Plugin(false)); // Show something in the Browser, but no upload
  $server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
  $server->addPlugin(new OC_Connector_Sabre_ExceptionLoggerPlugin('carddav'));
d1bafeea1   Kload   [fix] Upgrade to ...
72

6d9380f96   Cédric Dupont   Update sources OC...
73
  if (defined('DEBUG') && DEBUG) {
d1bafeea1   Kload   [fix] Upgrade to ...
74
75
  	$server->debugExceptions = true;
  }
6d9380f96   Cédric Dupont   Update sources OC...
76

d1bafeea1   Kload   [fix] Upgrade to ...
77
78
  // And off we go!
  $server->exec();