Completed
Pull Request — master (#6836)
by René
15:31 queued 03:35
created
apps/user_ldap/lib/Settings/Admin.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -31,59 +31,59 @@
 block discarded – undo
31 31
 use OCP\Template;
32 32
 
33 33
 class Admin implements ISettings {
34
-	/** @var IL10N */
35
-	private $l;
34
+    /** @var IL10N */
35
+    private $l;
36 36
 
37
-	/**
38
-	 * @param IL10N $l
39
-	 */
40
-	public function __construct(IL10N $l) {
41
-		$this->l = $l;
42
-	}
37
+    /**
38
+     * @param IL10N $l
39
+     */
40
+    public function __construct(IL10N $l) {
41
+        $this->l = $l;
42
+    }
43 43
 
44
-	/**
45
-	 * @return TemplateResponse
46
-	 */
47
-	public function getForm() {
48
-		$helper = new Helper(\OC::$server->getConfig());
49
-		$prefixes = $helper->getServerConfigurationPrefixes();
50
-		$hosts = $helper->getServerConfigurationHosts();
44
+    /**
45
+     * @return TemplateResponse
46
+     */
47
+    public function getForm() {
48
+        $helper = new Helper(\OC::$server->getConfig());
49
+        $prefixes = $helper->getServerConfigurationPrefixes();
50
+        $hosts = $helper->getServerConfigurationHosts();
51 51
 
52
-		$wControls = new Template('user_ldap', 'part.wizardcontrols');
53
-		$wControls = $wControls->fetchPage();
54
-		$sControls = new Template('user_ldap', 'part.settingcontrols');
55
-		$sControls = $sControls->fetchPage();
52
+        $wControls = new Template('user_ldap', 'part.wizardcontrols');
53
+        $wControls = $wControls->fetchPage();
54
+        $sControls = new Template('user_ldap', 'part.settingcontrols');
55
+        $sControls = $sControls->fetchPage();
56 56
 
57
-		$parameters['serverConfigurationPrefixes'] = $prefixes;
58
-		$parameters['serverConfigurationHosts'] = $hosts;
59
-		$parameters['settingControls'] = $sControls;
60
-		$parameters['wizardControls'] = $wControls;
57
+        $parameters['serverConfigurationPrefixes'] = $prefixes;
58
+        $parameters['serverConfigurationHosts'] = $hosts;
59
+        $parameters['settingControls'] = $sControls;
60
+        $parameters['wizardControls'] = $wControls;
61 61
 
62
-		// assign default values
63
-		$config = new Configuration('', false);
64
-		$defaults = $config->getDefaults();
65
-		foreach($defaults as $key => $default) {
66
-			$parameters[$key.'_default'] = $default;
67
-		}
62
+        // assign default values
63
+        $config = new Configuration('', false);
64
+        $defaults = $config->getDefaults();
65
+        foreach($defaults as $key => $default) {
66
+            $parameters[$key.'_default'] = $default;
67
+        }
68 68
 
69
-		return new TemplateResponse('user_ldap', 'settings', $parameters);
70
-	}
69
+        return new TemplateResponse('user_ldap', 'settings', $parameters);
70
+    }
71 71
 
72
-	/**
73
-	 * @return string the section ID, e.g. 'sharing'
74
-	 */
75
-	public function getSection() {
76
-		return 'ldap';
77
-	}
72
+    /**
73
+     * @return string the section ID, e.g. 'sharing'
74
+     */
75
+    public function getSection() {
76
+        return 'ldap';
77
+    }
78 78
 
79
-	/**
80
-	 * @return int whether the form should be rather on the top or bottom of
81
-	 * the admin section. The forms are arranged in ascending order of the
82
-	 * priority values. It is required to return a value between 0 and 100.
83
-	 *
84
-	 * E.g.: 70
85
-	 */
86
-	public function getPriority() {
87
-		return 5;
88
-	}
79
+    /**
80
+     * @return int whether the form should be rather on the top or bottom of
81
+     * the admin section. The forms are arranged in ascending order of the
82
+     * priority values. It is required to return a value between 0 and 100.
83
+     *
84
+     * E.g.: 70
85
+     */
86
+    public function getPriority() {
87
+        return 5;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 		// assign default values
63 63
 		$config = new Configuration('', false);
64 64
 		$defaults = $config->getDefaults();
65
-		foreach($defaults as $key => $default) {
65
+		foreach ($defaults as $key => $default) {
66 66
 			$parameters[$key.'_default'] = $default;
67 67
 		}
68 68
 
Please login to merge, or discard this patch.
apps/user_ldap/lib/LDAPProvider.php 2 patches
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -33,155 +33,155 @@
 block discarded – undo
33 33
  */
34 34
 class LDAPProvider implements ILDAPProvider, IDeletionFlagSupport {
35 35
 
36
-	private $backend;
37
-	private $logger;
38
-	private $helper;
39
-	private $deletedUsersIndex;
36
+    private $backend;
37
+    private $logger;
38
+    private $helper;
39
+    private $deletedUsersIndex;
40 40
 	
41
-	/**
42
-	 * Create new LDAPProvider
43
-	 * @param \OCP\IServerContainer $serverContainer
44
-	 * @throws \Exception if user_ldap app was not enabled
45
-	 */
46
-	public function __construct(IServerContainer $serverContainer, Helper $helper, DeletedUsersIndex $deletedUsersIndex) {
47
-		$this->logger = $serverContainer->getLogger();
48
-		$this->helper = $helper;
49
-		$this->deletedUsersIndex = $deletedUsersIndex;
50
-		foreach ($serverContainer->getUserManager()->getBackends() as $backend){
51
-			$this->logger->debug('instance '.get_class($backend).' backend.', ['app' => 'user_ldap']);
52
-			if ($backend instanceof IUserLDAP) {
53
-				$this->backend = $backend;
54
-				return;
55
-			}
41
+    /**
42
+     * Create new LDAPProvider
43
+     * @param \OCP\IServerContainer $serverContainer
44
+     * @throws \Exception if user_ldap app was not enabled
45
+     */
46
+    public function __construct(IServerContainer $serverContainer, Helper $helper, DeletedUsersIndex $deletedUsersIndex) {
47
+        $this->logger = $serverContainer->getLogger();
48
+        $this->helper = $helper;
49
+        $this->deletedUsersIndex = $deletedUsersIndex;
50
+        foreach ($serverContainer->getUserManager()->getBackends() as $backend){
51
+            $this->logger->debug('instance '.get_class($backend).' backend.', ['app' => 'user_ldap']);
52
+            if ($backend instanceof IUserLDAP) {
53
+                $this->backend = $backend;
54
+                return;
55
+            }
56 56
         }
57
-		throw new \Exception('To use the LDAPProvider, user_ldap app must be enabled');
58
-	}
57
+        throw new \Exception('To use the LDAPProvider, user_ldap app must be enabled');
58
+    }
59 59
 	
60
-	/**
61
-	 * Translate an user id to LDAP DN
62
-	 * @param string $uid user id
63
-	 * @return string with the LDAP DN
64
-	 * @throws \Exception if translation was unsuccessful
65
-	 */
66
-	public function getUserDN($uid) {
67
-		if(!$this->backend->userExists($uid)){
68
-			throw new \Exception('User id not found in LDAP');
69
-		}
70
-		$result = $this->backend->getLDAPAccess($uid)->username2dn($uid);
71
-		if(!$result){
72
-			throw new \Exception('Translation to LDAP DN unsuccessful');
73
-		}
74
-		return $result;
75
-	}
60
+    /**
61
+     * Translate an user id to LDAP DN
62
+     * @param string $uid user id
63
+     * @return string with the LDAP DN
64
+     * @throws \Exception if translation was unsuccessful
65
+     */
66
+    public function getUserDN($uid) {
67
+        if(!$this->backend->userExists($uid)){
68
+            throw new \Exception('User id not found in LDAP');
69
+        }
70
+        $result = $this->backend->getLDAPAccess($uid)->username2dn($uid);
71
+        if(!$result){
72
+            throw new \Exception('Translation to LDAP DN unsuccessful');
73
+        }
74
+        return $result;
75
+    }
76 76
 	
77
-	/**
78
-	 * Translate a LDAP DN to an internal user name. If there is no mapping between 
79
-	 * the DN and the user name, a new one will be created.
80
-	 * @param string $dn LDAP DN
81
-	 * @return string with the internal user name
82
-	 * @throws \Exception if translation was unsuccessful
83
-	 */
84
-	public function getUserName($dn) {
85
-		$result = $this->backend->dn2UserName($dn);
86
-		if(!$result){
87
-			throw new \Exception('Translation to internal user name unsuccessful');
88
-		}
89
-		return $result;
90
-	}
77
+    /**
78
+     * Translate a LDAP DN to an internal user name. If there is no mapping between 
79
+     * the DN and the user name, a new one will be created.
80
+     * @param string $dn LDAP DN
81
+     * @return string with the internal user name
82
+     * @throws \Exception if translation was unsuccessful
83
+     */
84
+    public function getUserName($dn) {
85
+        $result = $this->backend->dn2UserName($dn);
86
+        if(!$result){
87
+            throw new \Exception('Translation to internal user name unsuccessful');
88
+        }
89
+        return $result;
90
+    }
91 91
 	
92
-	/**
93
-	 * Convert a stored DN so it can be used as base parameter for LDAP queries.
94
-	 * @param string $dn the DN in question
95
-	 * @return string
96
-	 */
97
-	public function DNasBaseParameter($dn) {
98
-		return $this->helper->DNasBaseParameter($dn);
99
-	}
92
+    /**
93
+     * Convert a stored DN so it can be used as base parameter for LDAP queries.
94
+     * @param string $dn the DN in question
95
+     * @return string
96
+     */
97
+    public function DNasBaseParameter($dn) {
98
+        return $this->helper->DNasBaseParameter($dn);
99
+    }
100 100
 	
101
-	/**
102
-	 * Sanitize a DN received from the LDAP server.
103
-	 * @param array $dn the DN in question
104
-	 * @return array the sanitized DN
105
-	 */
106
-	public function sanitizeDN($dn) {
107
-		return $this->helper->sanitizeDN($dn);
108
-	}
101
+    /**
102
+     * Sanitize a DN received from the LDAP server.
103
+     * @param array $dn the DN in question
104
+     * @return array the sanitized DN
105
+     */
106
+    public function sanitizeDN($dn) {
107
+        return $this->helper->sanitizeDN($dn);
108
+    }
109 109
 	
110
-	/**
111
-	 * Return a new LDAP connection resource for the specified user. 
112
-	 * The connection must be closed manually.
113
-	 * @param string $uid user id
114
-	 * @return resource of the LDAP connection
115
-	 * @throws \Exception if user id was not found in LDAP
116
-	 */
117
-	public function getLDAPConnection($uid) {
118
-		if(!$this->backend->userExists($uid)){
119
-			throw new \Exception('User id not found in LDAP');
120
-		}
121
-		return $this->backend->getNewLDAPConnection($uid);
122
-	}
110
+    /**
111
+     * Return a new LDAP connection resource for the specified user. 
112
+     * The connection must be closed manually.
113
+     * @param string $uid user id
114
+     * @return resource of the LDAP connection
115
+     * @throws \Exception if user id was not found in LDAP
116
+     */
117
+    public function getLDAPConnection($uid) {
118
+        if(!$this->backend->userExists($uid)){
119
+            throw new \Exception('User id not found in LDAP');
120
+        }
121
+        return $this->backend->getNewLDAPConnection($uid);
122
+    }
123 123
 	
124
-	/**
125
-	 * Get the LDAP base for users.
126
-	 * @param string $uid user id
127
-	 * @return string the base for users
128
-	 * @throws \Exception if user id was not found in LDAP
129
-	 */
130
-	public function getLDAPBaseUsers($uid) {
131
-		if(!$this->backend->userExists($uid)){
132
-			throw new \Exception('User id not found in LDAP');
133
-		}	
134
-		return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_users'];
135
-	}
124
+    /**
125
+     * Get the LDAP base for users.
126
+     * @param string $uid user id
127
+     * @return string the base for users
128
+     * @throws \Exception if user id was not found in LDAP
129
+     */
130
+    public function getLDAPBaseUsers($uid) {
131
+        if(!$this->backend->userExists($uid)){
132
+            throw new \Exception('User id not found in LDAP');
133
+        }	
134
+        return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_users'];
135
+    }
136 136
 	
137
-	/**
138
-	 * Get the LDAP base for groups.
139
-	 * @param string $uid user id
140
-	 * @return string the base for groups
141
-	 * @throws \Exception if user id was not found in LDAP
142
-	 */
143
-	public function getLDAPBaseGroups($uid) {
144
-		if(!$this->backend->userExists($uid)){
145
-			throw new \Exception('User id not found in LDAP');
146
-		}
147
-		return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_groups'];
148
-	}
137
+    /**
138
+     * Get the LDAP base for groups.
139
+     * @param string $uid user id
140
+     * @return string the base for groups
141
+     * @throws \Exception if user id was not found in LDAP
142
+     */
143
+    public function getLDAPBaseGroups($uid) {
144
+        if(!$this->backend->userExists($uid)){
145
+            throw new \Exception('User id not found in LDAP');
146
+        }
147
+        return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_groups'];
148
+    }
149 149
 	
150
-	/**
151
-	 * Clear the cache if a cache is used, otherwise do nothing.
152
-	 * @param string $uid user id
153
-	 * @throws \Exception if user id was not found in LDAP
154
-	 */
155
-	public function clearCache($uid) {
156
-		if(!$this->backend->userExists($uid)){
157
-			throw new \Exception('User id not found in LDAP');
158
-		}
159
-		$this->backend->getLDAPAccess($uid)->getConnection()->clearCache();
160
-	}
150
+    /**
151
+     * Clear the cache if a cache is used, otherwise do nothing.
152
+     * @param string $uid user id
153
+     * @throws \Exception if user id was not found in LDAP
154
+     */
155
+    public function clearCache($uid) {
156
+        if(!$this->backend->userExists($uid)){
157
+            throw new \Exception('User id not found in LDAP');
158
+        }
159
+        $this->backend->getLDAPAccess($uid)->getConnection()->clearCache();
160
+    }
161 161
 	
162
-	/**
163
-	 * Check whether a LDAP DN exists
164
-	 * @param string $dn LDAP DN
165
-	 * @return bool whether the DN exists
166
-	 */
167
-	public function dnExists($dn) {
168
-		$result = $this->backend->dn2UserName($dn);
169
-		return !$result ? false : true;
170
-	}
162
+    /**
163
+     * Check whether a LDAP DN exists
164
+     * @param string $dn LDAP DN
165
+     * @return bool whether the DN exists
166
+     */
167
+    public function dnExists($dn) {
168
+        $result = $this->backend->dn2UserName($dn);
169
+        return !$result ? false : true;
170
+    }
171 171
 	
172
-	/**
173
-	 * Flag record for deletion.
174
-	 * @param string $uid user id
175
-	 */
176
-	public function flagRecord($uid) {
177
-		$this->deletedUsersIndex->markUser($uid);
178
-	}
172
+    /**
173
+     * Flag record for deletion.
174
+     * @param string $uid user id
175
+     */
176
+    public function flagRecord($uid) {
177
+        $this->deletedUsersIndex->markUser($uid);
178
+    }
179 179
 	
180
-	/**
181
-	 * Unflag record for deletion.
182
-	 * @param string $uid user id
183
-	 */
184
-	public function unflagRecord($uid) {
185
-		//do nothing
186
-	}
180
+    /**
181
+     * Unflag record for deletion.
182
+     * @param string $uid user id
183
+     */
184
+    public function unflagRecord($uid) {
185
+        //do nothing
186
+    }
187 187
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->logger = $serverContainer->getLogger();
48 48
 		$this->helper = $helper;
49 49
 		$this->deletedUsersIndex = $deletedUsersIndex;
50
-		foreach ($serverContainer->getUserManager()->getBackends() as $backend){
50
+		foreach ($serverContainer->getUserManager()->getBackends() as $backend) {
51 51
 			$this->logger->debug('instance '.get_class($backend).' backend.', ['app' => 'user_ldap']);
52 52
 			if ($backend instanceof IUserLDAP) {
53 53
 				$this->backend = $backend;
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 	 * @throws \Exception if translation was unsuccessful
65 65
 	 */
66 66
 	public function getUserDN($uid) {
67
-		if(!$this->backend->userExists($uid)){
67
+		if (!$this->backend->userExists($uid)) {
68 68
 			throw new \Exception('User id not found in LDAP');
69 69
 		}
70 70
 		$result = $this->backend->getLDAPAccess($uid)->username2dn($uid);
71
-		if(!$result){
71
+		if (!$result) {
72 72
 			throw new \Exception('Translation to LDAP DN unsuccessful');
73 73
 		}
74 74
 		return $result;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function getUserName($dn) {
85 85
 		$result = $this->backend->dn2UserName($dn);
86
-		if(!$result){
86
+		if (!$result) {
87 87
 			throw new \Exception('Translation to internal user name unsuccessful');
88 88
 		}
89 89
 		return $result;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @throws \Exception if user id was not found in LDAP
116 116
 	 */
117 117
 	public function getLDAPConnection($uid) {
118
-		if(!$this->backend->userExists($uid)){
118
+		if (!$this->backend->userExists($uid)) {
119 119
 			throw new \Exception('User id not found in LDAP');
120 120
 		}
121 121
 		return $this->backend->getNewLDAPConnection($uid);
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @throws \Exception if user id was not found in LDAP
129 129
 	 */
130 130
 	public function getLDAPBaseUsers($uid) {
131
-		if(!$this->backend->userExists($uid)){
131
+		if (!$this->backend->userExists($uid)) {
132 132
 			throw new \Exception('User id not found in LDAP');
133 133
 		}	
134 134
 		return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_users'];
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @throws \Exception if user id was not found in LDAP
142 142
 	 */
143 143
 	public function getLDAPBaseGroups($uid) {
144
-		if(!$this->backend->userExists($uid)){
144
+		if (!$this->backend->userExists($uid)) {
145 145
 			throw new \Exception('User id not found in LDAP');
146 146
 		}
147 147
 		return $this->backend->getLDAPAccess($uid)->getConnection()->getConfiguration()['ldap_base_groups'];
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @throws \Exception if user id was not found in LDAP
154 154
 	 */
155 155
 	public function clearCache($uid) {
156
-		if(!$this->backend->userExists($uid)){
156
+		if (!$this->backend->userExists($uid)) {
157 157
 			throw new \Exception('User id not found in LDAP');
158 158
 		}
159 159
 		$this->backend->getLDAPAccess($uid)->getConnection()->clearCache();
Please login to merge, or discard this patch.
apps/user_ldap/lib/LDAPProviderFactory.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -28,32 +28,32 @@
 block discarded – undo
28 28
 use OCA\User_LDAP\Mapping\UserMapping;
29 29
 
30 30
 class LDAPProviderFactory implements ILDAPProviderFactory {
31
-	/**
32
-	 * Server container
33
-	 *
34
-	 * @var IServerContainer
35
-	 */
36
-	private $serverContainer;
31
+    /**
32
+     * Server container
33
+     *
34
+     * @var IServerContainer
35
+     */
36
+    private $serverContainer;
37 37
 	
38
-	/**
39
-	 * Constructor for the LDAP provider factory
40
-	 *
41
-	 * @param IServerContainer $serverContainer server container
42
-	 */
43
-	public function __construct(IServerContainer $serverContainer) {
44
-		$this->serverContainer = $serverContainer;
45
-	}
38
+    /**
39
+     * Constructor for the LDAP provider factory
40
+     *
41
+     * @param IServerContainer $serverContainer server container
42
+     */
43
+    public function __construct(IServerContainer $serverContainer) {
44
+        $this->serverContainer = $serverContainer;
45
+    }
46 46
 	
47
-	/**
48
-	 * creates and returns an instance of the ILDAPProvider
49
-	 *
50
-	 * @return OCP\LDAP\ILDAPProvider
51
-	 */
52
-	public function getLDAPProvider() {
53
-		$dbConnection = $this->serverContainer->getDatabaseConnection();
54
-		$userMapping = new UserMapping($dbConnection);
55
-		return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()),
56
-					new DeletedUsersIndex($this->serverContainer->getConfig(), 
57
-					$dbConnection, $userMapping));
58
-	}
47
+    /**
48
+     * creates and returns an instance of the ILDAPProvider
49
+     *
50
+     * @return OCP\LDAP\ILDAPProvider
51
+     */
52
+    public function getLDAPProvider() {
53
+        $dbConnection = $this->serverContainer->getDatabaseConnection();
54
+        $userMapping = new UserMapping($dbConnection);
55
+        return new LDAPProvider($this->serverContainer, new Helper($this->serverContainer->getConfig()),
56
+                    new DeletedUsersIndex($this->serverContainer->getConfig(), 
57
+                    $dbConnection, $userMapping));
58
+    }
59 59
 }
Please login to merge, or discard this patch.
apps/user_ldap/appinfo/routes.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 $application->registerRoutes($this, [
42 42
 	'ocs' => [
43 43
 		['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'],
44
-		['name' => 'ConfigAPI#show',   'url' => '/api/v1/config/{configID}', 'verb' => 'GET'],
44
+		['name' => 'ConfigAPI#show', 'url' => '/api/v1/config/{configID}', 'verb' => 'GET'],
45 45
 		['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'],
46 46
 		['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'],
47 47
 	]
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -23,36 +23,36 @@
 block discarded – undo
23 23
 
24 24
 /** @var $this \OCP\Route\IRouter */
25 25
 $this->create('user_ldap_ajax_clearMappings', 'ajax/clearMappings.php')
26
-	->actionInclude('user_ldap/ajax/clearMappings.php');
26
+    ->actionInclude('user_ldap/ajax/clearMappings.php');
27 27
 $this->create('user_ldap_ajax_deleteConfiguration', 'ajax/deleteConfiguration.php')
28
-	->actionInclude('user_ldap/ajax/deleteConfiguration.php');
28
+    ->actionInclude('user_ldap/ajax/deleteConfiguration.php');
29 29
 $this->create('user_ldap_ajax_getConfiguration', 'ajax/getConfiguration.php')
30
-	->actionInclude('user_ldap/ajax/getConfiguration.php');
30
+    ->actionInclude('user_ldap/ajax/getConfiguration.php');
31 31
 $this->create('user_ldap_ajax_getNewServerConfigPrefix', 'ajax/getNewServerConfigPrefix.php')
32
-	->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php');
32
+    ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php');
33 33
 $this->create('user_ldap_ajax_setConfiguration', 'ajax/setConfiguration.php')
34
-	->actionInclude('user_ldap/ajax/setConfiguration.php');
34
+    ->actionInclude('user_ldap/ajax/setConfiguration.php');
35 35
 $this->create('user_ldap_ajax_testConfiguration', 'ajax/testConfiguration.php')
36
-	->actionInclude('user_ldap/ajax/testConfiguration.php');
36
+    ->actionInclude('user_ldap/ajax/testConfiguration.php');
37 37
 $this->create('user_ldap_ajax_wizard', 'ajax/wizard.php')
38
-	->actionInclude('user_ldap/ajax/wizard.php');
38
+    ->actionInclude('user_ldap/ajax/wizard.php');
39 39
 
40 40
 $application = new \OCP\AppFramework\App('user_ldap');
41 41
 $application->registerRoutes($this, [
42
-	'ocs' => [
43
-		['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'],
44
-		['name' => 'ConfigAPI#show',   'url' => '/api/v1/config/{configID}', 'verb' => 'GET'],
45
-		['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'],
46
-		['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'],
47
-	]
42
+    'ocs' => [
43
+        ['name' => 'ConfigAPI#create', 'url' => '/api/v1/config', 'verb' => 'POST'],
44
+        ['name' => 'ConfigAPI#show',   'url' => '/api/v1/config/{configID}', 'verb' => 'GET'],
45
+        ['name' => 'ConfigAPI#modify', 'url' => '/api/v1/config/{configID}', 'verb' => 'PUT'],
46
+        ['name' => 'ConfigAPI#delete', 'url' => '/api/v1/config/{configID}', 'verb' => 'DELETE'],
47
+    ]
48 48
 ]);
49 49
 
50 50
 $application = new OCA\User_LDAP\AppInfo\Application();
51 51
 $application->registerRoutes($this, [
52
-	'routes' => [
53
-		['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'],
54
-		['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'],
55
-		['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'],
56
-		['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'],
57
-	]
52
+    'routes' => [
53
+        ['name' => 'renewPassword#tryRenewPassword', 'url' => '/renewpassword', 'verb' => 'POST'],
54
+        ['name' => 'renewPassword#showRenewPasswordForm', 'url' => '/renewpassword/{user}', 'verb' => 'GET'],
55
+        ['name' => 'renewPassword#cancel', 'url' => '/renewpassword/cancel', 'verb' => 'GET'],
56
+        ['name' => 'renewPassword#showLoginFormInvalidPassword', 'url' => '/renewpassword/invalidlogin/{user}', 'verb' => 'GET'],
57
+    ]
58 58
 ]);
Please login to merge, or discard this patch.
apps/files_external/templates/list.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 <div id="emptycontent" class="hidden">
8 8
 	<div class="icon-external"></div>
9 9
 	<h2><?php p($l->t('No external storage configured')); ?></h2>
10
-	<p><a href="<?php p(link_to('', 'index.php/settings/personal#files_external' )); ?>"><?php p($l->t('You can add external storages in the personal settings')); ?></a></p>
10
+	<p><a href="<?php p(link_to('', 'index.php/settings/personal#files_external')); ?>"><?php p($l->t('You can add external storages in the personal settings')); ?></a></p>
11 11
 </div>
12 12
 
13 13
 <input type="hidden" name="dir" value="" id="dir">
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 		<tr>
18 18
 			<th id='headerName' class="hidden column-name">
19 19
 				<div id="headerName-container">
20
-					<a class="name sort columntitle" data-sort="name"><span><?php p($l->t( 'Name' )); ?></span><span class="sort-indicator"></span></a>
20
+					<a class="name sort columntitle" data-sort="name"><span><?php p($l->t('Name')); ?></span><span class="sort-indicator"></span></a>
21 21
 				</div>
22 22
 			</th>
23 23
 			<th id="headerBackend" class="hidden column-backend">
Please login to merge, or discard this patch.
apps/files_external/templates/settings.php 4 patches
Switch Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -41,44 +41,44 @@
 block discarded – undo
41 41
 		$is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL);
42 42
 
43 43
 		switch ($parameter->getType()) {
44
-		case DefinitionParameter::VALUE_PASSWORD: ?>
45
-			<?php if ($is_optional) { $classes[] = 'optional'; } ?>
46
-			<input type="password"
44
+		    case DefinitionParameter::VALUE_PASSWORD: ?>
45
+    			<?php if ($is_optional) { $classes[] = 'optional'; } ?>
46
+    			<input type="password"
47 47
 				<?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?>
48
-				data-parameter="<?php p($parameter->getName()); ?>"
48
+    				data-parameter="<?php p($parameter->getName()); ?>"
49 49
 				value="<?php p($value); ?>"
50 50
 				placeholder="<?php p($placeholder); ?>"
51 51
 			/>
52 52
 			<?php
53
-			break;
54
-		case DefinitionParameter::VALUE_BOOLEAN: ?>
55
-			<?php $checkboxId = uniqid("checkbox_"); ?>
53
+			    break;
54
+		    case DefinitionParameter::VALUE_BOOLEAN: ?>
55
+    			<?php $checkboxId = uniqid("checkbox_"); ?>
56 56
 			<div>
57 57
 			<label>
58 58
 			<input type="checkbox"
59 59
 				id="<?php p($checkboxId); ?>"
60 60
 				<?php if (!empty($classes)): ?> class="checkbox <?php p(implode(' ', $classes)); ?>"<?php endif; ?>
61
-				data-parameter="<?php p($parameter->getName()); ?>"
61
+    				data-parameter="<?php p($parameter->getName()); ?>"
62 62
 				<?php if ($value === true): ?> checked="checked"<?php endif; ?>
63
-			/>
63
+    			/>
64 64
 			<?php p($placeholder); ?>
65 65
 			</label>
66 66
 			</div>
67 67
 			<?php
68
-			break;
69
-		case DefinitionParameter::VALUE_HIDDEN: ?>
70
-			<input type="hidden"
68
+			    break;
69
+		    case DefinitionParameter::VALUE_HIDDEN: ?>
70
+    			<input type="hidden"
71 71
 				<?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?>
72
-				data-parameter="<?php p($parameter->getName()); ?>"
72
+    				data-parameter="<?php p($parameter->getName()); ?>"
73 73
 				value="<?php p($value); ?>"
74 74
 			/>
75 75
 			<?php
76
-			break;
77
-		default: ?>
78
-			<?php if ($is_optional) { $classes[] = 'optional'; } ?>
79
-			<input type="text"
76
+			    break;
77
+		    default: ?>
78
+    			<?php if ($is_optional) { $classes[] = 'optional'; } ?>
79
+    			<input type="text"
80 80
 				<?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?>
81
-				data-parameter="<?php p($parameter->getName()); ?>"
81
+    				data-parameter="<?php p($parameter->getName()); ?>"
82 82
 				value="<?php p($value); ?>"
83 83
 				placeholder="<?php p($placeholder); ?>"
84 84
 			/>
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	use \OCA\Files_External\Lib\Backend\Backend;
3
-	use \OCA\Files_External\Lib\Auth\AuthMechanism;
4
-	use \OCA\Files_External\Lib\DefinitionParameter;
5
-	use \OCA\Files_External\Service\BackendService;
2
+    use \OCA\Files_External\Lib\Backend\Backend;
3
+    use \OCA\Files_External\Lib\Auth\AuthMechanism;
4
+    use \OCA\Files_External\Lib\DefinitionParameter;
5
+    use \OCA\Files_External\Service\BackendService;
6 6
 
7
-	$canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting'];
7
+    $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting'];
8 8
 
9
-	$l->t("Enable encryption");
10
-	$l->t("Enable previews");
11
-	$l->t("Enable sharing");
12
-	$l->t("Check for changes");
13
-	$l->t("Never");
14
-	$l->t("Once every direct access");
9
+    $l->t("Enable encryption");
10
+    $l->t("Enable previews");
11
+    $l->t("Enable sharing");
12
+    $l->t("Check for changes");
13
+    $l->t("Never");
14
+    $l->t("Once every direct access");
15 15
 
16
-	script('files_external', 'settings');
17
-	style('files_external', 'settings');
16
+    script('files_external', 'settings');
17
+    style('files_external', 'settings');
18 18
 
19
-	// load custom JS
20
-	foreach ($_['backends'] as $backend) {
21
-		/** @var Backend $backend */
22
-		$scripts = $backend->getCustomJs();
23
-		foreach ($scripts as $script) {
24
-			script('files_external', $script);
25
-		}
26
-	}
27
-	foreach ($_['authMechanisms'] as $authMechanism) {
28
-		/** @var AuthMechanism $authMechanism */
29
-		$scripts = $authMechanism->getCustomJs();
30
-		foreach ($scripts as $script) {
31
-			script('files_external', $script);
32
-		}
33
-	}
19
+    // load custom JS
20
+    foreach ($_['backends'] as $backend) {
21
+        /** @var Backend $backend */
22
+        $scripts = $backend->getCustomJs();
23
+        foreach ($scripts as $script) {
24
+            script('files_external', $script);
25
+        }
26
+    }
27
+    foreach ($_['authMechanisms'] as $authMechanism) {
28
+        /** @var AuthMechanism $authMechanism */
29
+        $scripts = $authMechanism->getCustomJs();
30
+        foreach ($scripts as $script) {
31
+            script('files_external', $script);
32
+        }
33
+    }
34 34
 
35
-	function writeParameterInput($parameter, $options, $classes = []) {
36
-		$value = '';
37
-		if (isset($options[$parameter->getName()])) {
38
-			$value = $options[$parameter->getName()];
39
-		}
40
-		$placeholder = $parameter->getText();
41
-		$is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL);
35
+    function writeParameterInput($parameter, $options, $classes = []) {
36
+        $value = '';
37
+        if (isset($options[$parameter->getName()])) {
38
+            $value = $options[$parameter->getName()];
39
+        }
40
+        $placeholder = $parameter->getText();
41
+        $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL);
42 42
 
43
-		switch ($parameter->getType()) {
44
-		case DefinitionParameter::VALUE_PASSWORD: ?>
43
+        switch ($parameter->getType()) {
44
+        case DefinitionParameter::VALUE_PASSWORD: ?>
45 45
 			<?php if ($is_optional) { $classes[] = 'optional'; } ?>
46 46
 			<input type="password"
47 47
 				<?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?>
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 				placeholder="<?php p($placeholder); ?>"
51 51
 			/>
52 52
 			<?php
53
-			break;
54
-		case DefinitionParameter::VALUE_BOOLEAN: ?>
53
+            break;
54
+        case DefinitionParameter::VALUE_BOOLEAN: ?>
55 55
 			<?php $checkboxId = uniqid("checkbox_"); ?>
56 56
 			<div>
57 57
 			<label>
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
 			</label>
66 66
 			</div>
67 67
 			<?php
68
-			break;
69
-		case DefinitionParameter::VALUE_HIDDEN: ?>
68
+            break;
69
+        case DefinitionParameter::VALUE_HIDDEN: ?>
70 70
 			<input type="hidden"
71 71
 				<?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?>
72 72
 				data-parameter="<?php p($parameter->getName()); ?>"
73 73
 				value="<?php p($value); ?>"
74 74
 			/>
75 75
 			<?php
76
-			break;
77
-		default: ?>
76
+            break;
77
+        default: ?>
78 78
 			<?php if ($is_optional) { $classes[] = 'optional'; } ?>
79 79
 			<input type="text"
80 80
 				<?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?>
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 				placeholder="<?php p($placeholder); ?>"
84 84
 			/>
85 85
 			<?php
86
-		}
87
-	}
86
+        }
87
+    }
88 88
 ?>
89 89
 
90 90
 <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>">
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 							<?php p($l->t('Add storage')); ?>
123 123
 						</option>
124 124
 						<?php
125
-							$sortedBackends = array_filter($_['backends'], function($backend) use ($_) {
126
-								return $backend->isVisibleFor($_['visibilityType']);
127
-							});
128
-							uasort($sortedBackends, function($a, $b) {
129
-								return strcasecmp($a->getText(), $b->getText());
130
-							});
131
-						?>
125
+                            $sortedBackends = array_filter($_['backends'], function($backend) use ($_) {
126
+                                return $backend->isVisibleFor($_['visibilityType']);
127
+                            });
128
+                            uasort($sortedBackends, function($a, $b) {
129
+                                return strcasecmp($a->getText(), $b->getText());
130
+                            });
131
+                        ?>
132 132
 						<?php foreach ($sortedBackends as $backend): ?>
133 133
 							<?php if ($backend->getDeprecateTo()) continue; // ignore deprecated backends ?>
134 134
 							<option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option>
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 		<p id="userMountingBackends"<?php if ($_['allowUserMounting'] !== 'yes'): ?> class="hidden"<?php endif; ?>>
176 176
 			<?php p($l->t('Allow users to mount the following external storage')); ?><br />
177 177
 			<?php
178
-				$userBackends = array_filter($_['backends'], function($backend) {
179
-					return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL);
180
-				});
181
-			?>
178
+                $userBackends = array_filter($_['backends'], function($backend) {
179
+                    return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL);
180
+                });
181
+            ?>
182 182
 			<?php $i = 0; foreach ($userBackends as $backend): ?>
183 183
 				<?php if ($deprecateTo = $backend->getDeprecateTo()): ?>
184 184
 					<input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" />
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
 	}
88 88
 ?>
89 89
 
90
-<form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>">
90
+<form data-can-create="<?php echo $canCreateMounts ? 'true' : 'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled'] ? 'true' : 'false'; ?>">
91 91
 	<h2 data-anchor-name="external-storage"><?php p($l->t('External storages')); ?></h2>
92 92
 	<?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?>
93 93
 	<table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'>
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -89,7 +89,10 @@  discard block
 block discarded – undo
89 89
 
90 90
 <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>">
91 91
 	<h2 data-anchor-name="external-storage"><?php p($l->t('External storages')); ?></h2>
92
-	<?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?>
92
+	<?php if (isset($_['dependencies']) and ($_['dependencies'] !== '') and $canCreateMounts) {
93
+    print_unescaped(''.$_['dependencies'].'');
94
+}
95
+?>
93 96
 	<table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'>
94 97
 		<thead>
95 98
 			<tr>
@@ -98,7 +101,10 @@  discard block
 block discarded – undo
98 101
 				<th><?php p($l->t('External storage')); ?></th>
99 102
 				<th><?php p($l->t('Authentication')); ?></th>
100 103
 				<th><?php p($l->t('Configuration')); ?></th>
101
-				<?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) print_unescaped('<th>'.$l->t('Available for').'</th>'); ?>
104
+				<?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) {
105
+    print_unescaped('<th>'.$l->t('Available for').'</th>');
106
+}
107
+?>
102 108
 				<th>&nbsp;</th>
103 109
 				<th>&nbsp;</th>
104 110
 			</tr>
@@ -130,7 +136,10 @@  discard block
 block discarded – undo
130 136
 							});
131 137
 						?>
132 138
 						<?php foreach ($sortedBackends as $backend): ?>
133
-							<?php if ($backend->getDeprecateTo()) continue; // ignore deprecated backends ?>
139
+							<?php if ($backend->getDeprecateTo()) {
140
+    continue;
141
+}
142
+// ignore deprecated backends ?>
134 143
 							<option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option>
135 144
 						<?php endforeach; ?>
136 145
 					</select>
@@ -169,7 +178,10 @@  discard block
 block discarded – undo
169 178
 
170 179
 	<?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?>
171 180
 		<input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox"
172
-			value="1" <?php if ($_['allowUserMounting'] === 'yes') print_unescaped(' checked="checked"'); ?> />
181
+			value="1" <?php if ($_['allowUserMounting'] === 'yes') {
182
+    print_unescaped(' checked="checked"');
183
+}
184
+?> />
173 185
 		<label for="allowUserMounting"><?php p($l->t('Allow users to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span>
174 186
 
175 187
 		<p id="userMountingBackends"<?php if ($_['allowUserMounting'] !== 'yes'): ?> class="hidden"<?php endif; ?>>
@@ -182,8 +194,14 @@  discard block
 block discarded – undo
182 194
 			<?php $i = 0; foreach ($userBackends as $backend): ?>
183 195
 				<?php if ($deprecateTo = $backend->getDeprecateTo()): ?>
184 196
 					<input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" />
185
-				<?php else: ?>
186
-					<input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) print_unescaped(' checked="checked"'); ?> />
197
+				<?php else {
198
+    : ?>
199
+					<input type="checkbox" id="allowUserMountingBackends<?php p($i);
200
+}
201
+?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) {
202
+    print_unescaped(' checked="checked"');
203
+}
204
+?> />
187 205
 					<label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br />
188 206
 				<?php endif; ?>
189 207
 				<?php $i++; ?>
Please login to merge, or discard this patch.
apps/files_external/ajax/applicable.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,23 +30,23 @@
 block discarded – undo
30 30
 $limit = null;
31 31
 $offset = null;
32 32
 if (isset($_GET['pattern'])) {
33
-	$pattern = (string)$_GET['pattern'];
33
+    $pattern = (string)$_GET['pattern'];
34 34
 }
35 35
 if (isset($_GET['limit'])) {
36
-	$limit = (int)$_GET['limit'];
36
+    $limit = (int)$_GET['limit'];
37 37
 }
38 38
 if (isset($_GET['offset'])) {
39
-	$offset = (int)$_GET['offset'];
39
+    $offset = (int)$_GET['offset'];
40 40
 }
41 41
 
42 42
 $groups = [];
43 43
 foreach (\OC::$server->getGroupManager()->search($pattern, $limit, $offset) as $group) {
44
-	$groups[$group->getGID()] = $group->getGID();
44
+    $groups[$group->getGID()] = $group->getGID();
45 45
 }
46 46
 
47 47
 $users = [];
48 48
 foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) {
49
-	$users[$user->getUID()] = $user->getDisplayName();
49
+    $users[$user->getUID()] = $user->getDisplayName();
50 50
 }
51 51
 
52 52
 $results = array('groups' => $groups, 'users' => $users);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@
 block discarded – undo
30 30
 $limit = null;
31 31
 $offset = null;
32 32
 if (isset($_GET['pattern'])) {
33
-	$pattern = (string)$_GET['pattern'];
33
+	$pattern = (string) $_GET['pattern'];
34 34
 }
35 35
 if (isset($_GET['limit'])) {
36
-	$limit = (int)$_GET['limit'];
36
+	$limit = (int) $_GET['limit'];
37 37
 }
38 38
 if (isset($_GET['offset'])) {
39
-	$offset = (int)$_GET['offset'];
39
+	$offset = (int) $_GET['offset'];
40 40
 }
41 41
 
42 42
 $groups = [];
Please login to merge, or discard this patch.
apps/files_external/lib/Service/ImportLegacyStoragesService.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,25 +24,25 @@
 block discarded – undo
24 24
 namespace OCA\Files_External\Service;
25 25
 
26 26
 class ImportLegacyStoragesService extends LegacyStoragesService {
27
-	private $data;
27
+    private $data;
28 28
 
29
-	/**
30
-	 * @param BackendService $backendService
31
-	 */
32
-	public function __construct(BackendService $backendService) {
33
-		$this->backendService = $backendService;
34
-	}
29
+    /**
30
+     * @param BackendService $backendService
31
+     */
32
+    public function __construct(BackendService $backendService) {
33
+        $this->backendService = $backendService;
34
+    }
35 35
 
36
-	public function setData($data) {
37
-		$this->data = $data;
38
-	}
36
+    public function setData($data) {
37
+        $this->data = $data;
38
+    }
39 39
 
40
-	/**
41
-	 * Read legacy config data
42
-	 *
43
-	 * @return array list of mount configs
44
-	 */
45
-	protected function readLegacyConfig() {
46
-		return $this->data;
47
-	}
40
+    /**
41
+     * Read legacy config data
42
+     *
43
+     * @return array list of mount configs
44
+     */
45
+    protected function readLegacyConfig() {
46
+        return $this->data;
47
+    }
48 48
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Service/UserGlobalStoragesService.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -34,167 +34,167 @@
 block discarded – undo
34 34
  */
35 35
 class UserGlobalStoragesService extends GlobalStoragesService {
36 36
 
37
-	use UserTrait;
38
-
39
-	/** @var IGroupManager */
40
-	protected $groupManager;
41
-
42
-	/**
43
-	 * @param BackendService $backendService
44
-	 * @param DBConfigService $dbConfig
45
-	 * @param IUserSession $userSession
46
-	 * @param IGroupManager $groupManager
47
-	 * @param IUserMountCache $userMountCache
48
-	 */
49
-	public function __construct(
50
-		BackendService $backendService,
51
-		DBConfigService $dbConfig,
52
-		IUserSession $userSession,
53
-		IGroupManager $groupManager,
54
-		IUserMountCache $userMountCache
55
-	) {
56
-		parent::__construct($backendService, $dbConfig, $userMountCache);
57
-		$this->userSession = $userSession;
58
-		$this->groupManager = $groupManager;
59
-	}
60
-
61
-	/**
62
-	 * Replace config hash ID with real IDs, for migrating legacy storages
63
-	 *
64
-	 * @param StorageConfig[] $storages Storages with real IDs
65
-	 * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs
66
-	 */
67
-	protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) {
68
-		// as a read-only view, storage IDs don't need to be real
69
-		foreach ($storagesWithConfigHash as $storage) {
70
-			$storages[$storage->getId()] = $storage;
71
-		}
72
-	}
73
-
74
-	protected function readDBConfig() {
75
-		$userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
76
-		$globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
77
-		$groups = $this->groupManager->getUserGroupIds($this->getUser());
78
-		if (is_array($groups) && count($groups) !== 0) {
79
-			$groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups);
80
-		} else {
81
-			$groupMounts = [];
82
-		}
83
-		return array_merge($userMounts, $groupMounts, $globalMounts);
84
-	}
85
-
86
-	public function addStorage(StorageConfig $newStorage) {
87
-		throw new \DomainException('UserGlobalStoragesService writing disallowed');
88
-	}
89
-
90
-	public function updateStorage(StorageConfig $updatedStorage) {
91
-		throw new \DomainException('UserGlobalStoragesService writing disallowed');
92
-	}
93
-
94
-	/**
95
-	 * @param integer $id
96
-	 */
97
-	public function removeStorage($id) {
98
-		throw new \DomainException('UserGlobalStoragesService writing disallowed');
99
-	}
100
-
101
-	/**
102
-	 * Get unique storages, in case two are defined with the same mountpoint
103
-	 * Higher priority storages take precedence
104
-	 *
105
-	 * @return StorageConfig[]
106
-	 */
107
-	public function getUniqueStorages() {
108
-		$storages = $this->getStorages();
109
-
110
-		$storagesByMountpoint = [];
111
-		foreach ($storages as $storage) {
112
-			$storagesByMountpoint[$storage->getMountPoint()][] = $storage;
113
-		}
114
-
115
-		$result = [];
116
-		foreach ($storagesByMountpoint as $storageList) {
117
-			$storage = array_reduce($storageList, function ($carry, $item) {
118
-				if (isset($carry)) {
119
-					$carryPriorityType = $this->getPriorityType($carry);
120
-					$itemPriorityType = $this->getPriorityType($item);
121
-					if ($carryPriorityType > $itemPriorityType) {
122
-						return $carry;
123
-					} elseif ($carryPriorityType === $itemPriorityType) {
124
-						if ($carry->getPriority() > $item->getPriority()) {
125
-							return $carry;
126
-						}
127
-					}
128
-				}
129
-				return $item;
130
-			});
131
-			$result[$storage->getID()] = $storage;
132
-		}
133
-
134
-		return $result;
135
-	}
136
-
137
-	/**
138
-	 * Get a priority 'type', where a bigger number means higher priority
139
-	 * user applicable > group applicable > 'all'
140
-	 *
141
-	 * @param StorageConfig $storage
142
-	 * @return int
143
-	 */
144
-	protected function getPriorityType(StorageConfig $storage) {
145
-		$applicableUsers = $storage->getApplicableUsers();
146
-		$applicableGroups = $storage->getApplicableGroups();
147
-
148
-		if ($applicableUsers && $applicableUsers[0] !== 'all') {
149
-			return 2;
150
-		}
151
-		if ($applicableGroups) {
152
-			return 1;
153
-		}
154
-		return 0;
155
-	}
156
-
157
-	protected function isApplicable(StorageConfig $config) {
158
-		$applicableUsers = $config->getApplicableUsers();
159
-		$applicableGroups = $config->getApplicableGroups();
160
-
161
-		if (count($applicableUsers) === 0 && count($applicableGroups) === 0) {
162
-			return true;
163
-		}
164
-		if (in_array($this->getUser()->getUID(), $applicableUsers, true)) {
165
-			return true;
166
-		}
167
-		$groupIds = $this->groupManager->getUserGroupIds($this->getUser());
168
-		foreach ($groupIds as $groupId) {
169
-			if (in_array($groupId, $applicableGroups, true)) {
170
-				return true;
171
-			}
172
-		}
173
-		return false;
174
-	}
175
-
176
-
177
-	/**
178
-	 * Gets all storages for the user, admin, personal, global, etc
179
-	 *
180
-	 * @return StorageConfig[] array of storage configs
181
-	 */
182
-	public function getAllStoragesForUser() {
183
-		if (is_null($this->getUser())) {
184
-			return [];
185
-		}
186
-		$groupIds = $this->groupManager->getUserGroupIds($this->getUser());
187
-		$mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds);
188
-		$configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
189
-		$configs = array_filter($configs, function ($config) {
190
-			return $config instanceof StorageConfig;
191
-		});
192
-
193
-		$keys = array_map(function (StorageConfig $config) {
194
-			return $config->getId();
195
-		}, $configs);
196
-
197
-		$storages = array_combine($keys, $configs);
198
-		return array_filter($storages, [$this, 'validateStorage']);
199
-	}
37
+    use UserTrait;
38
+
39
+    /** @var IGroupManager */
40
+    protected $groupManager;
41
+
42
+    /**
43
+     * @param BackendService $backendService
44
+     * @param DBConfigService $dbConfig
45
+     * @param IUserSession $userSession
46
+     * @param IGroupManager $groupManager
47
+     * @param IUserMountCache $userMountCache
48
+     */
49
+    public function __construct(
50
+        BackendService $backendService,
51
+        DBConfigService $dbConfig,
52
+        IUserSession $userSession,
53
+        IGroupManager $groupManager,
54
+        IUserMountCache $userMountCache
55
+    ) {
56
+        parent::__construct($backendService, $dbConfig, $userMountCache);
57
+        $this->userSession = $userSession;
58
+        $this->groupManager = $groupManager;
59
+    }
60
+
61
+    /**
62
+     * Replace config hash ID with real IDs, for migrating legacy storages
63
+     *
64
+     * @param StorageConfig[] $storages Storages with real IDs
65
+     * @param StorageConfig[] $storagesWithConfigHash Storages with config hash IDs
66
+     */
67
+    protected function setRealStorageIds(array &$storages, array $storagesWithConfigHash) {
68
+        // as a read-only view, storage IDs don't need to be real
69
+        foreach ($storagesWithConfigHash as $storage) {
70
+            $storages[$storage->getId()] = $storage;
71
+        }
72
+    }
73
+
74
+    protected function readDBConfig() {
75
+        $userMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_USER, $this->getUser()->getUID());
76
+        $globalMounts = $this->dbConfig->getAdminMountsFor(DBConfigService::APPLICABLE_TYPE_GLOBAL, null);
77
+        $groups = $this->groupManager->getUserGroupIds($this->getUser());
78
+        if (is_array($groups) && count($groups) !== 0) {
79
+            $groupMounts = $this->dbConfig->getAdminMountsForMultiple(DBConfigService::APPLICABLE_TYPE_GROUP, $groups);
80
+        } else {
81
+            $groupMounts = [];
82
+        }
83
+        return array_merge($userMounts, $groupMounts, $globalMounts);
84
+    }
85
+
86
+    public function addStorage(StorageConfig $newStorage) {
87
+        throw new \DomainException('UserGlobalStoragesService writing disallowed');
88
+    }
89
+
90
+    public function updateStorage(StorageConfig $updatedStorage) {
91
+        throw new \DomainException('UserGlobalStoragesService writing disallowed');
92
+    }
93
+
94
+    /**
95
+     * @param integer $id
96
+     */
97
+    public function removeStorage($id) {
98
+        throw new \DomainException('UserGlobalStoragesService writing disallowed');
99
+    }
100
+
101
+    /**
102
+     * Get unique storages, in case two are defined with the same mountpoint
103
+     * Higher priority storages take precedence
104
+     *
105
+     * @return StorageConfig[]
106
+     */
107
+    public function getUniqueStorages() {
108
+        $storages = $this->getStorages();
109
+
110
+        $storagesByMountpoint = [];
111
+        foreach ($storages as $storage) {
112
+            $storagesByMountpoint[$storage->getMountPoint()][] = $storage;
113
+        }
114
+
115
+        $result = [];
116
+        foreach ($storagesByMountpoint as $storageList) {
117
+            $storage = array_reduce($storageList, function ($carry, $item) {
118
+                if (isset($carry)) {
119
+                    $carryPriorityType = $this->getPriorityType($carry);
120
+                    $itemPriorityType = $this->getPriorityType($item);
121
+                    if ($carryPriorityType > $itemPriorityType) {
122
+                        return $carry;
123
+                    } elseif ($carryPriorityType === $itemPriorityType) {
124
+                        if ($carry->getPriority() > $item->getPriority()) {
125
+                            return $carry;
126
+                        }
127
+                    }
128
+                }
129
+                return $item;
130
+            });
131
+            $result[$storage->getID()] = $storage;
132
+        }
133
+
134
+        return $result;
135
+    }
136
+
137
+    /**
138
+     * Get a priority 'type', where a bigger number means higher priority
139
+     * user applicable > group applicable > 'all'
140
+     *
141
+     * @param StorageConfig $storage
142
+     * @return int
143
+     */
144
+    protected function getPriorityType(StorageConfig $storage) {
145
+        $applicableUsers = $storage->getApplicableUsers();
146
+        $applicableGroups = $storage->getApplicableGroups();
147
+
148
+        if ($applicableUsers && $applicableUsers[0] !== 'all') {
149
+            return 2;
150
+        }
151
+        if ($applicableGroups) {
152
+            return 1;
153
+        }
154
+        return 0;
155
+    }
156
+
157
+    protected function isApplicable(StorageConfig $config) {
158
+        $applicableUsers = $config->getApplicableUsers();
159
+        $applicableGroups = $config->getApplicableGroups();
160
+
161
+        if (count($applicableUsers) === 0 && count($applicableGroups) === 0) {
162
+            return true;
163
+        }
164
+        if (in_array($this->getUser()->getUID(), $applicableUsers, true)) {
165
+            return true;
166
+        }
167
+        $groupIds = $this->groupManager->getUserGroupIds($this->getUser());
168
+        foreach ($groupIds as $groupId) {
169
+            if (in_array($groupId, $applicableGroups, true)) {
170
+                return true;
171
+            }
172
+        }
173
+        return false;
174
+    }
175
+
176
+
177
+    /**
178
+     * Gets all storages for the user, admin, personal, global, etc
179
+     *
180
+     * @return StorageConfig[] array of storage configs
181
+     */
182
+    public function getAllStoragesForUser() {
183
+        if (is_null($this->getUser())) {
184
+            return [];
185
+        }
186
+        $groupIds = $this->groupManager->getUserGroupIds($this->getUser());
187
+        $mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds);
188
+        $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
189
+        $configs = array_filter($configs, function ($config) {
190
+            return $config instanceof StorageConfig;
191
+        });
192
+
193
+        $keys = array_map(function (StorageConfig $config) {
194
+            return $config->getId();
195
+        }, $configs);
196
+
197
+        $storages = array_combine($keys, $configs);
198
+        return array_filter($storages, [$this, 'validateStorage']);
199
+    }
200 200
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$result = [];
116 116
 		foreach ($storagesByMountpoint as $storageList) {
117
-			$storage = array_reduce($storageList, function ($carry, $item) {
117
+			$storage = array_reduce($storageList, function($carry, $item) {
118 118
 				if (isset($carry)) {
119 119
 					$carryPriorityType = $this->getPriorityType($carry);
120 120
 					$itemPriorityType = $this->getPriorityType($item);
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 		$groupIds = $this->groupManager->getUserGroupIds($this->getUser());
187 187
 		$mounts = $this->dbConfig->getMountsForUser($this->getUser()->getUID(), $groupIds);
188 188
 		$configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts);
189
-		$configs = array_filter($configs, function ($config) {
189
+		$configs = array_filter($configs, function($config) {
190 190
 			return $config instanceof StorageConfig;
191 191
 		});
192 192
 
193
-		$keys = array_map(function (StorageConfig $config) {
193
+		$keys = array_map(function(StorageConfig $config) {
194 194
 			return $config->getId();
195 195
 		}, $configs);
196 196
 
Please login to merge, or discard this patch.