1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\DAV\Exception\InvalidResourceType; 6*a1a3b679SAndreas Boehleruse Sabre\DAV\Exception\Forbidden; 7*a1a3b679SAndreas Boehleruse Sabre\DAV\IExtendedCollection; 8*a1a3b679SAndreas Boehleruse Sabre\DAV\MkCol; 9*a1a3b679SAndreas Boehler 10*a1a3b679SAndreas Boehler/** 11*a1a3b679SAndreas Boehler * Principals Collection 12*a1a3b679SAndreas Boehler * 13*a1a3b679SAndreas Boehler * This collection represents a list of users. 14*a1a3b679SAndreas Boehler * The users are instances of Sabre\DAVACL\Principal 15*a1a3b679SAndreas Boehler * 16*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 17*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/) 18*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License 19*a1a3b679SAndreas Boehler */ 20*a1a3b679SAndreas Boehlerclass PrincipalCollection extends AbstractPrincipalCollection implements IExtendedCollection, IACL { 21*a1a3b679SAndreas Boehler 22*a1a3b679SAndreas Boehler /** 23*a1a3b679SAndreas Boehler * This method returns a node for a principal. 24*a1a3b679SAndreas Boehler * 25*a1a3b679SAndreas Boehler * The passed array contains principal information, and is guaranteed to 26*a1a3b679SAndreas Boehler * at least contain a uri item. Other properties may or may not be 27*a1a3b679SAndreas Boehler * supplied by the authentication backend. 28*a1a3b679SAndreas Boehler * 29*a1a3b679SAndreas Boehler * @param array $principal 30*a1a3b679SAndreas Boehler * @return \Sabre\DAV\INode 31*a1a3b679SAndreas Boehler */ 32*a1a3b679SAndreas Boehler function getChildForPrincipal(array $principal) { 33*a1a3b679SAndreas Boehler 34*a1a3b679SAndreas Boehler return new Principal($this->principalBackend, $principal); 35*a1a3b679SAndreas Boehler 36*a1a3b679SAndreas Boehler } 37*a1a3b679SAndreas Boehler 38*a1a3b679SAndreas Boehler /** 39*a1a3b679SAndreas Boehler * Creates a new collection. 40*a1a3b679SAndreas Boehler * 41*a1a3b679SAndreas Boehler * This method will receive a MkCol object with all the information about 42*a1a3b679SAndreas Boehler * the new collection that's being created. 43*a1a3b679SAndreas Boehler * 44*a1a3b679SAndreas Boehler * The MkCol object contains information about the resourceType of the new 45*a1a3b679SAndreas Boehler * collection. If you don't support the specified resourceType, you should 46*a1a3b679SAndreas Boehler * throw Exception\InvalidResourceType. 47*a1a3b679SAndreas Boehler * 48*a1a3b679SAndreas Boehler * The object also contains a list of WebDAV properties for the new 49*a1a3b679SAndreas Boehler * collection. 50*a1a3b679SAndreas Boehler * 51*a1a3b679SAndreas Boehler * You should call the handle() method on this object to specify exactly 52*a1a3b679SAndreas Boehler * which properties you are storing. This allows the system to figure out 53*a1a3b679SAndreas Boehler * exactly which properties you didn't store, which in turn allows other 54*a1a3b679SAndreas Boehler * plugins (such as the propertystorage plugin) to handle storing the 55*a1a3b679SAndreas Boehler * property for you. 56*a1a3b679SAndreas Boehler * 57*a1a3b679SAndreas Boehler * @param string $name 58*a1a3b679SAndreas Boehler * @param MkCol $mkCol 59*a1a3b679SAndreas Boehler * @throws Exception\InvalidResourceType 60*a1a3b679SAndreas Boehler * @return void 61*a1a3b679SAndreas Boehler */ 62*a1a3b679SAndreas Boehler function createExtendedCollection($name, MkCol $mkCol) { 63*a1a3b679SAndreas Boehler 64*a1a3b679SAndreas Boehler if (!$mkCol->hasResourceType('{DAV:}principal')) { 65*a1a3b679SAndreas Boehler throw new InvalidResourceType('Only resources of type {DAV:}principal may be created here'); 66*a1a3b679SAndreas Boehler } 67*a1a3b679SAndreas Boehler 68*a1a3b679SAndreas Boehler $this->principalBackend->createPrincipal( 69*a1a3b679SAndreas Boehler $this->principalPrefix . '/' . $name, 70*a1a3b679SAndreas Boehler $mkCol 71*a1a3b679SAndreas Boehler ); 72*a1a3b679SAndreas Boehler 73*a1a3b679SAndreas Boehler } 74*a1a3b679SAndreas Boehler 75*a1a3b679SAndreas Boehler /** 76*a1a3b679SAndreas Boehler * Returns the owner principal 77*a1a3b679SAndreas Boehler * 78*a1a3b679SAndreas Boehler * This must be a url to a principal, or null if there's no owner 79*a1a3b679SAndreas Boehler * 80*a1a3b679SAndreas Boehler * @return string|null 81*a1a3b679SAndreas Boehler */ 82*a1a3b679SAndreas Boehler function getOwner() { 83*a1a3b679SAndreas Boehler return null; 84*a1a3b679SAndreas Boehler } 85*a1a3b679SAndreas Boehler 86*a1a3b679SAndreas Boehler /** 87*a1a3b679SAndreas Boehler * Returns a group principal 88*a1a3b679SAndreas Boehler * 89*a1a3b679SAndreas Boehler * This must be a url to a principal, or null if there's no owner 90*a1a3b679SAndreas Boehler * 91*a1a3b679SAndreas Boehler * @return string|null 92*a1a3b679SAndreas Boehler */ 93*a1a3b679SAndreas Boehler function getGroup() { 94*a1a3b679SAndreas Boehler return null; 95*a1a3b679SAndreas Boehler } 96*a1a3b679SAndreas Boehler 97*a1a3b679SAndreas Boehler /** 98*a1a3b679SAndreas Boehler * Returns a list of ACE's for this node. 99*a1a3b679SAndreas Boehler * 100*a1a3b679SAndreas Boehler * Each ACE has the following properties: 101*a1a3b679SAndreas Boehler * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are 102*a1a3b679SAndreas Boehler * currently the only supported privileges 103*a1a3b679SAndreas Boehler * * 'principal', a url to the principal who owns the node 104*a1a3b679SAndreas Boehler * * 'protected' (optional), indicating that this ACE is not allowed to 105*a1a3b679SAndreas Boehler * be updated. 106*a1a3b679SAndreas Boehler * 107*a1a3b679SAndreas Boehler * @return array 108*a1a3b679SAndreas Boehler */ 109*a1a3b679SAndreas Boehler function getACL() { 110*a1a3b679SAndreas Boehler return [ 111*a1a3b679SAndreas Boehler [ 112*a1a3b679SAndreas Boehler 'principal' => '{DAV:}authenticated', 113*a1a3b679SAndreas Boehler 'privilege' => '{DAV:}read', 114*a1a3b679SAndreas Boehler 'protected' => true, 115*a1a3b679SAndreas Boehler ], 116*a1a3b679SAndreas Boehler ]; 117*a1a3b679SAndreas Boehler } 118*a1a3b679SAndreas Boehler 119*a1a3b679SAndreas Boehler /** 120*a1a3b679SAndreas Boehler * Updates the ACL 121*a1a3b679SAndreas Boehler * 122*a1a3b679SAndreas Boehler * This method will receive a list of new ACE's as an array argument. 123*a1a3b679SAndreas Boehler * 124*a1a3b679SAndreas Boehler * @param array $acl 125*a1a3b679SAndreas Boehler * @return void 126*a1a3b679SAndreas Boehler */ 127*a1a3b679SAndreas Boehler function setACL(array $acl) { 128*a1a3b679SAndreas Boehler 129*a1a3b679SAndreas Boehler throw new Forbidden('Updating ACLs is not allowed on this node'); 130*a1a3b679SAndreas Boehler 131*a1a3b679SAndreas Boehler } 132*a1a3b679SAndreas Boehler 133*a1a3b679SAndreas Boehler /** 134*a1a3b679SAndreas Boehler * Returns the list of supported privileges for this node. 135*a1a3b679SAndreas Boehler * 136*a1a3b679SAndreas Boehler * The returned data structure is a list of nested privileges. 137*a1a3b679SAndreas Boehler * See Sabre\DAVACL\Plugin::getDefaultSupportedPrivilegeSet for a simple 138*a1a3b679SAndreas Boehler * standard structure. 139*a1a3b679SAndreas Boehler * 140*a1a3b679SAndreas Boehler * If null is returned from this method, the default privilege set is used, 141*a1a3b679SAndreas Boehler * which is fine for most common usecases. 142*a1a3b679SAndreas Boehler * 143*a1a3b679SAndreas Boehler * @return array|null 144*a1a3b679SAndreas Boehler */ 145*a1a3b679SAndreas Boehler function getSupportedPrivilegeSet() { 146*a1a3b679SAndreas Boehler 147*a1a3b679SAndreas Boehler return null; 148*a1a3b679SAndreas Boehler 149*a1a3b679SAndreas Boehler } 150*a1a3b679SAndreas Boehler 151*a1a3b679SAndreas Boehler} 152