1<?php 2 3namespace Sabre\DAVACL\FS; 4 5use Sabre\DAV\Exception\Forbidden; 6use Sabre\DAV\Exception\NotFound; 7use Sabre\DAV\FSExt\Directory as BaseCollection; 8use Sabre\DAVACL\ACLTrait; 9use Sabre\DAVACL\IACL; 10 11/** 12 * This is an ACL-enabled collection. 13 * 14 * @copyright Copyright (C) fruux GmbH (https://fruux.com/) 15 * @author Evert Pot (http://evertpot.com/) 16 * @license http://sabre.io/license/ Modified BSD License 17 */ 18class Collection extends BaseCollection implements IACL { 19 20 use ACLTrait; 21 22 /** 23 * A list of ACL rules. 24 * 25 * @var array 26 */ 27 protected $acl; 28 29 /** 30 * Owner uri, or null for no owner. 31 * 32 * @var string|null 33 */ 34 protected $owner; 35 36 /** 37 * Constructor 38 * 39 * @param string $path on-disk path. 40 * @param array $acl ACL rules. 41 * @param string|null $owner principal owner string. 42 */ 43 function __construct($path, array $acl, $owner = null) { 44 45 parent::__construct($path); 46 $this->acl = $acl; 47 $this->owner = $owner; 48 49 } 50 51 /** 52 * Returns a specific child node, referenced by its name 53 * 54 * This method must throw Sabre\DAV\Exception\NotFound if the node does not 55 * exist. 56 * 57 * @param string $name 58 * @throws NotFound 59 * @return \Sabre\DAV\INode 60 */ 61 function getChild($name) { 62 63 $path = $this->path . '/' . $name; 64 65 if (!file_exists($path)) throw new NotFound('File could not be located'); 66 if ($name == '.' || $name == '..') throw new Forbidden('Permission denied to . and ..'); 67 68 if (is_dir($path)) { 69 70 return new self($path, $this->acl, $this->owner); 71 72 } else { 73 74 return new File($path, $this->acl, $this->owner); 75 76 } 77 78 } 79 80 /** 81 * Returns the owner principal 82 * 83 * This must be a url to a principal, or null if there's no owner 84 * 85 * @return string|null 86 */ 87 function getOwner() { 88 89 return $this->owner; 90 91 } 92 93 /** 94 * Returns a list of ACE's for this node. 95 * 96 * Each ACE has the following properties: 97 * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are 98 * currently the only supported privileges 99 * * 'principal', a url to the principal who owns the node 100 * * 'protected' (optional), indicating that this ACE is not allowed to 101 * be updated. 102 * 103 * @return array 104 */ 105 function getACL() { 106 107 return $this->acl; 108 109 } 110 111} 112