aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAVACL/PrincipalBackend
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAVACL/PrincipalBackend
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/DAVACL/PrincipalBackend')
-rw-r--r--vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php17
-rw-r--r--vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php41
-rw-r--r--vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php12
-rw-r--r--vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php209
4 files changed, 146 insertions, 133 deletions
diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php
index 9bf9ba445..03a9c4bad 100644
--- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php
+++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/AbstractBackend.php
@@ -1,9 +1,11 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL\PrincipalBackend;
/**
- * Abstract Principal Backend
+ * Abstract Principal Backend.
*
* Currently this class has no function. It's here for consistency and so we
* have a non-bc-breaking way to add a default generic implementation to
@@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-abstract class AbstractBackend implements BackendInterface {
-
+abstract class AbstractBackend implements BackendInterface
+{
/**
* Finds a principal by its URI.
*
@@ -30,13 +32,14 @@ abstract class AbstractBackend implements BackendInterface {
*
* @param string $uri
* @param string $principalPrefix
+ *
* @return string
*/
- function findByUri($uri, $principalPrefix) {
-
+ public function findByUri($uri, $principalPrefix)
+ {
// Note that the default implementation here is a bit slow and could
// likely be optimized.
- if (substr($uri, 0, 7) !== 'mailto:') {
+ if ('mailto:' !== substr($uri, 0, 7)) {
return;
}
$result = $this->searchPrincipals(
@@ -47,7 +50,5 @@ abstract class AbstractBackend implements BackendInterface {
if ($result) {
return $result[0];
}
-
}
-
}
diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php
index 40b6e33ea..40ac272b5 100644
--- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php
+++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/BackendInterface.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL\PrincipalBackend;
/**
@@ -13,8 +15,8 @@ namespace Sabre\DAVACL\PrincipalBackend;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface BackendInterface {
-
+interface BackendInterface
+{
/**
* Returns a list of principals based on a prefix.
*
@@ -29,9 +31,10 @@ interface BackendInterface {
* you have an email address, use this property.
*
* @param string $prefixPath
+ *
* @return array
*/
- function getPrincipalsByPrefix($prefixPath);
+ public function getPrincipalsByPrefix($prefixPath);
/**
* Returns a specific principal, specified by it's path.
@@ -39,9 +42,10 @@ interface BackendInterface {
* getPrincipalsByPrefix.
*
* @param string $path
+ *
* @return array
*/
- function getPrincipalByPath($path);
+ public function getPrincipalByPath($path);
/**
* Updates one ore more webdav properties on a principal.
@@ -55,11 +59,10 @@ interface BackendInterface {
*
* Read the PropPatch documentation for more info and examples.
*
- * @param string $path
+ * @param string $path
* @param \Sabre\DAV\PropPatch $propPatch
- * @return void
*/
- function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch);
+ public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch);
/**
* This method is used to search for principals matching a set of
@@ -86,11 +89,12 @@ interface BackendInterface {
* from working.
*
* @param string $prefixPath
- * @param array $searchProperties
+ * @param array $searchProperties
* @param string $test
+ *
* @return array
*/
- function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof');
+ public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof');
/**
* Finds a principal by its URI.
@@ -107,25 +111,28 @@ interface BackendInterface {
*
* @param string $uri
* @param string $principalPrefix
+ *
* @return string
*/
- function findByUri($uri, $principalPrefix);
+ public function findByUri($uri, $principalPrefix);
/**
- * Returns the list of members for a group-principal
+ * Returns the list of members for a group-principal.
*
* @param string $principal
+ *
* @return array
*/
- function getGroupMemberSet($principal);
+ public function getGroupMemberSet($principal);
/**
- * Returns the list of groups a principal is a member of
+ * Returns the list of groups a principal is a member of.
*
* @param string $principal
+ *
* @return array
*/
- function getGroupMembership($principal);
+ public function getGroupMembership($principal);
/**
* Updates the list of group members for a group principal.
@@ -133,9 +140,7 @@ interface BackendInterface {
* The principals should be passed as a list of uri's.
*
* @param string $principal
- * @param array $members
- * @return void
+ * @param array $members
*/
- function setGroupMemberSet($principal, array $members);
-
+ public function setGroupMemberSet($principal, array $members);
}
diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php
index e354a697d..ee418e49b 100644
--- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php
+++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/CreatePrincipalSupport.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL\PrincipalBackend;
use Sabre\DAV\MkCol;
@@ -12,8 +14,8 @@ use Sabre\DAV\MkCol;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface CreatePrincipalSupport extends BackendInterface {
-
+interface CreatePrincipalSupport extends BackendInterface
+{
/**
* Creates a new principal.
*
@@ -22,9 +24,7 @@ interface CreatePrincipalSupport extends BackendInterface {
* of the principal.
*
* @param string $path
- * @param MkCol $mkCol
- * @return void
+ * @param MkCol $mkCol
*/
- function createPrincipal($path, MkCol $mkCol);
-
+ public function createPrincipal($path, MkCol $mkCol);
}
diff --git a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
index eb0df888b..350ecb145 100644
--- a/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
+++ b/vendor/sabre/dav/lib/DAVACL/PrincipalBackend/PDO.php
@@ -1,13 +1,15 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL\PrincipalBackend;
use Sabre\DAV;
use Sabre\DAV\MkCol;
-use Sabre\HTTP\URLUtil;
+use Sabre\Uri;
/**
- * PDO principal backend
+ * PDO principal backend.
*
*
* This backend assumes all principals are in a single collection. The default collection
@@ -17,44 +19,43 @@ use Sabre\HTTP\URLUtil;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class PDO extends AbstractBackend implements CreatePrincipalSupport {
-
+class PDO extends AbstractBackend implements CreatePrincipalSupport
+{
/**
- * PDO table name for 'principals'
+ * PDO table name for 'principals'.
*
* @var string
*/
public $tableName = 'principals';
/**
- * PDO table name for 'group members'
+ * PDO table name for 'group members'.
*
* @var string
*/
public $groupMembersTableName = 'groupmembers';
/**
- * pdo
+ * pdo.
*
* @var PDO
*/
protected $pdo;
/**
- * A list of additional fields to support
+ * A list of additional fields to support.
*
* @var array
*/
protected $fieldMap = [
-
- /**
+ /*
* This property can be used to display the users' real name.
*/
'{DAV:}displayname' => [
'dbField' => 'displayname',
],
- /**
+ /*
* This is the users' primary email-address.
*/
'{http://sabredav.org/ns}email-address' => [
@@ -67,10 +68,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
*
* @param \PDO $pdo
*/
- function __construct(\PDO $pdo) {
-
+ public function __construct(\PDO $pdo)
+ {
$this->pdo = $pdo;
-
}
/**
@@ -87,10 +87,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
* you have an email address, use this property.
*
* @param string $prefixPath
+ *
* @return array
*/
- function getPrincipalsByPrefix($prefixPath) {
-
+ public function getPrincipalsByPrefix($prefixPath)
+ {
$fields = [
'uri',
];
@@ -98,15 +99,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
foreach ($this->fieldMap as $key => $value) {
$fields[] = $value['dbField'];
}
- $result = $this->pdo->query('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName);
+ $result = $this->pdo->query('SELECT '.implode(',', $fields).' FROM '.$this->tableName);
$principals = [];
while ($row = $result->fetch(\PDO::FETCH_ASSOC)) {
-
// Checking if the principal is in the prefix
- list($rowPrefix) = URLUtil::splitPath($row['uri']);
- if ($rowPrefix !== $prefixPath) continue;
+ list($rowPrefix) = Uri\split($row['uri']);
+ if ($rowPrefix !== $prefixPath) {
+ continue;
+ }
$principal = [
'uri' => $row['uri'],
@@ -117,11 +119,9 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
}
}
$principals[] = $principal;
-
}
return $principals;
-
}
/**
@@ -130,10 +130,11 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
* getPrincipalsByPrefix.
*
* @param string $path
+ *
* @return array
*/
- function getPrincipalByPath($path) {
-
+ public function getPrincipalByPath($path)
+ {
$fields = [
'id',
'uri',
@@ -142,14 +143,16 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
foreach ($this->fieldMap as $key => $value) {
$fields[] = $value['dbField'];
}
- $stmt = $this->pdo->prepare('SELECT ' . implode(',', $fields) . ' FROM ' . $this->tableName . ' WHERE uri = ?');
+ $stmt = $this->pdo->prepare('SELECT '.implode(',', $fields).' FROM '.$this->tableName.' WHERE uri = ?');
$stmt->execute([$path]);
$row = $stmt->fetch(\PDO::FETCH_ASSOC);
- if (!$row) return;
+ if (!$row) {
+ return;
+ }
$principal = [
- 'id' => $row['id'],
+ 'id' => $row['id'],
'uri' => $row['uri'],
];
foreach ($this->fieldMap as $key => $value) {
@@ -157,8 +160,8 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
$principal[$key] = $row[$value['dbField']];
}
}
- return $principal;
+ return $principal;
}
/**
@@ -173,41 +176,36 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
*
* Read the PropPatch documentation for more info and examples.
*
- * @param string $path
+ * @param string $path
* @param DAV\PropPatch $propPatch
*/
- function updatePrincipal($path, DAV\PropPatch $propPatch) {
-
- $propPatch->handle(array_keys($this->fieldMap), function($properties) use ($path) {
-
- $query = "UPDATE " . $this->tableName . " SET ";
+ public function updatePrincipal($path, DAV\PropPatch $propPatch)
+ {
+ $propPatch->handle(array_keys($this->fieldMap), function ($properties) use ($path) {
+ $query = 'UPDATE '.$this->tableName.' SET ';
$first = true;
$values = [];
foreach ($properties as $key => $value) {
-
$dbField = $this->fieldMap[$key]['dbField'];
if (!$first) {
$query .= ', ';
}
$first = false;
- $query .= $dbField . ' = :' . $dbField;
+ $query .= $dbField.' = :'.$dbField;
$values[$dbField] = $value;
-
}
- $query .= " WHERE uri = :uri";
+ $query .= ' WHERE uri = :uri';
$values['uri'] = $path;
$stmt = $this->pdo->prepare($query);
$stmt->execute($values);
return true;
-
});
-
}
/**
@@ -235,48 +233,52 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
* from working.
*
* @param string $prefixPath
- * @param array $searchProperties
+ * @param array $searchProperties
* @param string $test
+ *
* @return array
*/
- function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
- if (count($searchProperties) == 0) return []; //No criteria
+ public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
+ {
+ if (0 == count($searchProperties)) {
+ return [];
+ } //No criteria
- $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE ';
+ $query = 'SELECT uri FROM '.$this->tableName.' WHERE ';
$values = [];
foreach ($searchProperties as $property => $value) {
switch ($property) {
- case '{DAV:}displayname' :
- $column = "displayname";
+ case '{DAV:}displayname':
+ $column = 'displayname';
break;
- case '{http://sabredav.org/ns}email-address' :
- $column = "email";
+ case '{http://sabredav.org/ns}email-address':
+ $column = 'email';
break;
- default :
+ default:
// Unsupported property
return [];
}
- if (count($values) > 0) $query .= (strcmp($test, "anyof") == 0 ? " OR " : " AND ");
- $query .= 'lower(' . $column . ') LIKE lower(?)';
- $values[] = '%' . $value . '%';
-
+ if (count($values) > 0) {
+ $query .= (0 == strcmp($test, 'anyof') ? ' OR ' : ' AND ');
+ }
+ $query .= 'lower('.$column.') LIKE lower(?)';
+ $values[] = '%'.$value.'%';
}
$stmt = $this->pdo->prepare($query);
$stmt->execute($values);
$principals = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
-
// Checking if the principal is in the prefix
- list($rowPrefix) = URLUtil::splitPath($row['uri']);
- if ($rowPrefix !== $prefixPath) continue;
+ list($rowPrefix) = Uri\split($row['uri']);
+ if ($rowPrefix !== $prefixPath) {
+ continue;
+ }
$principals[] = $row['uri'];
-
}
return $principals;
-
}
/**
@@ -294,26 +296,32 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
*
* @param string $uri
* @param string $principalPrefix
+ *
* @return string
*/
- function findByUri($uri, $principalPrefix) {
+ public function findByUri($uri, $principalPrefix)
+ {
$value = null;
$scheme = null;
- list($scheme, $value) = explode(":", $uri, 2);
- if (empty($value)) return null;
+ list($scheme, $value) = explode(':', $uri, 2);
+ if (empty($value)) {
+ return null;
+ }
$uri = null;
- switch ($scheme){
- case "mailto":
- $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE lower(email)=lower(?)';
+ switch ($scheme) {
+ case 'mailto':
+ $query = 'SELECT uri FROM '.$this->tableName.' WHERE lower(email)=lower(?)';
$stmt = $this->pdo->prepare($query);
$stmt->execute([$value]);
-
+
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
// Checking if the principal is in the prefix
- list($rowPrefix) = URLUtil::splitPath($row['uri']);
- if ($rowPrefix !== $principalPrefix) continue;
-
+ list($rowPrefix) = Uri\split($row['uri']);
+ if ($rowPrefix !== $principalPrefix) {
+ continue;
+ }
+
$uri = $row['uri'];
break; //Stop on first match
}
@@ -322,51 +330,56 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
//unsupported uri scheme
return null;
}
+
return $uri;
}
/**
- * Returns the list of members for a group-principal
+ * Returns the list of members for a group-principal.
*
* @param string $principal
+ *
* @return array
*/
- function getGroupMemberSet($principal) {
-
+ public function getGroupMemberSet($principal)
+ {
$principal = $this->getPrincipalByPath($principal);
- if (!$principal) throw new DAV\Exception('Principal not found');
-
- $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?');
+ if (!$principal) {
+ throw new DAV\Exception('Principal not found');
+ }
+ $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.member_id = principals.id WHERE groupmembers.principal_id = ?');
$stmt->execute([$principal['id']]);
$result = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row['uri'];
}
- return $result;
+ return $result;
}
/**
- * Returns the list of groups a principal is a member of
+ * Returns the list of groups a principal is a member of.
*
* @param string $principal
+ *
* @return array
*/
- function getGroupMembership($principal) {
-
+ public function getGroupMembership($principal)
+ {
$principal = $this->getPrincipalByPath($principal);
- if (!$principal) throw new DAV\Exception('Principal not found');
-
- $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM ' . $this->groupMembersTableName . ' AS groupmembers LEFT JOIN ' . $this->tableName . ' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?');
+ if (!$principal) {
+ throw new DAV\Exception('Principal not found');
+ }
+ $stmt = $this->pdo->prepare('SELECT principals.uri as uri FROM '.$this->groupMembersTableName.' AS groupmembers LEFT JOIN '.$this->tableName.' AS principals ON groupmembers.principal_id = principals.id WHERE groupmembers.member_id = ?');
$stmt->execute([$principal['id']]);
$result = [];
while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
$result[] = $row['uri'];
}
- return $result;
+ return $result;
}
/**
@@ -375,13 +388,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
* The principals should be passed as a list of uri's.
*
* @param string $principal
- * @param array $members
- * @return void
+ * @param array $members
*/
- function setGroupMemberSet($principal, array $members) {
-
+ public function setGroupMemberSet($principal, array $members)
+ {
// Grabbing the list of principal id's.
- $stmt = $this->pdo->prepare('SELECT id, uri FROM ' . $this->tableName . ' WHERE uri IN (? ' . str_repeat(', ? ', count($members)) . ');');
+ $stmt = $this->pdo->prepare('SELECT id, uri FROM '.$this->tableName.' WHERE uri IN (? '.str_repeat(', ? ', count($members)).');');
$stmt->execute(array_merge([$principal], $members));
$memberIds = [];
@@ -394,19 +406,17 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
$memberIds[] = $row['id'];
}
}
- if (!$principalId) throw new DAV\Exception('Principal not found');
-
+ if (!$principalId) {
+ throw new DAV\Exception('Principal not found');
+ }
// Wiping out old members
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->groupMembersTableName . ' WHERE principal_id = ?;');
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->groupMembersTableName.' WHERE principal_id = ?;');
$stmt->execute([$principalId]);
foreach ($memberIds as $memberId) {
-
- $stmt = $this->pdo->prepare('INSERT INTO ' . $this->groupMembersTableName . ' (principal_id, member_id) VALUES (?, ?);');
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->groupMembersTableName.' (principal_id, member_id) VALUES (?, ?);');
$stmt->execute([$principalId, $memberId]);
-
}
-
}
/**
@@ -417,15 +427,12 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
* of the principal.
*
* @param string $path
- * @param MkCol $mkCol
- * @return void
+ * @param MkCol $mkCol
*/
- function createPrincipal($path, MkCol $mkCol) {
-
- $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (uri) VALUES (?)');
+ public function createPrincipal($path, MkCol $mkCol)
+ {
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (uri) VALUES (?)');
$stmt->execute([$path]);
$this->updatePrincipal($path, $mkCol);
-
}
-
}