@@ -56,13 +56,13 @@ |
||
56 | 56 | $translations = $this->l10n->getTranslations(); |
57 | 57 | |
58 | 58 | $text = $this->text; |
59 | - if(array_key_exists($this->text, $translations)) { |
|
60 | - if(is_array($translations[$this->text])) { |
|
59 | + if (array_key_exists($this->text, $translations)) { |
|
60 | + if (is_array($translations[$this->text])) { |
|
61 | 61 | $fn = $this->l10n->getPluralFormFunction(); |
62 | 62 | $id = $fn($this->count); |
63 | 63 | $text = $translations[$this->text][$id]; |
64 | 64 | } |
65 | - else{ |
|
65 | + else { |
|
66 | 66 | $text = $translations[$this->text]; |
67 | 67 | } |
68 | 68 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | public function isComplete() { |
86 | 86 | $prefix = $this->getPrefix(); |
87 | 87 | $cache = $this->getCache(); |
88 | - $chunkcount = (int)$this->info['chunkcount']; |
|
88 | + $chunkcount = (int) $this->info['chunkcount']; |
|
89 | 89 | |
90 | - for($i=($chunkcount-1); $i >= 0; $i--) { |
|
90 | + for ($i = ($chunkcount - 1); $i >= 0; $i--) { |
|
91 | 91 | if (!$cache->hasKey($prefix.$i)) { |
92 | 92 | return false; |
93 | 93 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function cleanup() { |
144 | 144 | $cache = $this->getCache(); |
145 | 145 | $prefix = $this->getPrefix(); |
146 | - for($i=0; $i < $this->info['chunkcount']; $i++) { |
|
146 | + for ($i = 0; $i < $this->info['chunkcount']; $i++) { |
|
147 | 147 | $cache->remove($prefix.$i); |
148 | 148 | } |
149 | 149 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $requirements = array()) { |
93 | 93 | $name = strtolower($method).$url; |
94 | 94 | $name = str_replace(array('/', '{', '}'), '_', $name); |
95 | - if(!isset(self::$actions[$name])) { |
|
95 | + if (!isset(self::$actions[$name])) { |
|
96 | 96 | $oldCollection = OC::$server->getRouter()->getCurrentCollection(); |
97 | 97 | OC::$server->getRouter()->useCollection('ocs'); |
98 | 98 | OC::$server->getRouter()->create($name, $url) |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | $method = $request->getMethod(); |
116 | 116 | |
117 | 117 | // Prepare the request variables |
118 | - if($method === 'PUT') { |
|
118 | + if ($method === 'PUT') { |
|
119 | 119 | $parameters['_put'] = $request->getParams(); |
120 | - } else if($method === 'DELETE') { |
|
120 | + } else if ($method === 'DELETE') { |
|
121 | 121 | $parameters['_delete'] = $request->getParams(); |
122 | 122 | } |
123 | 123 | $name = $parameters['_route']; |
124 | 124 | // Foreach registered action |
125 | 125 | $responses = array(); |
126 | - foreach(self::$actions[$name] as $action) { |
|
126 | + foreach (self::$actions[$name] as $action) { |
|
127 | 127 | // Check authentication and availability |
128 | - if(!self::isAuthorised($action)) { |
|
128 | + if (!self::isAuthorised($action)) { |
|
129 | 129 | $responses[] = array( |
130 | 130 | 'app' => $action['app'], |
131 | 131 | 'response' => new OC_OCS_Result(null, API::RESPOND_UNAUTHORISED, 'Unauthorised'), |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | ); |
134 | 134 | continue; |
135 | 135 | } |
136 | - if(!is_callable($action['action'])) { |
|
136 | + if (!is_callable($action['action'])) { |
|
137 | 137 | $responses[] = array( |
138 | 138 | 'app' => $action['app'], |
139 | 139 | 'response' => new OC_OCS_Result(null, API::RESPOND_NOT_FOUND, 'Api method not found'), |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | 'failed' => array(), |
174 | 174 | ); |
175 | 175 | |
176 | - foreach($responses as $response) { |
|
177 | - if($response['shipped'] || ($response['app'] === 'core')) { |
|
178 | - if($response['response']->succeeded()) { |
|
176 | + foreach ($responses as $response) { |
|
177 | + if ($response['shipped'] || ($response['app'] === 'core')) { |
|
178 | + if ($response['response']->succeeded()) { |
|
179 | 179 | $shipped['succeeded'][$response['app']] = $response; |
180 | 180 | } else { |
181 | 181 | $shipped['failed'][$response['app']] = $response; |
182 | 182 | } |
183 | 183 | } else { |
184 | - if($response['response']->succeeded()) { |
|
184 | + if ($response['response']->succeeded()) { |
|
185 | 185 | $thirdparty['succeeded'][$response['app']] = $response; |
186 | 186 | } else { |
187 | 187 | $thirdparty['failed'][$response['app']] = $response; |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | // Remove any error responses if there is one shipped response that succeeded |
193 | - if(!empty($shipped['failed'])) { |
|
193 | + if (!empty($shipped['failed'])) { |
|
194 | 194 | // Which shipped response do we use if they all failed? |
195 | 195 | // They may have failed for different reasons (different status codes) |
196 | 196 | // Which response code should we return? |
197 | 197 | // Maybe any that are not \OCP\API::RESPOND_SERVER_ERROR |
198 | 198 | // Merge failed responses if more than one |
199 | 199 | $data = array(); |
200 | - foreach($shipped['failed'] as $failure) { |
|
200 | + foreach ($shipped['failed'] as $failure) { |
|
201 | 201 | $data = array_merge_recursive($data, $failure['response']->getData()); |
202 | 202 | } |
203 | 203 | $picked = reset($shipped['failed']); |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | $headers = $picked['response']->getHeaders(); |
207 | 207 | $response = new OC_OCS_Result($data, $code, $meta['message'], $headers); |
208 | 208 | return $response; |
209 | - } elseif(!empty($shipped['succeeded'])) { |
|
209 | + } elseif (!empty($shipped['succeeded'])) { |
|
210 | 210 | $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']); |
211 | - } elseif(!empty($thirdparty['failed'])) { |
|
211 | + } elseif (!empty($thirdparty['failed'])) { |
|
212 | 212 | // Merge failed responses if more than one |
213 | 213 | $data = array(); |
214 | - foreach($thirdparty['failed'] as $failure) { |
|
214 | + foreach ($thirdparty['failed'] as $failure) { |
|
215 | 215 | $data = array_merge_recursive($data, $failure['response']->getData()); |
216 | 216 | } |
217 | 217 | $picked = reset($thirdparty['failed']); |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $codes = []; |
229 | 229 | $header = []; |
230 | 230 | |
231 | - foreach($responses as $response) { |
|
232 | - if($response['shipped']) { |
|
231 | + foreach ($responses as $response) { |
|
232 | + if ($response['shipped']) { |
|
233 | 233 | $data = array_merge_recursive($response['response']->getData(), $data); |
234 | 234 | } else { |
235 | 235 | $data = array_merge_recursive($data, $response['response']->getData()); |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | // Use any non 100 status codes |
243 | 243 | $statusCode = 100; |
244 | 244 | $statusMessage = null; |
245 | - foreach($codes as $code) { |
|
246 | - if($code['code'] != 100) { |
|
245 | + foreach ($codes as $code) { |
|
246 | + if ($code['code'] != 100) { |
|
247 | 247 | $statusCode = $code['code']; |
248 | 248 | $statusMessage = $code['meta']['message']; |
249 | 249 | break; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | private static function isAuthorised($action) { |
262 | 262 | $level = $action['authlevel']; |
263 | - switch($level) { |
|
263 | + switch ($level) { |
|
264 | 264 | case API::GUEST_AUTH: |
265 | 265 | // Anyone can access |
266 | 266 | return true; |
@@ -270,16 +270,16 @@ discard block |
||
270 | 270 | case API::SUBADMIN_AUTH: |
271 | 271 | // Check for subadmin |
272 | 272 | $user = self::loginUser(); |
273 | - if(!$user) { |
|
273 | + if (!$user) { |
|
274 | 274 | return false; |
275 | 275 | } else { |
276 | 276 | $userObject = \OC::$server->getUserSession()->getUser(); |
277 | - if($userObject === null) { |
|
277 | + if ($userObject === null) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
281 | 281 | $admin = OC_User::isAdminUser($user); |
282 | - if($isSubAdmin || $admin) { |
|
282 | + if ($isSubAdmin || $admin) { |
|
283 | 283 | return true; |
284 | 284 | } else { |
285 | 285 | return false; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | case API::ADMIN_AUTH: |
289 | 289 | // Check for admin |
290 | 290 | $user = self::loginUser(); |
291 | - if(!$user) { |
|
291 | + if (!$user) { |
|
292 | 292 | return false; |
293 | 293 | } else { |
294 | 294 | return OC_User::isAdminUser($user); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @return string|false (username, or false on failure) |
305 | 305 | */ |
306 | 306 | private static function loginUser() { |
307 | - if(self::$isLoggedIn === true) { |
|
307 | + if (self::$isLoggedIn === true) { |
|
308 | 308 | return \OC_User::getUser(); |
309 | 309 | } |
310 | 310 | |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | * @param OC_OCS_Result $result |
359 | 359 | * @param string $format the format xml|json |
360 | 360 | */ |
361 | - public static function respond($result, $format='xml') { |
|
361 | + public static function respond($result, $format = 'xml') { |
|
362 | 362 | $request = \OC::$server->getRequest(); |
363 | 363 | |
364 | 364 | // Send 401 headers if unauthorised |
365 | - if($result->getStatusCode() === API::RESPOND_UNAUTHORISED) { |
|
365 | + if ($result->getStatusCode() === API::RESPOND_UNAUTHORISED) { |
|
366 | 366 | // If request comes from JS return dummy auth request |
367 | - if($request->getHeader('X-Requested-With') === 'XMLHttpRequest') { |
|
367 | + if ($request->getHeader('X-Requested-With') === 'XMLHttpRequest') { |
|
368 | 368 | header('WWW-Authenticate: DummyBasic realm="Authorisation Required"'); |
369 | 369 | } else { |
370 | 370 | header('WWW-Authenticate: Basic realm="Authorisation Required"'); |
@@ -372,8 +372,8 @@ discard block |
||
372 | 372 | header('HTTP/1.0 401 Unauthorized'); |
373 | 373 | } |
374 | 374 | |
375 | - foreach($result->getHeaders() as $name => $value) { |
|
376 | - header($name . ': ' . $value); |
|
375 | + foreach ($result->getHeaders() as $name => $value) { |
|
376 | + header($name.': '.$value); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $meta = $result->getMeta(); |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | * @param XMLWriter $writer |
396 | 396 | */ |
397 | 397 | private static function toXML($array, $writer) { |
398 | - foreach($array as $k => $v) { |
|
398 | + foreach ($array as $k => $v) { |
|
399 | 399 | if ($k[0] === '@') { |
400 | 400 | $writer->writeAttribute(substr($k, 1), $v); |
401 | 401 | continue; |
402 | 402 | } else if (is_numeric($k)) { |
403 | 403 | $k = 'element'; |
404 | 404 | } |
405 | - if(is_array($v)) { |
|
405 | + if (is_array($v)) { |
|
406 | 406 | $writer->startElement($k); |
407 | 407 | self::toXML($v, $writer); |
408 | 408 | $writer->endElement(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * |
54 | 54 | * SQL query via Doctrine prepare(), needs to be execute()'d! |
55 | 55 | */ |
56 | - static public function prepare( $query , $limit = null, $offset = null, $isManipulation = null) { |
|
56 | + static public function prepare($query, $limit = null, $offset = null, $isManipulation = null) { |
|
57 | 57 | $connection = \OC::$server->getDatabaseConnection(); |
58 | 58 | |
59 | 59 | if ($isManipulation === null) { |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | // return the result |
65 | 65 | try { |
66 | - $result =$connection->prepare($query, $limit, $offset); |
|
66 | + $result = $connection->prepare($query, $limit, $offset); |
|
67 | 67 | } catch (\Doctrine\DBAL\DBALException $e) { |
68 | 68 | throw new \OC\DatabaseException($e->getMessage(), $query); |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param string $sql |
80 | 80 | * @return bool |
81 | 81 | */ |
82 | - static public function isManipulation( $sql ) { |
|
82 | + static public function isManipulation($sql) { |
|
83 | 83 | $selectOccurrence = stripos($sql, 'SELECT'); |
84 | 84 | if ($selectOccurrence !== false && $selectOccurrence < 10) { |
85 | 85 | return false; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @return OC_DB_StatementWrapper |
109 | 109 | * @throws \OC\DatabaseException |
110 | 110 | */ |
111 | - static public function executeAudited( $stmt, array $parameters = null) { |
|
111 | + static public function executeAudited($stmt, array $parameters = null) { |
|
112 | 112 | if (is_string($stmt)) { |
113 | 113 | // convert to an array with 'sql' |
114 | 114 | if (stripos($stmt, 'LIMIT') !== false) { //OFFSET requires LIMIT, so we only need to check for LIMIT |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | } |
122 | 122 | if (is_array($stmt)) { |
123 | 123 | // convert to prepared statement |
124 | - if ( ! array_key_exists('sql', $stmt) ) { |
|
124 | + if (!array_key_exists('sql', $stmt)) { |
|
125 | 125 | $message = 'statement array must at least contain key \'sql\''; |
126 | 126 | throw new \OC\DatabaseException($message); |
127 | 127 | } |
128 | - if ( ! array_key_exists('limit', $stmt) ) { |
|
128 | + if (!array_key_exists('limit', $stmt)) { |
|
129 | 129 | $stmt['limit'] = null; |
130 | 130 | } |
131 | - if ( ! array_key_exists('limit', $stmt) ) { |
|
131 | + if (!array_key_exists('limit', $stmt)) { |
|
132 | 132 | $stmt['offset'] = null; |
133 | 133 | } |
134 | 134 | $stmt = self::prepare($stmt['sql'], $stmt['limit'], $stmt['offset']); |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | self::raiseExceptionOnError($result, 'Could not execute statement'); |
140 | 140 | } else { |
141 | 141 | if (is_object($stmt)) { |
142 | - $message = 'Expected a prepared statement or array got ' . get_class($stmt); |
|
142 | + $message = 'Expected a prepared statement or array got '.get_class($stmt); |
|
143 | 143 | } else { |
144 | - $message = 'Expected a prepared statement or array got ' . gettype($stmt); |
|
144 | + $message = 'Expected a prepared statement or array got '.gettype($stmt); |
|
145 | 145 | } |
146 | 146 | throw new \OC\DatabaseException($message); |
147 | 147 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * |
169 | 169 | * TODO: write more documentation |
170 | 170 | */ |
171 | - public static function createDbFromStructure( $file ) { |
|
171 | + public static function createDbFromStructure($file) { |
|
172 | 172 | $schemaManager = self::getMDB2SchemaManager(); |
173 | 173 | $result = $schemaManager->createDbFromStructure($file); |
174 | 174 | return $result; |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | * @throws \OC\DatabaseException |
209 | 209 | */ |
210 | 210 | public static function raiseExceptionOnError($result, $message = null) { |
211 | - if($result === false) { |
|
211 | + if ($result === false) { |
|
212 | 212 | if ($message === null) { |
213 | 213 | $message = self::getErrorMessage(); |
214 | 214 | } else { |
215 | - $message .= ', Root cause:' . self::getErrorMessage(); |
|
215 | + $message .= ', Root cause:'.self::getErrorMessage(); |
|
216 | 216 | } |
217 | 217 | throw new \OC\DatabaseException($message, \OC::$server->getDatabaseConnection()->errorCode()); |
218 | 218 | } |
@@ -31,27 +31,27 @@ |
||
31 | 31 | * error code for functions not provided by the user backend |
32 | 32 | * @deprecated Use \OC_User_Backend::NOT_IMPLEMENTED instead |
33 | 33 | */ |
34 | -define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); |
|
34 | +define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501); |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * actions that user backends can define |
38 | 38 | */ |
39 | 39 | /** @deprecated Use \OC_User_Backend::CREATE_USER instead */ |
40 | -define('OC_USER_BACKEND_CREATE_USER', 1 << 0); |
|
40 | +define('OC_USER_BACKEND_CREATE_USER', 1 << 0); |
|
41 | 41 | /** @deprecated Use \OC_User_Backend::SET_PASSWORD instead */ |
42 | -define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4); |
|
42 | +define('OC_USER_BACKEND_SET_PASSWORD', 1 << 4); |
|
43 | 43 | /** @deprecated Use \OC_User_Backend::CHECK_PASSWORD instead */ |
44 | -define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8); |
|
44 | +define('OC_USER_BACKEND_CHECK_PASSWORD', 1 << 8); |
|
45 | 45 | /** @deprecated Use \OC_User_Backend::GET_HOME instead */ |
46 | -define('OC_USER_BACKEND_GET_HOME', 1 << 12); |
|
46 | +define('OC_USER_BACKEND_GET_HOME', 1 << 12); |
|
47 | 47 | /** @deprecated Use \OC_User_Backend::GET_DISPLAYNAME instead */ |
48 | -define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16); |
|
48 | +define('OC_USER_BACKEND_GET_DISPLAYNAME', 1 << 16); |
|
49 | 49 | /** @deprecated Use \OC_User_Backend::SET_DISPLAYNAME instead */ |
50 | -define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20); |
|
50 | +define('OC_USER_BACKEND_SET_DISPLAYNAME', 1 << 20); |
|
51 | 51 | /** @deprecated Use \OC_User_Backend::PROVIDE_AVATAR instead */ |
52 | -define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24); |
|
52 | +define('OC_USER_BACKEND_PROVIDE_AVATAR', 1 << 24); |
|
53 | 53 | /** @deprecated Use \OC_User_Backend::COUNT_USERS instead */ |
54 | -define('OC_USER_BACKEND_COUNT_USERS', 1 << 28); |
|
54 | +define('OC_USER_BACKEND_COUNT_USERS', 1 << 28); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Abstract base class for user management. Provides methods for querying backend |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * along with this program. If not, see <http://www.gnu.org/licenses/> |
29 | 29 | * |
30 | 30 | */ |
31 | -class OC_Hook{ |
|
31 | +class OC_Hook { |
|
32 | 32 | public static $thrownExceptions = []; |
33 | 33 | |
34 | 34 | static private $registered = array(); |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | * |
47 | 47 | * TODO: write example |
48 | 48 | */ |
49 | - static public function connect($signalClass, $signalName, $slotClass, $slotName ) { |
|
49 | + static public function connect($signalClass, $signalName, $slotClass, $slotName) { |
|
50 | 50 | // If we're trying to connect to an emitting class that isn't |
51 | 51 | // yet registered, register it |
52 | - if( !array_key_exists($signalClass, self::$registered )) { |
|
52 | + if (!array_key_exists($signalClass, self::$registered)) { |
|
53 | 53 | self::$registered[$signalClass] = array(); |
54 | 54 | } |
55 | 55 | // If we're trying to connect to an emitting method that isn't |
56 | 56 | // yet registered, register it with the emitting class |
57 | - if( !array_key_exists( $signalName, self::$registered[$signalClass] )) { |
|
57 | + if (!array_key_exists($signalName, self::$registered[$signalClass])) { |
|
58 | 58 | self::$registered[$signalClass][$signalName] = array(); |
59 | 59 | } |
60 | 60 | |
@@ -90,27 +90,27 @@ discard block |
||
90 | 90 | |
91 | 91 | // Return false if no hook handlers are listening to this |
92 | 92 | // emitting class |
93 | - if( !array_key_exists($signalClass, self::$registered )) { |
|
93 | + if (!array_key_exists($signalClass, self::$registered)) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
97 | 97 | // Return false if no hook handlers are listening to this |
98 | 98 | // emitting method |
99 | - if( !array_key_exists( $signalName, self::$registered[$signalClass] )) { |
|
99 | + if (!array_key_exists($signalName, self::$registered[$signalClass])) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Call all slots |
104 | - foreach( self::$registered[$signalClass][$signalName] as $i ) { |
|
104 | + foreach (self::$registered[$signalClass][$signalName] as $i) { |
|
105 | 105 | try { |
106 | - call_user_func( array( $i["class"], $i["name"] ), $params ); |
|
107 | - } catch (Exception $e){ |
|
106 | + call_user_func(array($i["class"], $i["name"]), $params); |
|
107 | + } catch (Exception $e) { |
|
108 | 108 | self::$thrownExceptions[] = $e; |
109 | 109 | \OC::$server->getLogger()->logException($e); |
110 | - if($e instanceof \OC\HintException) { |
|
110 | + if ($e instanceof \OC\HintException) { |
|
111 | 111 | throw $e; |
112 | 112 | } |
113 | - if($e instanceof \OC\ServerNotAvailableException) { |
|
113 | + if ($e instanceof \OC\ServerNotAvailableException) { |
|
114 | 114 | throw $e; |
115 | 115 | } |
116 | 116 | } |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @param string $signalClass |
125 | 125 | * @param string $signalName |
126 | 126 | */ |
127 | - static public function clear($signalClass='', $signalName='') { |
|
127 | + static public function clear($signalClass = '', $signalName = '') { |
|
128 | 128 | if ($signalClass) { |
129 | 129 | if ($signalName) { |
130 | - self::$registered[$signalClass][$signalName]=array(); |
|
131 | - }else{ |
|
132 | - self::$registered[$signalClass]=array(); |
|
130 | + self::$registered[$signalClass][$signalName] = array(); |
|
131 | + } else { |
|
132 | + self::$registered[$signalClass] = array(); |
|
133 | 133 | } |
134 | - }else{ |
|
135 | - self::$registered=array(); |
|
134 | + } else { |
|
135 | + self::$registered = array(); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | ->from(self::TABLE_ADMIN_SETTINGS, 'f') |
70 | 70 | ->where($query->expr()->eq('s.id', 'f.section')); |
71 | 71 | $result = $query->execute(); |
72 | - return array_map(function ($row) { |
|
73 | - $row['priority'] = (int)$row['priority']; |
|
72 | + return array_map(function($row) { |
|
73 | + $row['priority'] = (int) $row['priority']; |
|
74 | 74 | return $row; |
75 | 75 | }, $result->fetchAll()); |
76 | 76 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function add($table, array $values) { |
83 | 83 | $query = $this->dbc->getQueryBuilder(); |
84 | - $values = array_map(function ($value) use ($query) { |
|
84 | + $values = array_map(function($value) use ($query) { |
|
85 | 85 | return $query->createNamedParameter($value); |
86 | 86 | }, $values); |
87 | 87 | $query->insert($table)->values($values); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $data = $resultStatement->fetchAll(); |
103 | 103 | $resultStatement->closeCursor(); |
104 | 104 | |
105 | - return array_map(function ($row) { |
|
105 | + return array_map(function($row) { |
|
106 | 106 | return $row['class']; |
107 | 107 | }, $data); |
108 | 108 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $row = $result->fetch(); |
126 | 126 | $result->closeCursor(); |
127 | 127 | |
128 | - return (bool)$row; |
|
128 | + return (bool) $row; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | private $manager; |
47 | 47 | |
48 | 48 | public function __construct(Manager $manager = null) { |
49 | - if($manager !== null) { |
|
49 | + if ($manager !== null) { |
|
50 | 50 | $this->manager = $manager; |
51 | 51 | } else { |
52 | 52 | // fix DI for Jobs |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function execute($jobList, ILogger $logger = null) { |
64 | 64 | // add an interval of 15 mins |
65 | - $this->setInterval(15*60); |
|
65 | + $this->setInterval(15 * 60); |
|
66 | 66 | |
67 | 67 | $this->jobList = $jobList; |
68 | 68 | $this->logger = $logger; |
@@ -29,12 +29,12 @@ discard block |
||
29 | 29 | |
30 | 30 | class Streamer { |
31 | 31 | // array of regexp. Matching user agents will get tar instead of zip |
32 | - private $preferTarFor = [ '/macintosh|mac os x/i' ]; |
|
32 | + private $preferTarFor = ['/macintosh|mac os x/i']; |
|
33 | 33 | |
34 | 34 | // streamer instance |
35 | 35 | private $streamerInstance; |
36 | 36 | |
37 | - public function __construct(){ |
|
37 | + public function __construct() { |
|
38 | 38 | /** @var \OCP\IRequest */ |
39 | 39 | $request = \OC::$server->getRequest(); |
40 | 40 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | * Send HTTP headers |
50 | 50 | * @param string $name |
51 | 51 | */ |
52 | - public function sendHeaders($name){ |
|
52 | + public function sendHeaders($name) { |
|
53 | 53 | $extension = $this->streamerInstance instanceof ZipStreamer ? '.zip' : '.tar'; |
54 | - $fullName = $name . $extension; |
|
54 | + $fullName = $name.$extension; |
|
55 | 55 | $this->streamerInstance->sendHeaders($fullName); |
56 | 56 | } |
57 | 57 | |
@@ -60,27 +60,27 @@ discard block |
||
60 | 60 | * @param string $dir |
61 | 61 | * @param string $internalDir |
62 | 62 | */ |
63 | - public function addDirRecursive($dir, $internalDir='') { |
|
63 | + public function addDirRecursive($dir, $internalDir = '') { |
|
64 | 64 | $dirname = basename($dir); |
65 | - $rootDir = $internalDir . $dirname; |
|
65 | + $rootDir = $internalDir.$dirname; |
|
66 | 66 | if (!empty($rootDir)) { |
67 | 67 | $this->streamerInstance->addEmptyDir($rootDir); |
68 | 68 | } |
69 | - $internalDir .= $dirname . '/'; |
|
69 | + $internalDir .= $dirname.'/'; |
|
70 | 70 | // prevent absolute dirs |
71 | 71 | $internalDir = ltrim($internalDir, '/'); |
72 | 72 | |
73 | - $files= \OC\Files\Filesystem::getDirectoryContent($dir); |
|
74 | - foreach($files as $file) { |
|
73 | + $files = \OC\Files\Filesystem::getDirectoryContent($dir); |
|
74 | + foreach ($files as $file) { |
|
75 | 75 | $filename = $file['name']; |
76 | - $file = $dir . '/' . $filename; |
|
77 | - if(\OC\Files\Filesystem::is_file($file)) { |
|
76 | + $file = $dir.'/'.$filename; |
|
77 | + if (\OC\Files\Filesystem::is_file($file)) { |
|
78 | 78 | $filesize = \OC\Files\Filesystem::filesize($file); |
79 | 79 | $fileTime = \OC\Files\Filesystem::filemtime($file); |
80 | 80 | $fh = \OC\Files\Filesystem::fopen($file, 'r'); |
81 | - $this->addFileFromStream($fh, $internalDir . $filename, $filesize, $fileTime); |
|
81 | + $this->addFileFromStream($fh, $internalDir.$filename, $filesize, $fileTime); |
|
82 | 82 | fclose($fh); |
83 | - }elseif(\OC\Files\Filesystem::is_dir($file)) { |
|
83 | + }elseif (\OC\Files\Filesystem::is_dir($file)) { |
|
84 | 84 | $this->addDirRecursive($file, $internalDir); |
85 | 85 | } |
86 | 86 | } |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param string $dirName Directory Path and name to be added to the archive. |
117 | 117 | * @return bool $success |
118 | 118 | */ |
119 | - public function addEmptyDir($dirName){ |
|
119 | + public function addEmptyDir($dirName) { |
|
120 | 120 | return $this->streamerInstance->addEmptyDir($dirName); |
121 | 121 | } |
122 | 122 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * closing, the file is completely written to the output stream. |
127 | 127 | * @return bool $success |
128 | 128 | */ |
129 | - public function finalize(){ |
|
129 | + public function finalize() { |
|
130 | 130 | return $this->streamerInstance->finalize(); |
131 | 131 | } |
132 | 132 | } |