[Pkg-owncloud-commits] [php-sabredav] 05/80: sabre-cs-fixer on PDO.php

David Prévot taffit at moszumanska.debian.org
Thu Jan 7 02:56:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 1710134acca47f9e62f5683820b1d13a38788d4e
Author: vmire <vincent_257 at mireau.com>
Date:   Wed Jul 15 20:13:08 2015 +0200

    sabre-cs-fixer on PDO.php
---
 lib/DAVACL/PrincipalBackend/PDO.php | 70 +++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 37 deletions(-)

diff --git a/lib/DAVACL/PrincipalBackend/PDO.php b/lib/DAVACL/PrincipalBackend/PDO.php
index 2ff773f..f300441 100644
--- a/lib/DAVACL/PrincipalBackend/PDO.php
+++ b/lib/DAVACL/PrincipalBackend/PDO.php
@@ -240,25 +240,24 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
      * @return array
      */
     function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
-		if(count($searchProperties) == 0) return [];	//No criteria
+        if (count($searchProperties) == 0) return [];    //No criteria
 
         $query = 'SELECT uri FROM ' . $this->tableName . ' WHERE ';
         $values = [];
         foreach ($searchProperties as $property => $value) {
-			$column;
             switch ($property) {
                 case '{DAV:}displayname' :
-					$column = "displayname";
+                    $column = "displayname";
                     break;
                 case '{http://sabredav.org/ns}email-address' :
-					$column = "email";
+                    $column = "email";
                     break;
                 default :
                     // Unsupported property
                     return [];
             }
-			if(count($values) > 0) $query .= (strcmp($test,"anyof")==0 ? " OR ":" AND ");
-            $query .= 'lower('.$column.') LIKE lower(?)';
+            if (count($values) > 0) $query .= (strcmp($test, "anyof") == 0 ? " OR " : " AND ");
+            $query .= 'lower(' . $column . ') LIKE lower(?)';
             $values[] = '%' . $value . '%';
 
         }
@@ -280,7 +279,7 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
 
     }
 
-	/**
+    /**
      * Finds a principal by its URI.
      *
      * This method may receive any type of uri, but mailto: addresses will be
@@ -297,36 +296,33 @@ class PDO extends AbstractBackend implements CreatePrincipalSupport {
      * @param string $principalPrefix
      * @return string
      */
-	function findByUri($uri, $principalPrefix) {
-		$idx = strpos($uri,":");
-		if($idx===FALSE){
-			return null;
-		}
-		
-		$scheme = substr($uri,0,$idx);
-		$value = substr($uri,$idx+1);
-
-		$uri = null;
-		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;
-					
-	            	$uri = $row['uri'];
-					break; //Stop on first match
-				}
-				break;
-			default:
-				//unsupported uri scheme
-				return null;
-		}
-		return $uri;
+    function findByUri($uri, $principalPrefix) {
+        $value = null;
+        $scheme = null;
+        list($scheme, $value) = explode(":", $uri, 2);
+        if ($value == null) return null;
+
+        $uri = null;
+        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;
+                    
+                    $uri = $row['uri'];
+                    break; //Stop on first match
+                }
+                break;
+            default:
+                //unsupported uri scheme
+                return null;
+        }
+        return $uri;
     }
 
     /**

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list