1<?php 2 3namespace SabreForRainLoop\CalDAV\Principal; 4use SabreForRainLoop\DAVACL; 5use SabreForRainLoop\DAV; 6 7/** 8 * ProxyWrite principal 9 * 10 * This class represents a principal group, hosted under the main principal. 11 * This is needed to implement 'Calendar delegation' support. This class is 12 * instantiated by User. 13 * 14 * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/). 15 * @author Evert Pot (http://evertpot.com/) 16 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License 17 */ 18class ProxyWrite implements IProxyWrite { 19 20 /** 21 * Parent principal information 22 * 23 * @var array 24 */ 25 protected $principalInfo; 26 27 /** 28 * Principal Backend 29 * 30 * @var DAVACL\PrincipalBackend\BackendInterface 31 */ 32 protected $principalBackend; 33 34 /** 35 * Creates the object 36 * 37 * Note that you MUST supply the parent principal information. 38 * 39 * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend 40 * @param array $principalInfo 41 */ 42 public function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, array $principalInfo) { 43 44 $this->principalInfo = $principalInfo; 45 $this->principalBackend = $principalBackend; 46 47 } 48 49 /** 50 * Returns this principals name. 51 * 52 * @return string 53 */ 54 public function getName() { 55 56 return 'calendar-proxy-write'; 57 58 } 59 60 /** 61 * Returns the last modification time 62 * 63 * @return null 64 */ 65 public function getLastModified() { 66 67 return null; 68 69 } 70 71 /** 72 * Deletes the current node 73 * 74 * @throws DAV\Exception\Forbidden 75 * @return void 76 */ 77 public function delete() { 78 79 throw new DAV\Exception\Forbidden('Permission denied to delete node'); 80 81 } 82 83 /** 84 * Renames the node 85 * 86 * @throws DAV\Exception\Forbidden 87 * @param string $name The new name 88 * @return void 89 */ 90 public function setName($name) { 91 92 throw new DAV\Exception\Forbidden('Permission denied to rename file'); 93 94 } 95 96 97 /** 98 * Returns a list of alternative urls for a principal 99 * 100 * This can for example be an email address, or ldap url. 101 * 102 * @return array 103 */ 104 public function getAlternateUriSet() { 105 106 return array(); 107 108 } 109 110 /** 111 * Returns the full principal url 112 * 113 * @return string 114 */ 115 public function getPrincipalUrl() { 116 117 return $this->principalInfo['uri'] . '/' . $this->getName(); 118 119 } 120 121 /** 122 * Returns the list of group members 123 * 124 * If this principal is a group, this function should return 125 * all member principal uri's for the group. 126 * 127 * @return array 128 */ 129 public function getGroupMemberSet() { 130 131 return $this->principalBackend->getGroupMemberSet($this->getPrincipalUrl()); 132 133 } 134 135 /** 136 * Returns the list of groups this principal is member of 137 * 138 * If this principal is a member of a (list of) groups, this function 139 * should return a list of principal uri's for it's members. 140 * 141 * @return array 142 */ 143 public function getGroupMembership() { 144 145 return $this->principalBackend->getGroupMembership($this->getPrincipalUrl()); 146 147 } 148 149 /** 150 * Sets a list of group members 151 * 152 * If this principal is a group, this method sets all the group members. 153 * The list of members is always overwritten, never appended to. 154 * 155 * This method should throw an exception if the members could not be set. 156 * 157 * @param array $principals 158 * @return void 159 */ 160 public function setGroupMemberSet(array $principals) { 161 162 $this->principalBackend->setGroupMemberSet($this->getPrincipalUrl(), $principals); 163 164 } 165 166 /** 167 * Returns the displayname 168 * 169 * This should be a human readable name for the principal. 170 * If none is available, return the nodename. 171 * 172 * @return string 173 */ 174 public function getDisplayName() { 175 176 return $this->getName(); 177 178 } 179 180} 181