@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | //pass in app.php we do add here, except something else is passed e.g. |
81 | 81 | //in tests. |
82 | 82 | |
83 | - if(isset($arguments['helper'])) { |
|
83 | + if (isset($arguments['helper'])) { |
|
84 | 84 | $this->ldapHelper = $arguments['helper']; |
85 | 85 | } else { |
86 | 86 | $this->ldapHelper = new Helper(\OC::$server->getConfig()); |
87 | 87 | } |
88 | 88 | |
89 | - if(isset($arguments['ocConfig'])) { |
|
89 | + if (isset($arguments['ocConfig'])) { |
|
90 | 90 | $this->ocConfig = $arguments['ocConfig']; |
91 | 91 | } else { |
92 | 92 | $this->ocConfig = \OC::$server->getConfig(); |
93 | 93 | } |
94 | 94 | |
95 | - if(isset($arguments['userBackend'])) { |
|
95 | + if (isset($arguments['userBackend'])) { |
|
96 | 96 | $this->userBackend = $arguments['userBackend']; |
97 | 97 | } else { |
98 | - $this->userBackend = new User_Proxy( |
|
98 | + $this->userBackend = new User_Proxy( |
|
99 | 99 | $this->ldapHelper->getServerConfigurationPrefixes(true), |
100 | 100 | new LDAP(), |
101 | 101 | $this->ocConfig, |
@@ -103,19 +103,19 @@ discard block |
||
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
106 | - if(isset($arguments['db'])) { |
|
106 | + if (isset($arguments['db'])) { |
|
107 | 107 | $this->db = $arguments['db']; |
108 | 108 | } else { |
109 | 109 | $this->db = \OC::$server->getDatabaseConnection(); |
110 | 110 | } |
111 | 111 | |
112 | - if(isset($arguments['mapping'])) { |
|
112 | + if (isset($arguments['mapping'])) { |
|
113 | 113 | $this->mapping = $arguments['mapping']; |
114 | 114 | } else { |
115 | 115 | $this->mapping = new UserMapping($this->db); |
116 | 116 | } |
117 | 117 | |
118 | - if(isset($arguments['deletedUsersIndex'])) { |
|
118 | + if (isset($arguments['deletedUsersIndex'])) { |
|
119 | 119 | $this->dui = $arguments['deletedUsersIndex']; |
120 | 120 | } else { |
121 | 121 | $this->dui = new DeletedUsersIndex( |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | public function run($argument) { |
131 | 131 | $this->setArguments($argument); |
132 | 132 | |
133 | - if(!$this->isCleanUpAllowed()) { |
|
133 | + if (!$this->isCleanUpAllowed()) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | 136 | $users = $this->mapping->getList($this->getOffset(), $this->limit); |
137 | - if(!is_array($users)) { |
|
137 | + if (!is_array($users)) { |
|
138 | 138 | //something wrong? Let's start from the beginning next time and |
139 | 139 | //abort |
140 | 140 | $this->setOffset(true); |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function isCleanUpAllowed() { |
162 | 162 | try { |
163 | - if($this->ldapHelper->haveDisabledConfigurations()) { |
|
163 | + if ($this->ldapHelper->haveDisabledConfigurations()) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | } catch (\Exception $e) { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @return bool |
178 | 178 | */ |
179 | 179 | private function isCleanUpEnabled() { |
180 | - return (bool)$this->ocConfig->getSystemValue( |
|
180 | + return (bool) $this->ocConfig->getSystemValue( |
|
181 | 181 | 'ldapUserCleanupInterval', strval($this->defaultIntervalMin)); |
182 | 182 | } |
183 | 183 | |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param array $users result from getMappedUsers() |
187 | 187 | */ |
188 | 188 | private function checkUsers(array $users) { |
189 | - foreach($users as $user) { |
|
189 | + foreach ($users as $user) { |
|
190 | 190 | $this->checkUser($user); |
191 | 191 | } |
192 | 192 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @param string[] $user |
197 | 197 | */ |
198 | 198 | private function checkUser(array $user) { |
199 | - if($this->userBackend->userExistsOnLDAP($user['name'])) { |
|
199 | + if ($this->userBackend->userExistsOnLDAP($user['name'])) { |
|
200 | 200 | //still available, all good |
201 | 201 | |
202 | 202 | return; |
@@ -218,8 +218,7 @@ discard block |
||
218 | 218 | * @param bool $reset whether the offset should be set to 0 |
219 | 219 | */ |
220 | 220 | public function setOffset($reset = false) { |
221 | - $newOffset = $reset ? 0 : |
|
222 | - $this->getOffset() + $this->limit; |
|
221 | + $newOffset = $reset ? 0 : $this->getOffset() + $this->limit; |
|
223 | 222 | $this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset); |
224 | 223 | } |
225 | 224 |
@@ -27,7 +27,7 @@ |
||
27 | 27 | use OCP\AppFramework\IAppContainer; |
28 | 28 | |
29 | 29 | class Application extends App { |
30 | - public function __construct () { |
|
30 | + public function __construct() { |
|
31 | 31 | parent::__construct('user_ldap'); |
32 | 32 | $container = $this->getContainer(); |
33 | 33 |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $updatedEntries = $builder->execute(); |
73 | 73 | if ($updatedEntries > 0) { |
74 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + $out->info('Fixed file share permissions for '.$updatedEntries.' shares'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | if ($deletedEntries) { |
110 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + $out->info('Removed '.$deletedEntries.' shares where the parent did not exist'); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | public function getACL() { |
102 | - $acl = [ |
|
102 | + $acl = [ |
|
103 | 103 | [ |
104 | 104 | 'privilege' => '{DAV:}read', |
105 | 105 | 'principal' => $this->getOwner(), |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | 'protected' => true, |
112 | 112 | ]; |
113 | 113 | if ($this->getOwner() !== parent::getOwner()) { |
114 | - $acl[] = [ |
|
114 | + $acl[] = [ |
|
115 | 115 | 'privilege' => '{DAV:}read', |
116 | 116 | 'principal' => parent::getOwner(), |
117 | 117 | 'protected' => true, |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | public function delete() { |
172 | 172 | if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) { |
173 | - $principal = 'principal:' . parent::getOwner(); |
|
173 | + $principal = 'principal:'.parent::getOwner(); |
|
174 | 174 | $shares = $this->carddavBackend->getShares($this->getResourceId()); |
175 | 175 | $shares = array_filter($shares, function($share) use ($principal){ |
176 | 176 | return $share['href'] === $principal; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | ], |
55 | 55 | ]; |
56 | 56 | |
57 | - if($this->appManager->isEnabledForUser('files_sharing')) { |
|
57 | + if ($this->appManager->isEnabledForUser('files_sharing')) { |
|
58 | 58 | $services['SHARING'] = [ |
59 | 59 | 'version' => 1, |
60 | 60 | 'endpoints' => [ |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if($this->appManager->isEnabledForUser('activity')) { |
|
88 | + if ($this->appManager->isEnabledForUser('activity')) { |
|
89 | 89 | $services['ACTIVITY'] = [ |
90 | 90 | 'version' => 1, |
91 | 91 | 'endpoints' => [ |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ]; |
95 | 95 | } |
96 | 96 | |
97 | - if($this->appManager->isEnabledForUser('provisioning_api')) { |
|
97 | + if ($this->appManager->isEnabledForUser('provisioning_api')) { |
|
98 | 98 | $services['PROVISIONING'] = [ |
99 | 99 | 'version' => 1, |
100 | 100 | 'endpoints' => [ |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $principals = []; |
84 | 84 | |
85 | 85 | if ($prefixPath === $this->principalPrefix) { |
86 | - foreach($this->userManager->search('') as $user) { |
|
86 | + foreach ($this->userManager->search('') as $user) { |
|
87 | 87 | $principals[] = $this->userToPrincipal($user); |
88 | 88 | } |
89 | 89 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $groups = $this->groupManager->getUserGroups($user); |
151 | 151 | $groups = array_map(function($group) { |
152 | 152 | /** @var IGroup $group */ |
153 | - return 'principals/groups/' . urlencode($group->getGID()); |
|
153 | + return 'principals/groups/'.urlencode($group->getGID()); |
|
154 | 154 | }, $groups); |
155 | 155 | |
156 | 156 | return $groups; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $email = substr($uri, 7); |
202 | 202 | $users = $this->userManager->getByEmail($email); |
203 | 203 | if (count($users) === 1) { |
204 | - return $this->principalPrefix . '/' . $users[0]->getUID(); |
|
204 | + return $this->principalPrefix.'/'.$users[0]->getUID(); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $userId = $user->getUID(); |
217 | 217 | $displayName = $user->getDisplayName(); |
218 | 218 | $principal = [ |
219 | - 'uri' => $this->principalPrefix . '/' . $userId, |
|
219 | + 'uri' => $this->principalPrefix.'/'.$userId, |
|
220 | 220 | '{DAV:}displayname' => is_null($displayName) ? $userId : $displayName, |
221 | 221 | ]; |
222 | 222 |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $principals = []; |
60 | 60 | |
61 | 61 | if ($prefixPath === self::PRINCIPAL_PREFIX) { |
62 | - foreach($this->groupManager->search('') as $user) { |
|
62 | + foreach ($this->groupManager->search('') as $user) { |
|
63 | 63 | $principals[] = $this->groupToPrincipal($user); |
64 | 64 | } |
65 | 65 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return array |
77 | 77 | */ |
78 | 78 | public function getPrincipalByPath($path) { |
79 | - $elements = explode('/', $path, 3); |
|
79 | + $elements = explode('/', $path, 3); |
|
80 | 80 | if ($elements[0] !== 'principals') { |
81 | 81 | return null; |
82 | 82 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | protected function groupToPrincipal($group) { |
180 | 180 | $groupId = $group->getGID(); |
181 | 181 | $principal = [ |
182 | - 'uri' => 'principals/groups/' . urlencode($groupId), |
|
182 | + 'uri' => 'principals/groups/'.urlencode($groupId), |
|
183 | 183 | '{DAV:}displayname' => $groupId, |
184 | 184 | ]; |
185 | 185 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | protected function userToPrincipal($user) { |
194 | 194 | $principal = [ |
195 | - 'uri' => 'principals/users/' . $user->getUID(), |
|
195 | + 'uri' => 'principals/users/'.$user->getUID(), |
|
196 | 196 | '{DAV:}displayname' => $user->getDisplayName(), |
197 | 197 | ]; |
198 | 198 |
@@ -34,16 +34,16 @@ discard block |
||
34 | 34 | * Class OC_JSON |
35 | 35 | * @deprecated Use a AppFramework JSONResponse instead |
36 | 36 | */ |
37 | -class OC_JSON{ |
|
37 | +class OC_JSON { |
|
38 | 38 | static protected $send_content_type_header = false; |
39 | 39 | /** |
40 | 40 | * set Content-Type header to jsonrequest |
41 | 41 | * @deprecated Use a AppFramework JSONResponse instead |
42 | 42 | */ |
43 | - public static function setContentTypeHeader($type='application/json') { |
|
43 | + public static function setContentTypeHeader($type = 'application/json') { |
|
44 | 44 | if (!self::$send_content_type_header) { |
45 | 45 | // We send json data |
46 | - header( 'Content-Type: '.$type . '; charset=utf-8'); |
|
46 | + header('Content-Type: '.$type.'; charset=utf-8'); |
|
47 | 47 | self::$send_content_type_header = true; |
48 | 48 | } |
49 | 49 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @deprecated Use the AppFramework instead. It will automatically check if the app is enabled. |
55 | 55 | */ |
56 | 56 | public static function checkAppEnabled($app) { |
57 | - if( !OC_App::isEnabled($app)) { |
|
57 | + if (!OC_App::isEnabled($app)) { |
|
58 | 58 | $l = \OC::$server->getL10N('lib'); |
59 | - self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled' ))); |
|
59 | + self::error(array('data' => array('message' => $l->t('Application is not enabled'), 'error' => 'application_not_enabled'))); |
|
60 | 60 | exit(); |
61 | 61 | } |
62 | 62 | } |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public static function checkLoggedIn() { |
69 | 69 | $twoFactorAuthManger = \OC::$server->getTwoFactorAuthManager(); |
70 | - if( !\OC::$server->getUserSession()->isLoggedIn() |
|
70 | + if (!\OC::$server->getUserSession()->isLoggedIn() |
|
71 | 71 | || $twoFactorAuthManger->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
72 | 72 | $l = \OC::$server->getL10N('lib'); |
73 | 73 | http_response_code(\OCP\AppFramework\Http::STATUS_UNAUTHORIZED); |
74 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
74 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
75 | 75 | exit(); |
76 | 76 | } |
77 | 77 | } |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * @deprecated Use annotation based CSRF checks from the AppFramework instead |
82 | 82 | */ |
83 | 83 | public static function callCheck() { |
84 | - if(!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
84 | + if (!\OC::$server->getRequest()->passesStrictCookieCheck()) { |
|
85 | 85 | header('Location: '.\OC::$WEBROOT); |
86 | 86 | exit(); |
87 | 87 | } |
88 | 88 | |
89 | - if( !(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
89 | + if (!(\OC::$server->getRequest()->passesCSRFCheck())) { |
|
90 | 90 | $l = \OC::$server->getL10N('lib'); |
91 | - self::error(array( 'data' => array( 'message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired' ))); |
|
91 | + self::error(array('data' => array('message' => $l->t('Token expired. Please reload page.'), 'error' => 'token_expired'))); |
|
92 | 92 | exit(); |
93 | 93 | } |
94 | 94 | } |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | * @deprecated Use annotation based ACLs from the AppFramework instead |
99 | 99 | */ |
100 | 100 | public static function checkAdminUser() { |
101 | - if( !OC_User::isAdminUser(OC_User::getUser())) { |
|
101 | + if (!OC_User::isAdminUser(OC_User::getUser())) { |
|
102 | 102 | $l = \OC::$server->getL10N('lib'); |
103 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
103 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
104 | 104 | exit(); |
105 | 105 | } |
106 | 106 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | public static function checkUserExists($user) { |
114 | 114 | if (!OCP\User::userExists($user)) { |
115 | 115 | $l = \OC::$server->getL10N('lib'); |
116 | - OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user' ))); |
|
116 | + OCP\JSON::error(array('data' => array('message' => $l->t('Unknown user'), 'error' => 'unknown_user'))); |
|
117 | 117 | exit; |
118 | 118 | } |
119 | 119 | } |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | public static function checkSubAdminUser() { |
127 | 127 | $userObject = \OC::$server->getUserSession()->getUser(); |
128 | 128 | $isSubAdmin = false; |
129 | - if($userObject !== null) { |
|
129 | + if ($userObject !== null) { |
|
130 | 130 | $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); |
131 | 131 | } |
132 | 132 | |
133 | - if(!$isSubAdmin) { |
|
133 | + if (!$isSubAdmin) { |
|
134 | 134 | $l = \OC::$server->getL10N('lib'); |
135 | - self::error(array( 'data' => array( 'message' => $l->t('Authentication error'), 'error' => 'authentication_error' ))); |
|
135 | + self::error(array('data' => array('message' => $l->t('Authentication error'), 'error' => 'authentication_error'))); |
|
136 | 136 | exit(); |
137 | 137 | } |
138 | 138 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | protected static function to_string(&$value) { |
162 | 162 | if ($value instanceof OC_L10N_String) { |
163 | - $value = (string)$value; |
|
163 | + $value = (string) $value; |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * Encode and print $data in json format |
169 | 169 | * @deprecated Use a AppFramework JSONResponse instead |
170 | 170 | */ |
171 | - public static function encodedPrint($data, $setContentType=true) { |
|
172 | - if($setContentType) { |
|
171 | + public static function encodedPrint($data, $setContentType = true) { |
|
172 | + if ($setContentType) { |
|
173 | 173 | self::setContentTypeHeader(); |
174 | 174 | } |
175 | 175 | echo self::encode($data); |
@@ -68,34 +68,34 @@ |
||
68 | 68 | * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
69 | 69 | */ |
70 | 70 | public function prepare(INotification $notification, $languageCode) { |
71 | - if($notification->getApp() !== 'comments') { |
|
71 | + if ($notification->getApp() !== 'comments') { |
|
72 | 72 | throw new \InvalidArgumentException(); |
73 | 73 | } |
74 | 74 | try { |
75 | 75 | $comment = $this->commentsManager->get($notification->getObjectId()); |
76 | - } catch(NotFoundException $e) { |
|
76 | + } catch (NotFoundException $e) { |
|
77 | 77 | // needs to be converted to InvalidArgumentException, otherwise none Notifications will be shown at all |
78 | 78 | throw new \InvalidArgumentException('Comment not found', 0, $e); |
79 | 79 | } |
80 | 80 | $l = $this->l10nFactory->get('comments', $languageCode); |
81 | 81 | $displayName = $comment->getActorId(); |
82 | 82 | $isDeletedActor = $comment->getActorType() === ICommentsManager::DELETED_USER; |
83 | - if($comment->getActorType() === 'users') { |
|
83 | + if ($comment->getActorType() === 'users') { |
|
84 | 84 | $commenter = $this->userManager->get($comment->getActorId()); |
85 | - if(!is_null($commenter)) { |
|
85 | + if (!is_null($commenter)) { |
|
86 | 86 | $displayName = $commenter->getDisplayName(); |
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - switch($notification->getSubject()) { |
|
90 | + switch ($notification->getSubject()) { |
|
91 | 91 | case 'mention': |
92 | 92 | $parameters = $notification->getSubjectParameters(); |
93 | - if($parameters[0] !== 'files') { |
|
93 | + if ($parameters[0] !== 'files') { |
|
94 | 94 | throw new \InvalidArgumentException('Unsupported comment object'); |
95 | 95 | } |
96 | 96 | $userFolder = $this->rootFolder->getUserFolder($notification->getUser()); |
97 | 97 | $nodes = $userFolder->getById($parameters[1]); |
98 | - if(empty($nodes)) { |
|
98 | + if (empty($nodes)) { |
|
99 | 99 | throw new \InvalidArgumentException('Cannot resolve file id to Node instance'); |
100 | 100 | } |
101 | 101 | $node = $nodes[0]; |