public function getPermissions($path)
{
// TODO: OPTIMIZE - once we have ACL this might be done without any server request
$body = '<?xml version="1.0" encoding="UTF-8"?>' . '<dcr:privileges xmlns:dcr="http://www.day.com/jcr/webdav/1.0">' . '<D:href xmlns:D="DAV:">' . $this->addWorkspacePathToUri($path) . '</D:href>' . '</dcr:privileges>';
$valid_permissions = array(SessionInterface::ACTION_ADD_NODE, SessionInterface::ACTION_READ, SessionInterface::ACTION_REMOVE, SessionInterface::ACTION_SET_PROPERTY);
$result = array();
$request = $this->getRequest(Request::REPORT, $this->workspaceUri);
$request->setBody($body);
$dom = $request->executeDom();
foreach ($dom->getElementsByTagNameNS(self::NS_DAV, 'current-user-privilege-set') as $node) {
foreach ($node->getElementsByTagNameNS(self::NS_DAV, 'privilege') as $privilege) {
foreach ($privilege->childNodes as $child) {
$permission = str_replace('dcr:', '', $child->tagName);
if (!in_array($permission, $valid_permissions)) {
throw new RepositoryException("Invalid permission '{$permission}'");
}
$result[] = $permission;
}
}
}
return $result;
}