@@ -33,19 +33,19 @@ |
||
33 | 33 | * @template-extends QBMapper<ProfileConfig> |
34 | 34 | */ |
35 | 35 | class ProfileConfigMapper extends QBMapper { |
36 | - public function __construct(IDBConnection $db) { |
|
37 | - parent::__construct($db, 'profile_config', ProfileConfig::class); |
|
38 | - } |
|
36 | + public function __construct(IDBConnection $db) { |
|
37 | + parent::__construct($db, 'profile_config', ProfileConfig::class); |
|
38 | + } |
|
39 | 39 | |
40 | - public function get(string $userId): ProfileConfig { |
|
41 | - $qb = $this->db->getQueryBuilder(); |
|
42 | - $qb->select('*') |
|
43 | - ->from($this->getTableName()) |
|
44 | - ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); |
|
45 | - return $this->findEntity($qb); |
|
46 | - } |
|
40 | + public function get(string $userId): ProfileConfig { |
|
41 | + $qb = $this->db->getQueryBuilder(); |
|
42 | + $qb->select('*') |
|
43 | + ->from($this->getTableName()) |
|
44 | + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); |
|
45 | + return $this->findEntity($qb); |
|
46 | + } |
|
47 | 47 | |
48 | - public function getArray(string $userId): array { |
|
49 | - return $this->get($userId)->getConfigArray(); |
|
50 | - } |
|
48 | + public function getArray(string $userId): array { |
|
49 | + return $this->get($userId)->getConfigArray(); |
|
50 | + } |
|
51 | 51 | } |
@@ -36,93 +36,93 @@ |
||
36 | 36 | * @template-extends QBMapper<AuthorizedGroup> |
37 | 37 | */ |
38 | 38 | class AuthorizedGroupMapper extends QBMapper { |
39 | - public function __construct(IDBConnection $db) { |
|
40 | - parent::__construct($db, 'authorized_groups', AuthorizedGroup::class); |
|
41 | - } |
|
39 | + public function __construct(IDBConnection $db) { |
|
40 | + parent::__construct($db, 'authorized_groups', AuthorizedGroup::class); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @throws Exception |
|
45 | - */ |
|
46 | - public function findAllClassesForUser(IUser $user): array { |
|
47 | - $qb = $this->db->getQueryBuilder(); |
|
43 | + /** |
|
44 | + * @throws Exception |
|
45 | + */ |
|
46 | + public function findAllClassesForUser(IUser $user): array { |
|
47 | + $qb = $this->db->getQueryBuilder(); |
|
48 | 48 | |
49 | - /** @var IGroupManager $groupManager */ |
|
50 | - $groupManager = \OC::$server->get(IGroupManager::class); |
|
51 | - $groups = $groupManager->getUserGroups($user); |
|
52 | - if (count($groups) === 0) { |
|
53 | - return []; |
|
54 | - } |
|
49 | + /** @var IGroupManager $groupManager */ |
|
50 | + $groupManager = \OC::$server->get(IGroupManager::class); |
|
51 | + $groups = $groupManager->getUserGroups($user); |
|
52 | + if (count($groups) === 0) { |
|
53 | + return []; |
|
54 | + } |
|
55 | 55 | |
56 | - $result = $qb->select('class') |
|
57 | - ->from($this->getTableName(), 'auth') |
|
58 | - ->where($qb->expr()->in('group_id', array_map(function (IGroup $group) use ($qb) { |
|
59 | - return $qb->createNamedParameter($group->getGID()); |
|
60 | - }, $groups), IQueryBuilder::PARAM_STR)) |
|
61 | - ->executeQuery(); |
|
56 | + $result = $qb->select('class') |
|
57 | + ->from($this->getTableName(), 'auth') |
|
58 | + ->where($qb->expr()->in('group_id', array_map(function (IGroup $group) use ($qb) { |
|
59 | + return $qb->createNamedParameter($group->getGID()); |
|
60 | + }, $groups), IQueryBuilder::PARAM_STR)) |
|
61 | + ->executeQuery(); |
|
62 | 62 | |
63 | - $classes = []; |
|
64 | - while ($row = $result->fetch()) { |
|
65 | - $classes[] = $row['class']; |
|
66 | - } |
|
67 | - $result->closeCursor(); |
|
68 | - return $classes; |
|
69 | - } |
|
63 | + $classes = []; |
|
64 | + while ($row = $result->fetch()) { |
|
65 | + $classes[] = $row['class']; |
|
66 | + } |
|
67 | + $result->closeCursor(); |
|
68 | + return $classes; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @throws \OCP\AppFramework\Db\DoesNotExistException |
|
73 | - * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
74 | - * @throws \OCP\DB\Exception |
|
75 | - */ |
|
76 | - public function find(int $id): AuthorizedGroup { |
|
77 | - $queryBuilder = $this->db->getQueryBuilder(); |
|
78 | - $queryBuilder->select('*') |
|
79 | - ->from($this->getTableName()) |
|
80 | - ->where($queryBuilder->expr()->eq('id', $queryBuilder->createNamedParameter($id))); |
|
81 | - /** @var AuthorizedGroup $authorizedGroup */ |
|
82 | - $authorizedGroup = $this->findEntity($queryBuilder); |
|
83 | - return $authorizedGroup; |
|
84 | - } |
|
71 | + /** |
|
72 | + * @throws \OCP\AppFramework\Db\DoesNotExistException |
|
73 | + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException |
|
74 | + * @throws \OCP\DB\Exception |
|
75 | + */ |
|
76 | + public function find(int $id): AuthorizedGroup { |
|
77 | + $queryBuilder = $this->db->getQueryBuilder(); |
|
78 | + $queryBuilder->select('*') |
|
79 | + ->from($this->getTableName()) |
|
80 | + ->where($queryBuilder->expr()->eq('id', $queryBuilder->createNamedParameter($id))); |
|
81 | + /** @var AuthorizedGroup $authorizedGroup */ |
|
82 | + $authorizedGroup = $this->findEntity($queryBuilder); |
|
83 | + return $authorizedGroup; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get all the authorizations stored in the database. |
|
88 | - * |
|
89 | - * @return AuthorizedGroup[] |
|
90 | - * @throws \OCP\DB\Exception |
|
91 | - */ |
|
92 | - public function findAll(): array { |
|
93 | - $qb = $this->db->getQueryBuilder(); |
|
94 | - $qb->select('*')->from($this->getTableName()); |
|
95 | - return $this->findEntities($qb); |
|
96 | - } |
|
86 | + /** |
|
87 | + * Get all the authorizations stored in the database. |
|
88 | + * |
|
89 | + * @return AuthorizedGroup[] |
|
90 | + * @throws \OCP\DB\Exception |
|
91 | + */ |
|
92 | + public function findAll(): array { |
|
93 | + $qb = $this->db->getQueryBuilder(); |
|
94 | + $qb->select('*')->from($this->getTableName()); |
|
95 | + return $this->findEntities($qb); |
|
96 | + } |
|
97 | 97 | |
98 | - public function findByGroupIdAndClass(string $groupId, string $class) { |
|
99 | - $qb = $this->db->getQueryBuilder(); |
|
100 | - $qb->select('*') |
|
101 | - ->from($this->getTableName()) |
|
102 | - ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($groupId))) |
|
103 | - ->andWhere($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
104 | - return $this->findEntity($qb); |
|
105 | - } |
|
98 | + public function findByGroupIdAndClass(string $groupId, string $class) { |
|
99 | + $qb = $this->db->getQueryBuilder(); |
|
100 | + $qb->select('*') |
|
101 | + ->from($this->getTableName()) |
|
102 | + ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($groupId))) |
|
103 | + ->andWhere($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
104 | + return $this->findEntity($qb); |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @return Entity[] |
|
109 | - * @throws \OCP\DB\Exception |
|
110 | - */ |
|
111 | - public function findExistingGroupsForClass(string $class): array { |
|
112 | - $qb = $this->db->getQueryBuilder(); |
|
113 | - $qb->select('*') |
|
114 | - ->from($this->getTableName()) |
|
115 | - ->where($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
116 | - return $this->findEntities($qb); |
|
117 | - } |
|
107 | + /** |
|
108 | + * @return Entity[] |
|
109 | + * @throws \OCP\DB\Exception |
|
110 | + */ |
|
111 | + public function findExistingGroupsForClass(string $class): array { |
|
112 | + $qb = $this->db->getQueryBuilder(); |
|
113 | + $qb->select('*') |
|
114 | + ->from($this->getTableName()) |
|
115 | + ->where($qb->expr()->eq('class', $qb->createNamedParameter($class))); |
|
116 | + return $this->findEntities($qb); |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * @throws Exception |
|
121 | - */ |
|
122 | - public function removeGroup(string $gid) { |
|
123 | - $qb = $this->db->getQueryBuilder(); |
|
124 | - $qb->delete($this->getTableName()) |
|
125 | - ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($gid))) |
|
126 | - ->executeStatement(); |
|
127 | - } |
|
119 | + /** |
|
120 | + * @throws Exception |
|
121 | + */ |
|
122 | + public function removeGroup(string $gid) { |
|
123 | + $qb = $this->db->getQueryBuilder(); |
|
124 | + $qb->delete($this->getTableName()) |
|
125 | + ->where($qb->expr()->eq('group_id', $qb->createNamedParameter($gid))) |
|
126 | + ->executeStatement(); |
|
127 | + } |
|
128 | 128 | } |
@@ -36,49 +36,49 @@ |
||
36 | 36 | * @template-extends QBMapper<Tag> |
37 | 37 | */ |
38 | 38 | class TagMapper extends QBMapper { |
39 | - /** |
|
40 | - * Constructor. |
|
41 | - * |
|
42 | - * @param IDBConnection $db Instance of the Db abstraction layer. |
|
43 | - */ |
|
44 | - public function __construct(IDBConnection $db) { |
|
45 | - parent::__construct($db, 'vcategory', Tag::class); |
|
46 | - } |
|
39 | + /** |
|
40 | + * Constructor. |
|
41 | + * |
|
42 | + * @param IDBConnection $db Instance of the Db abstraction layer. |
|
43 | + */ |
|
44 | + public function __construct(IDBConnection $db) { |
|
45 | + parent::__construct($db, 'vcategory', Tag::class); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Load tags from the database. |
|
50 | - * |
|
51 | - * @param array $owners The user(s) whose tags we are going to load. |
|
52 | - * @param string $type The type of item for which we are loading tags. |
|
53 | - * @return array An array of Tag objects. |
|
54 | - */ |
|
55 | - public function loadTags(array $owners, string $type): array { |
|
56 | - $qb = $this->db->getQueryBuilder(); |
|
57 | - $qb->select(['id', 'uid', 'type', 'category']) |
|
58 | - ->from($this->getTableName()) |
|
59 | - ->where($qb->expr()->in('uid', $qb->createNamedParameter($owners, IQueryBuilder::PARAM_STR_ARRAY))) |
|
60 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR))) |
|
61 | - ->orderBy('category'); |
|
62 | - return $this->findEntities($qb); |
|
63 | - } |
|
48 | + /** |
|
49 | + * Load tags from the database. |
|
50 | + * |
|
51 | + * @param array $owners The user(s) whose tags we are going to load. |
|
52 | + * @param string $type The type of item for which we are loading tags. |
|
53 | + * @return array An array of Tag objects. |
|
54 | + */ |
|
55 | + public function loadTags(array $owners, string $type): array { |
|
56 | + $qb = $this->db->getQueryBuilder(); |
|
57 | + $qb->select(['id', 'uid', 'type', 'category']) |
|
58 | + ->from($this->getTableName()) |
|
59 | + ->where($qb->expr()->in('uid', $qb->createNamedParameter($owners, IQueryBuilder::PARAM_STR_ARRAY))) |
|
60 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($type, IQueryBuilder::PARAM_STR))) |
|
61 | + ->orderBy('category'); |
|
62 | + return $this->findEntities($qb); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Check if a given Tag object already exists in the database. |
|
67 | - * |
|
68 | - * @param Tag $tag The tag to look for in the database. |
|
69 | - */ |
|
70 | - public function tagExists(Tag $tag): bool { |
|
71 | - $qb = $this->db->getQueryBuilder(); |
|
72 | - $qb->select(['id', 'uid', 'type', 'category']) |
|
73 | - ->from($this->getTableName()) |
|
74 | - ->where($qb->expr()->eq('uid', $qb->createNamedParameter($tag->getOwner(), IQueryBuilder::PARAM_STR))) |
|
75 | - ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($tag->getType(), IQueryBuilder::PARAM_STR))) |
|
76 | - ->andWhere($qb->expr()->eq('category', $qb->createNamedParameter($tag->getName(), IQueryBuilder::PARAM_STR))); |
|
77 | - try { |
|
78 | - $this->findEntity($qb); |
|
79 | - } catch (DoesNotExistException $e) { |
|
80 | - return false; |
|
81 | - } |
|
82 | - return true; |
|
83 | - } |
|
65 | + /** |
|
66 | + * Check if a given Tag object already exists in the database. |
|
67 | + * |
|
68 | + * @param Tag $tag The tag to look for in the database. |
|
69 | + */ |
|
70 | + public function tagExists(Tag $tag): bool { |
|
71 | + $qb = $this->db->getQueryBuilder(); |
|
72 | + $qb->select(['id', 'uid', 'type', 'category']) |
|
73 | + ->from($this->getTableName()) |
|
74 | + ->where($qb->expr()->eq('uid', $qb->createNamedParameter($tag->getOwner(), IQueryBuilder::PARAM_STR))) |
|
75 | + ->andWhere($qb->expr()->eq('type', $qb->createNamedParameter($tag->getType(), IQueryBuilder::PARAM_STR))) |
|
76 | + ->andWhere($qb->expr()->eq('category', $qb->createNamedParameter($tag->getName(), IQueryBuilder::PARAM_STR))); |
|
77 | + try { |
|
78 | + $this->findEntity($qb); |
|
79 | + } catch (DoesNotExistException $e) { |
|
80 | + return false; |
|
81 | + } |
|
82 | + return true; |
|
83 | + } |
|
84 | 84 | } |
@@ -34,57 +34,57 @@ |
||
34 | 34 | * @template-extends QBMapper<KnownUser> |
35 | 35 | */ |
36 | 36 | class KnownUserMapper extends QBMapper { |
37 | - /** |
|
38 | - * @param IDBConnection $db |
|
39 | - */ |
|
40 | - public function __construct(IDBConnection $db) { |
|
41 | - parent::__construct($db, 'known_users', KnownUser::class); |
|
42 | - } |
|
37 | + /** |
|
38 | + * @param IDBConnection $db |
|
39 | + */ |
|
40 | + public function __construct(IDBConnection $db) { |
|
41 | + parent::__construct($db, 'known_users', KnownUser::class); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string $knownTo |
|
46 | - * @return int Number of deleted entities |
|
47 | - */ |
|
48 | - public function deleteKnownTo(string $knownTo): int { |
|
49 | - $query = $this->db->getQueryBuilder(); |
|
50 | - $query->delete($this->getTableName()) |
|
51 | - ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
44 | + /** |
|
45 | + * @param string $knownTo |
|
46 | + * @return int Number of deleted entities |
|
47 | + */ |
|
48 | + public function deleteKnownTo(string $knownTo): int { |
|
49 | + $query = $this->db->getQueryBuilder(); |
|
50 | + $query->delete($this->getTableName()) |
|
51 | + ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
52 | 52 | |
53 | - return $query->executeStatement(); |
|
54 | - } |
|
53 | + return $query->executeStatement(); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param string $knownUser |
|
58 | - * @return int Number of deleted entities |
|
59 | - */ |
|
60 | - public function deleteKnownUser(string $knownUser): int { |
|
61 | - $query = $this->db->getQueryBuilder(); |
|
62 | - $query->delete($this->getTableName()) |
|
63 | - ->where($query->expr()->eq('known_user', $query->createNamedParameter($knownUser))); |
|
56 | + /** |
|
57 | + * @param string $knownUser |
|
58 | + * @return int Number of deleted entities |
|
59 | + */ |
|
60 | + public function deleteKnownUser(string $knownUser): int { |
|
61 | + $query = $this->db->getQueryBuilder(); |
|
62 | + $query->delete($this->getTableName()) |
|
63 | + ->where($query->expr()->eq('known_user', $query->createNamedParameter($knownUser))); |
|
64 | 64 | |
65 | - return $query->executeStatement(); |
|
66 | - } |
|
65 | + return $query->executeStatement(); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Returns all "known users" for the given "known to" user |
|
70 | - * |
|
71 | - * @param string $knownTo |
|
72 | - * @return KnownUser[] |
|
73 | - */ |
|
74 | - public function getKnownUsers(string $knownTo): array { |
|
75 | - $query = $this->db->getQueryBuilder(); |
|
76 | - $query->select('*') |
|
77 | - ->from($this->getTableName()) |
|
78 | - ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
68 | + /** |
|
69 | + * Returns all "known users" for the given "known to" user |
|
70 | + * |
|
71 | + * @param string $knownTo |
|
72 | + * @return KnownUser[] |
|
73 | + */ |
|
74 | + public function getKnownUsers(string $knownTo): array { |
|
75 | + $query = $this->db->getQueryBuilder(); |
|
76 | + $query->select('*') |
|
77 | + ->from($this->getTableName()) |
|
78 | + ->where($query->expr()->eq('known_to', $query->createNamedParameter($knownTo))); |
|
79 | 79 | |
80 | - return $this->findEntities($query); |
|
81 | - } |
|
80 | + return $this->findEntities($query); |
|
81 | + } |
|
82 | 82 | |
83 | - public function createKnownUserFromRow(array $row): KnownUser { |
|
84 | - return $this->mapRowToEntity([ |
|
85 | - 'id' => $row['s_id'], |
|
86 | - 'known_to' => $row['known_to'], |
|
87 | - 'known_user' => $row['known_user'], |
|
88 | - ]); |
|
89 | - } |
|
83 | + public function createKnownUserFromRow(array $row): KnownUser { |
|
84 | + return $this->mapRowToEntity([ |
|
85 | + 'id' => $row['s_id'], |
|
86 | + 'known_to' => $row['known_to'], |
|
87 | + 'known_user' => $row['known_user'], |
|
88 | + ]); |
|
89 | + } |
|
90 | 90 | } |
@@ -36,68 +36,68 @@ |
||
36 | 36 | * @since 6.0.0 |
37 | 37 | */ |
38 | 38 | abstract class Middleware { |
39 | - /** |
|
40 | - * This is being run in normal order before the controller is being |
|
41 | - * called which allows several modifications and checks |
|
42 | - * |
|
43 | - * @param Controller $controller the controller that is being called |
|
44 | - * @param string $methodName the name of the method that will be called on |
|
45 | - * the controller |
|
46 | - * @return void |
|
47 | - * @since 6.0.0 |
|
48 | - */ |
|
49 | - public function beforeController(Controller $controller, string $methodName) { |
|
50 | - } |
|
39 | + /** |
|
40 | + * This is being run in normal order before the controller is being |
|
41 | + * called which allows several modifications and checks |
|
42 | + * |
|
43 | + * @param Controller $controller the controller that is being called |
|
44 | + * @param string $methodName the name of the method that will be called on |
|
45 | + * the controller |
|
46 | + * @return void |
|
47 | + * @since 6.0.0 |
|
48 | + */ |
|
49 | + public function beforeController(Controller $controller, string $methodName) { |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * This is being run when either the beforeController method or the |
|
55 | - * controller method itself is throwing an exception. The middleware is |
|
56 | - * asked in reverse order to handle the exception and to return a response. |
|
57 | - * If the response is null, it is assumed that the exception could not be |
|
58 | - * handled and the error will be thrown again |
|
59 | - * |
|
60 | - * @param Controller $controller the controller that is being called |
|
61 | - * @param string $methodName the name of the method that will be called on |
|
62 | - * the controller |
|
63 | - * @param Exception $exception the thrown exception |
|
64 | - * @throws Exception the passed in exception if it can't handle it |
|
65 | - * @return Response a Response object in case that the exception was handled |
|
66 | - * @since 6.0.0 |
|
67 | - */ |
|
68 | - public function afterException(Controller $controller, string $methodName, Exception $exception) { |
|
69 | - throw $exception; |
|
70 | - } |
|
53 | + /** |
|
54 | + * This is being run when either the beforeController method or the |
|
55 | + * controller method itself is throwing an exception. The middleware is |
|
56 | + * asked in reverse order to handle the exception and to return a response. |
|
57 | + * If the response is null, it is assumed that the exception could not be |
|
58 | + * handled and the error will be thrown again |
|
59 | + * |
|
60 | + * @param Controller $controller the controller that is being called |
|
61 | + * @param string $methodName the name of the method that will be called on |
|
62 | + * the controller |
|
63 | + * @param Exception $exception the thrown exception |
|
64 | + * @throws Exception the passed in exception if it can't handle it |
|
65 | + * @return Response a Response object in case that the exception was handled |
|
66 | + * @since 6.0.0 |
|
67 | + */ |
|
68 | + public function afterException(Controller $controller, string $methodName, Exception $exception) { |
|
69 | + throw $exception; |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * This is being run after a successful controllermethod call and allows |
|
75 | - * the manipulation of a Response object. The middleware is run in reverse order |
|
76 | - * |
|
77 | - * @param Controller $controller the controller that is being called |
|
78 | - * @param string $methodName the name of the method that will be called on |
|
79 | - * the controller |
|
80 | - * @param Response $response the generated response from the controller |
|
81 | - * @return Response a Response object |
|
82 | - * @since 6.0.0 |
|
83 | - */ |
|
84 | - public function afterController(Controller $controller, string $methodName, Response $response) { |
|
85 | - return $response; |
|
86 | - } |
|
73 | + /** |
|
74 | + * This is being run after a successful controllermethod call and allows |
|
75 | + * the manipulation of a Response object. The middleware is run in reverse order |
|
76 | + * |
|
77 | + * @param Controller $controller the controller that is being called |
|
78 | + * @param string $methodName the name of the method that will be called on |
|
79 | + * the controller |
|
80 | + * @param Response $response the generated response from the controller |
|
81 | + * @return Response a Response object |
|
82 | + * @since 6.0.0 |
|
83 | + */ |
|
84 | + public function afterController(Controller $controller, string $methodName, Response $response) { |
|
85 | + return $response; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * This is being run after the response object has been rendered and |
|
91 | - * allows the manipulation of the output. The middleware is run in reverse order |
|
92 | - * |
|
93 | - * @param Controller $controller the controller that is being called |
|
94 | - * @param string $methodName the name of the method that will be called on |
|
95 | - * the controller |
|
96 | - * @param string $output the generated output from a response |
|
97 | - * @return string the output that should be printed |
|
98 | - * @since 6.0.0 |
|
99 | - */ |
|
100 | - public function beforeOutput(Controller $controller, string $methodName, string $output) { |
|
101 | - return $output; |
|
102 | - } |
|
89 | + /** |
|
90 | + * This is being run after the response object has been rendered and |
|
91 | + * allows the manipulation of the output. The middleware is run in reverse order |
|
92 | + * |
|
93 | + * @param Controller $controller the controller that is being called |
|
94 | + * @param string $methodName the name of the method that will be called on |
|
95 | + * the controller |
|
96 | + * @param string $output the generated output from a response |
|
97 | + * @return string the output that should be printed |
|
98 | + * @since 6.0.0 |
|
99 | + */ |
|
100 | + public function beforeOutput(Controller $controller, string $methodName, string $output) { |
|
101 | + return $output; |
|
102 | + } |
|
103 | 103 | } |
@@ -32,29 +32,29 @@ |
||
32 | 32 | use OCP\Migration\IRepairStep; |
33 | 33 | |
34 | 34 | class ClearCollectionsAccessCache implements IRepairStep { |
35 | - /** @var IConfig */ |
|
36 | - private $config; |
|
37 | - |
|
38 | - /** @var Manager */ |
|
39 | - private $manager; |
|
40 | - |
|
41 | - public function __construct(IConfig $config, IManager $manager) { |
|
42 | - $this->config = $config; |
|
43 | - $this->manager = $manager; |
|
44 | - } |
|
45 | - |
|
46 | - public function getName(): string { |
|
47 | - return 'Clear access cache of projects'; |
|
48 | - } |
|
49 | - |
|
50 | - private function shouldRun(): bool { |
|
51 | - $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); |
|
52 | - return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<='); |
|
53 | - } |
|
54 | - |
|
55 | - public function run(IOutput $output): void { |
|
56 | - if ($this->shouldRun()) { |
|
57 | - $this->manager->invalidateAccessCacheForAllCollections(); |
|
58 | - } |
|
59 | - } |
|
35 | + /** @var IConfig */ |
|
36 | + private $config; |
|
37 | + |
|
38 | + /** @var Manager */ |
|
39 | + private $manager; |
|
40 | + |
|
41 | + public function __construct(IConfig $config, IManager $manager) { |
|
42 | + $this->config = $config; |
|
43 | + $this->manager = $manager; |
|
44 | + } |
|
45 | + |
|
46 | + public function getName(): string { |
|
47 | + return 'Clear access cache of projects'; |
|
48 | + } |
|
49 | + |
|
50 | + private function shouldRun(): bool { |
|
51 | + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); |
|
52 | + return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<='); |
|
53 | + } |
|
54 | + |
|
55 | + public function run(IOutput $output): void { |
|
56 | + if ($this->shouldRun()) { |
|
57 | + $this->manager->invalidateAccessCacheForAllCollections(); |
|
58 | + } |
|
59 | + } |
|
60 | 60 | } |
@@ -31,114 +31,114 @@ |
||
31 | 31 | use OCP\L10N\ILanguageIterator; |
32 | 32 | |
33 | 33 | class LanguageIterator implements ILanguageIterator { |
34 | - private $i = 0; |
|
35 | - /** @var IConfig */ |
|
36 | - private $config; |
|
37 | - /** @var IUser */ |
|
38 | - private $user; |
|
34 | + private $i = 0; |
|
35 | + /** @var IConfig */ |
|
36 | + private $config; |
|
37 | + /** @var IUser */ |
|
38 | + private $user; |
|
39 | 39 | |
40 | - public function __construct(IUser $user, IConfig $config) { |
|
41 | - $this->config = $config; |
|
42 | - $this->user = $user; |
|
43 | - } |
|
40 | + public function __construct(IUser $user, IConfig $config) { |
|
41 | + $this->config = $config; |
|
42 | + $this->user = $user; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * Rewind the Iterator to the first element |
|
47 | - */ |
|
48 | - public function rewind(): void { |
|
49 | - $this->i = 0; |
|
50 | - } |
|
45 | + /** |
|
46 | + * Rewind the Iterator to the first element |
|
47 | + */ |
|
48 | + public function rewind(): void { |
|
49 | + $this->i = 0; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Return the current element |
|
54 | - * |
|
55 | - * @since 14.0.0 |
|
56 | - */ |
|
57 | - public function current(): string { |
|
58 | - switch ($this->i) { |
|
59 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
60 | - case 0: |
|
61 | - $forcedLang = $this->config->getSystemValue('force_language', false); |
|
62 | - if (is_string($forcedLang)) { |
|
63 | - return $forcedLang; |
|
64 | - } |
|
65 | - $this->next(); |
|
66 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
67 | - // no break |
|
68 | - case 1: |
|
69 | - $forcedLang = $this->config->getSystemValue('force_language', false); |
|
70 | - if (is_string($forcedLang) |
|
71 | - && ($truncated = $this->getTruncatedLanguage($forcedLang)) !== $forcedLang |
|
72 | - ) { |
|
73 | - return $truncated; |
|
74 | - } |
|
75 | - $this->next(); |
|
76 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
77 | - // no break |
|
78 | - case 2: |
|
79 | - $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
80 | - if (is_string($userLang)) { |
|
81 | - return $userLang; |
|
82 | - } |
|
83 | - $this->next(); |
|
84 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
85 | - // no break |
|
86 | - case 3: |
|
87 | - $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
88 | - if (is_string($userLang) |
|
89 | - && ($truncated = $this->getTruncatedLanguage($userLang)) !== $userLang |
|
90 | - ) { |
|
91 | - return $truncated; |
|
92 | - } |
|
93 | - $this->next(); |
|
94 | - // no break |
|
95 | - case 4: |
|
96 | - return $this->config->getSystemValueString('default_language', 'en'); |
|
97 | - /** @noinspection PhpMissingBreakStatementInspection */ |
|
98 | - case 5: |
|
99 | - $defaultLang = $this->config->getSystemValueString('default_language', 'en'); |
|
100 | - if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) { |
|
101 | - return $truncated; |
|
102 | - } |
|
103 | - $this->next(); |
|
104 | - // no break |
|
105 | - default: |
|
106 | - return 'en'; |
|
107 | - } |
|
108 | - } |
|
52 | + /** |
|
53 | + * Return the current element |
|
54 | + * |
|
55 | + * @since 14.0.0 |
|
56 | + */ |
|
57 | + public function current(): string { |
|
58 | + switch ($this->i) { |
|
59 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
60 | + case 0: |
|
61 | + $forcedLang = $this->config->getSystemValue('force_language', false); |
|
62 | + if (is_string($forcedLang)) { |
|
63 | + return $forcedLang; |
|
64 | + } |
|
65 | + $this->next(); |
|
66 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
67 | + // no break |
|
68 | + case 1: |
|
69 | + $forcedLang = $this->config->getSystemValue('force_language', false); |
|
70 | + if (is_string($forcedLang) |
|
71 | + && ($truncated = $this->getTruncatedLanguage($forcedLang)) !== $forcedLang |
|
72 | + ) { |
|
73 | + return $truncated; |
|
74 | + } |
|
75 | + $this->next(); |
|
76 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
77 | + // no break |
|
78 | + case 2: |
|
79 | + $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
80 | + if (is_string($userLang)) { |
|
81 | + return $userLang; |
|
82 | + } |
|
83 | + $this->next(); |
|
84 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
85 | + // no break |
|
86 | + case 3: |
|
87 | + $userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null); |
|
88 | + if (is_string($userLang) |
|
89 | + && ($truncated = $this->getTruncatedLanguage($userLang)) !== $userLang |
|
90 | + ) { |
|
91 | + return $truncated; |
|
92 | + } |
|
93 | + $this->next(); |
|
94 | + // no break |
|
95 | + case 4: |
|
96 | + return $this->config->getSystemValueString('default_language', 'en'); |
|
97 | + /** @noinspection PhpMissingBreakStatementInspection */ |
|
98 | + case 5: |
|
99 | + $defaultLang = $this->config->getSystemValueString('default_language', 'en'); |
|
100 | + if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) { |
|
101 | + return $truncated; |
|
102 | + } |
|
103 | + $this->next(); |
|
104 | + // no break |
|
105 | + default: |
|
106 | + return 'en'; |
|
107 | + } |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Move forward to next element |
|
112 | - * |
|
113 | - * @since 14.0.0 |
|
114 | - */ |
|
115 | - public function next(): void { |
|
116 | - ++$this->i; |
|
117 | - } |
|
110 | + /** |
|
111 | + * Move forward to next element |
|
112 | + * |
|
113 | + * @since 14.0.0 |
|
114 | + */ |
|
115 | + public function next(): void { |
|
116 | + ++$this->i; |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Return the key of the current element |
|
121 | - * |
|
122 | - * @since 14.0.0 |
|
123 | - */ |
|
124 | - public function key(): int { |
|
125 | - return $this->i; |
|
126 | - } |
|
119 | + /** |
|
120 | + * Return the key of the current element |
|
121 | + * |
|
122 | + * @since 14.0.0 |
|
123 | + */ |
|
124 | + public function key(): int { |
|
125 | + return $this->i; |
|
126 | + } |
|
127 | 127 | |
128 | - /** |
|
129 | - * Checks if current position is valid |
|
130 | - * |
|
131 | - * @since 14.0.0 |
|
132 | - */ |
|
133 | - public function valid(): bool { |
|
134 | - return $this->i <= 6; |
|
135 | - } |
|
128 | + /** |
|
129 | + * Checks if current position is valid |
|
130 | + * |
|
131 | + * @since 14.0.0 |
|
132 | + */ |
|
133 | + public function valid(): bool { |
|
134 | + return $this->i <= 6; |
|
135 | + } |
|
136 | 136 | |
137 | - protected function getTruncatedLanguage(string $lang):string { |
|
138 | - $pos = strpos($lang, '_'); |
|
139 | - if ($pos !== false) { |
|
140 | - $lang = substr($lang, 0, $pos); |
|
141 | - } |
|
142 | - return $lang; |
|
143 | - } |
|
137 | + protected function getTruncatedLanguage(string $lang):string { |
|
138 | + $pos = strpos($lang, '_'); |
|
139 | + if ($pos !== false) { |
|
140 | + $lang = substr($lang, 0, $pos); |
|
141 | + } |
|
142 | + return $lang; |
|
143 | + } |
|
144 | 144 | } |
@@ -28,42 +28,42 @@ |
||
28 | 28 | namespace OC\IntegrityCheck\Iterator; |
29 | 29 | |
30 | 30 | class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { |
31 | - private $excludedFolders; |
|
31 | + private $excludedFolders; |
|
32 | 32 | |
33 | - public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
34 | - parent::__construct($iterator); |
|
33 | + public function __construct(\RecursiveIterator $iterator, $root = '') { |
|
34 | + parent::__construct($iterator); |
|
35 | 35 | |
36 | - $appFolders = \OC::$APPSROOTS; |
|
37 | - foreach ($appFolders as $key => $appFolder) { |
|
38 | - $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
39 | - } |
|
36 | + $appFolders = \OC::$APPSROOTS; |
|
37 | + foreach ($appFolders as $key => $appFolder) { |
|
38 | + $appFolders[$key] = rtrim($appFolder['path'], '/'); |
|
39 | + } |
|
40 | 40 | |
41 | - $excludedFolders = [ |
|
42 | - rtrim($root . '/data', '/'), |
|
43 | - rtrim($root . '/themes', '/'), |
|
44 | - rtrim($root . '/config', '/'), |
|
45 | - rtrim($root . '/apps', '/'), |
|
46 | - rtrim($root . '/assets', '/'), |
|
47 | - rtrim($root . '/lost+found', '/'), |
|
48 | - // Ignore folders generated by updater since the updater is replaced |
|
49 | - // after the integrity check is run. |
|
50 | - // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
51 | - rtrim($root . '/updater', '/'), |
|
52 | - rtrim($root . '/_oc_upgrade', '/'), |
|
53 | - ]; |
|
54 | - $customDataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', ''); |
|
55 | - if ($customDataDir !== '') { |
|
56 | - $excludedFolders[] = rtrim($customDataDir, '/'); |
|
57 | - } |
|
41 | + $excludedFolders = [ |
|
42 | + rtrim($root . '/data', '/'), |
|
43 | + rtrim($root . '/themes', '/'), |
|
44 | + rtrim($root . '/config', '/'), |
|
45 | + rtrim($root . '/apps', '/'), |
|
46 | + rtrim($root . '/assets', '/'), |
|
47 | + rtrim($root . '/lost+found', '/'), |
|
48 | + // Ignore folders generated by updater since the updater is replaced |
|
49 | + // after the integrity check is run. |
|
50 | + // See https://github.com/owncloud/updater/issues/318#issuecomment-212497846 |
|
51 | + rtrim($root . '/updater', '/'), |
|
52 | + rtrim($root . '/_oc_upgrade', '/'), |
|
53 | + ]; |
|
54 | + $customDataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', ''); |
|
55 | + if ($customDataDir !== '') { |
|
56 | + $excludedFolders[] = rtrim($customDataDir, '/'); |
|
57 | + } |
|
58 | 58 | |
59 | - $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
60 | - } |
|
59 | + $this->excludedFolders = array_merge($excludedFolders, $appFolders); |
|
60 | + } |
|
61 | 61 | |
62 | - public function accept(): bool { |
|
63 | - return !\in_array( |
|
64 | - $this->current()->getPathName(), |
|
65 | - $this->excludedFolders, |
|
66 | - true |
|
67 | - ); |
|
68 | - } |
|
62 | + public function accept(): bool { |
|
63 | + return !\in_array( |
|
64 | + $this->current()->getPathName(), |
|
65 | + $this->excludedFolders, |
|
66 | + true |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -30,42 +30,42 @@ |
||
30 | 30 | * Mount provider for custom cache storages |
31 | 31 | */ |
32 | 32 | class CacheMountProvider implements IMountProvider { |
33 | - /** |
|
34 | - * @var IConfig |
|
35 | - */ |
|
36 | - private $config; |
|
33 | + /** |
|
34 | + * @var IConfig |
|
35 | + */ |
|
36 | + private $config; |
|
37 | 37 | |
38 | - /** |
|
39 | - * ObjectStoreHomeMountProvider constructor. |
|
40 | - * |
|
41 | - * @param IConfig $config |
|
42 | - */ |
|
43 | - public function __construct(IConfig $config) { |
|
44 | - $this->config = $config; |
|
45 | - } |
|
38 | + /** |
|
39 | + * ObjectStoreHomeMountProvider constructor. |
|
40 | + * |
|
41 | + * @param IConfig $config |
|
42 | + */ |
|
43 | + public function __construct(IConfig $config) { |
|
44 | + $this->config = $config; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Get the cache mount for a user |
|
49 | - * |
|
50 | - * @param IUser $user |
|
51 | - * @param IStorageFactory $loader |
|
52 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
53 | - */ |
|
54 | - public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
55 | - $cacheBaseDir = $this->config->getSystemValueString('cache_path', ''); |
|
56 | - if ($cacheBaseDir !== '') { |
|
57 | - $cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID(); |
|
58 | - if (!file_exists($cacheDir)) { |
|
59 | - mkdir($cacheDir, 0770, true); |
|
60 | - mkdir($cacheDir . '/uploads', 0770, true); |
|
61 | - } |
|
47 | + /** |
|
48 | + * Get the cache mount for a user |
|
49 | + * |
|
50 | + * @param IUser $user |
|
51 | + * @param IStorageFactory $loader |
|
52 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
53 | + */ |
|
54 | + public function getMountsForUser(IUser $user, IStorageFactory $loader) { |
|
55 | + $cacheBaseDir = $this->config->getSystemValueString('cache_path', ''); |
|
56 | + if ($cacheBaseDir !== '') { |
|
57 | + $cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID(); |
|
58 | + if (!file_exists($cacheDir)) { |
|
59 | + mkdir($cacheDir, 0770, true); |
|
60 | + mkdir($cacheDir . '/uploads', 0770, true); |
|
61 | + } |
|
62 | 62 | |
63 | - return [ |
|
64 | - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), |
|
65 | - new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) |
|
66 | - ]; |
|
67 | - } else { |
|
68 | - return []; |
|
69 | - } |
|
70 | - } |
|
63 | + return [ |
|
64 | + new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/cache', ['datadir' => $cacheDir], $loader, null, null, self::class), |
|
65 | + new MountPoint('\OC\Files\Storage\Local', '/' . $user->getUID() . '/uploads', ['datadir' => $cacheDir . '/uploads'], $loader, null, null, self::class) |
|
66 | + ]; |
|
67 | + } else { |
|
68 | + return []; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |