summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/Mapping
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2020-04-17 16:02:04 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2020-04-23 21:34:05 +0200
commit4babdc082b988485608682a6a0bf3cccfd42fe8b (patch)
tree6cd1f1fd3a3d8eb2b1b0fdda1fa4e3624a5bb6cd /apps/user_ldap/lib/Mapping
parentab550d682f5ddbef35c3a11f7672c2fab26d4659 (diff)
downloadnextcloud-server-4babdc082b988485608682a6a0bf3cccfd42fe8b.tar.gz
nextcloud-server-4babdc082b988485608682a6a0bf3cccfd42fe8b.zip
formatting
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib/Mapping')
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index c88b84635f9..6fd07f5f483 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -30,7 +30,7 @@ use OC\DB\QueryBuilder\QueryBuilder;
/**
* Class AbstractMapping
-*
+ *
* @package OCA\User_LDAP\Mapping
*/
abstract class AbstractMapping {
@@ -41,6 +41,7 @@ abstract class AbstractMapping {
/**
* returns the DB table name which holds the mappings
+ *
* @return string
*/
abstract protected function getTableName(bool $includePrefix = true);
@@ -57,6 +58,7 @@ abstract class AbstractMapping {
/**
* checks whether a provided string represents an existing table col
+ *
* @param string $col
* @return bool
*/
@@ -73,11 +75,12 @@ abstract class AbstractMapping {
/**
* Gets the value of one column based on a provided value of another column
+ *
* @param string $fetchCol
* @param string $compareCol
* @param string $search
- * @throws \Exception
* @return string|false
+ * @throws \Exception
*/
protected function getXbyY($fetchCol, $compareCol, $search) {
if (!$this->isColNameValid($fetchCol)) {
@@ -87,7 +90,7 @@ abstract class AbstractMapping {
}
$query = $this->dbc->prepare('
SELECT `' . $fetchCol . '`
- FROM `'. $this->getTableName() .'`
+ FROM `' . $this->getTableName() . '`
WHERE `' . $compareCol . '` = ?
');
@@ -101,6 +104,7 @@ abstract class AbstractMapping {
/**
* Performs a DELETE or UPDATE query to the database.
+ *
* @param \Doctrine\DBAL\Driver\Statement $query
* @param array $parameters
* @return bool true if at least one row was modified, false otherwise
@@ -113,12 +117,13 @@ abstract class AbstractMapping {
/**
* Gets the LDAP DN based on the provided name.
* Replaces Access::ocname2dn
+ *
* @param string $name
* @return string|false
*/
public function getDNByName($name) {
$dn = array_search($name, $this->cache);
- if($dn === false) {
+ if ($dn === false) {
$dn = $this->getXbyY('ldap_dn', 'owncloud_name', $name);
$this->cache[$dn] = $name;
}
@@ -127,6 +132,7 @@ abstract class AbstractMapping {
/**
* Updates the DN based on the given UUID
+ *
* @param string $fdn
* @param string $uuid
* @return bool
@@ -141,7 +147,7 @@ abstract class AbstractMapping {
$r = $this->modify($query, [$fdn, $uuid]);
- if($r && is_string($oldDn) && isset($this->cache[$oldDn])) {
+ if ($r && is_string($oldDn) && isset($this->cache[$oldDn])) {
$this->cache[$fdn] = $this->cache[$oldDn];
unset($this->cache[$oldDn]);
}
@@ -172,11 +178,12 @@ abstract class AbstractMapping {
/**
* Gets the name based on the provided LDAP DN.
+ *
* @param string $fdn
* @return string|false
*/
public function getNameByDN($fdn) {
- if(!isset($this->cache[$fdn])) {
+ if (!isset($this->cache[$fdn])) {
$this->cache[$fdn] = $this->getXbyY('owncloud_name', 'ldap_dn', $fdn);
}
return $this->cache[$fdn];
@@ -201,6 +208,7 @@ abstract class AbstractMapping {
/**
* Searches mapped names by the giving string in the name column
+ *
* @param string $search
* @param string $prefixMatch
* @param string $postfixMatch
@@ -209,11 +217,11 @@ abstract class AbstractMapping {
public function getNamesBySearch($search, $prefixMatch = "", $postfixMatch = "") {
$query = $this->dbc->prepare('
SELECT `owncloud_name`
- FROM `'. $this->getTableName() .'`
+ FROM `' . $this->getTableName() . '`
WHERE `owncloud_name` LIKE ?
');
- $res = $query->execute([$prefixMatch.$this->dbc->escapeLikeParameter($search).$postfixMatch]);
+ $res = $query->execute([$prefixMatch . $this->dbc->escapeLikeParameter($search) . $postfixMatch]);
$names = [];
if ($res !== false) {
while ($row = $query->fetch()) {
@@ -225,6 +233,7 @@ abstract class AbstractMapping {
/**
* Gets the name based on the provided LDAP UUID.
+ *
* @param string $uuid
* @return string|false
*/
@@ -238,6 +247,7 @@ abstract class AbstractMapping {
/**
* Gets the UUID based on the provided LDAP DN
+ *
* @param string $dn
* @return false|string
* @throws \Exception
@@ -248,6 +258,7 @@ abstract class AbstractMapping {
/**
* gets a piece of the mapping list
+ *
* @param int $offset
* @param int $limit
* @return array
@@ -269,6 +280,7 @@ abstract class AbstractMapping {
/**
* attempts to map the given entry
+ *
* @param string $fdn fully distinguished name (from LDAP)
* @param string $name
* @param string $uuid a unique identifier as used in LDAP
@@ -287,14 +299,14 @@ abstract class AbstractMapping {
}
$row = [
- 'ldap_dn' => $fdn,
- 'owncloud_name' => $name,
+ 'ldap_dn' => $fdn,
+ 'owncloud_name' => $name,
'directory_uuid' => $uuid
];
try {
$result = $this->dbc->insertIfNotExist($this->getTableName(), $row);
- if((bool)$result === true) {
+ if ((bool)$result === true) {
$this->cache[$fdn] = $name;
}
// insertIfNotExist returns values as int
@@ -306,12 +318,13 @@ abstract class AbstractMapping {
/**
* removes a mapping based on the owncloud_name of the entry
+ *
* @param string $name
* @return bool
*/
public function unmap($name) {
$query = $this->dbc->prepare('
- DELETE FROM `'. $this->getTableName() .'`
+ DELETE FROM `' . $this->getTableName() . '`
WHERE `owncloud_name` = ?');
return $this->modify($query, [$name]);
@@ -319,6 +332,7 @@ abstract class AbstractMapping {
/**
* Truncate's the mapping table
+ *
* @return bool
*/
public function clear() {