Passed
Push — master ( 1b5db2...2445b9 )
by Morris
14:45 queued 11s
created
apps/encryption/templates/mail.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	<tr><td>
28 28
 			<table cellspacing="0" cellpadding="0" border="0" width="600px">
29 29
 				<tr>
30
-					<td colspan="2" bgcolor="<?php p($theme->getColorPrimary());?>">
30
+					<td colspan="2" bgcolor="<?php p($theme->getColorPrimary()); ?>">
31 31
 						<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
32 32
 					</td>
33 33
 				</tr>
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
53 53
 						<?php p($theme->getName()); ?> -
54 54
 						<?php p($theme->getSlogan()); ?>
55
-						<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
55
+						<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl()); ?></a>
56 56
 					</td>
57 57
 				</tr>
58 58
 				<tr>
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
 					<td width="20px">&nbsp;</td>
16 16
 					<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
17 17
 						<?php
18
-						print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']]));
19
-						// TRANSLATORS term at the end of a mail
20
-						p($l->t('Cheers!'));
21
-						?>
18
+                        print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']]));
19
+                        // TRANSLATORS term at the end of a mail
20
+                        p($l->t('Cheers!'));
21
+                        ?>
22 22
 					</td>
23 23
 				</tr>
24 24
 				<tr><td colspan="2">&nbsp;</td></tr>
Please login to merge, or discard this patch.
lib/private/Repair/CleanTags.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -171,14 +171,14 @@
 block discarded – undo
171 171
 	protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
172 172
 		$qb = $this->connection->getQueryBuilder();
173 173
 
174
-		$qb->select('d.' . $deleteId)
174
+		$qb->select('d.'.$deleteId)
175 175
 			->from($deleteTable, 'd')
176
-			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
176
+			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.'.$deleteId, 's.'.$sourceId))
177 177
 			->where(
178 178
 				$qb->expr()->eq('d.type', $qb->expr()->literal('files'))
179 179
 			)
180 180
 			->andWhere(
181
-				$qb->expr()->isNull('s.' . $sourceNullColumn)
181
+				$qb->expr()->isNull('s.'.$sourceNullColumn)
182 182
 			);
183 183
 		$result = $qb->execute();
184 184
 
Please login to merge, or discard this patch.
Indentation   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -41,171 +41,171 @@
 block discarded – undo
41 41
  */
42 42
 class CleanTags implements IRepairStep {
43 43
 
44
-	/** @var IDBConnection */
45
-	protected $connection;
46
-
47
-	/** @var IUserManager */
48
-	protected $userManager;
49
-
50
-	protected $deletedTags = 0;
51
-
52
-	/**
53
-	 * @param IDBConnection $connection
54
-	 * @param IUserManager $userManager
55
-	 */
56
-	public function __construct(IDBConnection $connection, IUserManager $userManager) {
57
-		$this->connection = $connection;
58
-		$this->userManager = $userManager;
59
-	}
60
-
61
-	/**
62
-	 * @return string
63
-	 */
64
-	public function getName() {
65
-		return 'Clean tags and favorites';
66
-	}
67
-
68
-	/**
69
-	 * Updates the configuration after running an update
70
-	 */
71
-	public function run(IOutput $output) {
72
-		$this->deleteOrphanTags($output);
73
-		$this->deleteOrphanFileEntries($output);
74
-		$this->deleteOrphanTagEntries($output);
75
-		$this->deleteOrphanCategoryEntries($output);
76
-	}
77
-
78
-	/**
79
-	 * Delete tags for deleted users
80
-	 */
81
-	protected function deleteOrphanTags(IOutput $output) {
82
-		$offset = 0;
83
-		while ($this->checkTags($offset)) {
84
-			$offset += 50;
85
-		}
86
-
87
-		$output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
88
-	}
89
-
90
-	protected function checkTags($offset) {
91
-		$query = $this->connection->getQueryBuilder();
92
-		$query->select('uid')
93
-			->from('vcategory')
94
-			->groupBy('uid')
95
-			->orderBy('uid')
96
-			->setMaxResults(50)
97
-			->setFirstResult($offset);
98
-		$result = $query->execute();
99
-
100
-		$users = [];
101
-		$hadResults = false;
102
-		while ($row = $result->fetch()) {
103
-			$hadResults = true;
104
-			if (!$this->userManager->userExists($row['uid'])) {
105
-				$users[] = $row['uid'];
106
-			}
107
-		}
108
-		$result->closeCursor();
109
-
110
-		if (!$hadResults) {
111
-			// No more tags, stop looping
112
-			return false;
113
-		}
114
-
115
-		if (!empty($users)) {
116
-			$query = $this->connection->getQueryBuilder();
117
-			$query->delete('vcategory')
118
-				->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
119
-			$this->deletedTags += $query->execute();
120
-		}
121
-		return true;
122
-	}
123
-
124
-	/**
125
-	 * Delete tag entries for deleted files
126
-	 */
127
-	protected function deleteOrphanFileEntries(IOutput $output) {
128
-		$this->deleteOrphanEntries(
129
-			$output,
130
-			'%d tags for delete files have been removed.',
131
-			'vcategory_to_object', 'objid',
132
-			'filecache', 'fileid', 'path_hash'
133
-		);
134
-	}
135
-
136
-	/**
137
-	 * Delete tag entries for deleted tags
138
-	 */
139
-	protected function deleteOrphanTagEntries(IOutput $output) {
140
-		$this->deleteOrphanEntries(
141
-			$output,
142
-			'%d tag entries for deleted tags have been removed.',
143
-			'vcategory_to_object', 'categoryid',
144
-			'vcategory', 'id', 'uid'
145
-		);
146
-	}
147
-
148
-	/**
149
-	 * Delete tags that have no entries
150
-	 */
151
-	protected function deleteOrphanCategoryEntries(IOutput $output) {
152
-		$this->deleteOrphanEntries(
153
-			$output,
154
-			'%d tags with no entries have been removed.',
155
-			'vcategory', 'id',
156
-			'vcategory_to_object', 'categoryid', 'type'
157
-		);
158
-	}
159
-
160
-	/**
161
-	 * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
162
-	 *
163
-	 * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
164
-	 * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
165
-	 * is being deleted.
166
-	 *
167
-	 * @param string $repairInfo
168
-	 * @param string $deleteTable
169
-	 * @param string $deleteId
170
-	 * @param string $sourceTable
171
-	 * @param string $sourceId
172
-	 * @param string $sourceNullColumn	If this column is null in the source table,
173
-	 * 								the entry is deleted in the $deleteTable
174
-	 */
175
-	protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
176
-		$qb = $this->connection->getQueryBuilder();
177
-
178
-		$qb->select('d.' . $deleteId)
179
-			->from($deleteTable, 'd')
180
-			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
181
-			->where(
182
-				$qb->expr()->eq('d.type', $qb->expr()->literal('files'))
183
-			)
184
-			->andWhere(
185
-				$qb->expr()->isNull('s.' . $sourceNullColumn)
186
-			);
187
-		$result = $qb->execute();
188
-
189
-		$orphanItems = [];
190
-		while ($row = $result->fetch()) {
191
-			$orphanItems[] = (int) $row[$deleteId];
192
-		}
193
-
194
-		if (!empty($orphanItems)) {
195
-			$orphanItemsBatch = array_chunk($orphanItems, 200);
196
-			foreach ($orphanItemsBatch as $items) {
197
-				$qb->delete($deleteTable)
198
-					->where(
199
-						$qb->expr()->eq('type', $qb->expr()->literal('files'))
200
-					)
201
-					->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids')));
202
-				$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
203
-				$qb->execute();
204
-			}
205
-		}
206
-
207
-		if ($repairInfo) {
208
-			$output->info(sprintf($repairInfo, count($orphanItems)));
209
-		}
210
-	}
44
+    /** @var IDBConnection */
45
+    protected $connection;
46
+
47
+    /** @var IUserManager */
48
+    protected $userManager;
49
+
50
+    protected $deletedTags = 0;
51
+
52
+    /**
53
+     * @param IDBConnection $connection
54
+     * @param IUserManager $userManager
55
+     */
56
+    public function __construct(IDBConnection $connection, IUserManager $userManager) {
57
+        $this->connection = $connection;
58
+        $this->userManager = $userManager;
59
+    }
60
+
61
+    /**
62
+     * @return string
63
+     */
64
+    public function getName() {
65
+        return 'Clean tags and favorites';
66
+    }
67
+
68
+    /**
69
+     * Updates the configuration after running an update
70
+     */
71
+    public function run(IOutput $output) {
72
+        $this->deleteOrphanTags($output);
73
+        $this->deleteOrphanFileEntries($output);
74
+        $this->deleteOrphanTagEntries($output);
75
+        $this->deleteOrphanCategoryEntries($output);
76
+    }
77
+
78
+    /**
79
+     * Delete tags for deleted users
80
+     */
81
+    protected function deleteOrphanTags(IOutput $output) {
82
+        $offset = 0;
83
+        while ($this->checkTags($offset)) {
84
+            $offset += 50;
85
+        }
86
+
87
+        $output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
88
+    }
89
+
90
+    protected function checkTags($offset) {
91
+        $query = $this->connection->getQueryBuilder();
92
+        $query->select('uid')
93
+            ->from('vcategory')
94
+            ->groupBy('uid')
95
+            ->orderBy('uid')
96
+            ->setMaxResults(50)
97
+            ->setFirstResult($offset);
98
+        $result = $query->execute();
99
+
100
+        $users = [];
101
+        $hadResults = false;
102
+        while ($row = $result->fetch()) {
103
+            $hadResults = true;
104
+            if (!$this->userManager->userExists($row['uid'])) {
105
+                $users[] = $row['uid'];
106
+            }
107
+        }
108
+        $result->closeCursor();
109
+
110
+        if (!$hadResults) {
111
+            // No more tags, stop looping
112
+            return false;
113
+        }
114
+
115
+        if (!empty($users)) {
116
+            $query = $this->connection->getQueryBuilder();
117
+            $query->delete('vcategory')
118
+                ->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
119
+            $this->deletedTags += $query->execute();
120
+        }
121
+        return true;
122
+    }
123
+
124
+    /**
125
+     * Delete tag entries for deleted files
126
+     */
127
+    protected function deleteOrphanFileEntries(IOutput $output) {
128
+        $this->deleteOrphanEntries(
129
+            $output,
130
+            '%d tags for delete files have been removed.',
131
+            'vcategory_to_object', 'objid',
132
+            'filecache', 'fileid', 'path_hash'
133
+        );
134
+    }
135
+
136
+    /**
137
+     * Delete tag entries for deleted tags
138
+     */
139
+    protected function deleteOrphanTagEntries(IOutput $output) {
140
+        $this->deleteOrphanEntries(
141
+            $output,
142
+            '%d tag entries for deleted tags have been removed.',
143
+            'vcategory_to_object', 'categoryid',
144
+            'vcategory', 'id', 'uid'
145
+        );
146
+    }
147
+
148
+    /**
149
+     * Delete tags that have no entries
150
+     */
151
+    protected function deleteOrphanCategoryEntries(IOutput $output) {
152
+        $this->deleteOrphanEntries(
153
+            $output,
154
+            '%d tags with no entries have been removed.',
155
+            'vcategory', 'id',
156
+            'vcategory_to_object', 'categoryid', 'type'
157
+        );
158
+    }
159
+
160
+    /**
161
+     * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
162
+     *
163
+     * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
164
+     * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
165
+     * is being deleted.
166
+     *
167
+     * @param string $repairInfo
168
+     * @param string $deleteTable
169
+     * @param string $deleteId
170
+     * @param string $sourceTable
171
+     * @param string $sourceId
172
+     * @param string $sourceNullColumn	If this column is null in the source table,
173
+     * 								the entry is deleted in the $deleteTable
174
+     */
175
+    protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
176
+        $qb = $this->connection->getQueryBuilder();
177
+
178
+        $qb->select('d.' . $deleteId)
179
+            ->from($deleteTable, 'd')
180
+            ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
181
+            ->where(
182
+                $qb->expr()->eq('d.type', $qb->expr()->literal('files'))
183
+            )
184
+            ->andWhere(
185
+                $qb->expr()->isNull('s.' . $sourceNullColumn)
186
+            );
187
+        $result = $qb->execute();
188
+
189
+        $orphanItems = [];
190
+        while ($row = $result->fetch()) {
191
+            $orphanItems[] = (int) $row[$deleteId];
192
+        }
193
+
194
+        if (!empty($orphanItems)) {
195
+            $orphanItemsBatch = array_chunk($orphanItems, 200);
196
+            foreach ($orphanItemsBatch as $items) {
197
+                $qb->delete($deleteTable)
198
+                    ->where(
199
+                        $qb->expr()->eq('type', $qb->expr()->literal('files'))
200
+                    )
201
+                    ->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids')));
202
+                $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
203
+                $qb->execute();
204
+            }
205
+        }
206
+
207
+        if ($repairInfo) {
208
+            $output->info(sprintf($repairInfo, count($orphanItems)));
209
+        }
210
+    }
211 211
 }
Please login to merge, or discard this patch.
lib/private/Lockdown/LockdownManager.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -24,56 +24,56 @@
 block discarded – undo
24 24
 use OCP\Lockdown\ILockdownManager;
25 25
 
26 26
 class LockdownManager implements ILockdownManager {
27
-	/** @var ISession */
28
-	private $sessionCallback;
27
+    /** @var ISession */
28
+    private $sessionCallback;
29 29
 
30
-	private $enabled = false;
30
+    private $enabled = false;
31 31
 
32
-	/** @var array|null */
33
-	private $scope;
32
+    /** @var array|null */
33
+    private $scope;
34 34
 
35
-	/**
36
-	 * LockdownManager constructor.
37
-	 *
38
-	 * @param callable $sessionCallback we need to inject the session lazily to avoid dependency loops
39
-	 */
40
-	public function __construct(callable $sessionCallback) {
41
-		$this->sessionCallback = $sessionCallback;
42
-	}
35
+    /**
36
+     * LockdownManager constructor.
37
+     *
38
+     * @param callable $sessionCallback we need to inject the session lazily to avoid dependency loops
39
+     */
40
+    public function __construct(callable $sessionCallback) {
41
+        $this->sessionCallback = $sessionCallback;
42
+    }
43 43
 
44 44
 
45
-	public function enable() {
46
-		$this->enabled = true;
47
-	}
45
+    public function enable() {
46
+        $this->enabled = true;
47
+    }
48 48
 
49
-	/**
50
-	 * @return ISession
51
-	 */
52
-	private function getSession() {
53
-		$callback = $this->sessionCallback;
54
-		return $callback();
55
-	}
49
+    /**
50
+     * @return ISession
51
+     */
52
+    private function getSession() {
53
+        $callback = $this->sessionCallback;
54
+        return $callback();
55
+    }
56 56
 
57
-	private function getScopeAsArray() {
58
-		if (!$this->scope) {
59
-			$session = $this->getSession();
60
-			$sessionScope = $session->get('token_scope');
61
-			if ($sessionScope) {
62
-				$this->scope = $sessionScope;
63
-			}
64
-		}
65
-		return $this->scope;
66
-	}
57
+    private function getScopeAsArray() {
58
+        if (!$this->scope) {
59
+            $session = $this->getSession();
60
+            $sessionScope = $session->get('token_scope');
61
+            if ($sessionScope) {
62
+                $this->scope = $sessionScope;
63
+            }
64
+        }
65
+        return $this->scope;
66
+    }
67 67
 
68
-	public function setToken(IToken $token) {
69
-		$this->scope = $token->getScopeAsArray();
70
-		$session = $this->getSession();
71
-		$session->set('token_scope', $this->scope);
72
-		$this->enable();
73
-	}
68
+    public function setToken(IToken $token) {
69
+        $this->scope = $token->getScopeAsArray();
70
+        $session = $this->getSession();
71
+        $session->set('token_scope', $this->scope);
72
+        $this->enable();
73
+    }
74 74
 
75
-	public function canAccessFilesystem() {
76
-		$scope = $this->getScopeAsArray();
77
-		return !$scope || $scope['filesystem'];
78
-	}
75
+    public function canAccessFilesystem() {
76
+        $scope = $this->getScopeAsArray();
77
+        return !$scope || $scope['filesystem'];
78
+    }
79 79
 }
Please login to merge, or discard this patch.
lib/public/Contacts/ContactsMenu/IProvider.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@
 block discarded – undo
29 29
  */
30 30
 interface IProvider {
31 31
 
32
-	/**
33
-	 * @since 12.0
34
-	 * @param IEntry $entry
35
-	 * @return void
36
-	 */
37
-	public function process(IEntry $entry);
32
+    /**
33
+     * @since 12.0
34
+     * @param IEntry $entry
35
+     * @return void
36
+     */
37
+    public function process(IEntry $entry);
38 38
 }
Please login to merge, or discard this patch.
lib/public/Share/IShareHelper.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
  */
33 33
 interface IShareHelper {
34 34
 
35
-	/**
36
-	 * @param Node $node
37
-	 * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
38
-	 * @since 12
39
-	 */
40
-	public function getPathsForAccessList(Node $node);
35
+    /**
36
+     * @param Node $node
37
+     * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
38
+     * @since 12
39
+     */
40
+    public function getPathsForAccessList(Node $node);
41 41
 }
Please login to merge, or discard this patch.
lib/private/Share20/ShareHelper.php 2 patches
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -31,187 +31,187 @@
 block discarded – undo
31 31
 
32 32
 class ShareHelper implements IShareHelper {
33 33
 
34
-	/** @var IManager */
35
-	private $shareManager;
36
-
37
-	public function __construct(IManager $shareManager) {
38
-		$this->shareManager = $shareManager;
39
-	}
40
-
41
-	/**
42
-	 * @param Node $node
43
-	 * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
44
-	 */
45
-	public function getPathsForAccessList(Node $node) {
46
-		$result = [
47
-			'users' => [],
48
-			'remotes' => [],
49
-		];
50
-
51
-		$accessList = $this->shareManager->getAccessList($node, true, true);
52
-		if (!empty($accessList['users'])) {
53
-			$result['users'] = $this->getPathsForUsers($node, $accessList['users']);
54
-		}
55
-		if (!empty($accessList['remote'])) {
56
-			$result['remotes'] = $this->getPathsForRemotes($node, $accessList['remote']);
57
-		}
58
-
59
-		return $result;
60
-	}
61
-
62
-	/**
63
-	 * Sample:
64
-	 * $users = [
65
-	 *   'test1' => ['node_id' => 16, 'node_path' => '/foo'],
66
-	 *   'test2' => ['node_id' => 23, 'node_path' => '/bar'],
67
-	 *   'test3' => ['node_id' => 42, 'node_path' => '/cat'],
68
-	 *   'test4' => ['node_id' => 48, 'node_path' => '/dog'],
69
-	 * ];
70
-	 *
71
-	 * Node tree:
72
-	 * - SixTeen is the parent of TwentyThree
73
-	 * - TwentyThree is the parent of FortyTwo
74
-	 * - FortyEight does not exist
75
-	 *
76
-	 * $return = [
77
-	 *   'test1' => '/foo/TwentyThree/FortyTwo',
78
-	 *   'test2' => '/bar/FortyTwo',
79
-	 *   'test3' => '/cat',
80
-	 * ],
81
-	 *
82
-	 * @param Node $node
83
-	 * @param array[] $users
84
-	 * @return array
85
-	 */
86
-	protected function getPathsForUsers(Node $node, array $users) {
87
-		/** @var array[] $byId */
88
-		$byId = [];
89
-		/** @var array[] $results */
90
-		$results = [];
91
-
92
-		foreach ($users as $uid => $info) {
93
-			if (!isset($byId[$info['node_id']])) {
94
-				$byId[$info['node_id']] = [];
95
-			}
96
-			$byId[$info['node_id']][$uid] = $info['node_path'];
97
-		}
98
-
99
-		try {
100
-			if (isset($byId[$node->getId()])) {
101
-				foreach ($byId[$node->getId()] as $uid => $path) {
102
-					$results[$uid] = $path;
103
-				}
104
-				unset($byId[$node->getId()]);
105
-			}
106
-		} catch (NotFoundException $e) {
107
-			return $results;
108
-		} catch (InvalidPathException $e) {
109
-			return $results;
110
-		}
111
-
112
-		if (empty($byId)) {
113
-			return $results;
114
-		}
115
-
116
-		$item = $node;
117
-		$appendix = '/' . $node->getName();
118
-		while (!empty($byId)) {
119
-			try {
120
-				/** @var Node $item */
121
-				$item = $item->getParent();
122
-
123
-				if (!empty($byId[$item->getId()])) {
124
-					foreach ($byId[$item->getId()] as $uid => $path) {
125
-						$results[$uid] = $path . $appendix;
126
-					}
127
-					unset($byId[$item->getId()]);
128
-				}
129
-
130
-				$appendix = '/' . $item->getName() . $appendix;
131
-			} catch (NotFoundException $e) {
132
-				return $results;
133
-			} catch (InvalidPathException $e) {
134
-				return $results;
135
-			} catch (NotPermittedException $e) {
136
-				return $results;
137
-			}
138
-		}
139
-
140
-		return $results;
141
-	}
142
-
143
-	/**
144
-	 * Sample:
145
-	 * $remotes = [
146
-	 *   'test1' => ['node_id' => 16, 'token' => 't1'],
147
-	 *   'test2' => ['node_id' => 23, 'token' => 't2'],
148
-	 *   'test3' => ['node_id' => 42, 'token' => 't3'],
149
-	 *   'test4' => ['node_id' => 48, 'token' => 't4'],
150
-	 * ];
151
-	 *
152
-	 * Node tree:
153
-	 * - SixTeen is the parent of TwentyThree
154
-	 * - TwentyThree is the parent of FortyTwo
155
-	 * - FortyEight does not exist
156
-	 *
157
-	 * $return = [
158
-	 *   'test1' => ['token' => 't1', 'node_path' => '/SixTeen'],
159
-	 *   'test2' => ['token' => 't2', 'node_path' => '/SixTeen/TwentyThree'],
160
-	 *   'test3' => ['token' => 't3', 'node_path' => '/SixTeen/TwentyThree/FortyTwo'],
161
-	 * ],
162
-	 *
163
-	 * @param Node $node
164
-	 * @param array[] $remotes
165
-	 * @return array
166
-	 */
167
-	protected function getPathsForRemotes(Node $node, array $remotes) {
168
-		/** @var array[] $byId */
169
-		$byId = [];
170
-		/** @var array[] $results */
171
-		$results = [];
172
-
173
-		foreach ($remotes as $cloudId => $info) {
174
-			if (!isset($byId[$info['node_id']])) {
175
-				$byId[$info['node_id']] = [];
176
-			}
177
-			$byId[$info['node_id']][$cloudId] = $info['token'];
178
-		}
179
-
180
-		$item = $node;
181
-		while (!empty($byId)) {
182
-			try {
183
-				if (!empty($byId[$item->getId()])) {
184
-					$path = $this->getMountedPath($item);
185
-					foreach ($byId[$item->getId()] as $uid => $token) {
186
-						$results[$uid] = [
187
-							'node_path' => $path,
188
-							'token' => $token,
189
-						];
190
-					}
191
-					unset($byId[$item->getId()]);
192
-				}
193
-
194
-				/** @var Node $item */
195
-				$item = $item->getParent();
196
-			} catch (NotFoundException $e) {
197
-				return $results;
198
-			} catch (InvalidPathException $e) {
199
-				return $results;
200
-			} catch (NotPermittedException $e) {
201
-				return $results;
202
-			}
203
-		}
204
-
205
-		return $results;
206
-	}
207
-
208
-	/**
209
-	 * @param Node $node
210
-	 * @return string
211
-	 */
212
-	protected function getMountedPath(Node $node) {
213
-		$path = $node->getPath();
214
-		$sections = explode('/', $path, 4);
215
-		return '/' . $sections[3];
216
-	}
34
+    /** @var IManager */
35
+    private $shareManager;
36
+
37
+    public function __construct(IManager $shareManager) {
38
+        $this->shareManager = $shareManager;
39
+    }
40
+
41
+    /**
42
+     * @param Node $node
43
+     * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]]
44
+     */
45
+    public function getPathsForAccessList(Node $node) {
46
+        $result = [
47
+            'users' => [],
48
+            'remotes' => [],
49
+        ];
50
+
51
+        $accessList = $this->shareManager->getAccessList($node, true, true);
52
+        if (!empty($accessList['users'])) {
53
+            $result['users'] = $this->getPathsForUsers($node, $accessList['users']);
54
+        }
55
+        if (!empty($accessList['remote'])) {
56
+            $result['remotes'] = $this->getPathsForRemotes($node, $accessList['remote']);
57
+        }
58
+
59
+        return $result;
60
+    }
61
+
62
+    /**
63
+     * Sample:
64
+     * $users = [
65
+     *   'test1' => ['node_id' => 16, 'node_path' => '/foo'],
66
+     *   'test2' => ['node_id' => 23, 'node_path' => '/bar'],
67
+     *   'test3' => ['node_id' => 42, 'node_path' => '/cat'],
68
+     *   'test4' => ['node_id' => 48, 'node_path' => '/dog'],
69
+     * ];
70
+     *
71
+     * Node tree:
72
+     * - SixTeen is the parent of TwentyThree
73
+     * - TwentyThree is the parent of FortyTwo
74
+     * - FortyEight does not exist
75
+     *
76
+     * $return = [
77
+     *   'test1' => '/foo/TwentyThree/FortyTwo',
78
+     *   'test2' => '/bar/FortyTwo',
79
+     *   'test3' => '/cat',
80
+     * ],
81
+     *
82
+     * @param Node $node
83
+     * @param array[] $users
84
+     * @return array
85
+     */
86
+    protected function getPathsForUsers(Node $node, array $users) {
87
+        /** @var array[] $byId */
88
+        $byId = [];
89
+        /** @var array[] $results */
90
+        $results = [];
91
+
92
+        foreach ($users as $uid => $info) {
93
+            if (!isset($byId[$info['node_id']])) {
94
+                $byId[$info['node_id']] = [];
95
+            }
96
+            $byId[$info['node_id']][$uid] = $info['node_path'];
97
+        }
98
+
99
+        try {
100
+            if (isset($byId[$node->getId()])) {
101
+                foreach ($byId[$node->getId()] as $uid => $path) {
102
+                    $results[$uid] = $path;
103
+                }
104
+                unset($byId[$node->getId()]);
105
+            }
106
+        } catch (NotFoundException $e) {
107
+            return $results;
108
+        } catch (InvalidPathException $e) {
109
+            return $results;
110
+        }
111
+
112
+        if (empty($byId)) {
113
+            return $results;
114
+        }
115
+
116
+        $item = $node;
117
+        $appendix = '/' . $node->getName();
118
+        while (!empty($byId)) {
119
+            try {
120
+                /** @var Node $item */
121
+                $item = $item->getParent();
122
+
123
+                if (!empty($byId[$item->getId()])) {
124
+                    foreach ($byId[$item->getId()] as $uid => $path) {
125
+                        $results[$uid] = $path . $appendix;
126
+                    }
127
+                    unset($byId[$item->getId()]);
128
+                }
129
+
130
+                $appendix = '/' . $item->getName() . $appendix;
131
+            } catch (NotFoundException $e) {
132
+                return $results;
133
+            } catch (InvalidPathException $e) {
134
+                return $results;
135
+            } catch (NotPermittedException $e) {
136
+                return $results;
137
+            }
138
+        }
139
+
140
+        return $results;
141
+    }
142
+
143
+    /**
144
+     * Sample:
145
+     * $remotes = [
146
+     *   'test1' => ['node_id' => 16, 'token' => 't1'],
147
+     *   'test2' => ['node_id' => 23, 'token' => 't2'],
148
+     *   'test3' => ['node_id' => 42, 'token' => 't3'],
149
+     *   'test4' => ['node_id' => 48, 'token' => 't4'],
150
+     * ];
151
+     *
152
+     * Node tree:
153
+     * - SixTeen is the parent of TwentyThree
154
+     * - TwentyThree is the parent of FortyTwo
155
+     * - FortyEight does not exist
156
+     *
157
+     * $return = [
158
+     *   'test1' => ['token' => 't1', 'node_path' => '/SixTeen'],
159
+     *   'test2' => ['token' => 't2', 'node_path' => '/SixTeen/TwentyThree'],
160
+     *   'test3' => ['token' => 't3', 'node_path' => '/SixTeen/TwentyThree/FortyTwo'],
161
+     * ],
162
+     *
163
+     * @param Node $node
164
+     * @param array[] $remotes
165
+     * @return array
166
+     */
167
+    protected function getPathsForRemotes(Node $node, array $remotes) {
168
+        /** @var array[] $byId */
169
+        $byId = [];
170
+        /** @var array[] $results */
171
+        $results = [];
172
+
173
+        foreach ($remotes as $cloudId => $info) {
174
+            if (!isset($byId[$info['node_id']])) {
175
+                $byId[$info['node_id']] = [];
176
+            }
177
+            $byId[$info['node_id']][$cloudId] = $info['token'];
178
+        }
179
+
180
+        $item = $node;
181
+        while (!empty($byId)) {
182
+            try {
183
+                if (!empty($byId[$item->getId()])) {
184
+                    $path = $this->getMountedPath($item);
185
+                    foreach ($byId[$item->getId()] as $uid => $token) {
186
+                        $results[$uid] = [
187
+                            'node_path' => $path,
188
+                            'token' => $token,
189
+                        ];
190
+                    }
191
+                    unset($byId[$item->getId()]);
192
+                }
193
+
194
+                /** @var Node $item */
195
+                $item = $item->getParent();
196
+            } catch (NotFoundException $e) {
197
+                return $results;
198
+            } catch (InvalidPathException $e) {
199
+                return $results;
200
+            } catch (NotPermittedException $e) {
201
+                return $results;
202
+            }
203
+        }
204
+
205
+        return $results;
206
+    }
207
+
208
+    /**
209
+     * @param Node $node
210
+     * @return string
211
+     */
212
+    protected function getMountedPath(Node $node) {
213
+        $path = $node->getPath();
214
+        $sections = explode('/', $path, 4);
215
+        return '/' . $sections[3];
216
+    }
217 217
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		}
115 115
 
116 116
 		$item = $node;
117
-		$appendix = '/' . $node->getName();
117
+		$appendix = '/'.$node->getName();
118 118
 		while (!empty($byId)) {
119 119
 			try {
120 120
 				/** @var Node $item */
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 
123 123
 				if (!empty($byId[$item->getId()])) {
124 124
 					foreach ($byId[$item->getId()] as $uid => $path) {
125
-						$results[$uid] = $path . $appendix;
125
+						$results[$uid] = $path.$appendix;
126 126
 					}
127 127
 					unset($byId[$item->getId()]);
128 128
 				}
129 129
 
130
-				$appendix = '/' . $item->getName() . $appendix;
130
+				$appendix = '/'.$item->getName().$appendix;
131 131
 			} catch (NotFoundException $e) {
132 132
 				return $results;
133 133
 			} catch (InvalidPathException $e) {
@@ -212,6 +212,6 @@  discard block
 block discarded – undo
212 212
 	protected function getMountedPath(Node $node) {
213 213
 		$path = $node->getPath();
214 214
 		$sections = explode('/', $path, 4);
215
-		return '/' . $sections[3];
215
+		return '/'.$sections[3];
216 216
 	}
217 217
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/LogWrapper.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
  * @brief wraps around static Nextcloud core methods
29 29
  */
30 30
 class LogWrapper {
31
-	protected $app = 'user_ldap';
31
+    protected $app = 'user_ldap';
32 32
 
33
-	/**
34
-	 * @brief states whether the filesystem was loaded
35
-	 * @return bool
36
-	 */
37
-	public function log($msg, $level) {
38
-		\OCP\Util::writeLog($this->app, $msg, $level);
39
-	}
33
+    /**
34
+     * @brief states whether the filesystem was loaded
35
+     * @return bool
36
+     */
37
+    public function log($msg, $level) {
38
+        \OCP\Util::writeLog($this->app, $msg, $level);
39
+    }
40 40
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/FilesystemHelper.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@
 block discarded – undo
29 29
  */
30 30
 class FilesystemHelper {
31 31
 
32
-	/**
33
-	 * @brief states whether the filesystem was loaded
34
-	 * @return bool
35
-	 */
36
-	public function isLoaded() {
37
-		return \OC\Files\Filesystem::$loaded;
38
-	}
32
+    /**
33
+     * @brief states whether the filesystem was loaded
34
+     * @return bool
35
+     */
36
+    public function isLoaded() {
37
+        return \OC\Files\Filesystem::$loaded;
38
+    }
39 39
 
40
-	/**
41
-	 * @brief initializes the filesystem for the given user
42
-	 * @param string $uid the Nextcloud username of the user
43
-	 */
44
-	public function setup($uid) {
45
-		\OC_Util::setupFS($uid);
46
-	}
40
+    /**
41
+     * @brief initializes the filesystem for the given user
42
+     * @param string $uid the Nextcloud username of the user
43
+     */
44
+    public function setup($uid) {
45
+        \OC_Util::setupFS($uid);
46
+    }
47 47
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Migration/StorageMigrator.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -42,97 +42,97 @@
 block discarded – undo
42 42
  * Migrate mount config from mount.json to the database
43 43
  */
44 44
 class StorageMigrator {
45
-	/**
46
-	 * @var BackendService
47
-	 */
48
-	private $backendService;
45
+    /**
46
+     * @var BackendService
47
+     */
48
+    private $backendService;
49 49
 
50
-	/**
51
-	 * @var DBConfigService
52
-	 */
53
-	private $dbConfig;
50
+    /**
51
+     * @var DBConfigService
52
+     */
53
+    private $dbConfig;
54 54
 
55
-	/**
56
-	 * @var IConfig
57
-	 */
58
-	private $config;
55
+    /**
56
+     * @var IConfig
57
+     */
58
+    private $config;
59 59
 
60
-	/**
61
-	 * @var IDBConnection
62
-	 */
63
-	private $connection;
60
+    /**
61
+     * @var IDBConnection
62
+     */
63
+    private $connection;
64 64
 
65
-	/**
66
-	 * @var ILogger
67
-	 */
68
-	private $logger;
65
+    /**
66
+     * @var ILogger
67
+     */
68
+    private $logger;
69 69
 
70
-	/** @var IUserMountCache  */
71
-	private $userMountCache;
70
+    /** @var IUserMountCache  */
71
+    private $userMountCache;
72 72
 
73
-	/**
74
-	 * StorageMigrator constructor.
75
-	 *
76
-	 * @param BackendService $backendService
77
-	 * @param DBConfigService $dbConfig
78
-	 * @param IConfig $config
79
-	 * @param IDBConnection $connection
80
-	 * @param ILogger $logger
81
-	 * @param IUserMountCache $userMountCache
82
-	 */
83
-	public function __construct(
84
-		BackendService $backendService,
85
-		DBConfigService $dbConfig,
86
-		IConfig $config,
87
-		IDBConnection $connection,
88
-		ILogger $logger,
89
-		IUserMountCache $userMountCache
90
-	) {
91
-		$this->backendService = $backendService;
92
-		$this->dbConfig = $dbConfig;
93
-		$this->config = $config;
94
-		$this->connection = $connection;
95
-		$this->logger = $logger;
96
-		$this->userMountCache = $userMountCache;
97
-	}
73
+    /**
74
+     * StorageMigrator constructor.
75
+     *
76
+     * @param BackendService $backendService
77
+     * @param DBConfigService $dbConfig
78
+     * @param IConfig $config
79
+     * @param IDBConnection $connection
80
+     * @param ILogger $logger
81
+     * @param IUserMountCache $userMountCache
82
+     */
83
+    public function __construct(
84
+        BackendService $backendService,
85
+        DBConfigService $dbConfig,
86
+        IConfig $config,
87
+        IDBConnection $connection,
88
+        ILogger $logger,
89
+        IUserMountCache $userMountCache
90
+    ) {
91
+        $this->backendService = $backendService;
92
+        $this->dbConfig = $dbConfig;
93
+        $this->config = $config;
94
+        $this->connection = $connection;
95
+        $this->logger = $logger;
96
+        $this->userMountCache = $userMountCache;
97
+    }
98 98
 
99
-	private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) {
100
-		$existingStorage = $legacyService->getAllStorages();
99
+    private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) {
100
+        $existingStorage = $legacyService->getAllStorages();
101 101
 
102
-		$this->connection->beginTransaction();
103
-		try {
104
-			foreach ($existingStorage as $storage) {
105
-				$mountOptions = $storage->getMountOptions();
106
-				if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) {
107
-					// existing mounts must have sharing enabled by default to avoid surprises
108
-					$mountOptions['enable_sharing'] = true;
109
-					$storage->setMountOptions($mountOptions);
110
-				}
111
-				$storageService->addStorage($storage);
112
-			}
113
-			$this->connection->commit();
114
-		} catch (\Exception $e) {
115
-			$this->logger->logException($e);
116
-			$this->connection->rollBack();
117
-		}
118
-	}
102
+        $this->connection->beginTransaction();
103
+        try {
104
+            foreach ($existingStorage as $storage) {
105
+                $mountOptions = $storage->getMountOptions();
106
+                if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) {
107
+                    // existing mounts must have sharing enabled by default to avoid surprises
108
+                    $mountOptions['enable_sharing'] = true;
109
+                    $storage->setMountOptions($mountOptions);
110
+                }
111
+                $storageService->addStorage($storage);
112
+            }
113
+            $this->connection->commit();
114
+        } catch (\Exception $e) {
115
+            $this->logger->logException($e);
116
+            $this->connection->rollBack();
117
+        }
118
+    }
119 119
 
120
-	/**
121
-	 * Migrate personal storages configured by the current user
122
-	 *
123
-	 * @param IUser $user
124
-	 */
125
-	public function migrateUser(IUser $user) {
126
-		$dummySession = new DummyUserSession();
127
-		$dummySession->setUser($user);
128
-		$userId = $user->getUID();
129
-		$userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0');
130
-		if (version_compare($userVersion, '0.5.0', '<')) {
131
-			$this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0');
132
-			$legacyService = new UserLegacyStoragesService($this->backendService, $dummySession);
133
-			$storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache);
120
+    /**
121
+     * Migrate personal storages configured by the current user
122
+     *
123
+     * @param IUser $user
124
+     */
125
+    public function migrateUser(IUser $user) {
126
+        $dummySession = new DummyUserSession();
127
+        $dummySession->setUser($user);
128
+        $userId = $user->getUID();
129
+        $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0');
130
+        if (version_compare($userVersion, '0.5.0', '<')) {
131
+            $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0');
132
+            $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession);
133
+            $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache);
134 134
 
135
-			$this->migrate($legacyService, $storageService);
136
-		}
137
-	}
135
+            $this->migrate($legacyService, $storageService);
136
+        }
137
+    }
138 138
 }
Please login to merge, or discard this patch.