ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Principal.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAVACL;
4 
5 use Sabre\DAV;
7 
23 class Principal extends DAV\Node implements IPrincipal, DAV\IProperties, IACL {
24 
25  use ACLTrait;
26 
33 
39  protected $principalBackend;
40 
47  function __construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties = []) {
48 
49  if (!isset($principalProperties['uri'])) {
50  throw new DAV\Exception('The principal properties must at least contain the \'uri\' key');
51  }
52  $this->principalBackend = $principalBackend;
53  $this->principalProperties = $principalProperties;
54 
55  }
56 
62  function getPrincipalUrl() {
63 
64  return $this->principalProperties['uri'];
65 
66  }
67 
75  function getAlternateUriSet() {
76 
77  $uris = [];
78  if (isset($this->principalProperties['{DAV:}alternate-URI-set'])) {
79 
80  $uris = $this->principalProperties['{DAV:}alternate-URI-set'];
81 
82  }
83 
84  if (isset($this->principalProperties['{http://sabredav.org/ns}email-address'])) {
85  $uris[] = 'mailto:' . $this->principalProperties['{http://sabredav.org/ns}email-address'];
86  }
87 
88  return array_unique($uris);
89 
90  }
91 
100  function getGroupMemberSet() {
101 
102  return $this->principalBackend->getGroupMemberSet($this->principalProperties['uri']);
103 
104  }
105 
114  function getGroupMembership() {
115 
116  return $this->principalBackend->getGroupMemberShip($this->principalProperties['uri']);
117 
118  }
119 
131  function setGroupMemberSet(array $groupMembers) {
132 
133  $this->principalBackend->setGroupMemberSet($this->principalProperties['uri'], $groupMembers);
134 
135  }
136 
142  function getName() {
143 
144  $uri = $this->principalProperties['uri'];
145  list(, $name) = URLUtil::splitPath($uri);
146  return $name;
147 
148  }
149 
155  function getDisplayName() {
156 
157  if (isset($this->principalProperties['{DAV:}displayname'])) {
158  return $this->principalProperties['{DAV:}displayname'];
159  } else {
160  return $this->getName();
161  }
162 
163  }
164 
171  function getProperties($requestedProperties) {
172 
173  $newProperties = [];
174  foreach ($requestedProperties as $propName) {
175 
176  if (isset($this->principalProperties[$propName])) {
177  $newProperties[$propName] = $this->principalProperties[$propName];
178  }
179 
180  }
181 
182  return $newProperties;
183 
184  }
185 
198  function propPatch(DAV\PropPatch $propPatch) {
199 
200  return $this->principalBackend->updatePrincipal(
201  $this->principalProperties['uri'],
202  $propPatch
203  );
204 
205  }
206 
214  function getOwner() {
215 
216  return $this->principalProperties['uri'];
217 
218 
219  }
220 
221 }
This class represents a set of properties that are going to be updated.
Definition: PropPatch.php:20
getOwner()
Returns the owner principal.
Definition: Principal.php:214
getGroupMembership()
Returns the list of groups this principal is member of.
Definition: Principal.php:114
Principal class.
Definition: Principal.php:23
propPatch(DAV\PropPatch $propPatch)
Updates properties on this node.
Definition: Principal.php:198
setGroupMemberSet(array $groupMembers)
Sets a list of group members.
Definition: Principal.php:131
getProperties($requestedProperties)
Returns a list of properties.
Definition: Principal.php:171
__construct(PrincipalBackend\BackendInterface $principalBackend, array $principalProperties=[])
Creates the principal object.
Definition: Principal.php:47
getName()
Returns this principals name.
Definition: Principal.php:142
Main Exception class.
Definition: Exception.php:18
ACL-enabled node.
Definition: IACL.php:16
getPrincipalUrl()
Returns the full principal url.
Definition: Principal.php:62
getAlternateUriSet()
Returns a list of alternative urls for a principal.
Definition: Principal.php:75
Node class.
Definition: Node.php:14
getDisplayName()
Returns the name of the user.
Definition: Principal.php:155
getGroupMemberSet()
Returns the list of group members.
Definition: Principal.php:100
IPrincipal interface.
Definition: IPrincipal.php:16
IProperties interface.
Definition: IProperties.php:14
static splitPath($path)
Returns the &#39;dirname&#39; and &#39;basename&#39; for a path.
Definition: URLUtil.php:83