]> git.mxchange.org Git - friendica-addons.git/blob - dav/common/dav_carddav_root.inc.php
Bug fix for Twitter
[friendica-addons.git] / dav / common / dav_carddav_root.inc.php
1 <?php
2
3 class Sabre_CardDAV_AddressBookRootFriendica extends Sabre_DAVACL_AbstractPrincipalCollection {
4
5         /**
6          * Principal Backend
7          *
8          * @var Sabre_DAVACL_IPrincipalBackend
9          */
10         protected $principalBackend;
11
12         /**
13          * CardDAV backend
14          *
15          * @var array|Sabre_CardDAV_Backend_Abstract[]
16          */
17         protected $carddavBackends;
18
19         /**
20          * Constructor
21          *
22          * This constructor needs both a principal and a carddav backend.
23          *
24          * By default this class will show a list of addressbook collections for
25          * principals in the 'principals' collection. If your main principals are
26          * actually located in a different path, use the $principalPrefix argument
27          * to override this.
28          *
29          * @param Sabre_DAVACL_IPrincipalBackend $principalBackend
30          * @param array|Sabre_CardDAV_Backend_Abstract[] $carddavBackends
31          * @param string $principalPrefix
32          */
33         public function __construct(Sabre_DAVACL_IPrincipalBackend $principalBackend, $carddavBackends, $principalPrefix = 'principals/users') {
34
35                 $this->carddavBackends = $carddavBackends;
36                 parent::__construct($principalBackend, $principalPrefix);
37
38         }
39
40         /**
41          * Returns the name of the node
42          *
43          * @return string
44          */
45         public function getName() {
46                 return Sabre_CardDAV_Plugin::ADDRESSBOOK_ROOT;
47         }
48
49         /**
50          * This method returns a node for a principal.
51          *
52          * The passed array contains principal information, and is guaranteed to
53          * at least contain a uri item. Other properties may or may not be
54          * supplied by the authentication backend.
55          *
56          * @param array $principal
57          * @return Sabre_DAVACL_IPrincipal
58          */
59         public function getChildForPrincipal(array $principal) {
60                 return new Sabre_CardDAV_UserAddressBooksMultiBackend($this->carddavBackends, $principal['uri']);
61
62         }
63
64 }