Passed
Push — master ( f0dd71...c56a27 )
by Christoph
11:49 queued 12s
created
lib/private/Share20/LegacyHooks.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@
 block discarded – undo
66 66
 		/** @var IShare[] $deletedShares */
67 67
 		$deletedShares = $e->getArgument('deletedShares');
68 68
 
69
-		$formattedDeletedShares = array_map(function ($share) {
69
+		$formattedDeletedShares = array_map(function($share) {
70 70
 			return $this->formatHookParams($share);
71 71
 		}, $deletedShares);
72 72
 
Please login to merge, or discard this patch.
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -34,145 +34,145 @@
 block discarded – undo
34 34
 
35 35
 class LegacyHooks {
36 36
 
37
-	/** @var EventDispatcherInterface */
38
-	private $eventDispatcher;
39
-
40
-	/**
41
-	 * LegacyHooks constructor.
42
-	 *
43
-	 * @param EventDispatcherInterface $eventDispatcher
44
-	 */
45
-	public function __construct(EventDispatcherInterface $eventDispatcher) {
46
-		$this->eventDispatcher = $eventDispatcher;
47
-
48
-		$this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
49
-		$this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
50
-		$this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
51
-		$this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
52
-		$this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
53
-	}
54
-
55
-	/**
56
-	 * @param GenericEvent $e
57
-	 */
58
-	public function preUnshare(GenericEvent $e) {
59
-		/** @var IShare $share */
60
-		$share = $e->getSubject();
61
-
62
-		$formatted = $this->formatHookParams($share);
63
-		\OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
64
-	}
65
-
66
-	/**
67
-	 * @param GenericEvent $e
68
-	 */
69
-	public function postUnshare(GenericEvent $e) {
70
-		/** @var IShare $share */
71
-		$share = $e->getSubject();
72
-
73
-		$formatted = $this->formatHookParams($share);
74
-
75
-		/** @var IShare[] $deletedShares */
76
-		$deletedShares = $e->getArgument('deletedShares');
77
-
78
-		$formattedDeletedShares = array_map(function ($share) {
79
-			return $this->formatHookParams($share);
80
-		}, $deletedShares);
81
-
82
-		$formatted['deletedShares'] = $formattedDeletedShares;
83
-
84
-		\OC_Hook::emit(Share::class, 'post_unshare', $formatted);
85
-	}
86
-
87
-	/**
88
-	 * @param GenericEvent $e
89
-	 */
90
-	public function postUnshareFromSelf(GenericEvent $e) {
91
-		/** @var IShare $share */
92
-		$share = $e->getSubject();
93
-
94
-		$formatted = $this->formatHookParams($share);
95
-		$formatted['itemTarget'] = $formatted['fileTarget'];
96
-		$formatted['unsharedItems'] = [$formatted];
97
-
98
-		\OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
99
-	}
100
-
101
-	private function formatHookParams(IShare $share) {
102
-		// Prepare hook
103
-		$shareType = $share->getShareType();
104
-		$sharedWith = '';
105
-		if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
106
-			$shareType === \OCP\Share::SHARE_TYPE_GROUP ||
107
-			$shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
108
-			$sharedWith = $share->getSharedWith();
109
-		}
110
-
111
-		$hookParams = [
112
-			'id' => $share->getId(),
113
-			'itemType' => $share->getNodeType(),
114
-			'itemSource' => $share->getNodeId(),
115
-			'shareType' => $shareType,
116
-			'shareWith' => $sharedWith,
117
-			'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
118
-			'uidOwner' => $share->getSharedBy(),
119
-			'fileSource' => $share->getNodeId(),
120
-			'fileTarget' => $share->getTarget()
121
-		];
122
-		return $hookParams;
123
-	}
124
-
125
-	public function preShare(GenericEvent $e) {
126
-		/** @var IShare $share */
127
-		$share = $e->getSubject();
128
-
129
-		// Pre share hook
130
-		$run = true;
131
-		$error = '';
132
-		$preHookData = [
133
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
134
-			'itemSource' => $share->getNode()->getId(),
135
-			'shareType' => $share->getShareType(),
136
-			'uidOwner' => $share->getSharedBy(),
137
-			'permissions' => $share->getPermissions(),
138
-			'fileSource' => $share->getNode()->getId(),
139
-			'expiration' => $share->getExpirationDate(),
140
-			'token' => $share->getToken(),
141
-			'itemTarget' => $share->getTarget(),
142
-			'shareWith' => $share->getSharedWith(),
143
-			'run' => &$run,
144
-			'error' => &$error,
145
-		];
146
-		\OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
147
-
148
-		if ($run === false) {
149
-			$e->setArgument('error', $error);
150
-			$e->stopPropagation();
151
-		}
152
-
153
-		return $e;
154
-	}
155
-
156
-	public function postShare(GenericEvent $e) {
157
-		/** @var IShare $share */
158
-		$share = $e->getSubject();
159
-
160
-		$postHookData = [
161
-			'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
162
-			'itemSource' => $share->getNode()->getId(),
163
-			'shareType' => $share->getShareType(),
164
-			'uidOwner' => $share->getSharedBy(),
165
-			'permissions' => $share->getPermissions(),
166
-			'fileSource' => $share->getNode()->getId(),
167
-			'expiration' => $share->getExpirationDate(),
168
-			'token' => $share->getToken(),
169
-			'id' => $share->getId(),
170
-			'shareWith' => $share->getSharedWith(),
171
-			'itemTarget' => $share->getTarget(),
172
-			'fileTarget' => $share->getTarget(),
173
-		];
174
-
175
-		\OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
-
177
-	}
37
+    /** @var EventDispatcherInterface */
38
+    private $eventDispatcher;
39
+
40
+    /**
41
+     * LegacyHooks constructor.
42
+     *
43
+     * @param EventDispatcherInterface $eventDispatcher
44
+     */
45
+    public function __construct(EventDispatcherInterface $eventDispatcher) {
46
+        $this->eventDispatcher = $eventDispatcher;
47
+
48
+        $this->eventDispatcher->addListener('OCP\Share::preUnshare', [$this, 'preUnshare']);
49
+        $this->eventDispatcher->addListener('OCP\Share::postUnshare', [$this, 'postUnshare']);
50
+        $this->eventDispatcher->addListener('OCP\Share::postUnshareFromSelf', [$this, 'postUnshareFromSelf']);
51
+        $this->eventDispatcher->addListener('OCP\Share::preShare', [$this, 'preShare']);
52
+        $this->eventDispatcher->addListener('OCP\Share::postShare', [$this, 'postShare']);
53
+    }
54
+
55
+    /**
56
+     * @param GenericEvent $e
57
+     */
58
+    public function preUnshare(GenericEvent $e) {
59
+        /** @var IShare $share */
60
+        $share = $e->getSubject();
61
+
62
+        $formatted = $this->formatHookParams($share);
63
+        \OC_Hook::emit(Share::class, 'pre_unshare', $formatted);
64
+    }
65
+
66
+    /**
67
+     * @param GenericEvent $e
68
+     */
69
+    public function postUnshare(GenericEvent $e) {
70
+        /** @var IShare $share */
71
+        $share = $e->getSubject();
72
+
73
+        $formatted = $this->formatHookParams($share);
74
+
75
+        /** @var IShare[] $deletedShares */
76
+        $deletedShares = $e->getArgument('deletedShares');
77
+
78
+        $formattedDeletedShares = array_map(function ($share) {
79
+            return $this->formatHookParams($share);
80
+        }, $deletedShares);
81
+
82
+        $formatted['deletedShares'] = $formattedDeletedShares;
83
+
84
+        \OC_Hook::emit(Share::class, 'post_unshare', $formatted);
85
+    }
86
+
87
+    /**
88
+     * @param GenericEvent $e
89
+     */
90
+    public function postUnshareFromSelf(GenericEvent $e) {
91
+        /** @var IShare $share */
92
+        $share = $e->getSubject();
93
+
94
+        $formatted = $this->formatHookParams($share);
95
+        $formatted['itemTarget'] = $formatted['fileTarget'];
96
+        $formatted['unsharedItems'] = [$formatted];
97
+
98
+        \OC_Hook::emit(Share::class, 'post_unshareFromSelf', $formatted);
99
+    }
100
+
101
+    private function formatHookParams(IShare $share) {
102
+        // Prepare hook
103
+        $shareType = $share->getShareType();
104
+        $sharedWith = '';
105
+        if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
106
+            $shareType === \OCP\Share::SHARE_TYPE_GROUP ||
107
+            $shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
108
+            $sharedWith = $share->getSharedWith();
109
+        }
110
+
111
+        $hookParams = [
112
+            'id' => $share->getId(),
113
+            'itemType' => $share->getNodeType(),
114
+            'itemSource' => $share->getNodeId(),
115
+            'shareType' => $shareType,
116
+            'shareWith' => $sharedWith,
117
+            'itemparent' => method_exists($share, 'getParent') ? $share->getParent() : '',
118
+            'uidOwner' => $share->getSharedBy(),
119
+            'fileSource' => $share->getNodeId(),
120
+            'fileTarget' => $share->getTarget()
121
+        ];
122
+        return $hookParams;
123
+    }
124
+
125
+    public function preShare(GenericEvent $e) {
126
+        /** @var IShare $share */
127
+        $share = $e->getSubject();
128
+
129
+        // Pre share hook
130
+        $run = true;
131
+        $error = '';
132
+        $preHookData = [
133
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
134
+            'itemSource' => $share->getNode()->getId(),
135
+            'shareType' => $share->getShareType(),
136
+            'uidOwner' => $share->getSharedBy(),
137
+            'permissions' => $share->getPermissions(),
138
+            'fileSource' => $share->getNode()->getId(),
139
+            'expiration' => $share->getExpirationDate(),
140
+            'token' => $share->getToken(),
141
+            'itemTarget' => $share->getTarget(),
142
+            'shareWith' => $share->getSharedWith(),
143
+            'run' => &$run,
144
+            'error' => &$error,
145
+        ];
146
+        \OC_Hook::emit(Share::class, 'pre_shared', $preHookData);
147
+
148
+        if ($run === false) {
149
+            $e->setArgument('error', $error);
150
+            $e->stopPropagation();
151
+        }
152
+
153
+        return $e;
154
+    }
155
+
156
+    public function postShare(GenericEvent $e) {
157
+        /** @var IShare $share */
158
+        $share = $e->getSubject();
159
+
160
+        $postHookData = [
161
+            'itemType' => $share->getNode() instanceof File ? 'file' : 'folder',
162
+            'itemSource' => $share->getNode()->getId(),
163
+            'shareType' => $share->getShareType(),
164
+            'uidOwner' => $share->getSharedBy(),
165
+            'permissions' => $share->getPermissions(),
166
+            'fileSource' => $share->getNode()->getId(),
167
+            'expiration' => $share->getExpirationDate(),
168
+            'token' => $share->getToken(),
169
+            'id' => $share->getId(),
170
+            'shareWith' => $share->getSharedWith(),
171
+            'itemTarget' => $share->getTarget(),
172
+            'fileTarget' => $share->getTarget(),
173
+        ];
174
+
175
+        \OC_Hook::emit(Share::class, 'post_shared', $postHookData);
176
+
177
+    }
178 178
 }
Please login to merge, or discard this patch.
lib/private/AppConfig.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@
 block discarded – undo
275 275
 			return $this->getAppValues($app);
276 276
 		} else {
277 277
 			$appIds = $this->getApps();
278
-			$values = array_map(function ($appId) use ($key) {
278
+			$values = array_map(function($appId) use ($key) {
279 279
 				return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null;
280 280
 			}, $appIds);
281 281
 			$result = array_combine($appIds, $values);
Please login to merge, or discard this patch.
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -42,304 +42,304 @@
 block discarded – undo
42 42
  */
43 43
 class AppConfig implements IAppConfig {
44 44
 
45
-	/** @var array[] */
46
-	protected $sensitiveValues = [
47
-		'external' => [
48
-			'/^sites$/',
49
-		],
50
-		'spreed' => [
51
-			'/^signaling_ticket_secret$/',
52
-			'/^turn_server_secret$/',
53
-			'/^stun_servers$/',
54
-			'/^turn_servers$/',
55
-			'/^signaling_servers$/',
56
-		],
57
-		'theming' => [
58
-			'/^imprintUrl$/',
59
-			'/^privacyUrl$/',
60
-			'/^slogan$/',
61
-			'/^url$/',
62
-		],
63
-		'user_ldap' => [
64
-			'/^(s..)?ldap_agent_password$/',
65
-		],
66
-	];
67
-
68
-	/** @var \OCP\IDBConnection */
69
-	protected $conn;
70
-
71
-	/** @var array[] */
72
-	private $cache = [];
73
-
74
-	/** @var bool */
75
-	private $configLoaded = false;
76
-
77
-	/**
78
-	 * @param IDBConnection $conn
79
-	 */
80
-	public function __construct(IDBConnection $conn) {
81
-		$this->conn = $conn;
82
-		$this->configLoaded = false;
83
-	}
84
-
85
-	/**
86
-	 * @param string $app
87
-	 * @return array
88
-	 */
89
-	private function getAppValues($app) {
90
-		$this->loadConfigValues();
91
-
92
-		if (isset($this->cache[$app])) {
93
-			return $this->cache[$app];
94
-		}
95
-
96
-		return [];
97
-	}
98
-
99
-	/**
100
-	 * Get all apps using the config
101
-	 *
102
-	 * @return array an array of app ids
103
-	 *
104
-	 * This function returns a list of all apps that have at least one
105
-	 * entry in the appconfig table.
106
-	 */
107
-	public function getApps() {
108
-		$this->loadConfigValues();
109
-
110
-		return $this->getSortedKeys($this->cache);
111
-	}
112
-
113
-	/**
114
-	 * Get the available keys for an app
115
-	 *
116
-	 * @param string $app the app we are looking for
117
-	 * @return array an array of key names
118
-	 *
119
-	 * This function gets all keys of an app. Please note that the values are
120
-	 * not returned.
121
-	 */
122
-	public function getKeys($app) {
123
-		$this->loadConfigValues();
124
-
125
-		if (isset($this->cache[$app])) {
126
-			return $this->getSortedKeys($this->cache[$app]);
127
-		}
128
-
129
-		return [];
130
-	}
131
-
132
-	public function getSortedKeys($data) {
133
-		$keys = array_keys($data);
134
-		sort($keys);
135
-		return $keys;
136
-	}
137
-
138
-	/**
139
-	 * Gets the config value
140
-	 *
141
-	 * @param string $app app
142
-	 * @param string $key key
143
-	 * @param string $default = null, default value if the key does not exist
144
-	 * @return string the value or $default
145
-	 *
146
-	 * This function gets a value from the appconfig table. If the key does
147
-	 * not exist the default value will be returned
148
-	 */
149
-	public function getValue($app, $key, $default = null) {
150
-		$this->loadConfigValues();
151
-
152
-		if ($this->hasKey($app, $key)) {
153
-			return $this->cache[$app][$key];
154
-		}
155
-
156
-		return $default;
157
-	}
158
-
159
-	/**
160
-	 * check if a key is set in the appconfig
161
-	 *
162
-	 * @param string $app
163
-	 * @param string $key
164
-	 * @return bool
165
-	 */
166
-	public function hasKey($app, $key) {
167
-		$this->loadConfigValues();
168
-
169
-		return isset($this->cache[$app][$key]);
170
-	}
171
-
172
-	/**
173
-	 * Sets a value. If the key did not exist before it will be created.
174
-	 *
175
-	 * @param string $app app
176
-	 * @param string $key key
177
-	 * @param string|float|int $value value
178
-	 * @return bool True if the value was inserted or updated, false if the value was the same
179
-	 */
180
-	public function setValue($app, $key, $value) {
181
-		if (!$this->hasKey($app, $key)) {
182
-			$inserted = (bool) $this->conn->insertIfNotExist('*PREFIX*appconfig', [
183
-				'appid' => $app,
184
-				'configkey' => $key,
185
-				'configvalue' => $value,
186
-			], [
187
-				'appid',
188
-				'configkey',
189
-			]);
190
-
191
-			if ($inserted) {
192
-				if (!isset($this->cache[$app])) {
193
-					$this->cache[$app] = [];
194
-				}
195
-
196
-				$this->cache[$app][$key] = $value;
197
-				return true;
198
-			}
199
-		}
200
-
201
-		$sql = $this->conn->getQueryBuilder();
202
-		$sql->update('appconfig')
203
-			->set('configvalue', $sql->createParameter('configvalue'))
204
-			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
205
-			->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
206
-			->setParameter('configvalue', $value)
207
-			->setParameter('app', $app)
208
-			->setParameter('configkey', $key);
209
-
210
-		/*
45
+    /** @var array[] */
46
+    protected $sensitiveValues = [
47
+        'external' => [
48
+            '/^sites$/',
49
+        ],
50
+        'spreed' => [
51
+            '/^signaling_ticket_secret$/',
52
+            '/^turn_server_secret$/',
53
+            '/^stun_servers$/',
54
+            '/^turn_servers$/',
55
+            '/^signaling_servers$/',
56
+        ],
57
+        'theming' => [
58
+            '/^imprintUrl$/',
59
+            '/^privacyUrl$/',
60
+            '/^slogan$/',
61
+            '/^url$/',
62
+        ],
63
+        'user_ldap' => [
64
+            '/^(s..)?ldap_agent_password$/',
65
+        ],
66
+    ];
67
+
68
+    /** @var \OCP\IDBConnection */
69
+    protected $conn;
70
+
71
+    /** @var array[] */
72
+    private $cache = [];
73
+
74
+    /** @var bool */
75
+    private $configLoaded = false;
76
+
77
+    /**
78
+     * @param IDBConnection $conn
79
+     */
80
+    public function __construct(IDBConnection $conn) {
81
+        $this->conn = $conn;
82
+        $this->configLoaded = false;
83
+    }
84
+
85
+    /**
86
+     * @param string $app
87
+     * @return array
88
+     */
89
+    private function getAppValues($app) {
90
+        $this->loadConfigValues();
91
+
92
+        if (isset($this->cache[$app])) {
93
+            return $this->cache[$app];
94
+        }
95
+
96
+        return [];
97
+    }
98
+
99
+    /**
100
+     * Get all apps using the config
101
+     *
102
+     * @return array an array of app ids
103
+     *
104
+     * This function returns a list of all apps that have at least one
105
+     * entry in the appconfig table.
106
+     */
107
+    public function getApps() {
108
+        $this->loadConfigValues();
109
+
110
+        return $this->getSortedKeys($this->cache);
111
+    }
112
+
113
+    /**
114
+     * Get the available keys for an app
115
+     *
116
+     * @param string $app the app we are looking for
117
+     * @return array an array of key names
118
+     *
119
+     * This function gets all keys of an app. Please note that the values are
120
+     * not returned.
121
+     */
122
+    public function getKeys($app) {
123
+        $this->loadConfigValues();
124
+
125
+        if (isset($this->cache[$app])) {
126
+            return $this->getSortedKeys($this->cache[$app]);
127
+        }
128
+
129
+        return [];
130
+    }
131
+
132
+    public function getSortedKeys($data) {
133
+        $keys = array_keys($data);
134
+        sort($keys);
135
+        return $keys;
136
+    }
137
+
138
+    /**
139
+     * Gets the config value
140
+     *
141
+     * @param string $app app
142
+     * @param string $key key
143
+     * @param string $default = null, default value if the key does not exist
144
+     * @return string the value or $default
145
+     *
146
+     * This function gets a value from the appconfig table. If the key does
147
+     * not exist the default value will be returned
148
+     */
149
+    public function getValue($app, $key, $default = null) {
150
+        $this->loadConfigValues();
151
+
152
+        if ($this->hasKey($app, $key)) {
153
+            return $this->cache[$app][$key];
154
+        }
155
+
156
+        return $default;
157
+    }
158
+
159
+    /**
160
+     * check if a key is set in the appconfig
161
+     *
162
+     * @param string $app
163
+     * @param string $key
164
+     * @return bool
165
+     */
166
+    public function hasKey($app, $key) {
167
+        $this->loadConfigValues();
168
+
169
+        return isset($this->cache[$app][$key]);
170
+    }
171
+
172
+    /**
173
+     * Sets a value. If the key did not exist before it will be created.
174
+     *
175
+     * @param string $app app
176
+     * @param string $key key
177
+     * @param string|float|int $value value
178
+     * @return bool True if the value was inserted or updated, false if the value was the same
179
+     */
180
+    public function setValue($app, $key, $value) {
181
+        if (!$this->hasKey($app, $key)) {
182
+            $inserted = (bool) $this->conn->insertIfNotExist('*PREFIX*appconfig', [
183
+                'appid' => $app,
184
+                'configkey' => $key,
185
+                'configvalue' => $value,
186
+            ], [
187
+                'appid',
188
+                'configkey',
189
+            ]);
190
+
191
+            if ($inserted) {
192
+                if (!isset($this->cache[$app])) {
193
+                    $this->cache[$app] = [];
194
+                }
195
+
196
+                $this->cache[$app][$key] = $value;
197
+                return true;
198
+            }
199
+        }
200
+
201
+        $sql = $this->conn->getQueryBuilder();
202
+        $sql->update('appconfig')
203
+            ->set('configvalue', $sql->createParameter('configvalue'))
204
+            ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
205
+            ->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
206
+            ->setParameter('configvalue', $value)
207
+            ->setParameter('app', $app)
208
+            ->setParameter('configkey', $key);
209
+
210
+        /*
211 211
 		 * Only limit to the existing value for non-Oracle DBs:
212 212
 		 * http://docs.oracle.com/cd/E11882_01/server.112/e26088/conditions002.htm#i1033286
213 213
 		 * > Large objects (LOBs) are not supported in comparison conditions.
214 214
 		 */
215
-		if (!($this->conn instanceof OracleConnection)) {
216
-			// Only update the value when it is not the same
217
-			$sql->andWhere($sql->expr()->neq('configvalue', $sql->createParameter('configvalue')))
218
-				->setParameter('configvalue', $value);
219
-		}
220
-
221
-		$changedRow = (bool) $sql->execute();
222
-
223
-		$this->cache[$app][$key] = $value;
224
-
225
-		return $changedRow;
226
-	}
227
-
228
-	/**
229
-	 * Deletes a key
230
-	 *
231
-	 * @param string $app app
232
-	 * @param string $key key
233
-	 * @return boolean
234
-	 */
235
-	public function deleteKey($app, $key) {
236
-		$this->loadConfigValues();
237
-
238
-		$sql = $this->conn->getQueryBuilder();
239
-		$sql->delete('appconfig')
240
-			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
241
-			->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
242
-			->setParameter('app', $app)
243
-			->setParameter('configkey', $key);
244
-		$sql->execute();
245
-
246
-		unset($this->cache[$app][$key]);
247
-		return false;
248
-	}
249
-
250
-	/**
251
-	 * Remove app from appconfig
252
-	 *
253
-	 * @param string $app app
254
-	 * @return boolean
255
-	 *
256
-	 * Removes all keys in appconfig belonging to the app.
257
-	 */
258
-	public function deleteApp($app) {
259
-		$this->loadConfigValues();
260
-
261
-		$sql = $this->conn->getQueryBuilder();
262
-		$sql->delete('appconfig')
263
-			->where($sql->expr()->eq('appid', $sql->createParameter('app')))
264
-			->setParameter('app', $app);
265
-		$sql->execute();
266
-
267
-		unset($this->cache[$app]);
268
-		return false;
269
-	}
270
-
271
-	/**
272
-	 * get multiple values, either the app or key can be used as wildcard by setting it to false
273
-	 *
274
-	 * @param string|false $app
275
-	 * @param string|false $key
276
-	 * @return array|false
277
-	 */
278
-	public function getValues($app, $key) {
279
-		if (($app !== false) === ($key !== false)) {
280
-			return false;
281
-		}
282
-
283
-		if ($key === false) {
284
-			return $this->getAppValues($app);
285
-		} else {
286
-			$appIds = $this->getApps();
287
-			$values = array_map(function ($appId) use ($key) {
288
-				return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null;
289
-			}, $appIds);
290
-			$result = array_combine($appIds, $values);
291
-
292
-			return array_filter($result);
293
-		}
294
-	}
295
-
296
-	/**
297
-	 * get all values of the app or and filters out sensitive data
298
-	 *
299
-	 * @param string $app
300
-	 * @return array
301
-	 */
302
-	public function getFilteredValues($app) {
303
-		$values = $this->getValues($app, false);
304
-
305
-		if (isset($this->sensitiveValues[$app])) {
306
-			foreach ($this->sensitiveValues[$app] as $sensitiveKeyExp) {
307
-				$sensitiveKeys = preg_grep($sensitiveKeyExp, array_keys($values));
308
-				foreach ($sensitiveKeys as $sensitiveKey) {
309
-					$values[$sensitiveKey] = IConfig::SENSITIVE_VALUE;
310
-				}
311
-			}
312
-		}
313
-
314
-		return $values;
315
-	}
316
-
317
-	/**
318
-	 * Load all the app config values
319
-	 */
320
-	protected function loadConfigValues() {
321
-		if ($this->configLoaded) {
322
-			return;
323
-		}
324
-
325
-		$this->cache = [];
326
-
327
-		$sql = $this->conn->getQueryBuilder();
328
-		$sql->select('*')
329
-			->from('appconfig');
330
-		$result = $sql->execute();
331
-
332
-		// we are going to store the result in memory anyway
333
-		$rows = $result->fetchAll();
334
-		foreach ($rows as $row) {
335
-			if (!isset($this->cache[$row['appid']])) {
336
-				$this->cache[$row['appid']] = [];
337
-			}
338
-
339
-			$this->cache[$row['appid']][$row['configkey']] = $row['configvalue'];
340
-		}
341
-		$result->closeCursor();
342
-
343
-		$this->configLoaded = true;
344
-	}
215
+        if (!($this->conn instanceof OracleConnection)) {
216
+            // Only update the value when it is not the same
217
+            $sql->andWhere($sql->expr()->neq('configvalue', $sql->createParameter('configvalue')))
218
+                ->setParameter('configvalue', $value);
219
+        }
220
+
221
+        $changedRow = (bool) $sql->execute();
222
+
223
+        $this->cache[$app][$key] = $value;
224
+
225
+        return $changedRow;
226
+    }
227
+
228
+    /**
229
+     * Deletes a key
230
+     *
231
+     * @param string $app app
232
+     * @param string $key key
233
+     * @return boolean
234
+     */
235
+    public function deleteKey($app, $key) {
236
+        $this->loadConfigValues();
237
+
238
+        $sql = $this->conn->getQueryBuilder();
239
+        $sql->delete('appconfig')
240
+            ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
241
+            ->andWhere($sql->expr()->eq('configkey', $sql->createParameter('configkey')))
242
+            ->setParameter('app', $app)
243
+            ->setParameter('configkey', $key);
244
+        $sql->execute();
245
+
246
+        unset($this->cache[$app][$key]);
247
+        return false;
248
+    }
249
+
250
+    /**
251
+     * Remove app from appconfig
252
+     *
253
+     * @param string $app app
254
+     * @return boolean
255
+     *
256
+     * Removes all keys in appconfig belonging to the app.
257
+     */
258
+    public function deleteApp($app) {
259
+        $this->loadConfigValues();
260
+
261
+        $sql = $this->conn->getQueryBuilder();
262
+        $sql->delete('appconfig')
263
+            ->where($sql->expr()->eq('appid', $sql->createParameter('app')))
264
+            ->setParameter('app', $app);
265
+        $sql->execute();
266
+
267
+        unset($this->cache[$app]);
268
+        return false;
269
+    }
270
+
271
+    /**
272
+     * get multiple values, either the app or key can be used as wildcard by setting it to false
273
+     *
274
+     * @param string|false $app
275
+     * @param string|false $key
276
+     * @return array|false
277
+     */
278
+    public function getValues($app, $key) {
279
+        if (($app !== false) === ($key !== false)) {
280
+            return false;
281
+        }
282
+
283
+        if ($key === false) {
284
+            return $this->getAppValues($app);
285
+        } else {
286
+            $appIds = $this->getApps();
287
+            $values = array_map(function ($appId) use ($key) {
288
+                return isset($this->cache[$appId][$key]) ? $this->cache[$appId][$key] : null;
289
+            }, $appIds);
290
+            $result = array_combine($appIds, $values);
291
+
292
+            return array_filter($result);
293
+        }
294
+    }
295
+
296
+    /**
297
+     * get all values of the app or and filters out sensitive data
298
+     *
299
+     * @param string $app
300
+     * @return array
301
+     */
302
+    public function getFilteredValues($app) {
303
+        $values = $this->getValues($app, false);
304
+
305
+        if (isset($this->sensitiveValues[$app])) {
306
+            foreach ($this->sensitiveValues[$app] as $sensitiveKeyExp) {
307
+                $sensitiveKeys = preg_grep($sensitiveKeyExp, array_keys($values));
308
+                foreach ($sensitiveKeys as $sensitiveKey) {
309
+                    $values[$sensitiveKey] = IConfig::SENSITIVE_VALUE;
310
+                }
311
+            }
312
+        }
313
+
314
+        return $values;
315
+    }
316
+
317
+    /**
318
+     * Load all the app config values
319
+     */
320
+    protected function loadConfigValues() {
321
+        if ($this->configLoaded) {
322
+            return;
323
+        }
324
+
325
+        $this->cache = [];
326
+
327
+        $sql = $this->conn->getQueryBuilder();
328
+        $sql->select('*')
329
+            ->from('appconfig');
330
+        $result = $sql->execute();
331
+
332
+        // we are going to store the result in memory anyway
333
+        $rows = $result->fetchAll();
334
+        foreach ($rows as $row) {
335
+            if (!isset($this->cache[$row['appid']])) {
336
+                $this->cache[$row['appid']] = [];
337
+            }
338
+
339
+            $this->cache[$row['appid']][$row['configkey']] = $row['configvalue'];
340
+        }
341
+        $result->closeCursor();
342
+
343
+        $this->configLoaded = true;
344
+    }
345 345
 }
Please login to merge, or discard this patch.
lib/private/DB/SchemaWrapper.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function getTableNamesWithoutPrefix() {
64 64
 		$tableNames = $this->schema->getTableNames();
65
-		return array_map(function ($tableName) {
65
+		return array_map(function($tableName) {
66 66
 			if (strpos($tableName, $this->connection->getPrefix()) === 0) {
67 67
 				return substr($tableName, strlen($this->connection->getPrefix()));
68 68
 			}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @throws \Doctrine\DBAL\Schema\SchemaException
81 81
 	 */
82 82
 	public function getTable($tableName) {
83
-		return $this->schema->getTable($this->connection->getPrefix() . $tableName);
83
+		return $this->schema->getTable($this->connection->getPrefix().$tableName);
84 84
 	}
85 85
 
86 86
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return boolean
92 92
 	 */
93 93
 	public function hasTable($tableName) {
94
-		return $this->schema->hasTable($this->connection->getPrefix() . $tableName);
94
+		return $this->schema->hasTable($this->connection->getPrefix().$tableName);
95 95
 	}
96 96
 
97 97
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return \Doctrine\DBAL\Schema\Table
102 102
 	 */
103 103
 	public function createTable($tableName) {
104
-		return $this->schema->createTable($this->connection->getPrefix() . $tableName);
104
+		return $this->schema->createTable($this->connection->getPrefix().$tableName);
105 105
 	}
106 106
 
107 107
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function dropTable($tableName) {
127 127
 		$this->tablesToDelete[$tableName] = true;
128
-		return $this->schema->dropTable($this->connection->getPrefix() . $tableName);
128
+		return $this->schema->dropTable($this->connection->getPrefix().$tableName);
129 129
 	}
130 130
 
131 131
 	/**
Please login to merge, or discard this patch.
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -29,107 +29,107 @@
 block discarded – undo
29 29
 
30 30
 class SchemaWrapper implements ISchemaWrapper {
31 31
 
32
-	/** @var IDBConnection|Connection */
33
-	protected $connection;
34
-
35
-	/** @var Schema */
36
-	protected $schema;
37
-
38
-	/** @var array */
39
-	protected $tablesToDelete = [];
40
-
41
-	/**
42
-	 * @param IDBConnection $connection
43
-	 */
44
-	public function __construct(IDBConnection $connection) {
45
-		$this->connection = $connection;
46
-		$this->schema = $this->connection->createSchema();
47
-	}
48
-
49
-	public function getWrappedSchema() {
50
-		return $this->schema;
51
-	}
52
-
53
-	public function performDropTableCalls() {
54
-		foreach ($this->tablesToDelete as $tableName => $true) {
55
-			$this->connection->dropTable($tableName);
56
-			unset($this->tablesToDelete[$tableName]);
57
-		}
58
-	}
59
-
60
-	/**
61
-	 * Gets all table names
62
-	 *
63
-	 * @return array
64
-	 */
65
-	public function getTableNamesWithoutPrefix() {
66
-		$tableNames = $this->schema->getTableNames();
67
-		return array_map(function ($tableName) {
68
-			if (strpos($tableName, $this->connection->getPrefix()) === 0) {
69
-				return substr($tableName, strlen($this->connection->getPrefix()));
70
-			}
71
-
72
-			return $tableName;
73
-		}, $tableNames);
74
-	}
75
-
76
-	// Overwritten methods
77
-
78
-	/**
79
-	 * @return array
80
-	 */
81
-	public function getTableNames() {
82
-		return $this->schema->getTableNames();
83
-	}
84
-
85
-	/**
86
-	 * @param string $tableName
87
-	 *
88
-	 * @return \Doctrine\DBAL\Schema\Table
89
-	 * @throws \Doctrine\DBAL\Schema\SchemaException
90
-	 */
91
-	public function getTable($tableName) {
92
-		return $this->schema->getTable($this->connection->getPrefix() . $tableName);
93
-	}
94
-
95
-	/**
96
-	 * Does this schema have a table with the given name?
97
-	 *
98
-	 * @param string $tableName
99
-	 *
100
-	 * @return boolean
101
-	 */
102
-	public function hasTable($tableName) {
103
-		return $this->schema->hasTable($this->connection->getPrefix() . $tableName);
104
-	}
105
-
106
-	/**
107
-	 * Creates a new table.
108
-	 *
109
-	 * @param string $tableName
110
-	 * @return \Doctrine\DBAL\Schema\Table
111
-	 */
112
-	public function createTable($tableName) {
113
-		return $this->schema->createTable($this->connection->getPrefix() . $tableName);
114
-	}
115
-
116
-	/**
117
-	 * Drops a table from the schema.
118
-	 *
119
-	 * @param string $tableName
120
-	 * @return \Doctrine\DBAL\Schema\Schema
121
-	 */
122
-	public function dropTable($tableName) {
123
-		$this->tablesToDelete[$tableName] = true;
124
-		return $this->schema->dropTable($this->connection->getPrefix() . $tableName);
125
-	}
126
-
127
-	/**
128
-	 * Gets all tables of this schema.
129
-	 *
130
-	 * @return \Doctrine\DBAL\Schema\Table[]
131
-	 */
132
-	public function getTables() {
133
-		return $this->schema->getTables();
134
-	}
32
+    /** @var IDBConnection|Connection */
33
+    protected $connection;
34
+
35
+    /** @var Schema */
36
+    protected $schema;
37
+
38
+    /** @var array */
39
+    protected $tablesToDelete = [];
40
+
41
+    /**
42
+     * @param IDBConnection $connection
43
+     */
44
+    public function __construct(IDBConnection $connection) {
45
+        $this->connection = $connection;
46
+        $this->schema = $this->connection->createSchema();
47
+    }
48
+
49
+    public function getWrappedSchema() {
50
+        return $this->schema;
51
+    }
52
+
53
+    public function performDropTableCalls() {
54
+        foreach ($this->tablesToDelete as $tableName => $true) {
55
+            $this->connection->dropTable($tableName);
56
+            unset($this->tablesToDelete[$tableName]);
57
+        }
58
+    }
59
+
60
+    /**
61
+     * Gets all table names
62
+     *
63
+     * @return array
64
+     */
65
+    public function getTableNamesWithoutPrefix() {
66
+        $tableNames = $this->schema->getTableNames();
67
+        return array_map(function ($tableName) {
68
+            if (strpos($tableName, $this->connection->getPrefix()) === 0) {
69
+                return substr($tableName, strlen($this->connection->getPrefix()));
70
+            }
71
+
72
+            return $tableName;
73
+        }, $tableNames);
74
+    }
75
+
76
+    // Overwritten methods
77
+
78
+    /**
79
+     * @return array
80
+     */
81
+    public function getTableNames() {
82
+        return $this->schema->getTableNames();
83
+    }
84
+
85
+    /**
86
+     * @param string $tableName
87
+     *
88
+     * @return \Doctrine\DBAL\Schema\Table
89
+     * @throws \Doctrine\DBAL\Schema\SchemaException
90
+     */
91
+    public function getTable($tableName) {
92
+        return $this->schema->getTable($this->connection->getPrefix() . $tableName);
93
+    }
94
+
95
+    /**
96
+     * Does this schema have a table with the given name?
97
+     *
98
+     * @param string $tableName
99
+     *
100
+     * @return boolean
101
+     */
102
+    public function hasTable($tableName) {
103
+        return $this->schema->hasTable($this->connection->getPrefix() . $tableName);
104
+    }
105
+
106
+    /**
107
+     * Creates a new table.
108
+     *
109
+     * @param string $tableName
110
+     * @return \Doctrine\DBAL\Schema\Table
111
+     */
112
+    public function createTable($tableName) {
113
+        return $this->schema->createTable($this->connection->getPrefix() . $tableName);
114
+    }
115
+
116
+    /**
117
+     * Drops a table from the schema.
118
+     *
119
+     * @param string $tableName
120
+     * @return \Doctrine\DBAL\Schema\Schema
121
+     */
122
+    public function dropTable($tableName) {
123
+        $this->tablesToDelete[$tableName] = true;
124
+        return $this->schema->dropTable($this->connection->getPrefix() . $tableName);
125
+    }
126
+
127
+    /**
128
+     * Gets all tables of this schema.
129
+     *
130
+     * @return \Doctrine\DBAL\Schema\Table[]
131
+     */
132
+    public function getTables() {
133
+        return $this->schema->getTables();
134
+    }
135 135
 }
Please login to merge, or discard this patch.
lib/private/Command/FileAccess.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user) {
29
-		\OC_Util::setupFS($user->getUID());
30
-	}
28
+    protected function setupFS(IUser $user) {
29
+        \OC_Util::setupFS($user->getUID());
30
+    }
31 31
 
32
-	protected function getUserFolder(IUser $user) {
33
-		$this->setupFS($user);
34
-		return \OC::$server->getUserFolder($user->getUID());
35
-	}
32
+    protected function getUserFolder(IUser $user) {
33
+        $this->setupFS($user);
34
+        return \OC::$server->getUserFolder($user->getUID());
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/Manager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
 	 * @return IEntry[]
90 90
 	 */
91 91
 	private function sortEntries(array $entries) {
92
-		usort($entries, function (IEntry $entryA, IEntry $entryB) {
92
+		usort($entries, function(IEntry $entryA, IEntry $entryB) {
93 93
 			return strcasecmp($entryA->getFullName(), $entryB->getFullName());
94 94
 		});
95 95
 		return $entries;
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -32,91 +32,91 @@
 block discarded – undo
32 32
 
33 33
 class Manager {
34 34
 
35
-	/** @var ContactsStore */
36
-	private $store;
37
-
38
-	/** @var ActionProviderStore */
39
-	private $actionProviderStore;
40
-
41
-	/** @var IAppManager */
42
-	private $appManager;
43
-
44
-	/** @var IConfig */
45
-	private $config;
46
-
47
-	/**
48
-	 * @param ContactsStore $store
49
-	 * @param ActionProviderStore $actionProviderStore
50
-	 * @param IAppManager $appManager
51
-	 */
52
-	public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager, IConfig $config) {
53
-		$this->store = $store;
54
-		$this->actionProviderStore = $actionProviderStore;
55
-		$this->appManager = $appManager;
56
-		$this->config = $config;
57
-	}
58
-
59
-	/**
60
-	 * @param IUser $user
61
-	 * @param string $filter
62
-	 * @return array
63
-	 */
64
-	public function getEntries(IUser $user, $filter) {
65
-		$maxAutocompleteResults = $this->config->getSystemValueInt('sharing.maxAutocompleteResults', 25);
66
-		$minSearchStringLength = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0);
67
-		$topEntries = [];
68
-		if (strlen($filter) >= $minSearchStringLength) {
69
-			$entries = $this->store->getContacts($user, $filter);
70
-
71
-			$sortedEntries = $this->sortEntries($entries);
72
-			$topEntries = array_slice($sortedEntries, 0, $maxAutocompleteResults);
73
-			$this->processEntries($topEntries, $user);
74
-		}
75
-
76
-		$contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user);
77
-		return [
78
-			'contacts' => $topEntries,
79
-			'contactsAppEnabled' => $contactsEnabled,
80
-		];
81
-	}
82
-
83
-	/**
84
-	 * @param IUser $user
85
-	 * @param integer $shareType
86
-	 * @param string $shareWith
87
-	 * @return IEntry
88
-	 */
89
-	public function findOne(IUser $user, $shareType, $shareWith) {
90
-		$entry = $this->store->findOne($user, $shareType, $shareWith);
91
-		if ($entry) {
92
-			$this->processEntries([$entry], $user);
93
-		}
94
-
95
-		return $entry;
96
-	}
97
-
98
-	/**
99
-	 * @param IEntry[] $entries
100
-	 * @return IEntry[]
101
-	 */
102
-	private function sortEntries(array $entries) {
103
-		usort($entries, function (IEntry $entryA, IEntry $entryB) {
104
-			return strcasecmp($entryA->getFullName(), $entryB->getFullName());
105
-		});
106
-		return $entries;
107
-	}
108
-
109
-	/**
110
-	 * @param IEntry[] $entries
111
-	 * @param IUser $user
112
-	 */
113
-	private function processEntries(array $entries, IUser $user) {
114
-		$providers = $this->actionProviderStore->getProviders($user);
115
-		foreach ($entries as $entry) {
116
-			foreach ($providers as $provider) {
117
-				$provider->process($entry);
118
-			}
119
-		}
120
-	}
35
+    /** @var ContactsStore */
36
+    private $store;
37
+
38
+    /** @var ActionProviderStore */
39
+    private $actionProviderStore;
40
+
41
+    /** @var IAppManager */
42
+    private $appManager;
43
+
44
+    /** @var IConfig */
45
+    private $config;
46
+
47
+    /**
48
+     * @param ContactsStore $store
49
+     * @param ActionProviderStore $actionProviderStore
50
+     * @param IAppManager $appManager
51
+     */
52
+    public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager, IConfig $config) {
53
+        $this->store = $store;
54
+        $this->actionProviderStore = $actionProviderStore;
55
+        $this->appManager = $appManager;
56
+        $this->config = $config;
57
+    }
58
+
59
+    /**
60
+     * @param IUser $user
61
+     * @param string $filter
62
+     * @return array
63
+     */
64
+    public function getEntries(IUser $user, $filter) {
65
+        $maxAutocompleteResults = $this->config->getSystemValueInt('sharing.maxAutocompleteResults', 25);
66
+        $minSearchStringLength = $this->config->getSystemValueInt('sharing.minSearchStringLength', 0);
67
+        $topEntries = [];
68
+        if (strlen($filter) >= $minSearchStringLength) {
69
+            $entries = $this->store->getContacts($user, $filter);
70
+
71
+            $sortedEntries = $this->sortEntries($entries);
72
+            $topEntries = array_slice($sortedEntries, 0, $maxAutocompleteResults);
73
+            $this->processEntries($topEntries, $user);
74
+        }
75
+
76
+        $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user);
77
+        return [
78
+            'contacts' => $topEntries,
79
+            'contactsAppEnabled' => $contactsEnabled,
80
+        ];
81
+    }
82
+
83
+    /**
84
+     * @param IUser $user
85
+     * @param integer $shareType
86
+     * @param string $shareWith
87
+     * @return IEntry
88
+     */
89
+    public function findOne(IUser $user, $shareType, $shareWith) {
90
+        $entry = $this->store->findOne($user, $shareType, $shareWith);
91
+        if ($entry) {
92
+            $this->processEntries([$entry], $user);
93
+        }
94
+
95
+        return $entry;
96
+    }
97
+
98
+    /**
99
+     * @param IEntry[] $entries
100
+     * @return IEntry[]
101
+     */
102
+    private function sortEntries(array $entries) {
103
+        usort($entries, function (IEntry $entryA, IEntry $entryB) {
104
+            return strcasecmp($entryA->getFullName(), $entryB->getFullName());
105
+        });
106
+        return $entries;
107
+    }
108
+
109
+    /**
110
+     * @param IEntry[] $entries
111
+     * @param IUser $user
112
+     */
113
+    private function processEntries(array $entries, IUser $user) {
114
+        $providers = $this->actionProviderStore->getProviders($user);
115
+        foreach ($entries as $entry) {
116
+            foreach ($providers as $provider) {
117
+                $provider->process($entry);
118
+            }
119
+        }
120
+    }
121 121
 
122 122
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/Entry.php 2 patches
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -29,140 +29,140 @@
 block discarded – undo
29 29
 
30 30
 class Entry implements IEntry {
31 31
 
32
-	/** @var string|int|null */
33
-	private $id = null;
34
-
35
-	/** @var string */
36
-	private $fullName = '';
37
-
38
-	/** @var string[] */
39
-	private $emailAddresses = [];
40
-
41
-	/** @var string|null */
42
-	private $avatar;
43
-
44
-	/** @var IAction[] */
45
-	private $actions = [];
46
-
47
-	/** @var array */
48
-	private $properties = [];
49
-
50
-	/**
51
-	 * @param string $id
52
-	 */
53
-	public function setId($id) {
54
-		$this->id = $id;
55
-	}
56
-
57
-	/**
58
-	 * @param string $displayName
59
-	 */
60
-	public function setFullName($displayName) {
61
-		$this->fullName = $displayName;
62
-	}
63
-
64
-	/**
65
-	 * @return string
66
-	 */
67
-	public function getFullName() {
68
-		return $this->fullName;
69
-	}
70
-
71
-	/**
72
-	 * @param string $address
73
-	 */
74
-	public function addEMailAddress($address) {
75
-		$this->emailAddresses[] = $address;
76
-	}
77
-
78
-	/**
79
-	 * @return string
80
-	 */
81
-	public function getEMailAddresses() {
82
-		return $this->emailAddresses;
83
-	}
84
-
85
-	/**
86
-	 * @param string $avatar
87
-	 */
88
-	public function setAvatar($avatar) {
89
-		$this->avatar = $avatar;
90
-	}
91
-
92
-	/**
93
-	 * @return string
94
-	 */
95
-	public function getAvatar() {
96
-		return $this->avatar;
97
-	}
98
-
99
-	/**
100
-	 * @param IAction $action
101
-	 */
102
-	public function addAction(IAction $action) {
103
-		$this->actions[] = $action;
104
-		$this->sortActions();
105
-	}
106
-
107
-	/**
108
-	 * @return IAction[]
109
-	 */
110
-	public function getActions() {
111
-		return $this->actions;
112
-	}
113
-
114
-	/**
115
-	 * sort the actions by priority and name
116
-	 */
117
-	private function sortActions() {
118
-		usort($this->actions, function (IAction $action1, IAction $action2) {
119
-			$prio1 = $action1->getPriority();
120
-			$prio2 = $action2->getPriority();
121
-
122
-			if ($prio1 === $prio2) {
123
-				// Ascending order for same priority
124
-				return strcasecmp($action1->getName(), $action2->getName());
125
-			}
126
-
127
-			// Descending order when priority differs
128
-			return $prio2 - $prio1;
129
-		});
130
-	}
131
-
132
-	/**
133
-	 * @param array $contact key-value array containing additional properties
134
-	 */
135
-	public function setProperties(array $contact) {
136
-		$this->properties = $contact;
137
-	}
138
-
139
-	/**
140
-	 * @param string $key
141
-	 * @return mixed
142
-	 */
143
-	public function getProperty($key) {
144
-		if (!isset($this->properties[$key])) {
145
-			return null;
146
-		}
147
-		return $this->properties[$key];
148
-	}
149
-
150
-	/**
151
-	 * @return array
152
-	 */
153
-	public function jsonSerialize() {
154
-		$topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
155
-		$otherActions = array_map(function (IAction $action) {
156
-			return $action->jsonSerialize();
157
-		}, array_slice($this->actions, 1));
158
-
159
-		return [
160
-			'id' => $this->id,
161
-			'fullName' => $this->fullName,
162
-			'avatar' => $this->getAvatar(),
163
-			'topAction' => $topAction,
164
-			'actions' => $otherActions,
165
-			'lastMessage' => '',
166
-		];
167
-	}
32
+    /** @var string|int|null */
33
+    private $id = null;
34
+
35
+    /** @var string */
36
+    private $fullName = '';
37
+
38
+    /** @var string[] */
39
+    private $emailAddresses = [];
40
+
41
+    /** @var string|null */
42
+    private $avatar;
43
+
44
+    /** @var IAction[] */
45
+    private $actions = [];
46
+
47
+    /** @var array */
48
+    private $properties = [];
49
+
50
+    /**
51
+     * @param string $id
52
+     */
53
+    public function setId($id) {
54
+        $this->id = $id;
55
+    }
56
+
57
+    /**
58
+     * @param string $displayName
59
+     */
60
+    public function setFullName($displayName) {
61
+        $this->fullName = $displayName;
62
+    }
63
+
64
+    /**
65
+     * @return string
66
+     */
67
+    public function getFullName() {
68
+        return $this->fullName;
69
+    }
70
+
71
+    /**
72
+     * @param string $address
73
+     */
74
+    public function addEMailAddress($address) {
75
+        $this->emailAddresses[] = $address;
76
+    }
77
+
78
+    /**
79
+     * @return string
80
+     */
81
+    public function getEMailAddresses() {
82
+        return $this->emailAddresses;
83
+    }
84
+
85
+    /**
86
+     * @param string $avatar
87
+     */
88
+    public function setAvatar($avatar) {
89
+        $this->avatar = $avatar;
90
+    }
91
+
92
+    /**
93
+     * @return string
94
+     */
95
+    public function getAvatar() {
96
+        return $this->avatar;
97
+    }
98
+
99
+    /**
100
+     * @param IAction $action
101
+     */
102
+    public function addAction(IAction $action) {
103
+        $this->actions[] = $action;
104
+        $this->sortActions();
105
+    }
106
+
107
+    /**
108
+     * @return IAction[]
109
+     */
110
+    public function getActions() {
111
+        return $this->actions;
112
+    }
113
+
114
+    /**
115
+     * sort the actions by priority and name
116
+     */
117
+    private function sortActions() {
118
+        usort($this->actions, function (IAction $action1, IAction $action2) {
119
+            $prio1 = $action1->getPriority();
120
+            $prio2 = $action2->getPriority();
121
+
122
+            if ($prio1 === $prio2) {
123
+                // Ascending order for same priority
124
+                return strcasecmp($action1->getName(), $action2->getName());
125
+            }
126
+
127
+            // Descending order when priority differs
128
+            return $prio2 - $prio1;
129
+        });
130
+    }
131
+
132
+    /**
133
+     * @param array $contact key-value array containing additional properties
134
+     */
135
+    public function setProperties(array $contact) {
136
+        $this->properties = $contact;
137
+    }
138
+
139
+    /**
140
+     * @param string $key
141
+     * @return mixed
142
+     */
143
+    public function getProperty($key) {
144
+        if (!isset($this->properties[$key])) {
145
+            return null;
146
+        }
147
+        return $this->properties[$key];
148
+    }
149
+
150
+    /**
151
+     * @return array
152
+     */
153
+    public function jsonSerialize() {
154
+        $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
155
+        $otherActions = array_map(function (IAction $action) {
156
+            return $action->jsonSerialize();
157
+        }, array_slice($this->actions, 1));
158
+
159
+        return [
160
+            'id' => $this->id,
161
+            'fullName' => $this->fullName,
162
+            'avatar' => $this->getAvatar(),
163
+            'topAction' => $topAction,
164
+            'actions' => $otherActions,
165
+            'lastMessage' => '',
166
+        ];
167
+    }
168 168
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * sort the actions by priority and name
116 116
 	 */
117 117
 	private function sortActions() {
118
-		usort($this->actions, function (IAction $action1, IAction $action2) {
118
+		usort($this->actions, function(IAction $action1, IAction $action2) {
119 119
 			$prio1 = $action1->getPriority();
120 120
 			$prio2 = $action2->getPriority();
121 121
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function jsonSerialize() {
154 154
 		$topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null;
155
-		$otherActions = array_map(function (IAction $action) {
155
+		$otherActions = array_map(function(IAction $action) {
156 156
 			return $action->jsonSerialize();
157 157
 		}, array_slice($this->actions, 1));
158 158
 
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ActionProviderStore.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -35,79 +35,79 @@
 block discarded – undo
35 35
 
36 36
 class ActionProviderStore {
37 37
 
38
-	/** @var IServerContainer */
39
-	private $serverContainer;
40
-
41
-	/** @var AppManager */
42
-	private $appManager;
43
-
44
-	/** @var ILogger */
45
-	private $logger;
46
-
47
-	/**
48
-	 * @param IServerContainer $serverContainer
49
-	 * @param AppManager $appManager
50
-	 * @param ILogger $logger
51
-	 */
52
-	public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) {
53
-		$this->serverContainer = $serverContainer;
54
-		$this->appManager = $appManager;
55
-		$this->logger = $logger;
56
-	}
57
-
58
-	/**
59
-	 * @param IUser $user
60
-	 * @return IProvider[]
61
-	 * @throws Exception
62
-	 */
63
-	public function getProviders(IUser $user) {
64
-		$appClasses = $this->getAppProviderClasses($user);
65
-		$providerClasses = $this->getServerProviderClasses();
66
-		$allClasses = array_merge($providerClasses, $appClasses);
67
-		$providers = [];
68
-
69
-		foreach ($allClasses as $class) {
70
-			try {
71
-				$providers[] = $this->serverContainer->query($class);
72
-			} catch (QueryException $ex) {
73
-				$this->logger->logException($ex, [
74
-					'message' => "Could not load contacts menu action provider $class",
75
-					'app' => 'core',
76
-				]);
77
-				throw new Exception("Could not load contacts menu action provider");
78
-			}
79
-		}
80
-
81
-		return $providers;
82
-	}
83
-
84
-	/**
85
-	 * @return string[]
86
-	 */
87
-	private function getServerProviderClasses() {
88
-		return [
89
-			EMailProvider::class,
90
-		];
91
-	}
92
-
93
-	/**
94
-	 * @param IUser $user
95
-	 * @return string[]
96
-	 */
97
-	private function getAppProviderClasses(IUser $user) {
98
-		return array_reduce($this->appManager->getEnabledAppsForUser($user), function ($all, $appId) {
99
-			$info = $this->appManager->getAppInfo($appId);
100
-
101
-			if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) {
102
-				// Nothing to add
103
-				return $all;
104
-			}
105
-
106
-			$providers = array_reduce($info['contactsmenu'], function ($all, $provider) {
107
-				return array_merge($all, [$provider]);
108
-			}, []);
109
-
110
-			return array_merge($all, $providers);
111
-		}, []);
112
-	}
38
+    /** @var IServerContainer */
39
+    private $serverContainer;
40
+
41
+    /** @var AppManager */
42
+    private $appManager;
43
+
44
+    /** @var ILogger */
45
+    private $logger;
46
+
47
+    /**
48
+     * @param IServerContainer $serverContainer
49
+     * @param AppManager $appManager
50
+     * @param ILogger $logger
51
+     */
52
+    public function __construct(IServerContainer $serverContainer, AppManager $appManager, ILogger $logger) {
53
+        $this->serverContainer = $serverContainer;
54
+        $this->appManager = $appManager;
55
+        $this->logger = $logger;
56
+    }
57
+
58
+    /**
59
+     * @param IUser $user
60
+     * @return IProvider[]
61
+     * @throws Exception
62
+     */
63
+    public function getProviders(IUser $user) {
64
+        $appClasses = $this->getAppProviderClasses($user);
65
+        $providerClasses = $this->getServerProviderClasses();
66
+        $allClasses = array_merge($providerClasses, $appClasses);
67
+        $providers = [];
68
+
69
+        foreach ($allClasses as $class) {
70
+            try {
71
+                $providers[] = $this->serverContainer->query($class);
72
+            } catch (QueryException $ex) {
73
+                $this->logger->logException($ex, [
74
+                    'message' => "Could not load contacts menu action provider $class",
75
+                    'app' => 'core',
76
+                ]);
77
+                throw new Exception("Could not load contacts menu action provider");
78
+            }
79
+        }
80
+
81
+        return $providers;
82
+    }
83
+
84
+    /**
85
+     * @return string[]
86
+     */
87
+    private function getServerProviderClasses() {
88
+        return [
89
+            EMailProvider::class,
90
+        ];
91
+    }
92
+
93
+    /**
94
+     * @param IUser $user
95
+     * @return string[]
96
+     */
97
+    private function getAppProviderClasses(IUser $user) {
98
+        return array_reduce($this->appManager->getEnabledAppsForUser($user), function ($all, $appId) {
99
+            $info = $this->appManager->getAppInfo($appId);
100
+
101
+            if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) {
102
+                // Nothing to add
103
+                return $all;
104
+            }
105
+
106
+            $providers = array_reduce($info['contactsmenu'], function ($all, $provider) {
107
+                return array_merge($all, [$provider]);
108
+            }, []);
109
+
110
+            return array_merge($all, $providers);
111
+        }, []);
112
+    }
113 113
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return string[]
96 96
 	 */
97 97
 	private function getAppProviderClasses(IUser $user) {
98
-		return array_reduce($this->appManager->getEnabledAppsForUser($user), function ($all, $appId) {
98
+		return array_reduce($this->appManager->getEnabledAppsForUser($user), function($all, $appId) {
99 99
 			$info = $this->appManager->getAppInfo($appId);
100 100
 
101 101
 			if (!isset($info['contactsmenu']) || !isset($info['contactsmenu'])) {
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 				return $all;
104 104
 			}
105 105
 
106
-			$providers = array_reduce($info['contactsmenu'], function ($all, $provider) {
106
+			$providers = array_reduce($info['contactsmenu'], function($all, $provider) {
107 107
 				return array_merge($all, [$provider]);
108 108
 			}, []);
109 109
 
Please login to merge, or discard this patch.
apps/dav/lib/Files/Sharing/FilesDropPlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 		$path = array_pop($path);
78 78
 
79 79
 		$newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view);
80
-		$url = $request->getBaseUrl() . $newName;
80
+		$url = $request->getBaseUrl().$newName;
81 81
 		$request->setUrl($url);
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -35,52 +35,52 @@
 block discarded – undo
35 35
  */
36 36
 class FilesDropPlugin extends ServerPlugin {
37 37
 
38
-	/** @var View */
39
-	private $view;
38
+    /** @var View */
39
+    private $view;
40 40
 
41
-	/** @var bool */
42
-	private $enabled = false;
41
+    /** @var bool */
42
+    private $enabled = false;
43 43
 
44
-	/**
45
-	 * @param View $view
46
-	 */
47
-	public function setView($view) {
48
-		$this->view = $view;
49
-	}
44
+    /**
45
+     * @param View $view
46
+     */
47
+    public function setView($view) {
48
+        $this->view = $view;
49
+    }
50 50
 
51
-	public function enable() {
52
-		$this->enabled = true;
53
-	}
51
+    public function enable() {
52
+        $this->enabled = true;
53
+    }
54 54
 
55 55
 
56
-	/**
57
-	 * This initializes the plugin.
58
-	 *
59
-	 * @param \Sabre\DAV\Server $server Sabre server
60
-	 *
61
-	 * @return void
62
-	 * @throws MethodNotAllowed
63
-	 */
64
-	public function initialize(\Sabre\DAV\Server $server) {
65
-		$server->on('beforeMethod:*', [$this, 'beforeMethod'], 999);
66
-		$this->enabled = false;
67
-	}
56
+    /**
57
+     * This initializes the plugin.
58
+     *
59
+     * @param \Sabre\DAV\Server $server Sabre server
60
+     *
61
+     * @return void
62
+     * @throws MethodNotAllowed
63
+     */
64
+    public function initialize(\Sabre\DAV\Server $server) {
65
+        $server->on('beforeMethod:*', [$this, 'beforeMethod'], 999);
66
+        $this->enabled = false;
67
+    }
68 68
 
69
-	public function beforeMethod(RequestInterface $request, ResponseInterface $response) {
69
+    public function beforeMethod(RequestInterface $request, ResponseInterface $response) {
70 70
 
71
-		if (!$this->enabled) {
72
-			return;
73
-		}
71
+        if (!$this->enabled) {
72
+            return;
73
+        }
74 74
 
75
-		if ($request->getMethod() !== 'PUT') {
76
-			throw new MethodNotAllowed('Only PUT is allowed on files drop');
77
-		}
75
+        if ($request->getMethod() !== 'PUT') {
76
+            throw new MethodNotAllowed('Only PUT is allowed on files drop');
77
+        }
78 78
 
79
-		$path = explode('/', $request->getPath());
80
-		$path = array_pop($path);
79
+        $path = explode('/', $request->getPath());
80
+        $path = array_pop($path);
81 81
 
82
-		$newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view);
83
-		$url = $request->getBaseUrl() . $newName;
84
-		$request->setUrl($url);
85
-	}
82
+        $newName = \OC_Helper::buildNotExistingFileNameForView('/', $path, $this->view);
83
+        $url = $request->getBaseUrl() . $newName;
84
+        $request->setUrl($url);
85
+    }
86 86
 }
Please login to merge, or discard this patch.
apps/dav/lib/Command/SyncSystemAddressBook.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
 		$output->writeln('Syncing users ...');
55 55
 		$progress = new ProgressBar($output);
56 56
 		$progress->start();
57
-		$this->syncService->syncInstance(function () use ($progress) {
57
+		$this->syncService->syncInstance(function() use ($progress) {
58 58
 			$progress->advance();
59 59
 		});
60 60
 
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@
 block discarded – undo
31 31
 
32 32
 class SyncSystemAddressBook extends Command {
33 33
 
34
-	/** @var SyncService */
35
-	private $syncService;
34
+    /** @var SyncService */
35
+    private $syncService;
36 36
 
37
-	/**
38
-	 * @param SyncService $syncService
39
-	 */
40
-	function __construct(SyncService $syncService) {
41
-		parent::__construct();
42
-		$this->syncService = $syncService;
43
-	}
37
+    /**
38
+     * @param SyncService $syncService
39
+     */
40
+    function __construct(SyncService $syncService) {
41
+        parent::__construct();
42
+        $this->syncService = $syncService;
43
+    }
44 44
 
45
-	protected function configure() {
46
-		$this
47
-			->setName('dav:sync-system-addressbook')
48
-			->setDescription('Synchronizes users to the system addressbook');
49
-	}
45
+    protected function configure() {
46
+        $this
47
+            ->setName('dav:sync-system-addressbook')
48
+            ->setDescription('Synchronizes users to the system addressbook');
49
+    }
50 50
 
51
-	/**
52
-	 * @param InputInterface $input
53
-	 * @param OutputInterface $output
54
-	 */
55
-	protected function execute(InputInterface $input, OutputInterface $output) {
56
-		$output->writeln('Syncing users ...');
57
-		$progress = new ProgressBar($output);
58
-		$progress->start();
59
-		$this->syncService->syncInstance(function () use ($progress) {
60
-			$progress->advance();
61
-		});
51
+    /**
52
+     * @param InputInterface $input
53
+     * @param OutputInterface $output
54
+     */
55
+    protected function execute(InputInterface $input, OutputInterface $output) {
56
+        $output->writeln('Syncing users ...');
57
+        $progress = new ProgressBar($output);
58
+        $progress->start();
59
+        $this->syncService->syncInstance(function () use ($progress) {
60
+            $progress->advance();
61
+        });
62 62
 
63
-		$progress->finish();
64
-		$output->writeln('');
65
-	}
63
+        $progress->finish();
64
+        $output->writeln('');
65
+    }
66 66
 }
Please login to merge, or discard this patch.