Passed
Push — master ( c00d6f...a085a8 )
by Morris
09:54 queued 11s
created
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   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -37,172 +37,172 @@
 block discarded – undo
37 37
  */
38 38
 class CleanTags implements IRepairStep {
39 39
 
40
-	/** @var IDBConnection */
41
-	protected $connection;
42
-
43
-	/** @var IUserManager */
44
-	protected $userManager;
45
-
46
-	protected $deletedTags = 0;
47
-
48
-	/**
49
-	 * @param IDBConnection $connection
50
-	 * @param IUserManager $userManager
51
-	 */
52
-	public function __construct(IDBConnection $connection, IUserManager $userManager) {
53
-		$this->connection = $connection;
54
-		$this->userManager = $userManager;
55
-	}
56
-
57
-	/**
58
-	 * @return string
59
-	 */
60
-	public function getName() {
61
-		return 'Clean tags and favorites';
62
-	}
63
-
64
-	/**
65
-	 * Updates the configuration after running an update
66
-	 */
67
-	public function run(IOutput $output) {
68
-		$this->deleteOrphanTags($output);
69
-		$this->deleteOrphanFileEntries($output);
70
-		$this->deleteOrphanTagEntries($output);
71
-		$this->deleteOrphanCategoryEntries($output);
72
-	}
73
-
74
-	/**
75
-	 * Delete tags for deleted users
76
-	 */
77
-	protected function deleteOrphanTags(IOutput $output) {
78
-		$offset = 0;
79
-		while ($this->checkTags($offset)) {
80
-			$offset += 50;
81
-		}
82
-
83
-		$output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
84
-	}
85
-
86
-	protected function checkTags($offset) {
87
-		$query = $this->connection->getQueryBuilder();
88
-		$query->select('uid')
89
-			->from('vcategory')
90
-			->groupBy('uid')
91
-			->orderBy('uid')
92
-			->setMaxResults(50)
93
-			->setFirstResult($offset);
94
-		$result = $query->execute();
95
-
96
-		$users = [];
97
-		$hadResults = false;
98
-		while ($row = $result->fetch()) {
99
-			$hadResults = true;
100
-			if (!$this->userManager->userExists($row['uid'])) {
101
-				$users[] = $row['uid'];
102
-			}
103
-		}
104
-		$result->closeCursor();
105
-
106
-		if (!$hadResults) {
107
-			// No more tags, stop looping
108
-			return false;
109
-		}
110
-
111
-		if (!empty($users)) {
112
-			$query = $this->connection->getQueryBuilder();
113
-			$query->delete('vcategory')
114
-				->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
115
-			$this->deletedTags += $query->execute();
116
-		}
117
-		return true;
118
-	}
119
-
120
-	/**
121
-	 * Delete tag entries for deleted files
122
-	 */
123
-	protected function deleteOrphanFileEntries(IOutput $output) {
124
-		$this->deleteOrphanEntries(
125
-			$output,
126
-			'%d tags for delete files have been removed.',
127
-			'vcategory_to_object', 'objid',
128
-			'filecache', 'fileid', 'path_hash'
129
-		);
130
-	}
131
-
132
-	/**
133
-	 * Delete tag entries for deleted tags
134
-	 */
135
-	protected function deleteOrphanTagEntries(IOutput $output) {
136
-		$this->deleteOrphanEntries(
137
-			$output,
138
-			'%d tag entries for deleted tags have been removed.',
139
-			'vcategory_to_object', 'categoryid',
140
-			'vcategory', 'id', 'uid'
141
-		);
142
-	}
143
-
144
-	/**
145
-	 * Delete tags that have no entries
146
-	 */
147
-	protected function deleteOrphanCategoryEntries(IOutput $output) {
148
-		$this->deleteOrphanEntries(
149
-			$output,
150
-			'%d tags with no entries have been removed.',
151
-			'vcategory', 'id',
152
-			'vcategory_to_object', 'categoryid', 'type'
153
-		);
154
-	}
155
-
156
-	/**
157
-	 * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
158
-	 *
159
-	 * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
160
-	 * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
161
-	 * is being deleted.
162
-	 *
163
-	 * @param string $repairInfo
164
-	 * @param string $deleteTable
165
-	 * @param string $deleteId
166
-	 * @param string $sourceTable
167
-	 * @param string $sourceId
168
-	 * @param string $sourceNullColumn	If this column is null in the source table,
169
-	 * 								the entry is deleted in the $deleteTable
170
-	 * @suppress SqlInjectionChecker
171
-	 */
172
-	protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
173
-		$qb = $this->connection->getQueryBuilder();
174
-
175
-		$qb->select('d.' . $deleteId)
176
-			->from($deleteTable, 'd')
177
-			->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
178
-			->where(
179
-				$qb->expr()->eq('d.type', $qb->expr()->literal('files'))
180
-			)
181
-			->andWhere(
182
-				$qb->expr()->isNull('s.' . $sourceNullColumn)
183
-			);
184
-		$result = $qb->execute();
185
-
186
-		$orphanItems = array();
187
-		while ($row = $result->fetch()) {
188
-			$orphanItems[] = (int) $row[$deleteId];
189
-		}
190
-
191
-		if (!empty($orphanItems)) {
192
-			$orphanItemsBatch = array_chunk($orphanItems, 200);
193
-			foreach ($orphanItemsBatch as $items) {
194
-				$qb->delete($deleteTable)
195
-					->where(
196
-						$qb->expr()->eq('type', $qb->expr()->literal('files'))
197
-					)
198
-					->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids')));
199
-				$qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
200
-				$qb->execute();
201
-			}
202
-		}
203
-
204
-		if ($repairInfo) {
205
-			$output->info(sprintf($repairInfo, count($orphanItems)));
206
-		}
207
-	}
40
+    /** @var IDBConnection */
41
+    protected $connection;
42
+
43
+    /** @var IUserManager */
44
+    protected $userManager;
45
+
46
+    protected $deletedTags = 0;
47
+
48
+    /**
49
+     * @param IDBConnection $connection
50
+     * @param IUserManager $userManager
51
+     */
52
+    public function __construct(IDBConnection $connection, IUserManager $userManager) {
53
+        $this->connection = $connection;
54
+        $this->userManager = $userManager;
55
+    }
56
+
57
+    /**
58
+     * @return string
59
+     */
60
+    public function getName() {
61
+        return 'Clean tags and favorites';
62
+    }
63
+
64
+    /**
65
+     * Updates the configuration after running an update
66
+     */
67
+    public function run(IOutput $output) {
68
+        $this->deleteOrphanTags($output);
69
+        $this->deleteOrphanFileEntries($output);
70
+        $this->deleteOrphanTagEntries($output);
71
+        $this->deleteOrphanCategoryEntries($output);
72
+    }
73
+
74
+    /**
75
+     * Delete tags for deleted users
76
+     */
77
+    protected function deleteOrphanTags(IOutput $output) {
78
+        $offset = 0;
79
+        while ($this->checkTags($offset)) {
80
+            $offset += 50;
81
+        }
82
+
83
+        $output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags));
84
+    }
85
+
86
+    protected function checkTags($offset) {
87
+        $query = $this->connection->getQueryBuilder();
88
+        $query->select('uid')
89
+            ->from('vcategory')
90
+            ->groupBy('uid')
91
+            ->orderBy('uid')
92
+            ->setMaxResults(50)
93
+            ->setFirstResult($offset);
94
+        $result = $query->execute();
95
+
96
+        $users = [];
97
+        $hadResults = false;
98
+        while ($row = $result->fetch()) {
99
+            $hadResults = true;
100
+            if (!$this->userManager->userExists($row['uid'])) {
101
+                $users[] = $row['uid'];
102
+            }
103
+        }
104
+        $result->closeCursor();
105
+
106
+        if (!$hadResults) {
107
+            // No more tags, stop looping
108
+            return false;
109
+        }
110
+
111
+        if (!empty($users)) {
112
+            $query = $this->connection->getQueryBuilder();
113
+            $query->delete('vcategory')
114
+                ->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY)));
115
+            $this->deletedTags += $query->execute();
116
+        }
117
+        return true;
118
+    }
119
+
120
+    /**
121
+     * Delete tag entries for deleted files
122
+     */
123
+    protected function deleteOrphanFileEntries(IOutput $output) {
124
+        $this->deleteOrphanEntries(
125
+            $output,
126
+            '%d tags for delete files have been removed.',
127
+            'vcategory_to_object', 'objid',
128
+            'filecache', 'fileid', 'path_hash'
129
+        );
130
+    }
131
+
132
+    /**
133
+     * Delete tag entries for deleted tags
134
+     */
135
+    protected function deleteOrphanTagEntries(IOutput $output) {
136
+        $this->deleteOrphanEntries(
137
+            $output,
138
+            '%d tag entries for deleted tags have been removed.',
139
+            'vcategory_to_object', 'categoryid',
140
+            'vcategory', 'id', 'uid'
141
+        );
142
+    }
143
+
144
+    /**
145
+     * Delete tags that have no entries
146
+     */
147
+    protected function deleteOrphanCategoryEntries(IOutput $output) {
148
+        $this->deleteOrphanEntries(
149
+            $output,
150
+            '%d tags with no entries have been removed.',
151
+            'vcategory', 'id',
152
+            'vcategory_to_object', 'categoryid', 'type'
153
+        );
154
+    }
155
+
156
+    /**
157
+     * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable
158
+     *
159
+     * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks
160
+     * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable
161
+     * is being deleted.
162
+     *
163
+     * @param string $repairInfo
164
+     * @param string $deleteTable
165
+     * @param string $deleteId
166
+     * @param string $sourceTable
167
+     * @param string $sourceId
168
+     * @param string $sourceNullColumn	If this column is null in the source table,
169
+     * 								the entry is deleted in the $deleteTable
170
+     * @suppress SqlInjectionChecker
171
+     */
172
+    protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) {
173
+        $qb = $this->connection->getQueryBuilder();
174
+
175
+        $qb->select('d.' . $deleteId)
176
+            ->from($deleteTable, 'd')
177
+            ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId))
178
+            ->where(
179
+                $qb->expr()->eq('d.type', $qb->expr()->literal('files'))
180
+            )
181
+            ->andWhere(
182
+                $qb->expr()->isNull('s.' . $sourceNullColumn)
183
+            );
184
+        $result = $qb->execute();
185
+
186
+        $orphanItems = array();
187
+        while ($row = $result->fetch()) {
188
+            $orphanItems[] = (int) $row[$deleteId];
189
+        }
190
+
191
+        if (!empty($orphanItems)) {
192
+            $orphanItemsBatch = array_chunk($orphanItems, 200);
193
+            foreach ($orphanItemsBatch as $items) {
194
+                $qb->delete($deleteTable)
195
+                    ->where(
196
+                        $qb->expr()->eq('type', $qb->expr()->literal('files'))
197
+                    )
198
+                    ->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids')));
199
+                $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY);
200
+                $qb->execute();
201
+            }
202
+        }
203
+
204
+        if ($repairInfo) {
205
+            $output->info(sprintf($repairInfo, count($orphanItems)));
206
+        }
207
+    }
208 208
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/FileSystemTags.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -33,137 +33,137 @@
 block discarded – undo
33 33
 
34 34
 class FileSystemTags implements ICheck {
35 35
 
36
-	/** @var array */
37
-	protected $fileIds;
38
-
39
-	/** @var array */
40
-	protected $fileSystemTags;
41
-
42
-	/** @var IL10N */
43
-	protected $l;
44
-
45
-	/** @var ISystemTagManager */
46
-	protected $systemTagManager;
47
-
48
-	/** @var ISystemTagObjectMapper */
49
-	protected $systemTagObjectMapper;
50
-
51
-	/** @var IStorage */
52
-	protected $storage;
53
-
54
-	/** @var string */
55
-	protected $path;
56
-
57
-	/**
58
-	 * @param IL10N $l
59
-	 * @param ISystemTagManager $systemTagManager
60
-	 * @param ISystemTagObjectMapper $systemTagObjectMapper
61
-	 */
62
-	public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) {
63
-		$this->l = $l;
64
-		$this->systemTagManager = $systemTagManager;
65
-		$this->systemTagObjectMapper = $systemTagObjectMapper;
66
-	}
67
-
68
-	/**
69
-	 * @param IStorage $storage
70
-	 * @param string $path
71
-	 */
72
-	public function setFileInfo(IStorage $storage, $path) {
73
-		$this->storage = $storage;
74
-		$this->path = $path;
75
-	}
76
-
77
-	/**
78
-	 * @param string $operator
79
-	 * @param string $value
80
-	 * @return bool
81
-	 */
82
-	public function executeCheck($operator, $value) {
83
-		$systemTags = $this->getSystemTags();
84
-		return ($operator === 'is') === in_array($value, $systemTags);
85
-	}
86
-
87
-	/**
88
-	 * @param string $operator
89
-	 * @param string $value
90
-	 * @throws \UnexpectedValueException
91
-	 */
92
-	public function validateCheck($operator, $value) {
93
-		if (!in_array($operator, ['is', '!is'])) {
94
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
95
-		}
96
-
97
-		try {
98
-			$this->systemTagManager->getTagsByIds($value);
99
-		} catch (TagNotFoundException $e) {
100
-			throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2);
101
-		} catch (\InvalidArgumentException $e) {
102
-			throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3);
103
-		}
104
-	}
105
-
106
-	/**
107
-	 * Get the ids of the assigned system tags
108
-	 * @return string[]
109
-	 */
110
-	protected function getSystemTags() {
111
-		$cache = $this->storage->getCache();
112
-		$fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class));
113
-
114
-		$systemTags = [];
115
-		foreach ($fileIds as $i => $fileId) {
116
-			if (isset($this->fileSystemTags[$fileId])) {
117
-				$systemTags[] = $this->fileSystemTags[$fileId];
118
-				unset($fileIds[$i]);
119
-			}
120
-		}
121
-
122
-		if (!empty($fileIds)) {
123
-			$mappedSystemTags = $this->systemTagObjectMapper->getTagIdsForObjects($fileIds, 'files');
124
-			foreach ($mappedSystemTags as $fileId => $fileSystemTags) {
125
-				$this->fileSystemTags[$fileId] = $fileSystemTags;
126
-				$systemTags[] = $fileSystemTags;
127
-			}
128
-		}
129
-
130
-		$systemTags = call_user_func_array('array_merge', $systemTags);
131
-		$systemTags = array_unique($systemTags);
132
-		return $systemTags;
133
-	}
134
-
135
-	/**
136
-	 * Get the file ids of the given path and its parents
137
-	 * @param ICache $cache
138
-	 * @param string $path
139
-	 * @param bool $isExternalStorage
140
-	 * @return int[]
141
-	 */
142
-	protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
143
-		$cacheId = $cache->getNumericStorageId();
144
-		if (isset($this->fileIds[$cacheId][$path])) {
145
-			return $this->fileIds[$cacheId][$path];
146
-		}
147
-
148
-		$parentIds = [];
149
-		if ($path !== $this->dirname($path)) {
150
-			$parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage);
151
-		} else if (!$isExternalStorage) {
152
-			return [];
153
-		}
154
-
155
-		$fileId = $cache->getId($path);
156
-		if ($fileId !== -1) {
157
-			$parentIds[] = $cache->getId($path);
158
-		}
159
-
160
-		$this->fileIds[$cacheId][$path] = $parentIds;
161
-
162
-		return $parentIds;
163
-	}
164
-
165
-	protected function dirname($path) {
166
-		$dir = dirname($path);
167
-		return $dir === '.' ? '' : $dir;
168
-	}
36
+    /** @var array */
37
+    protected $fileIds;
38
+
39
+    /** @var array */
40
+    protected $fileSystemTags;
41
+
42
+    /** @var IL10N */
43
+    protected $l;
44
+
45
+    /** @var ISystemTagManager */
46
+    protected $systemTagManager;
47
+
48
+    /** @var ISystemTagObjectMapper */
49
+    protected $systemTagObjectMapper;
50
+
51
+    /** @var IStorage */
52
+    protected $storage;
53
+
54
+    /** @var string */
55
+    protected $path;
56
+
57
+    /**
58
+     * @param IL10N $l
59
+     * @param ISystemTagManager $systemTagManager
60
+     * @param ISystemTagObjectMapper $systemTagObjectMapper
61
+     */
62
+    public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) {
63
+        $this->l = $l;
64
+        $this->systemTagManager = $systemTagManager;
65
+        $this->systemTagObjectMapper = $systemTagObjectMapper;
66
+    }
67
+
68
+    /**
69
+     * @param IStorage $storage
70
+     * @param string $path
71
+     */
72
+    public function setFileInfo(IStorage $storage, $path) {
73
+        $this->storage = $storage;
74
+        $this->path = $path;
75
+    }
76
+
77
+    /**
78
+     * @param string $operator
79
+     * @param string $value
80
+     * @return bool
81
+     */
82
+    public function executeCheck($operator, $value) {
83
+        $systemTags = $this->getSystemTags();
84
+        return ($operator === 'is') === in_array($value, $systemTags);
85
+    }
86
+
87
+    /**
88
+     * @param string $operator
89
+     * @param string $value
90
+     * @throws \UnexpectedValueException
91
+     */
92
+    public function validateCheck($operator, $value) {
93
+        if (!in_array($operator, ['is', '!is'])) {
94
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
95
+        }
96
+
97
+        try {
98
+            $this->systemTagManager->getTagsByIds($value);
99
+        } catch (TagNotFoundException $e) {
100
+            throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2);
101
+        } catch (\InvalidArgumentException $e) {
102
+            throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 3);
103
+        }
104
+    }
105
+
106
+    /**
107
+     * Get the ids of the assigned system tags
108
+     * @return string[]
109
+     */
110
+    protected function getSystemTags() {
111
+        $cache = $this->storage->getCache();
112
+        $fileIds = $this->getFileIds($cache, $this->path, !$this->storage->instanceOfStorage(IHomeStorage::class));
113
+
114
+        $systemTags = [];
115
+        foreach ($fileIds as $i => $fileId) {
116
+            if (isset($this->fileSystemTags[$fileId])) {
117
+                $systemTags[] = $this->fileSystemTags[$fileId];
118
+                unset($fileIds[$i]);
119
+            }
120
+        }
121
+
122
+        if (!empty($fileIds)) {
123
+            $mappedSystemTags = $this->systemTagObjectMapper->getTagIdsForObjects($fileIds, 'files');
124
+            foreach ($mappedSystemTags as $fileId => $fileSystemTags) {
125
+                $this->fileSystemTags[$fileId] = $fileSystemTags;
126
+                $systemTags[] = $fileSystemTags;
127
+            }
128
+        }
129
+
130
+        $systemTags = call_user_func_array('array_merge', $systemTags);
131
+        $systemTags = array_unique($systemTags);
132
+        return $systemTags;
133
+    }
134
+
135
+    /**
136
+     * Get the file ids of the given path and its parents
137
+     * @param ICache $cache
138
+     * @param string $path
139
+     * @param bool $isExternalStorage
140
+     * @return int[]
141
+     */
142
+    protected function getFileIds(ICache $cache, $path, $isExternalStorage) {
143
+        $cacheId = $cache->getNumericStorageId();
144
+        if (isset($this->fileIds[$cacheId][$path])) {
145
+            return $this->fileIds[$cacheId][$path];
146
+        }
147
+
148
+        $parentIds = [];
149
+        if ($path !== $this->dirname($path)) {
150
+            $parentIds = $this->getFileIds($cache, $this->dirname($path), $isExternalStorage);
151
+        } else if (!$isExternalStorage) {
152
+            return [];
153
+        }
154
+
155
+        $fileId = $cache->getId($path);
156
+        if ($fileId !== -1) {
157
+            $parentIds[] = $cache->getId($path);
158
+        }
159
+
160
+        $this->fileIds[$cacheId][$path] = $parentIds;
161
+
162
+        return $parentIds;
163
+    }
164
+
165
+    protected function dirname($path) {
166
+        $dir = dirname($path);
167
+        return $dir === '.' ? '' : $dir;
168
+    }
169 169
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/ActionProviderStore.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -35,80 +35,80 @@
 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
 
114 114
 }
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.
apps/user_ldap/lib/Controller/RenewPasswordController.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @return TemplateResponse|RedirectResponse
86 86
 	 */
87 87
 	public function showRenewPasswordForm($user) {
88
-		if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
88
+		if ($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
89 89
 			return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
90 90
 		}
91 91
 		$parameters = [];
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return RedirectResponse
130 130
 	 */
131 131
 	public function tryRenewPassword($user, $oldPassword, $newPassword) {
132
-		if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
132
+		if ($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
133 133
 			return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
134 134
 		}
135 135
 		$args = !is_null($user) ? ['user' => $user] : [];
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -37,144 +37,144 @@
 block discarded – undo
37 37
 use OCP\IUserManager;
38 38
 
39 39
 class RenewPasswordController extends Controller {
40
-	/** @var IUserManager */
41
-	private $userManager;
42
-	/** @var IConfig */
43
-	private $config;
44
-	/** @var IL10N */
45
-	protected $l10n;
46
-	/** @var ISession */
47
-	private $session;
48
-	/** @var IURLGenerator */
49
-	private $urlGenerator;
40
+    /** @var IUserManager */
41
+    private $userManager;
42
+    /** @var IConfig */
43
+    private $config;
44
+    /** @var IL10N */
45
+    protected $l10n;
46
+    /** @var ISession */
47
+    private $session;
48
+    /** @var IURLGenerator */
49
+    private $urlGenerator;
50 50
 
51
-	/**
52
-	 * @param string $appName
53
-	 * @param IRequest $request
54
-	 * @param IUserManager $userManager
55
-	 * @param IConfig $config
56
-	 * @param IURLGenerator $urlGenerator
57
-	 */
58
-	function __construct($appName, IRequest $request, IUserManager $userManager, 
59
-		IConfig $config, IL10N $l10n, ISession $session, IURLGenerator $urlGenerator) {
60
-		parent::__construct($appName, $request);
61
-		$this->userManager = $userManager;
62
-		$this->config = $config;
63
-		$this->l10n = $l10n;
64
-		$this->session = $session;
65
-		$this->urlGenerator = $urlGenerator;
66
-	}
51
+    /**
52
+     * @param string $appName
53
+     * @param IRequest $request
54
+     * @param IUserManager $userManager
55
+     * @param IConfig $config
56
+     * @param IURLGenerator $urlGenerator
57
+     */
58
+    function __construct($appName, IRequest $request, IUserManager $userManager, 
59
+        IConfig $config, IL10N $l10n, ISession $session, IURLGenerator $urlGenerator) {
60
+        parent::__construct($appName, $request);
61
+        $this->userManager = $userManager;
62
+        $this->config = $config;
63
+        $this->l10n = $l10n;
64
+        $this->session = $session;
65
+        $this->urlGenerator = $urlGenerator;
66
+    }
67 67
 
68
-	/**
69
-	 * @PublicPage
70
-	 * @NoCSRFRequired
71
-	 *
72
-	 * @return RedirectResponse
73
-	 */
74
-	public function cancel() {
75
-		return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
76
-	}
68
+    /**
69
+     * @PublicPage
70
+     * @NoCSRFRequired
71
+     *
72
+     * @return RedirectResponse
73
+     */
74
+    public function cancel() {
75
+        return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
76
+    }
77 77
 
78
-	/**
79
-	 * @PublicPage
80
-	 * @NoCSRFRequired
81
-	 * @UseSession
82
-	 *
83
-	 * @param string $user
84
-	 *
85
-	 * @return TemplateResponse|RedirectResponse
86
-	 */
87
-	public function showRenewPasswordForm($user) {
88
-		if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
89
-			return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
90
-		}
91
-		$parameters = [];
92
-		$renewPasswordMessages = $this->session->get('renewPasswordMessages');
93
-		$errors = [];
94
-		$messages = [];
95
-		if (is_array($renewPasswordMessages)) {
96
-			list($errors, $messages) = $renewPasswordMessages;
97
-		}
98
-		$this->session->remove('renewPasswordMessages');
99
-		foreach ($errors as $value) {
100
-			$parameters[$value] = true;
101
-		}
78
+    /**
79
+     * @PublicPage
80
+     * @NoCSRFRequired
81
+     * @UseSession
82
+     *
83
+     * @param string $user
84
+     *
85
+     * @return TemplateResponse|RedirectResponse
86
+     */
87
+    public function showRenewPasswordForm($user) {
88
+        if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
89
+            return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
90
+        }
91
+        $parameters = [];
92
+        $renewPasswordMessages = $this->session->get('renewPasswordMessages');
93
+        $errors = [];
94
+        $messages = [];
95
+        if (is_array($renewPasswordMessages)) {
96
+            list($errors, $messages) = $renewPasswordMessages;
97
+        }
98
+        $this->session->remove('renewPasswordMessages');
99
+        foreach ($errors as $value) {
100
+            $parameters[$value] = true;
101
+        }
102 102
 
103
-		$parameters['messages'] = $messages;
104
-		$parameters['user'] = $user;
103
+        $parameters['messages'] = $messages;
104
+        $parameters['user'] = $user;
105 105
 
106
-		$parameters['canResetPassword'] = true;
107
-		$parameters['resetPasswordLink'] = $this->config->getSystemValue('lost_password_link', '');
108
-		if (!$parameters['resetPasswordLink']) {
109
-			$userObj = $this->userManager->get($user);
110
-			if ($userObj instanceof IUser) {
111
-				$parameters['canResetPassword'] = $userObj->canChangePassword();
112
-			}
113
-		}
114
-		$parameters['cancelLink'] = $this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm');
106
+        $parameters['canResetPassword'] = true;
107
+        $parameters['resetPasswordLink'] = $this->config->getSystemValue('lost_password_link', '');
108
+        if (!$parameters['resetPasswordLink']) {
109
+            $userObj = $this->userManager->get($user);
110
+            if ($userObj instanceof IUser) {
111
+                $parameters['canResetPassword'] = $userObj->canChangePassword();
112
+            }
113
+        }
114
+        $parameters['cancelLink'] = $this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm');
115 115
 
116
-		return new TemplateResponse(
117
-			$this->appName, 'renewpassword', $parameters, 'guest'
118
-		);
119
-	}
116
+        return new TemplateResponse(
117
+            $this->appName, 'renewpassword', $parameters, 'guest'
118
+        );
119
+    }
120 120
 
121
-	/**
122
-	 * @PublicPage
123
-	 * @UseSession
124
-	 *
125
-	 * @param string $user
126
-	 * @param string $oldPassword
127
-	 * @param string $newPassword
128
-	 *
129
-	 * @return RedirectResponse
130
-	 */
131
-	public function tryRenewPassword($user, $oldPassword, $newPassword) {
132
-		if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
133
-			return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
134
-		}
135
-		$args = !is_null($user) ? ['user' => $user] : [];
136
-		$loginResult = $this->userManager->checkPassword($user, $oldPassword);
137
-		if ($loginResult === false) {
138
-			$this->session->set('renewPasswordMessages', [
139
-				['invalidpassword'], []
140
-			]);
141
-			return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
142
-		}
121
+    /**
122
+     * @PublicPage
123
+     * @UseSession
124
+     *
125
+     * @param string $user
126
+     * @param string $oldPassword
127
+     * @param string $newPassword
128
+     *
129
+     * @return RedirectResponse
130
+     */
131
+    public function tryRenewPassword($user, $oldPassword, $newPassword) {
132
+        if($this->config->getUserValue($user, 'user_ldap', 'needsPasswordReset') !== 'true') {
133
+            return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
134
+        }
135
+        $args = !is_null($user) ? ['user' => $user] : [];
136
+        $loginResult = $this->userManager->checkPassword($user, $oldPassword);
137
+        if ($loginResult === false) {
138
+            $this->session->set('renewPasswordMessages', [
139
+                ['invalidpassword'], []
140
+            ]);
141
+            return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
142
+        }
143 143
 		
144
-		try {
145
-			if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
146
-				$this->session->set('loginMessages', [
147
-					[], [$this->l10n->t("Please login with the new password")]
148
-				]);
149
-				$this->config->setUserValue($user, 'user_ldap', 'needsPasswordReset', 'false');
150
-				return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
151
-			} else {
152
-				$this->session->set('renewPasswordMessages', [
153
-					['internalexception'], []
154
-				]);
155
-			}
156
-		} catch (HintException $e) {
157
-			$this->session->set('renewPasswordMessages', [
158
-				[], [$e->getHint()]
159
-			]);
160
-		}
144
+        try {
145
+            if (!is_null($newPassword) && \OC_User::setPassword($user, $newPassword)) {
146
+                $this->session->set('loginMessages', [
147
+                    [], [$this->l10n->t("Please login with the new password")]
148
+                ]);
149
+                $this->config->setUserValue($user, 'user_ldap', 'needsPasswordReset', 'false');
150
+                return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
151
+            } else {
152
+                $this->session->set('renewPasswordMessages', [
153
+                    ['internalexception'], []
154
+                ]);
155
+            }
156
+        } catch (HintException $e) {
157
+            $this->session->set('renewPasswordMessages', [
158
+                [], [$e->getHint()]
159
+            ]);
160
+        }
161 161
 
162
-		return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
163
-	}
162
+        return new RedirectResponse($this->urlGenerator->linkToRoute('user_ldap.renewPassword.showRenewPasswordForm', $args));
163
+    }
164 164
 
165
-	/**
166
-	 * @PublicPage
167
-	 * @NoCSRFRequired
168
-	 * @UseSession
169
-	 *
170
-	 * @return RedirectResponse
171
-	 */
172
-	public function showLoginFormInvalidPassword($user) {
173
-		$args = !is_null($user) ? ['user' => $user] : [];
174
-		$this->session->set('loginMessages', [
175
-			['invalidpassword'], []
176
-		]);
177
-		return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
178
-	}
165
+    /**
166
+     * @PublicPage
167
+     * @NoCSRFRequired
168
+     * @UseSession
169
+     *
170
+     * @return RedirectResponse
171
+     */
172
+    public function showLoginFormInvalidPassword($user) {
173
+        $args = !is_null($user) ? ['user' => $user] : [];
174
+        $this->session->set('loginMessages', [
175
+            ['invalidpassword'], []
176
+        ]);
177
+        return new RedirectResponse($this->urlGenerator->linkToRoute('core.login.showLoginForm', $args));
178
+    }
179 179
 
180 180
 }
Please login to merge, or discard this patch.
settings/Mailer/NewUserMailHelper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -102,13 +102,13 @@
 block discarded – undo
102 102
 		if ($generatePasswordResetToken) {
103 103
 			$token = $this->secureRandom->generate(
104 104
 				21,
105
-				ISecureRandom::CHAR_DIGITS .
106
-				ISecureRandom::CHAR_LOWER .
105
+				ISecureRandom::CHAR_DIGITS.
106
+				ISecureRandom::CHAR_LOWER.
107 107
 				ISecureRandom::CHAR_UPPER
108 108
 			);
109
-			$tokenValue = $this->timeFactory->getTime() . ':' . $token;
109
+			$tokenValue = $this->timeFactory->getTime().':'.$token;
110 110
 			$mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : '';
111
-			$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret'));
111
+			$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress.$this->config->getSystemValue('secret'));
112 112
 			$this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
113 113
 			$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]);
114 114
 		} else {
Please login to merge, or discard this patch.
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -39,133 +39,133 @@
 block discarded – undo
39 39
 use OCP\Security\ISecureRandom;
40 40
 
41 41
 class NewUserMailHelper {
42
-	/** @var Defaults */
43
-	private $themingDefaults;
44
-	/** @var IURLGenerator */
45
-	private $urlGenerator;
46
-	/** @var IFactory */
47
-	private $l10nFactory;
48
-	/** @var IMailer */
49
-	private $mailer;
50
-	/** @var ISecureRandom */
51
-	private $secureRandom;
52
-	/** @var ITimeFactory */
53
-	private $timeFactory;
54
-	/** @var IConfig */
55
-	private $config;
56
-	/** @var ICrypto */
57
-	private $crypto;
58
-	/** @var string */
59
-	private $fromAddress;
42
+    /** @var Defaults */
43
+    private $themingDefaults;
44
+    /** @var IURLGenerator */
45
+    private $urlGenerator;
46
+    /** @var IFactory */
47
+    private $l10nFactory;
48
+    /** @var IMailer */
49
+    private $mailer;
50
+    /** @var ISecureRandom */
51
+    private $secureRandom;
52
+    /** @var ITimeFactory */
53
+    private $timeFactory;
54
+    /** @var IConfig */
55
+    private $config;
56
+    /** @var ICrypto */
57
+    private $crypto;
58
+    /** @var string */
59
+    private $fromAddress;
60 60
 
61
-	/**
62
-	 * @param Defaults $themingDefaults
63
-	 * @param IURLGenerator $urlGenerator
64
-	 * @param IFactory $l10nFactory
65
-	 * @param IMailer $mailer
66
-	 * @param ISecureRandom $secureRandom
67
-	 * @param ITimeFactory $timeFactory
68
-	 * @param IConfig $config
69
-	 * @param ICrypto $crypto
70
-	 * @param string $fromAddress
71
-	 */
72
-	public function __construct(Defaults $themingDefaults,
73
-								IURLGenerator $urlGenerator,
74
-								IFactory $l10nFactory,
75
-								IMailer $mailer,
76
-								ISecureRandom $secureRandom,
77
-								ITimeFactory $timeFactory,
78
-								IConfig $config,
79
-								ICrypto $crypto,
80
-								$fromAddress) {
81
-		$this->themingDefaults = $themingDefaults;
82
-		$this->urlGenerator = $urlGenerator;
83
-		$this->l10nFactory = $l10nFactory;
84
-		$this->mailer = $mailer;
85
-		$this->secureRandom = $secureRandom;
86
-		$this->timeFactory = $timeFactory;
87
-		$this->config = $config;
88
-		$this->crypto = $crypto;
89
-		$this->fromAddress = $fromAddress;
90
-	}
61
+    /**
62
+     * @param Defaults $themingDefaults
63
+     * @param IURLGenerator $urlGenerator
64
+     * @param IFactory $l10nFactory
65
+     * @param IMailer $mailer
66
+     * @param ISecureRandom $secureRandom
67
+     * @param ITimeFactory $timeFactory
68
+     * @param IConfig $config
69
+     * @param ICrypto $crypto
70
+     * @param string $fromAddress
71
+     */
72
+    public function __construct(Defaults $themingDefaults,
73
+                                IURLGenerator $urlGenerator,
74
+                                IFactory $l10nFactory,
75
+                                IMailer $mailer,
76
+                                ISecureRandom $secureRandom,
77
+                                ITimeFactory $timeFactory,
78
+                                IConfig $config,
79
+                                ICrypto $crypto,
80
+                                $fromAddress) {
81
+        $this->themingDefaults = $themingDefaults;
82
+        $this->urlGenerator = $urlGenerator;
83
+        $this->l10nFactory = $l10nFactory;
84
+        $this->mailer = $mailer;
85
+        $this->secureRandom = $secureRandom;
86
+        $this->timeFactory = $timeFactory;
87
+        $this->config = $config;
88
+        $this->crypto = $crypto;
89
+        $this->fromAddress = $fromAddress;
90
+    }
91 91
 
92
-	/**
93
-	 * @param IUser $user
94
-	 * @param bool $generatePasswordResetToken
95
-	 * @return IEMailTemplate
96
-	 */
97
-	public function generateTemplate(IUser $user, $generatePasswordResetToken = false) {
98
-		$userId = $user->getUID();
99
-		$lang = $this->config->getUserValue($userId, 'core', 'lang', 'en');
100
-		if (!$this->l10nFactory->languageExists('settings', $lang)) {
101
-			$lang = 'en';
102
-		}
92
+    /**
93
+     * @param IUser $user
94
+     * @param bool $generatePasswordResetToken
95
+     * @return IEMailTemplate
96
+     */
97
+    public function generateTemplate(IUser $user, $generatePasswordResetToken = false) {
98
+        $userId = $user->getUID();
99
+        $lang = $this->config->getUserValue($userId, 'core', 'lang', 'en');
100
+        if (!$this->l10nFactory->languageExists('settings', $lang)) {
101
+            $lang = 'en';
102
+        }
103 103
 
104
-		$l10n = $this->l10nFactory->get('settings', $lang);
104
+        $l10n = $this->l10nFactory->get('settings', $lang);
105 105
 
106
-		if ($generatePasswordResetToken) {
107
-			$token = $this->secureRandom->generate(
108
-				21,
109
-				ISecureRandom::CHAR_DIGITS .
110
-				ISecureRandom::CHAR_LOWER .
111
-				ISecureRandom::CHAR_UPPER
112
-			);
113
-			$tokenValue = $this->timeFactory->getTime() . ':' . $token;
114
-			$mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : '';
115
-			$encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret'));
116
-			$this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
117
-			$link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]);
118
-		} else {
119
-			$link = $this->urlGenerator->getAbsoluteURL('/');
120
-		}
121
-		$displayName = $user->getDisplayName();
106
+        if ($generatePasswordResetToken) {
107
+            $token = $this->secureRandom->generate(
108
+                21,
109
+                ISecureRandom::CHAR_DIGITS .
110
+                ISecureRandom::CHAR_LOWER .
111
+                ISecureRandom::CHAR_UPPER
112
+            );
113
+            $tokenValue = $this->timeFactory->getTime() . ':' . $token;
114
+            $mailAddress = (null !== $user->getEMailAddress()) ? $user->getEMailAddress() : '';
115
+            $encryptedValue = $this->crypto->encrypt($tokenValue, $mailAddress . $this->config->getSystemValue('secret'));
116
+            $this->config->setUserValue($user->getUID(), 'core', 'lostpassword', $encryptedValue);
117
+            $link = $this->urlGenerator->linkToRouteAbsolute('core.lost.resetform', ['userId' => $user->getUID(), 'token' => $token]);
118
+        } else {
119
+            $link = $this->urlGenerator->getAbsoluteURL('/');
120
+        }
121
+        $displayName = $user->getDisplayName();
122 122
 
123
-		$emailTemplate = $this->mailer->createEMailTemplate('settings.Welcome', [
124
-			'link' => $link,
125
-			'displayname' => $displayName,
126
-			'userid' => $userId,
127
-			'instancename' => $this->themingDefaults->getName(),
128
-			'resetTokenGenerated' => $generatePasswordResetToken,
129
-		]);
123
+        $emailTemplate = $this->mailer->createEMailTemplate('settings.Welcome', [
124
+            'link' => $link,
125
+            'displayname' => $displayName,
126
+            'userid' => $userId,
127
+            'instancename' => $this->themingDefaults->getName(),
128
+            'resetTokenGenerated' => $generatePasswordResetToken,
129
+        ]);
130 130
 
131
-		$emailTemplate->setSubject($l10n->t('Your %s account was created', [$this->themingDefaults->getName()]));
132
-		$emailTemplate->addHeader();
133
-		if ($displayName === $userId) {
134
-			$emailTemplate->addHeading($l10n->t('Welcome aboard'));
135
-		} else {
136
-			$emailTemplate->addHeading($l10n->t('Welcome aboard %s', [$displayName]));
137
-		}
138
-		$emailTemplate->addBodyText($l10n->t('Welcome to your %s account, you can add, protect, and share your data.', [$this->themingDefaults->getName()]));
139
-		$emailTemplate->addBodyText($l10n->t('Your username is: %s', [$userId]));
140
-		if ($generatePasswordResetToken) {
141
-			$leftButtonText = $l10n->t('Set your password');
142
-		} else {
143
-			$leftButtonText = $l10n->t('Go to %s', [$this->themingDefaults->getName()]);
144
-		}
145
-		$emailTemplate->addBodyButtonGroup(
146
-			$leftButtonText,
147
-			$link,
148
-			$l10n->t('Install Client'),
149
-			'https://nextcloud.com/install/#install-clients'
150
-		);
151
-		$emailTemplate->addFooter();
131
+        $emailTemplate->setSubject($l10n->t('Your %s account was created', [$this->themingDefaults->getName()]));
132
+        $emailTemplate->addHeader();
133
+        if ($displayName === $userId) {
134
+            $emailTemplate->addHeading($l10n->t('Welcome aboard'));
135
+        } else {
136
+            $emailTemplate->addHeading($l10n->t('Welcome aboard %s', [$displayName]));
137
+        }
138
+        $emailTemplate->addBodyText($l10n->t('Welcome to your %s account, you can add, protect, and share your data.', [$this->themingDefaults->getName()]));
139
+        $emailTemplate->addBodyText($l10n->t('Your username is: %s', [$userId]));
140
+        if ($generatePasswordResetToken) {
141
+            $leftButtonText = $l10n->t('Set your password');
142
+        } else {
143
+            $leftButtonText = $l10n->t('Go to %s', [$this->themingDefaults->getName()]);
144
+        }
145
+        $emailTemplate->addBodyButtonGroup(
146
+            $leftButtonText,
147
+            $link,
148
+            $l10n->t('Install Client'),
149
+            'https://nextcloud.com/install/#install-clients'
150
+        );
151
+        $emailTemplate->addFooter();
152 152
 
153
-		return $emailTemplate;
154
-	}
153
+        return $emailTemplate;
154
+    }
155 155
 
156
-	/**
157
-	 * Sends a welcome mail to $user
158
-	 *
159
-	 * @param IUser $user
160
-	 * @param IEmailTemplate $emailTemplate
161
-	 * @throws \Exception If mail could not be sent
162
-	 */
163
-	public function sendMail(IUser $user,
164
-							 IEMailTemplate $emailTemplate) {
165
-		$message = $this->mailer->createMessage();
166
-		$message->setTo([$user->getEMailAddress() => $user->getDisplayName()]);
167
-		$message->setFrom([$this->fromAddress => $this->themingDefaults->getName()]);
168
-		$message->useTemplate($emailTemplate);
169
-		$this->mailer->send($message);
170
-	}
156
+    /**
157
+     * Sends a welcome mail to $user
158
+     *
159
+     * @param IUser $user
160
+     * @param IEmailTemplate $emailTemplate
161
+     * @throws \Exception If mail could not be sent
162
+     */
163
+    public function sendMail(IUser $user,
164
+                                IEMailTemplate $emailTemplate) {
165
+        $message = $this->mailer->createMessage();
166
+        $message->setTo([$user->getEMailAddress() => $user->getDisplayName()]);
167
+        $message->setFrom([$this->fromAddress => $this->themingDefaults->getName()]);
168
+        $message->useTemplate($emailTemplate);
169
+        $this->mailer->send($message);
170
+    }
171 171
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/PublicCalendarObject.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
 
24 24
 class PublicCalendarObject extends CalendarObject {
25 25
 
26
-	/**
27
-	 * public calendars are always shared
28
-	 * @return bool
29
-	 */
30
-	protected function isShared() {
31
-		return true;
32
-	}
26
+    /**
27
+     * public calendars are always shared
28
+     * @return bool
29
+     */
30
+    protected function isShared() {
31
+        return true;
32
+    }
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/PublicCalendar.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -25,63 +25,63 @@
 block discarded – undo
25 25
 
26 26
 class PublicCalendar extends Calendar {
27 27
 
28
-	/**
29
-	 * @param string $name
30
-	 * @throws NotFound
31
-	 * @return PublicCalendarObject
32
-	 */
33
-	public function getChild($name) {
34
-		$obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
28
+    /**
29
+     * @param string $name
30
+     * @throws NotFound
31
+     * @return PublicCalendarObject
32
+     */
33
+    public function getChild($name) {
34
+        $obj = $this->caldavBackend->getCalendarObject($this->calendarInfo['id'], $name);
35 35
 
36
-		if (!$obj) {
37
-			throw new NotFound('Calendar object not found');
38
-		}
39
-		if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
40
-			throw new NotFound('Calendar object not found');
41
-		}
42
-		$obj['acl'] = $this->getChildACL();
36
+        if (!$obj) {
37
+            throw new NotFound('Calendar object not found');
38
+        }
39
+        if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
40
+            throw new NotFound('Calendar object not found');
41
+        }
42
+        $obj['acl'] = $this->getChildACL();
43 43
 
44
-		return new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
45
-	}
44
+        return new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
45
+    }
46 46
 
47
-	/**
48
-	 * @return PublicCalendarObject[]
49
-	 */
50
-	public function getChildren() {
51
-		$objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
52
-		$children = [];
53
-		foreach ($objs as $obj) {
54
-			if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
55
-				continue;
56
-			}
57
-			$obj['acl'] = $this->getChildACL();
58
-			$children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
59
-		}
60
-		return $children;
61
-	}
47
+    /**
48
+     * @return PublicCalendarObject[]
49
+     */
50
+    public function getChildren() {
51
+        $objs = $this->caldavBackend->getCalendarObjects($this->calendarInfo['id']);
52
+        $children = [];
53
+        foreach ($objs as $obj) {
54
+            if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
55
+                continue;
56
+            }
57
+            $obj['acl'] = $this->getChildACL();
58
+            $children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
59
+        }
60
+        return $children;
61
+    }
62 62
 
63
-	/**
64
-	 * @param string[] $paths
65
-	 * @return PublicCalendarObject[]
66
-	 */
67
-	public function getMultipleChildren(array $paths) {
68
-		$objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
69
-		$children = [];
70
-		foreach ($objs as $obj) {
71
-			if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
72
-				continue;
73
-			}
74
-			$obj['acl'] = $this->getChildACL();
75
-			$children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
76
-		}
77
-		return $children;
78
-	}
63
+    /**
64
+     * @param string[] $paths
65
+     * @return PublicCalendarObject[]
66
+     */
67
+    public function getMultipleChildren(array $paths) {
68
+        $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
69
+        $children = [];
70
+        foreach ($objs as $obj) {
71
+            if ($obj['classification'] === CalDavBackend::CLASSIFICATION_PRIVATE) {
72
+                continue;
73
+            }
74
+            $obj['acl'] = $this->getChildACL();
75
+            $children[] = new PublicCalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
76
+        }
77
+        return $children;
78
+    }
79 79
 
80
-	/**
81
-	 * public calendars are always shared
82
-	 * @return bool
83
-	 */
84
-	protected function isShared() {
85
-		return true;
86
-	}
80
+    /**
81
+     * public calendars are always shared
82
+     * @return bool
83
+     */
84
+    protected function isShared() {
85
+        return true;
86
+    }
87 87
 }
88 88
\ No newline at end of file
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.