Passed
Push — master ( 4e9cd2...bc8d14 )
by Roeland
19:16 queued 09:49
created
lib/public/Collaboration/Collaborators/ISearchPlugin.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchPlugin {
33
-	/**
34
-	 * @param string $search
35
-	 * @param int $limit
36
-	 * @param int $offset
37
-	 * @param ISearchResult $searchResult
38
-	 * @return bool whether the plugin has more results
39
-	 * @since 13.0.0
40
-	 */
41
-	public function search($search, $limit, $offset, ISearchResult $searchResult);
33
+    /**
34
+     * @param string $search
35
+     * @param int $limit
36
+     * @param int $offset
37
+     * @param ISearchResult $searchResult
38
+     * @return bool whether the plugin has more results
39
+     * @since 13.0.0
40
+     */
41
+    public function search($search, $limit, $offset, ISearchResult $searchResult);
42 42
 }
Please login to merge, or discard this patch.
lib/private/Setup/OCI.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -71,18 +71,18 @@
 block discarded – undo
71 71
 			$errorMessage = $this->getLastError();
72 72
 			if ($errorMessage) {
73 73
 				throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
74
-					$errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
75
-					. ' ORACLE_SID=' . getenv('ORACLE_SID')
76
-					. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
77
-					. ' NLS_LANG=' . getenv('NLS_LANG')
78
-					. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
74
+					$errorMessage.' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
75
+					. ' ORACLE_SID='.getenv('ORACLE_SID')
76
+					. ' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH')
77
+					. ' NLS_LANG='.getenv('NLS_LANG')
78
+					. ' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora') ? '' : 'not ').'readable');
79 79
 			}
80 80
 			throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
81
-				'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
82
-				. ' ORACLE_SID=' . getenv('ORACLE_SID')
83
-				. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
84
-				. ' NLS_LANG=' . getenv('NLS_LANG')
85
-				. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
81
+				'Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
82
+				. ' ORACLE_SID='.getenv('ORACLE_SID')
83
+				. ' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH')
84
+				. ' NLS_LANG='.getenv('NLS_LANG')
85
+				. ' tnsnames.ora is '.(is_readable(getenv('ORACLE_HOME').'/network/admin/tnsnames.ora') ? '' : 'not ').'readable');
86 86
 		}
87 87
 
88 88
 		$this->config->setValues([
Please login to merge, or discard this patch.
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -31,81 +31,81 @@
 block discarded – undo
31 31
 namespace OC\Setup;
32 32
 
33 33
 class OCI extends AbstractDatabase {
34
-	public $dbprettyname = 'Oracle';
34
+    public $dbprettyname = 'Oracle';
35 35
 
36
-	protected $dbtablespace;
36
+    protected $dbtablespace;
37 37
 
38
-	public function initialize($config) {
39
-		parent::initialize($config);
40
-		if (array_key_exists('dbtablespace', $config)) {
41
-			$this->dbtablespace = $config['dbtablespace'];
42
-		} else {
43
-			$this->dbtablespace = 'USERS';
44
-		}
45
-		// allow empty hostname for oracle
46
-		$this->dbHost = $config['dbhost'];
38
+    public function initialize($config) {
39
+        parent::initialize($config);
40
+        if (array_key_exists('dbtablespace', $config)) {
41
+            $this->dbtablespace = $config['dbtablespace'];
42
+        } else {
43
+            $this->dbtablespace = 'USERS';
44
+        }
45
+        // allow empty hostname for oracle
46
+        $this->dbHost = $config['dbhost'];
47 47
 
48
-		$this->config->setValues([
49
-			'dbhost' => $this->dbHost,
50
-			'dbtablespace' => $this->dbtablespace,
51
-		]);
52
-	}
48
+        $this->config->setValues([
49
+            'dbhost' => $this->dbHost,
50
+            'dbtablespace' => $this->dbtablespace,
51
+        ]);
52
+    }
53 53
 
54
-	public function validate($config) {
55
-		$errors = [];
56
-		if (empty($config['dbuser']) && empty($config['dbname'])) {
57
-			$errors[] = $this->trans->t("%s enter the database username and name.", [$this->dbprettyname]);
58
-		} else if (empty($config['dbuser'])) {
59
-			$errors[] = $this->trans->t("%s enter the database username.", [$this->dbprettyname]);
60
-		} else if (empty($config['dbname'])) {
61
-			$errors[] = $this->trans->t("%s enter the database name.", [$this->dbprettyname]);
62
-		}
63
-		return $errors;
64
-	}
54
+    public function validate($config) {
55
+        $errors = [];
56
+        if (empty($config['dbuser']) && empty($config['dbname'])) {
57
+            $errors[] = $this->trans->t("%s enter the database username and name.", [$this->dbprettyname]);
58
+        } else if (empty($config['dbuser'])) {
59
+            $errors[] = $this->trans->t("%s enter the database username.", [$this->dbprettyname]);
60
+        } else if (empty($config['dbname'])) {
61
+            $errors[] = $this->trans->t("%s enter the database name.", [$this->dbprettyname]);
62
+        }
63
+        return $errors;
64
+    }
65 65
 
66
-	public function setupDatabase($username) {
67
-		try {
68
-			$this->connect();
69
-		} catch (\Exception $e) {
70
-			$errorMessage = $this->getLastError();
71
-			if ($errorMessage) {
72
-				throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
73
-					$errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
74
-					. ' ORACLE_SID=' . getenv('ORACLE_SID')
75
-					. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
76
-					. ' NLS_LANG=' . getenv('NLS_LANG')
77
-					. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
78
-			}
79
-			throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
80
-				'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
81
-				. ' ORACLE_SID=' . getenv('ORACLE_SID')
82
-				. ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
83
-				. ' NLS_LANG=' . getenv('NLS_LANG')
84
-				. ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
85
-		}
66
+    public function setupDatabase($username) {
67
+        try {
68
+            $this->connect();
69
+        } catch (\Exception $e) {
70
+            $errorMessage = $this->getLastError();
71
+            if ($errorMessage) {
72
+                throw new \OC\DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
73
+                    $errorMessage . ' Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
74
+                    . ' ORACLE_SID=' . getenv('ORACLE_SID')
75
+                    . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
76
+                    . ' NLS_LANG=' . getenv('NLS_LANG')
77
+                    . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
78
+            }
79
+            throw new \OC\DatabaseSetupException($this->trans->t('Oracle username and/or password not valid'),
80
+                'Check environment: ORACLE_HOME=' . getenv('ORACLE_HOME')
81
+                . ' ORACLE_SID=' . getenv('ORACLE_SID')
82
+                . ' LD_LIBRARY_PATH=' . getenv('LD_LIBRARY_PATH')
83
+                . ' NLS_LANG=' . getenv('NLS_LANG')
84
+                . ' tnsnames.ora is ' . (is_readable(getenv('ORACLE_HOME') . '/network/admin/tnsnames.ora') ? '' : 'not ') . 'readable');
85
+        }
86 86
 
87
-		$this->config->setValues([
88
-			'dbuser' => $this->dbUser,
89
-			'dbname' => $this->dbName,
90
-			'dbpassword' => $this->dbPassword,
91
-		]);
92
-	}
87
+        $this->config->setValues([
88
+            'dbuser' => $this->dbUser,
89
+            'dbname' => $this->dbName,
90
+            'dbpassword' => $this->dbPassword,
91
+        ]);
92
+    }
93 93
 
94
-	/**
95
-	 * @param resource $connection
96
-	 * @return string
97
-	 */
98
-	protected function getLastError($connection = null) {
99
-		if ($connection) {
100
-			$error = oci_error($connection);
101
-		} else {
102
-			$error = oci_error();
103
-		}
104
-		foreach (['message', 'code'] as $key) {
105
-			if (isset($error[$key])) {
106
-				return $error[$key];
107
-			}
108
-		}
109
-		return '';
110
-	}
94
+    /**
95
+     * @param resource $connection
96
+     * @return string
97
+     */
98
+    protected function getLastError($connection = null) {
99
+        if ($connection) {
100
+            $error = oci_error($connection);
101
+        } else {
102
+            $error = oci_error();
103
+        }
104
+        foreach (['message', 'code'] as $key) {
105
+            if (isset($error[$key])) {
106
+                return $error[$key];
107
+            }
108
+        }
109
+        return '';
110
+    }
111 111
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearch.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,21 +30,21 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearch {
33
-	/**
34
-	 * @param string $search
35
-	 * @param array $shareTypes
36
-	 * @param bool $lookup
37
-	 * @param int $limit
38
-	 * @param int $offset
39
-	 * @return array with two elements, 1st ISearchResult as array, 2nd a bool indicating whether more result are available
40
-	 * @since 13.0.0
41
-	 */
42
-	public function search($search, array $shareTypes, $lookup, $limit, $offset);
33
+    /**
34
+     * @param string $search
35
+     * @param array $shareTypes
36
+     * @param bool $lookup
37
+     * @param int $limit
38
+     * @param int $offset
39
+     * @return array with two elements, 1st ISearchResult as array, 2nd a bool indicating whether more result are available
40
+     * @since 13.0.0
41
+     */
42
+    public function search($search, array $shareTypes, $lookup, $limit, $offset);
43 43
 
44
-	/**
45
-	 * @param array $pluginInfo with keys 'shareType' containing the name of a corresponding constant in \OCP\Share and
46
-	 * 	'class' with the class name of the plugin
47
-	 * @since 13.0.0
48
-	 */
49
-	public function registerPlugin(array $pluginInfo);
44
+    /**
45
+     * @param array $pluginInfo with keys 'shareType' containing the name of a corresponding constant in \OCP\Share and
46
+     * 	'class' with the class name of the plugin
47
+     * @since 13.0.0
48
+     */
49
+    public function registerPlugin(array $pluginInfo);
50 50
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Collaborators/ISearchResult.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -30,44 +30,44 @@
 block discarded – undo
30 30
  * @since 13.0.0
31 31
  */
32 32
 interface ISearchResult {
33
-	/**
34
-	 * @param SearchResultType $type
35
-	 * @param array $matches
36
-	 * @param array|null $exactMatches
37
-	 * @since 13.0.0
38
-	 */
39
-	public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
33
+    /**
34
+     * @param SearchResultType $type
35
+     * @param array $matches
36
+     * @param array|null $exactMatches
37
+     * @since 13.0.0
38
+     */
39
+    public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null);
40 40
 
41
-	/**
42
-	 * @param SearchResultType $type
43
-	 * @param string $collaboratorId
44
-	 * @return bool
45
-	 * @since 13.0.0
46
-	 */
47
-	public function hasResult(SearchResultType $type, $collaboratorId);
41
+    /**
42
+     * @param SearchResultType $type
43
+     * @param string $collaboratorId
44
+     * @return bool
45
+     * @since 13.0.0
46
+     */
47
+    public function hasResult(SearchResultType $type, $collaboratorId);
48 48
 
49
-	/**
50
-	 * @param SearchResultType $type
51
-	 * @since 13.0.0
52
-	 */
53
-	public function unsetResult(SearchResultType $type);
49
+    /**
50
+     * @param SearchResultType $type
51
+     * @since 13.0.0
52
+     */
53
+    public function unsetResult(SearchResultType $type);
54 54
 
55
-	/**
56
-	 * @param SearchResultType $type
57
-	 * @since 13.0.0
58
-	 */
59
-	public function markExactIdMatch(SearchResultType $type);
55
+    /**
56
+     * @param SearchResultType $type
57
+     * @since 13.0.0
58
+     */
59
+    public function markExactIdMatch(SearchResultType $type);
60 60
 
61
-	/**
62
-	 * @param SearchResultType $type
63
-	 * @return bool
64
-	 * @since 13.0.0
65
-	 */
66
-	public function hasExactIdMatch(SearchResultType $type);
61
+    /**
62
+     * @param SearchResultType $type
63
+     * @return bool
64
+     * @since 13.0.0
65
+     */
66
+    public function hasExactIdMatch(SearchResultType $type);
67 67
 
68
-	/**
69
-	 * @return array
70
-	 * @since 13.0.0
71
-	 */
72
-	public function asArray();
68
+    /**
69
+     * @return array
70
+     * @since 13.0.0
71
+     */
72
+    public function asArray();
73 73
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Collaborators/Search.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$searchResult = $this->c->resolve(SearchResult::class);
48 48
 
49 49
 		foreach ($shareTypes as $type) {
50
-			if(!isset($this->pluginList[$type])) {
50
+			if (!isset($this->pluginList[$type])) {
51 51
 				continue;
52 52
 			}
53 53
 			foreach ($this->pluginList[$type] as $plugin) {
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
 		// that the exact same email address and federated cloud id exists
71 71
 		$emailType = new SearchResultType('emails');
72 72
 		$remoteType = new SearchResultType('remotes');
73
-		if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
73
+		if ($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
74 74
 			$searchResult->unsetResult($remoteType);
75 75
 		} elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
76 76
 			$searchResult->unsetResult($emailType);
77 77
 		}
78 78
 
79
-		return [$searchResult->asArray(), (bool)$hasMoreResults];
79
+		return [$searchResult->asArray(), (bool) $hasMoreResults];
80 80
 	}
81 81
 
82 82
 	public function registerPlugin(array $pluginInfo) {
83
-		$shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
84
-		if($shareType === null) {
83
+		$shareType = constant(Share::class.'::'.$pluginInfo['shareType']);
84
+		if ($shareType === null) {
85 85
 			throw new \InvalidArgumentException('Provided ShareType is invalid');
86 86
 		}
87 87
 		$this->pluginList[$shareType][] = $pluginInfo['class'];
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -31,68 +31,68 @@
 block discarded – undo
31 31
 use OCP\Share;
32 32
 
33 33
 class Search implements ISearch {
34
-	/** @var IContainer */
35
-	private $c;
34
+    /** @var IContainer */
35
+    private $c;
36 36
 
37
-	protected $pluginList = [];
37
+    protected $pluginList = [];
38 38
 
39
-	public function __construct(IContainer $c) {
40
-		$this->c = $c;
41
-	}
39
+    public function __construct(IContainer $c) {
40
+        $this->c = $c;
41
+    }
42 42
 
43
-	/**
44
-	 * @param string $search
45
-	 * @param array $shareTypes
46
-	 * @param bool $lookup
47
-	 * @param int|null $limit
48
-	 * @param int|null $offset
49
-	 * @return array
50
-	 * @throws \OCP\AppFramework\QueryException
51
-	 */
52
-	public function search($search, array $shareTypes, $lookup, $limit, $offset) {
53
-		$hasMoreResults = false;
43
+    /**
44
+     * @param string $search
45
+     * @param array $shareTypes
46
+     * @param bool $lookup
47
+     * @param int|null $limit
48
+     * @param int|null $offset
49
+     * @return array
50
+     * @throws \OCP\AppFramework\QueryException
51
+     */
52
+    public function search($search, array $shareTypes, $lookup, $limit, $offset) {
53
+        $hasMoreResults = false;
54 54
 
55
-		/** @var ISearchResult $searchResult */
56
-		$searchResult = $this->c->resolve(SearchResult::class);
55
+        /** @var ISearchResult $searchResult */
56
+        $searchResult = $this->c->resolve(SearchResult::class);
57 57
 
58
-		foreach ($shareTypes as $type) {
59
-			if(!isset($this->pluginList[$type])) {
60
-				continue;
61
-			}
62
-			foreach ($this->pluginList[$type] as $plugin) {
63
-				/** @var ISearchPlugin $searchPlugin */
64
-				$searchPlugin = $this->c->resolve($plugin);
65
-				$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
66
-			}
67
-		}
58
+        foreach ($shareTypes as $type) {
59
+            if(!isset($this->pluginList[$type])) {
60
+                continue;
61
+            }
62
+            foreach ($this->pluginList[$type] as $plugin) {
63
+                /** @var ISearchPlugin $searchPlugin */
64
+                $searchPlugin = $this->c->resolve($plugin);
65
+                $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
66
+            }
67
+        }
68 68
 
69
-		// Get from lookup server, not a separate share type
70
-		if ($lookup) {
71
-			$searchPlugin = $this->c->resolve(LookupPlugin::class);
72
-			$hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
73
-		}
69
+        // Get from lookup server, not a separate share type
70
+        if ($lookup) {
71
+            $searchPlugin = $this->c->resolve(LookupPlugin::class);
72
+            $hasMoreResults |= $searchPlugin->search($search, $limit, $offset, $searchResult);
73
+        }
74 74
 
75
-		// sanitizing, could go into the plugins as well
75
+        // sanitizing, could go into the plugins as well
76 76
 
77
-		// if we have a exact match, either for the federated cloud id or for the
78
-		// email address we only return the exact match. It is highly unlikely
79
-		// that the exact same email address and federated cloud id exists
80
-		$emailType = new SearchResultType('emails');
81
-		$remoteType = new SearchResultType('remotes');
82
-		if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
83
-			$searchResult->unsetResult($remoteType);
84
-		} elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
85
-			$searchResult->unsetResult($emailType);
86
-		}
77
+        // if we have a exact match, either for the federated cloud id or for the
78
+        // email address we only return the exact match. It is highly unlikely
79
+        // that the exact same email address and federated cloud id exists
80
+        $emailType = new SearchResultType('emails');
81
+        $remoteType = new SearchResultType('remotes');
82
+        if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) {
83
+            $searchResult->unsetResult($remoteType);
84
+        } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) {
85
+            $searchResult->unsetResult($emailType);
86
+        }
87 87
 
88
-		return [$searchResult->asArray(), (bool)$hasMoreResults];
89
-	}
88
+        return [$searchResult->asArray(), (bool)$hasMoreResults];
89
+    }
90 90
 
91
-	public function registerPlugin(array $pluginInfo) {
92
-		$shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
93
-		if($shareType === null) {
94
-			throw new \InvalidArgumentException('Provided ShareType is invalid');
95
-		}
96
-		$this->pluginList[$shareType][] = $pluginInfo['class'];
97
-	}
91
+    public function registerPlugin(array $pluginInfo) {
92
+        $shareType = constant(Share::class . '::' . $pluginInfo['shareType']);
93
+        if($shareType === null) {
94
+            throw new \InvalidArgumentException('Provided ShareType is invalid');
95
+        }
96
+        $this->pluginList[$shareType][] = $pluginInfo['class'];
97
+    }
98 98
 }
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Events/MoveToTrashEvent.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -35,39 +35,39 @@
 block discarded – undo
35 35
  */
36 36
 class MoveToTrashEvent extends Event {
37 37
 
38
-	/** @var bool */
39
-	private $moveToTrashBin;
38
+    /** @var bool */
39
+    private $moveToTrashBin;
40 40
 
41
-	/** @var Node */
42
-	private $node;
41
+    /** @var Node */
42
+    private $node;
43 43
 
44
-	public function __construct(Node $node) {
45
-		$this->moveToTrashBin = true;
46
-		$this->node = $node;
47
-	}
44
+    public function __construct(Node $node) {
45
+        $this->moveToTrashBin = true;
46
+        $this->node = $node;
47
+    }
48 48
 
49
-	/**
50
-	 * get Node which will be deleted
51
-	 *
52
-	 * @return Node
53
-	 */
54
-	public function getNode() {
55
-		return $this->node;
56
-	}
49
+    /**
50
+     * get Node which will be deleted
51
+     *
52
+     * @return Node
53
+     */
54
+    public function getNode() {
55
+        return $this->node;
56
+    }
57 57
 
58
-	/**
59
-	 * disable trash bin for this operation
60
-	 */
61
-	public function disableTrashBin() {
62
-		$this->moveToTrashBin = false;
63
-	}
58
+    /**
59
+     * disable trash bin for this operation
60
+     */
61
+    public function disableTrashBin() {
62
+        $this->moveToTrashBin = false;
63
+    }
64 64
 
65
-	/**
66
-	 * should the file be moved to the trash bin?
67
-	 *
68
-	 * @return bool
69
-	 */
70
-	public function shouldMoveToTrashBin() {
71
-		return $this->moveToTrashBin;
72
-	}
65
+    /**
66
+     * should the file be moved to the trash bin?
67
+     *
68
+     * @return bool
69
+     */
70
+    public function shouldMoveToTrashBin() {
71
+        return $this->moveToTrashBin;
72
+    }
73 73
 }
Please login to merge, or discard this patch.
apps/files_versions/lib/Events/CreateVersionEvent.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -37,45 +37,45 @@
 block discarded – undo
37 37
 class CreateVersionEvent extends Event {
38 38
 
39 39
 
40
-	/** @var bool */
41
-	private $createVersion;
40
+    /** @var bool */
41
+    private $createVersion;
42 42
 
43
-	/** @var Node */
44
-	private $node;
43
+    /** @var Node */
44
+    private $node;
45 45
 
46
-	/**
47
-	 * CreateVersionEvent constructor.
48
-	 *
49
-	 * @param Node $node
50
-	 */
51
-	public function __construct(Node $node) {
52
-		$this->createVersion = true;
53
-		$this->node = $node;
54
-	}
46
+    /**
47
+     * CreateVersionEvent constructor.
48
+     *
49
+     * @param Node $node
50
+     */
51
+    public function __construct(Node $node) {
52
+        $this->createVersion = true;
53
+        $this->node = $node;
54
+    }
55 55
 
56
-	/**
57
-	 * get Node of the file which should be versioned
58
-	 *
59
-	 * @return Node
60
-	 */
61
-	public function getNode() {
62
-		return $this->node;
63
-	}
56
+    /**
57
+     * get Node of the file which should be versioned
58
+     *
59
+     * @return Node
60
+     */
61
+    public function getNode() {
62
+        return $this->node;
63
+    }
64 64
 
65
-	/**
66
-	 * disable versions for this file
67
-	 */
68
-	public function disableVersions() {
69
-		$this->createVersion = false;
70
-	}
65
+    /**
66
+     * disable versions for this file
67
+     */
68
+    public function disableVersions() {
69
+        $this->createVersion = false;
70
+    }
71 71
 
72
-	/**
73
-	 * should a version be created for this file?
74
-	 *
75
-	 * @return bool
76
-	 */
77
-	public function shouldCreateVersion() {
78
-		return $this->createVersion;
79
-	}
72
+    /**
73
+     * should a version be created for this file?
74
+     *
75
+     * @return bool
76
+     */
77
+    public function shouldCreateVersion() {
78
+        return $this->createVersion;
79
+    }
80 80
 
81 81
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ContactsStore.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		if ($excludedGroups) {
118 118
 			$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
119 119
 			$decodedExcludeGroups = json_decode($excludedGroups, true);
120
-			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
120
+			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups : [];
121 121
 
122 122
 			if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
123 123
 				// a group of the current user is excluded -> filter all local users
@@ -133,22 +133,22 @@  discard block
 block discarded – undo
133 133
 			}
134 134
 
135 135
 			// Prevent enumerating local users
136
-			if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
136
+			if ($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
137 137
 				$filterUser = true;
138 138
 
139 139
 				$mailAddresses = $entry->getEMailAddresses();
140
-				foreach($mailAddresses as $mailAddress) {
141
-					if($mailAddress === $filter) {
140
+				foreach ($mailAddresses as $mailAddress) {
141
+					if ($mailAddress === $filter) {
142 142
 						$filterUser = false;
143 143
 						break;
144 144
 					}
145 145
 				}
146 146
 
147
-				if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
147
+				if ($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
148 148
 					$filterUser = false;
149 149
 				}
150 150
 
151
-				if($filterUser) {
151
+				if ($filterUser) {
152 152
 					return false;
153 153
 				}
154 154
 			}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @return IEntry|null
173 173
 	 */
174 174
 	public function findOne(IUser $user, $shareType, $shareWith) {
175
-		switch($shareType) {
175
+		switch ($shareType) {
176 176
 			case 0:
177 177
 			case 6:
178 178
 				$filter = ['UID'];
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -39,228 +39,228 @@
 block discarded – undo
39 39
 
40 40
 class ContactsStore implements IContactsStore {
41 41
 
42
-	/** @var IManager */
43
-	private $contactsManager;
44
-
45
-	/** @var IConfig */
46
-	private $config;
47
-
48
-	/** @var IUserManager */
49
-	private $userManager;
50
-
51
-	/** @var IGroupManager */
52
-	private $groupManager;
53
-
54
-	/**
55
-	 * @param IManager $contactsManager
56
-	 * @param IConfig $config
57
-	 * @param IUserManager $userManager
58
-	 * @param IGroupManager $groupManager
59
-	 */
60
-	public function __construct(IManager $contactsManager,
61
-								IConfig $config,
62
-								IUserManager $userManager,
63
-								IGroupManager $groupManager) {
64
-		$this->contactsManager = $contactsManager;
65
-		$this->config = $config;
66
-		$this->userManager = $userManager;
67
-		$this->groupManager = $groupManager;
68
-	}
69
-
70
-	/**
71
-	 * @param IUser $user
72
-	 * @param string|null $filter
73
-	 * @return IEntry[]
74
-	 */
75
-	public function getContacts(IUser $user, $filter) {
76
-		$allContacts = $this->contactsManager->search($filter ?: '', [
77
-			'FN',
78
-			'EMAIL'
79
-		]);
80
-
81
-		$entries = array_map(function(array $contact) {
82
-			return $this->contactArrayToEntry($contact);
83
-		}, $allContacts);
84
-		return $this->filterContacts(
85
-			$user,
86
-			$entries,
87
-			$filter
88
-		);
89
-	}
90
-
91
-	/**
92
-	 * Filters the contacts. Applies 3 filters:
93
-	 *  1. filter the current user
94
-	 *  2. if the `shareapi_allow_share_dialog_user_enumeration` config option is
95
-	 * enabled it will filter all local users
96
-	 *  3. if the `shareapi_exclude_groups` config option is enabled and the
97
-	 * current user is in an excluded group it will filter all local users.
98
-	 *  4. if the `shareapi_only_share_with_group_members` config option is
99
-	 * enabled it will filter all users which doens't have a common group
100
-	 * with the current user.
101
-	 *
102
-	 * @param IUser $self
103
-	 * @param Entry[] $entries
104
-	 * @param string $filter
105
-	 * @return Entry[] the filtered contacts
106
-	 */
107
-	private function filterContacts(IUser $self,
108
-									array $entries,
109
-									$filter) {
110
-		$disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
111
-		$restrictEnumeration = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
112
-		$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
113
-
114
-		// whether to filter out local users
115
-		$skipLocal = false;
116
-		// whether to filter out all users which doesn't have the same group as the current user
117
-		$ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes' || $restrictEnumeration;
118
-
119
-		$selfGroups = $this->groupManager->getUserGroupIds($self);
120
-
121
-		if ($excludedGroups) {
122
-			$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
123
-			$decodedExcludeGroups = json_decode($excludedGroups, true);
124
-			$excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
125
-
126
-			if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
127
-				// a group of the current user is excluded -> filter all local users
128
-				$skipLocal = true;
129
-			}
130
-		}
131
-
132
-		$selfUID = $self->getUID();
133
-
134
-		return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) {
135
-			if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) {
136
-				return false;
137
-			}
138
-
139
-			// Prevent enumerating local users
140
-			if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
141
-				$filterUser = true;
142
-
143
-				$mailAddresses = $entry->getEMailAddresses();
144
-				foreach($mailAddresses as $mailAddress) {
145
-					if($mailAddress === $filter) {
146
-						$filterUser = false;
147
-						break;
148
-					}
149
-				}
150
-
151
-				if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
152
-					$filterUser = false;
153
-				}
154
-
155
-				if($filterUser) {
156
-					return false;
157
-				}
158
-			}
159
-
160
-			if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) {
161
-				$uid = $this->userManager->get($entry->getProperty('UID'));
162
-
163
-				if ($uid === null) {
164
-					return false;
165
-				}
166
-
167
-				$contactGroups = $this->groupManager->getUserGroupIds($uid);
168
-				if (count(array_intersect($contactGroups, $selfGroups)) === 0) {
169
-					// no groups in common, so shouldn't see the contact
170
-					return false;
171
-				}
172
-			}
173
-
174
-			return $entry->getProperty('UID') !== $selfUID;
175
-		}));
176
-	}
177
-
178
-	/**
179
-	 * @param IUser $user
180
-	 * @param integer $shareType
181
-	 * @param string $shareWith
182
-	 * @return IEntry|null
183
-	 */
184
-	public function findOne(IUser $user, $shareType, $shareWith) {
185
-		switch($shareType) {
186
-			case 0:
187
-			case 6:
188
-				$filter = ['UID'];
189
-				break;
190
-			case 4:
191
-				$filter = ['EMAIL'];
192
-				break;
193
-			default:
194
-				return null;
195
-		}
196
-
197
-		$userId = $user->getUID();
198
-		$allContacts = $this->contactsManager->search($shareWith, $filter);
199
-		$contacts = array_filter($allContacts, function($contact) use ($userId) {
200
-			return $contact['UID'] !== $userId;
201
-		});
202
-		$match = null;
203
-
204
-		foreach ($contacts as $contact) {
205
-			if ($shareType === 4 && isset($contact['EMAIL'])) {
206
-				if (in_array($shareWith, $contact['EMAIL'])) {
207
-					$match = $contact;
208
-					break;
209
-				}
210
-			}
211
-			if ($shareType === 0 || $shareType === 6) {
212
-				$isLocal = $contact['isLocalSystemBook'] ?? false;
213
-				if ($contact['UID'] === $shareWith && $isLocal === true) {
214
-					$match = $contact;
215
-					break;
216
-				}
217
-			}
218
-		}
219
-
220
-		if ($match) {
221
-			$match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith);
222
-			if (count($match) === 1) {
223
-				$match = $match[0];
224
-			} else {
225
-				$match = null;
226
-			}
227
-
228
-		}
229
-
230
-		return $match;
231
-	}
232
-
233
-	/**
234
-	 * @param array $contact
235
-	 * @return Entry
236
-	 */
237
-	private function contactArrayToEntry(array $contact) {
238
-		$entry = new Entry();
239
-
240
-		if (isset($contact['id'])) {
241
-			$entry->setId($contact['id']);
242
-		}
243
-
244
-		if (isset($contact['FN'])) {
245
-			$entry->setFullName($contact['FN']);
246
-		}
247
-
248
-		$avatarPrefix = "VALUE=uri:";
249
-		if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
250
-			$entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
251
-		}
252
-
253
-		if (isset($contact['EMAIL'])) {
254
-			foreach ($contact['EMAIL'] as $email) {
255
-				$entry->addEMailAddress($email);
256
-			}
257
-		}
258
-
259
-		// Attach all other properties to the entry too because some
260
-		// providers might make use of it.
261
-		$entry->setProperties($contact);
262
-
263
-		return $entry;
264
-	}
42
+    /** @var IManager */
43
+    private $contactsManager;
44
+
45
+    /** @var IConfig */
46
+    private $config;
47
+
48
+    /** @var IUserManager */
49
+    private $userManager;
50
+
51
+    /** @var IGroupManager */
52
+    private $groupManager;
53
+
54
+    /**
55
+     * @param IManager $contactsManager
56
+     * @param IConfig $config
57
+     * @param IUserManager $userManager
58
+     * @param IGroupManager $groupManager
59
+     */
60
+    public function __construct(IManager $contactsManager,
61
+                                IConfig $config,
62
+                                IUserManager $userManager,
63
+                                IGroupManager $groupManager) {
64
+        $this->contactsManager = $contactsManager;
65
+        $this->config = $config;
66
+        $this->userManager = $userManager;
67
+        $this->groupManager = $groupManager;
68
+    }
69
+
70
+    /**
71
+     * @param IUser $user
72
+     * @param string|null $filter
73
+     * @return IEntry[]
74
+     */
75
+    public function getContacts(IUser $user, $filter) {
76
+        $allContacts = $this->contactsManager->search($filter ?: '', [
77
+            'FN',
78
+            'EMAIL'
79
+        ]);
80
+
81
+        $entries = array_map(function(array $contact) {
82
+            return $this->contactArrayToEntry($contact);
83
+        }, $allContacts);
84
+        return $this->filterContacts(
85
+            $user,
86
+            $entries,
87
+            $filter
88
+        );
89
+    }
90
+
91
+    /**
92
+     * Filters the contacts. Applies 3 filters:
93
+     *  1. filter the current user
94
+     *  2. if the `shareapi_allow_share_dialog_user_enumeration` config option is
95
+     * enabled it will filter all local users
96
+     *  3. if the `shareapi_exclude_groups` config option is enabled and the
97
+     * current user is in an excluded group it will filter all local users.
98
+     *  4. if the `shareapi_only_share_with_group_members` config option is
99
+     * enabled it will filter all users which doens't have a common group
100
+     * with the current user.
101
+     *
102
+     * @param IUser $self
103
+     * @param Entry[] $entries
104
+     * @param string $filter
105
+     * @return Entry[] the filtered contacts
106
+     */
107
+    private function filterContacts(IUser $self,
108
+                                    array $entries,
109
+                                    $filter) {
110
+        $disallowEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') !== 'yes';
111
+        $restrictEnumeration = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes';
112
+        $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes';
113
+
114
+        // whether to filter out local users
115
+        $skipLocal = false;
116
+        // whether to filter out all users which doesn't have the same group as the current user
117
+        $ownGroupsOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes' || $restrictEnumeration;
118
+
119
+        $selfGroups = $this->groupManager->getUserGroupIds($self);
120
+
121
+        if ($excludedGroups) {
122
+            $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
123
+            $decodedExcludeGroups = json_decode($excludedGroups, true);
124
+            $excludeGroupsList = ($decodedExcludeGroups !== null) ? $decodedExcludeGroups :  [];
125
+
126
+            if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) {
127
+                // a group of the current user is excluded -> filter all local users
128
+                $skipLocal = true;
129
+            }
130
+        }
131
+
132
+        $selfUID = $self->getUID();
133
+
134
+        return array_values(array_filter($entries, function(IEntry $entry) use ($self, $skipLocal, $ownGroupsOnly, $selfGroups, $selfUID, $disallowEnumeration, $filter) {
135
+            if ($skipLocal && $entry->getProperty('isLocalSystemBook') === true) {
136
+                return false;
137
+            }
138
+
139
+            // Prevent enumerating local users
140
+            if($disallowEnumeration && $entry->getProperty('isLocalSystemBook')) {
141
+                $filterUser = true;
142
+
143
+                $mailAddresses = $entry->getEMailAddresses();
144
+                foreach($mailAddresses as $mailAddress) {
145
+                    if($mailAddress === $filter) {
146
+                        $filterUser = false;
147
+                        break;
148
+                    }
149
+                }
150
+
151
+                if($entry->getProperty('UID') && $entry->getProperty('UID') === $filter) {
152
+                    $filterUser = false;
153
+                }
154
+
155
+                if($filterUser) {
156
+                    return false;
157
+                }
158
+            }
159
+
160
+            if ($ownGroupsOnly && $entry->getProperty('isLocalSystemBook') === true) {
161
+                $uid = $this->userManager->get($entry->getProperty('UID'));
162
+
163
+                if ($uid === null) {
164
+                    return false;
165
+                }
166
+
167
+                $contactGroups = $this->groupManager->getUserGroupIds($uid);
168
+                if (count(array_intersect($contactGroups, $selfGroups)) === 0) {
169
+                    // no groups in common, so shouldn't see the contact
170
+                    return false;
171
+                }
172
+            }
173
+
174
+            return $entry->getProperty('UID') !== $selfUID;
175
+        }));
176
+    }
177
+
178
+    /**
179
+     * @param IUser $user
180
+     * @param integer $shareType
181
+     * @param string $shareWith
182
+     * @return IEntry|null
183
+     */
184
+    public function findOne(IUser $user, $shareType, $shareWith) {
185
+        switch($shareType) {
186
+            case 0:
187
+            case 6:
188
+                $filter = ['UID'];
189
+                break;
190
+            case 4:
191
+                $filter = ['EMAIL'];
192
+                break;
193
+            default:
194
+                return null;
195
+        }
196
+
197
+        $userId = $user->getUID();
198
+        $allContacts = $this->contactsManager->search($shareWith, $filter);
199
+        $contacts = array_filter($allContacts, function($contact) use ($userId) {
200
+            return $contact['UID'] !== $userId;
201
+        });
202
+        $match = null;
203
+
204
+        foreach ($contacts as $contact) {
205
+            if ($shareType === 4 && isset($contact['EMAIL'])) {
206
+                if (in_array($shareWith, $contact['EMAIL'])) {
207
+                    $match = $contact;
208
+                    break;
209
+                }
210
+            }
211
+            if ($shareType === 0 || $shareType === 6) {
212
+                $isLocal = $contact['isLocalSystemBook'] ?? false;
213
+                if ($contact['UID'] === $shareWith && $isLocal === true) {
214
+                    $match = $contact;
215
+                    break;
216
+                }
217
+            }
218
+        }
219
+
220
+        if ($match) {
221
+            $match = $this->filterContacts($user, [$this->contactArrayToEntry($match)], $shareWith);
222
+            if (count($match) === 1) {
223
+                $match = $match[0];
224
+            } else {
225
+                $match = null;
226
+            }
227
+
228
+        }
229
+
230
+        return $match;
231
+    }
232
+
233
+    /**
234
+     * @param array $contact
235
+     * @return Entry
236
+     */
237
+    private function contactArrayToEntry(array $contact) {
238
+        $entry = new Entry();
239
+
240
+        if (isset($contact['id'])) {
241
+            $entry->setId($contact['id']);
242
+        }
243
+
244
+        if (isset($contact['FN'])) {
245
+            $entry->setFullName($contact['FN']);
246
+        }
247
+
248
+        $avatarPrefix = "VALUE=uri:";
249
+        if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) {
250
+            $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix)));
251
+        }
252
+
253
+        if (isset($contact['EMAIL'])) {
254
+            foreach ($contact['EMAIL'] as $email) {
255
+                $entry->addEMailAddress($email);
256
+            }
257
+        }
258
+
259
+        // Attach all other properties to the entry too because some
260
+        // providers might make use of it.
261
+        $entry->setProperties($contact);
262
+
263
+        return $entry;
264
+    }
265 265
 
266 266
 }
Please login to merge, or discard this patch.
apps/theming/lib/IconBuilder.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			$icon->setImageFormat("png32");
64 64
 
65 65
 			$clone = clone $icon;
66
-			$clone->scaleImage(16,0);
66
+			$clone->scaleImage(16, 0);
67 67
 			$favicon->addImage($clone);
68 68
 
69 69
 			$clone = clone $icon;
70
-			$clone->scaleImage(32,0);
70
+			$clone->scaleImage(32, 0);
71 71
 			$favicon->addImage($clone);
72 72
 
73 73
 			$clone = clone $icon;
74
-			$clone->scaleImage(64,0);
74
+			$clone->scaleImage(64, 0);
75 75
 			$favicon->addImage($clone);
76 76
 
77 77
 			$clone = clone $icon;
78
-			$clone->scaleImage(128,0);
78
+			$clone->scaleImage(128, 0);
79 79
 			$favicon->addImage($clone);
80 80
 
81 81
 			$data = $favicon->getImagesBlob();
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function renderAppIcon($app, $size) {
119 119
 		$appIcon = $this->util->getAppIcon($app);
120
-		if($appIcon === false) {
120
+		if ($appIcon === false) {
121 121
 			return false;
122 122
 		}
123 123
 		if ($appIcon instanceof ISimpleFile) {
@@ -128,20 +128,20 @@  discard block
 block discarded – undo
128 128
 			$mime = mime_content_type($appIcon);
129 129
 		}
130 130
 
131
-		if($appIconContent === false || $appIconContent === "") {
131
+		if ($appIconContent === false || $appIconContent === "") {
132 132
 			return false;
133 133
 		}
134 134
 
135 135
 		$color = $this->themingDefaults->getColorPrimary();
136 136
 
137 137
 		// generate background image with rounded corners
138
-		$background = '<?xml version="1.0" encoding="UTF-8"?>' .
139
-			'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
140
-			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
138
+		$background = '<?xml version="1.0" encoding="UTF-8"?>'.
139
+			'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">'.
140
+			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:'.$color.';" />'.
141 141
 			'</svg>';
142 142
 		// resize svg magic as this seems broken in Imagemagick
143
-		if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
144
-			if(substr($appIconContent, 0, 5) !== "<?xml") {
143
+		if ($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
144
+			if (substr($appIconContent, 0, 5) !== "<?xml") {
145 145
 				$svg = "<?xml version=\"1.0\"?>".$appIconContent;
146 146
 			} else {
147 147
 				$svg = $appIconContent;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			$res = $tmp->getImageResolution();
154 154
 			$tmp->destroy();
155 155
 
156
-			if($x>$y) {
156
+			if ($x > $y) {
157 157
 				$max = $x;
158 158
 			} else {
159 159
 				$max = $y;
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 
162 162
 			// convert svg to resized image
163 163
 			$appIconFile = new Imagick();
164
-			$resX = (int)(512 * $res['x'] / $max * 2.53);
165
-			$resY = (int)(512 * $res['y'] / $max * 2.53);
164
+			$resX = (int) (512 * $res['x'] / $max * 2.53);
165
+			$resY = (int) (512 * $res['y'] / $max * 2.53);
166 166
 			$appIconFile->setResolution($resX, $resY);
167 167
 			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
168 168
 			$appIconFile->readImageBlob($svg);
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 			$appIconFile->scaleImage(512, 512, true);
186 186
 		}
187 187
 		// offset for icon positioning
188
-		$border_w = (int)($appIconFile->getImageWidth() * 0.05);
189
-		$border_h = (int)($appIconFile->getImageHeight() * 0.05);
190
-		$innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
191
-		$innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
188
+		$border_w = (int) ($appIconFile->getImageWidth() * 0.05);
189
+		$border_h = (int) ($appIconFile->getImageHeight() * 0.05);
190
+		$innerWidth = (int) ($appIconFile->getImageWidth() - $border_w * 2);
191
+		$innerHeight = (int) ($appIconFile->getImageHeight() - $border_h * 2);
192 192
 		$appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
193 193
 		// center icon
194 194
 		$offset_w = 512 / 2 - $innerWidth / 2;
Please login to merge, or discard this patch.
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -31,211 +31,211 @@
 block discarded – undo
31 31
 use OCP\Files\SimpleFS\ISimpleFile;
32 32
 
33 33
 class IconBuilder {
34
-	/** @var ThemingDefaults */
35
-	private $themingDefaults;
36
-	/** @var Util */
37
-	private $util;
38
-	/** @var ImageManager */
39
-	private $imageManager;
40
-
41
-	/**
42
-	 * IconBuilder constructor.
43
-	 *
44
-	 * @param ThemingDefaults $themingDefaults
45
-	 * @param Util $util
46
-	 * @param ImageManager $imageManager
47
-	 */
48
-	public function __construct(
49
-		ThemingDefaults $themingDefaults,
50
-		Util $util,
51
-		ImageManager $imageManager
52
-	) {
53
-		$this->themingDefaults = $themingDefaults;
54
-		$this->util = $util;
55
-		$this->imageManager = $imageManager;
56
-	}
57
-
58
-	/**
59
-	 * @param $app string app name
60
-	 * @return string|false image blob
61
-	 */
62
-	public function getFavicon($app) {
63
-		if (!$this->imageManager->shouldReplaceIcons()) {
64
-			return false;
65
-		}
66
-		try {
67
-			$favicon = new Imagick();
68
-			$favicon->setFormat("ico");
69
-			$icon = $this->renderAppIcon($app, 128);
70
-			if ($icon === false) {
71
-				return false;
72
-			}
73
-			$icon->setImageFormat("png32");
74
-
75
-			$clone = clone $icon;
76
-			$clone->scaleImage(16,0);
77
-			$favicon->addImage($clone);
78
-
79
-			$clone = clone $icon;
80
-			$clone->scaleImage(32,0);
81
-			$favicon->addImage($clone);
82
-
83
-			$clone = clone $icon;
84
-			$clone->scaleImage(64,0);
85
-			$favicon->addImage($clone);
86
-
87
-			$clone = clone $icon;
88
-			$clone->scaleImage(128,0);
89
-			$favicon->addImage($clone);
90
-
91
-			$data = $favicon->getImagesBlob();
92
-			$favicon->destroy();
93
-			$icon->destroy();
94
-			$clone->destroy();
95
-			return $data;
96
-		} catch (\ImagickException $e) {
97
-			return false;
98
-		}
99
-	}
100
-
101
-	/**
102
-	 * @param $app string app name
103
-	 * @return string|false image blob
104
-	 */
105
-	public function getTouchIcon($app) {
106
-		try {
107
-			$icon = $this->renderAppIcon($app, 512);
108
-			if ($icon === false) {
109
-				return false;
110
-			}
111
-			$icon->setImageFormat("png32");
112
-			$data = $icon->getImageBlob();
113
-			$icon->destroy();
114
-			return $data;
115
-		} catch (\ImagickException $e) {
116
-			return false;
117
-		}
118
-	}
119
-
120
-	/**
121
-	 * Render app icon on themed background color
122
-	 * fallback to logo
123
-	 *
124
-	 * @param $app string app name
125
-	 * @param $size int size of the icon in px
126
-	 * @return Imagick|false
127
-	 */
128
-	public function renderAppIcon($app, $size) {
129
-		$appIcon = $this->util->getAppIcon($app);
130
-		if($appIcon === false) {
131
-			return false;
132
-		}
133
-		if ($appIcon instanceof ISimpleFile) {
134
-			$appIconContent = $appIcon->getContent();
135
-			$mime = $appIcon->getMimeType();
136
-		} else {
137
-			$appIconContent = file_get_contents($appIcon);
138
-			$mime = mime_content_type($appIcon);
139
-		}
140
-
141
-		if($appIconContent === false || $appIconContent === "") {
142
-			return false;
143
-		}
144
-
145
-		$color = $this->themingDefaults->getColorPrimary();
146
-
147
-		// generate background image with rounded corners
148
-		$background = '<?xml version="1.0" encoding="UTF-8"?>' .
149
-			'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
150
-			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
151
-			'</svg>';
152
-		// resize svg magic as this seems broken in Imagemagick
153
-		if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
154
-			if(substr($appIconContent, 0, 5) !== "<?xml") {
155
-				$svg = "<?xml version=\"1.0\"?>".$appIconContent;
156
-			} else {
157
-				$svg = $appIconContent;
158
-			}
159
-			$tmp = new Imagick();
160
-			$tmp->readImageBlob($svg);
161
-			$x = $tmp->getImageWidth();
162
-			$y = $tmp->getImageHeight();
163
-			$res = $tmp->getImageResolution();
164
-			$tmp->destroy();
165
-
166
-			if($x>$y) {
167
-				$max = $x;
168
-			} else {
169
-				$max = $y;
170
-			}
171
-
172
-			// convert svg to resized image
173
-			$appIconFile = new Imagick();
174
-			$resX = (int)(512 * $res['x'] / $max * 2.53);
175
-			$resY = (int)(512 * $res['y'] / $max * 2.53);
176
-			$appIconFile->setResolution($resX, $resY);
177
-			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
178
-			$appIconFile->readImageBlob($svg);
179
-
180
-			/**
181
-			 * invert app icons for bright primary colors
182
-			 * the default nextcloud logo will not be inverted to black
183
-			 */
184
-			if ($this->util->invertTextColor($color)
185
-				&& !$appIcon instanceof ISimpleFile
186
-				&& $app !== "core"
187
-			) {
188
-				$appIconFile->negateImage(false);
189
-			}
190
-			$appIconFile->scaleImage(512, 512, true);
191
-		} else {
192
-			$appIconFile = new Imagick();
193
-			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
194
-			$appIconFile->readImageBlob($appIconContent);
195
-			$appIconFile->scaleImage(512, 512, true);
196
-		}
197
-		// offset for icon positioning
198
-		$border_w = (int)($appIconFile->getImageWidth() * 0.05);
199
-		$border_h = (int)($appIconFile->getImageHeight() * 0.05);
200
-		$innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
201
-		$innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
202
-		$appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
203
-		// center icon
204
-		$offset_w = 512 / 2 - $innerWidth / 2;
205
-		$offset_h = 512 / 2 - $innerHeight / 2;
206
-
207
-		$finalIconFile = new Imagick();
208
-		$finalIconFile->setBackgroundColor(new ImagickPixel('transparent'));
209
-		$finalIconFile->readImageBlob($background);
210
-		$finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
211
-		$finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5");
212
-		$finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h);
213
-		$finalIconFile->setImageFormat('png24');
214
-		if (defined("Imagick::INTERPOLATE_BICUBIC") === true) {
215
-			$filter = Imagick::INTERPOLATE_BICUBIC;
216
-		} else {
217
-			$filter = Imagick::FILTER_LANCZOS;
218
-		}
219
-		$finalIconFile->resizeImage($size, $size, $filter, 1, false);
220
-
221
-		$appIconFile->destroy();
222
-		return $finalIconFile;
223
-	}
224
-
225
-	public function colorSvg($app, $image) {
226
-		try {
227
-			$imageFile = $this->util->getAppImage($app, $image);
228
-		} catch (AppPathNotFoundException $e) {
229
-			return false;
230
-		}
231
-		$svg = file_get_contents($imageFile);
232
-		if ($svg !== false && $svg !== "") {
233
-			$color = $this->util->elementColor($this->themingDefaults->getColorPrimary());
234
-			$svg = $this->util->colorizeSvg($svg, $color);
235
-			return $svg;
236
-		} else {
237
-			return false;
238
-		}
239
-	}
34
+    /** @var ThemingDefaults */
35
+    private $themingDefaults;
36
+    /** @var Util */
37
+    private $util;
38
+    /** @var ImageManager */
39
+    private $imageManager;
40
+
41
+    /**
42
+     * IconBuilder constructor.
43
+     *
44
+     * @param ThemingDefaults $themingDefaults
45
+     * @param Util $util
46
+     * @param ImageManager $imageManager
47
+     */
48
+    public function __construct(
49
+        ThemingDefaults $themingDefaults,
50
+        Util $util,
51
+        ImageManager $imageManager
52
+    ) {
53
+        $this->themingDefaults = $themingDefaults;
54
+        $this->util = $util;
55
+        $this->imageManager = $imageManager;
56
+    }
57
+
58
+    /**
59
+     * @param $app string app name
60
+     * @return string|false image blob
61
+     */
62
+    public function getFavicon($app) {
63
+        if (!$this->imageManager->shouldReplaceIcons()) {
64
+            return false;
65
+        }
66
+        try {
67
+            $favicon = new Imagick();
68
+            $favicon->setFormat("ico");
69
+            $icon = $this->renderAppIcon($app, 128);
70
+            if ($icon === false) {
71
+                return false;
72
+            }
73
+            $icon->setImageFormat("png32");
74
+
75
+            $clone = clone $icon;
76
+            $clone->scaleImage(16,0);
77
+            $favicon->addImage($clone);
78
+
79
+            $clone = clone $icon;
80
+            $clone->scaleImage(32,0);
81
+            $favicon->addImage($clone);
82
+
83
+            $clone = clone $icon;
84
+            $clone->scaleImage(64,0);
85
+            $favicon->addImage($clone);
86
+
87
+            $clone = clone $icon;
88
+            $clone->scaleImage(128,0);
89
+            $favicon->addImage($clone);
90
+
91
+            $data = $favicon->getImagesBlob();
92
+            $favicon->destroy();
93
+            $icon->destroy();
94
+            $clone->destroy();
95
+            return $data;
96
+        } catch (\ImagickException $e) {
97
+            return false;
98
+        }
99
+    }
100
+
101
+    /**
102
+     * @param $app string app name
103
+     * @return string|false image blob
104
+     */
105
+    public function getTouchIcon($app) {
106
+        try {
107
+            $icon = $this->renderAppIcon($app, 512);
108
+            if ($icon === false) {
109
+                return false;
110
+            }
111
+            $icon->setImageFormat("png32");
112
+            $data = $icon->getImageBlob();
113
+            $icon->destroy();
114
+            return $data;
115
+        } catch (\ImagickException $e) {
116
+            return false;
117
+        }
118
+    }
119
+
120
+    /**
121
+     * Render app icon on themed background color
122
+     * fallback to logo
123
+     *
124
+     * @param $app string app name
125
+     * @param $size int size of the icon in px
126
+     * @return Imagick|false
127
+     */
128
+    public function renderAppIcon($app, $size) {
129
+        $appIcon = $this->util->getAppIcon($app);
130
+        if($appIcon === false) {
131
+            return false;
132
+        }
133
+        if ($appIcon instanceof ISimpleFile) {
134
+            $appIconContent = $appIcon->getContent();
135
+            $mime = $appIcon->getMimeType();
136
+        } else {
137
+            $appIconContent = file_get_contents($appIcon);
138
+            $mime = mime_content_type($appIcon);
139
+        }
140
+
141
+        if($appIconContent === false || $appIconContent === "") {
142
+            return false;
143
+        }
144
+
145
+        $color = $this->themingDefaults->getColorPrimary();
146
+
147
+        // generate background image with rounded corners
148
+        $background = '<?xml version="1.0" encoding="UTF-8"?>' .
149
+            '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
150
+            '<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
151
+            '</svg>';
152
+        // resize svg magic as this seems broken in Imagemagick
153
+        if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
154
+            if(substr($appIconContent, 0, 5) !== "<?xml") {
155
+                $svg = "<?xml version=\"1.0\"?>".$appIconContent;
156
+            } else {
157
+                $svg = $appIconContent;
158
+            }
159
+            $tmp = new Imagick();
160
+            $tmp->readImageBlob($svg);
161
+            $x = $tmp->getImageWidth();
162
+            $y = $tmp->getImageHeight();
163
+            $res = $tmp->getImageResolution();
164
+            $tmp->destroy();
165
+
166
+            if($x>$y) {
167
+                $max = $x;
168
+            } else {
169
+                $max = $y;
170
+            }
171
+
172
+            // convert svg to resized image
173
+            $appIconFile = new Imagick();
174
+            $resX = (int)(512 * $res['x'] / $max * 2.53);
175
+            $resY = (int)(512 * $res['y'] / $max * 2.53);
176
+            $appIconFile->setResolution($resX, $resY);
177
+            $appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
178
+            $appIconFile->readImageBlob($svg);
179
+
180
+            /**
181
+             * invert app icons for bright primary colors
182
+             * the default nextcloud logo will not be inverted to black
183
+             */
184
+            if ($this->util->invertTextColor($color)
185
+                && !$appIcon instanceof ISimpleFile
186
+                && $app !== "core"
187
+            ) {
188
+                $appIconFile->negateImage(false);
189
+            }
190
+            $appIconFile->scaleImage(512, 512, true);
191
+        } else {
192
+            $appIconFile = new Imagick();
193
+            $appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
194
+            $appIconFile->readImageBlob($appIconContent);
195
+            $appIconFile->scaleImage(512, 512, true);
196
+        }
197
+        // offset for icon positioning
198
+        $border_w = (int)($appIconFile->getImageWidth() * 0.05);
199
+        $border_h = (int)($appIconFile->getImageHeight() * 0.05);
200
+        $innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
201
+        $innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
202
+        $appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
203
+        // center icon
204
+        $offset_w = 512 / 2 - $innerWidth / 2;
205
+        $offset_h = 512 / 2 - $innerHeight / 2;
206
+
207
+        $finalIconFile = new Imagick();
208
+        $finalIconFile->setBackgroundColor(new ImagickPixel('transparent'));
209
+        $finalIconFile->readImageBlob($background);
210
+        $finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT);
211
+        $finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5");
212
+        $finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h);
213
+        $finalIconFile->setImageFormat('png24');
214
+        if (defined("Imagick::INTERPOLATE_BICUBIC") === true) {
215
+            $filter = Imagick::INTERPOLATE_BICUBIC;
216
+        } else {
217
+            $filter = Imagick::FILTER_LANCZOS;
218
+        }
219
+        $finalIconFile->resizeImage($size, $size, $filter, 1, false);
220
+
221
+        $appIconFile->destroy();
222
+        return $finalIconFile;
223
+    }
224
+
225
+    public function colorSvg($app, $image) {
226
+        try {
227
+            $imageFile = $this->util->getAppImage($app, $image);
228
+        } catch (AppPathNotFoundException $e) {
229
+            return false;
230
+        }
231
+        $svg = file_get_contents($imageFile);
232
+        if ($svg !== false && $svg !== "") {
233
+            $color = $this->util->elementColor($this->themingDefaults->getColorPrimary());
234
+            $svg = $this->util->colorizeSvg($svg, $color);
235
+            return $svg;
236
+        } else {
237
+            return false;
238
+        }
239
+    }
240 240
 
241 241
 }
Please login to merge, or discard this patch.