@@ -36,44 +36,44 @@ |
||
36 | 36 | |
37 | 37 | class SetTokenExpiration implements IRepairStep { |
38 | 38 | |
39 | - /** @var IDBConnection */ |
|
40 | - private $connection; |
|
39 | + /** @var IDBConnection */ |
|
40 | + private $connection; |
|
41 | 41 | |
42 | - /** @var ITimeFactory */ |
|
43 | - private $time; |
|
42 | + /** @var ITimeFactory */ |
|
43 | + private $time; |
|
44 | 44 | |
45 | - /** @var TokenProvider */ |
|
46 | - private $tokenProvider; |
|
45 | + /** @var TokenProvider */ |
|
46 | + private $tokenProvider; |
|
47 | 47 | |
48 | - public function __construct(IDBConnection $connection, |
|
49 | - ITimeFactory $timeFactory, |
|
50 | - TokenProvider $tokenProvider) { |
|
51 | - $this->connection = $connection; |
|
52 | - $this->time = $timeFactory; |
|
53 | - $this->tokenProvider = $tokenProvider; |
|
54 | - } |
|
48 | + public function __construct(IDBConnection $connection, |
|
49 | + ITimeFactory $timeFactory, |
|
50 | + TokenProvider $tokenProvider) { |
|
51 | + $this->connection = $connection; |
|
52 | + $this->time = $timeFactory; |
|
53 | + $this->tokenProvider = $tokenProvider; |
|
54 | + } |
|
55 | 55 | |
56 | - public function getName(): string { |
|
57 | - return 'Update OAuth token expiration times'; |
|
58 | - } |
|
56 | + public function getName(): string { |
|
57 | + return 'Update OAuth token expiration times'; |
|
58 | + } |
|
59 | 59 | |
60 | - public function run(IOutput $output) { |
|
61 | - $qb = $this->connection->getQueryBuilder(); |
|
62 | - $qb->select('*') |
|
63 | - ->from('oauth2_access_tokens'); |
|
60 | + public function run(IOutput $output) { |
|
61 | + $qb = $this->connection->getQueryBuilder(); |
|
62 | + $qb->select('*') |
|
63 | + ->from('oauth2_access_tokens'); |
|
64 | 64 | |
65 | - $cursor = $qb->execute(); |
|
65 | + $cursor = $qb->execute(); |
|
66 | 66 | |
67 | - while ($row = $cursor->fetch()) { |
|
68 | - $token = AccessToken::fromRow($row); |
|
69 | - try { |
|
70 | - $appToken = $this->tokenProvider->getTokenById($token->getTokenId()); |
|
71 | - $appToken->setExpires($this->time->getTime() + 3600); |
|
72 | - $this->tokenProvider->updateToken($appToken); |
|
73 | - } catch (InvalidTokenException $e) { |
|
74 | - //Skip this token |
|
75 | - } |
|
76 | - } |
|
77 | - $cursor->closeCursor(); |
|
78 | - } |
|
67 | + while ($row = $cursor->fetch()) { |
|
68 | + $token = AccessToken::fromRow($row); |
|
69 | + try { |
|
70 | + $appToken = $this->tokenProvider->getTokenById($token->getTokenId()); |
|
71 | + $appToken->setExpires($this->time->getTime() + 3600); |
|
72 | + $this->tokenProvider->updateToken($appToken); |
|
73 | + } catch (InvalidTokenException $e) { |
|
74 | + //Skip this token |
|
75 | + } |
|
76 | + } |
|
77 | + $cursor->closeCursor(); |
|
78 | + } |
|
79 | 79 | } |
@@ -60,11 +60,11 @@ |
||
60 | 60 | // at least on PHP 5.6 usort turned out to be not stable. So we add |
61 | 61 | // the current index to the value and compare it on a draw |
62 | 62 | $i = 0; |
63 | - $workArray = array_map(function ($element) use (&$i) { |
|
63 | + $workArray = array_map(function($element) use (&$i) { |
|
64 | 64 | return [$i++, $element]; |
65 | 65 | }, $byType); |
66 | 66 | |
67 | - usort($workArray, function ($a, $b) use ($commenters, $type) { |
|
67 | + usort($workArray, function($a, $b) use ($commenters, $type) { |
|
68 | 68 | $r = $this->compare($a[1], $b[1], $commenters[$type]); |
69 | 69 | if ($r === 0) { |
70 | 70 | $r = $a[0] - $b[0]; |
@@ -28,81 +28,81 @@ |
||
28 | 28 | |
29 | 29 | class CommentersSorter implements ISorter { |
30 | 30 | |
31 | - private ICommentsManager $commentsManager; |
|
31 | + private ICommentsManager $commentsManager; |
|
32 | 32 | |
33 | - public function __construct(ICommentsManager $commentsManager) { |
|
34 | - $this->commentsManager = $commentsManager; |
|
35 | - } |
|
33 | + public function __construct(ICommentsManager $commentsManager) { |
|
34 | + $this->commentsManager = $commentsManager; |
|
35 | + } |
|
36 | 36 | |
37 | - public function getId() { |
|
38 | - return 'commenters'; |
|
39 | - } |
|
37 | + public function getId() { |
|
38 | + return 'commenters'; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Sorts people who commented on the given item atop (descelating) of the |
|
43 | - * others |
|
44 | - * |
|
45 | - * @param array $sortArray |
|
46 | - * @param array $context |
|
47 | - */ |
|
48 | - public function sort(array &$sortArray, array $context) { |
|
49 | - $commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']); |
|
50 | - if (count($commenters) === 0) { |
|
51 | - return; |
|
52 | - } |
|
41 | + /** |
|
42 | + * Sorts people who commented on the given item atop (descelating) of the |
|
43 | + * others |
|
44 | + * |
|
45 | + * @param array $sortArray |
|
46 | + * @param array $context |
|
47 | + */ |
|
48 | + public function sort(array &$sortArray, array $context) { |
|
49 | + $commenters = $this->retrieveCommentsInformation($context['itemType'], $context['itemId']); |
|
50 | + if (count($commenters) === 0) { |
|
51 | + return; |
|
52 | + } |
|
53 | 53 | |
54 | - foreach ($sortArray as $type => &$byType) { |
|
55 | - if (!isset($commenters[$type])) { |
|
56 | - continue; |
|
57 | - } |
|
54 | + foreach ($sortArray as $type => &$byType) { |
|
55 | + if (!isset($commenters[$type])) { |
|
56 | + continue; |
|
57 | + } |
|
58 | 58 | |
59 | - // at least on PHP 5.6 usort turned out to be not stable. So we add |
|
60 | - // the current index to the value and compare it on a draw |
|
61 | - $i = 0; |
|
62 | - $workArray = array_map(function ($element) use (&$i) { |
|
63 | - return [$i++, $element]; |
|
64 | - }, $byType); |
|
59 | + // at least on PHP 5.6 usort turned out to be not stable. So we add |
|
60 | + // the current index to the value and compare it on a draw |
|
61 | + $i = 0; |
|
62 | + $workArray = array_map(function ($element) use (&$i) { |
|
63 | + return [$i++, $element]; |
|
64 | + }, $byType); |
|
65 | 65 | |
66 | - usort($workArray, function ($a, $b) use ($commenters, $type) { |
|
67 | - $r = $this->compare($a[1], $b[1], $commenters[$type]); |
|
68 | - if ($r === 0) { |
|
69 | - $r = $a[0] - $b[0]; |
|
70 | - } |
|
71 | - return $r; |
|
72 | - }); |
|
66 | + usort($workArray, function ($a, $b) use ($commenters, $type) { |
|
67 | + $r = $this->compare($a[1], $b[1], $commenters[$type]); |
|
68 | + if ($r === 0) { |
|
69 | + $r = $a[0] - $b[0]; |
|
70 | + } |
|
71 | + return $r; |
|
72 | + }); |
|
73 | 73 | |
74 | - // and remove the index values again |
|
75 | - $byType = array_column($workArray, 1); |
|
76 | - } |
|
77 | - } |
|
74 | + // and remove the index values again |
|
75 | + $byType = array_column($workArray, 1); |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | - protected function retrieveCommentsInformation(string $type, string $id): array { |
|
80 | - $comments = $this->commentsManager->getForObject($type, $id); |
|
81 | - if (count($comments) === 0) { |
|
82 | - return []; |
|
83 | - } |
|
79 | + protected function retrieveCommentsInformation(string $type, string $id): array { |
|
80 | + $comments = $this->commentsManager->getForObject($type, $id); |
|
81 | + if (count($comments) === 0) { |
|
82 | + return []; |
|
83 | + } |
|
84 | 84 | |
85 | - $actors = []; |
|
86 | - foreach ($comments as $comment) { |
|
87 | - if (!isset($actors[$comment->getActorType()])) { |
|
88 | - $actors[$comment->getActorType()] = []; |
|
89 | - } |
|
90 | - if (!isset($actors[$comment->getActorType()][$comment->getActorId()])) { |
|
91 | - $actors[$comment->getActorType()][$comment->getActorId()] = 1; |
|
92 | - } else { |
|
93 | - $actors[$comment->getActorType()][$comment->getActorId()]++; |
|
94 | - } |
|
95 | - } |
|
96 | - return $actors; |
|
97 | - } |
|
85 | + $actors = []; |
|
86 | + foreach ($comments as $comment) { |
|
87 | + if (!isset($actors[$comment->getActorType()])) { |
|
88 | + $actors[$comment->getActorType()] = []; |
|
89 | + } |
|
90 | + if (!isset($actors[$comment->getActorType()][$comment->getActorId()])) { |
|
91 | + $actors[$comment->getActorType()][$comment->getActorId()] = 1; |
|
92 | + } else { |
|
93 | + $actors[$comment->getActorType()][$comment->getActorId()]++; |
|
94 | + } |
|
95 | + } |
|
96 | + return $actors; |
|
97 | + } |
|
98 | 98 | |
99 | - protected function compare(array $a, array $b, array $commenters): int { |
|
100 | - $a = $a['value']['shareWith']; |
|
101 | - $b = $b['value']['shareWith']; |
|
99 | + protected function compare(array $a, array $b, array $commenters): int { |
|
100 | + $a = $a['value']['shareWith']; |
|
101 | + $b = $b['value']['shareWith']; |
|
102 | 102 | |
103 | - $valueA = $commenters[$a] ?? 0; |
|
104 | - $valueB = $commenters[$b] ?? 0; |
|
103 | + $valueA = $commenters[$a] ?? 0; |
|
104 | + $valueB = $commenters[$b] ?? 0; |
|
105 | 105 | |
106 | - return $valueB - $valueA; |
|
107 | - } |
|
106 | + return $valueB - $valueA; |
|
107 | + } |
|
108 | 108 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | return new NotFoundResponse(); |
113 | 113 | } |
114 | 114 | $userFolder = $this->rootFolder->getUserFolder($currentUser->getUID()); |
115 | - $files = $userFolder->getById((int)$comment->getObjectId()); |
|
115 | + $files = $userFolder->getById((int) $comment->getObjectId()); |
|
116 | 116 | |
117 | 117 | $this->markProcessed($comment, $currentUser); |
118 | 118 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | $url = $this->urlGenerator->linkToRouteAbsolute( |
124 | 124 | 'files.viewcontroller.showFile', |
125 | - [ 'fileid' => $comment->getObjectId() ] |
|
125 | + ['fileid' => $comment->getObjectId()] |
|
126 | 126 | ); |
127 | 127 | |
128 | 128 | return new RedirectResponse($url); |
@@ -44,83 +44,83 @@ |
||
44 | 44 | */ |
45 | 45 | class Notifications extends Controller { |
46 | 46 | |
47 | - protected IRootFolder $rootFolder; |
|
48 | - protected ICommentsManager $commentsManager; |
|
49 | - protected IURLGenerator $urlGenerator; |
|
50 | - protected IManager $notificationManager; |
|
51 | - protected IUserSession $userSession; |
|
47 | + protected IRootFolder $rootFolder; |
|
48 | + protected ICommentsManager $commentsManager; |
|
49 | + protected IURLGenerator $urlGenerator; |
|
50 | + protected IManager $notificationManager; |
|
51 | + protected IUserSession $userSession; |
|
52 | 52 | |
53 | - /** |
|
54 | - * Notifications constructor. |
|
55 | - */ |
|
56 | - public function __construct( |
|
57 | - string $appName, |
|
58 | - IRequest $request, |
|
59 | - ICommentsManager $commentsManager, |
|
60 | - IRootFolder $rootFolder, |
|
61 | - IURLGenerator $urlGenerator, |
|
62 | - IManager $notificationManager, |
|
63 | - IUserSession $userSession |
|
64 | - ) { |
|
65 | - parent::__construct($appName, $request); |
|
66 | - $this->commentsManager = $commentsManager; |
|
67 | - $this->rootFolder = $rootFolder; |
|
68 | - $this->urlGenerator = $urlGenerator; |
|
69 | - $this->notificationManager = $notificationManager; |
|
70 | - $this->userSession = $userSession; |
|
71 | - } |
|
53 | + /** |
|
54 | + * Notifications constructor. |
|
55 | + */ |
|
56 | + public function __construct( |
|
57 | + string $appName, |
|
58 | + IRequest $request, |
|
59 | + ICommentsManager $commentsManager, |
|
60 | + IRootFolder $rootFolder, |
|
61 | + IURLGenerator $urlGenerator, |
|
62 | + IManager $notificationManager, |
|
63 | + IUserSession $userSession |
|
64 | + ) { |
|
65 | + parent::__construct($appName, $request); |
|
66 | + $this->commentsManager = $commentsManager; |
|
67 | + $this->rootFolder = $rootFolder; |
|
68 | + $this->urlGenerator = $urlGenerator; |
|
69 | + $this->notificationManager = $notificationManager; |
|
70 | + $this->userSession = $userSession; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @PublicPage |
|
75 | - * @NoCSRFRequired |
|
76 | - */ |
|
77 | - public function view(string $id): Response { |
|
78 | - $currentUser = $this->userSession->getUser(); |
|
79 | - if (!$currentUser instanceof IUser) { |
|
80 | - return new RedirectResponse( |
|
81 | - $this->urlGenerator->linkToRoute('core.login.showLoginForm', [ |
|
82 | - 'redirect_url' => $this->urlGenerator->linkToRoute( |
|
83 | - 'comments.Notifications.view', |
|
84 | - ['id' => $id] |
|
85 | - ), |
|
86 | - ]) |
|
87 | - ); |
|
88 | - } |
|
73 | + /** |
|
74 | + * @PublicPage |
|
75 | + * @NoCSRFRequired |
|
76 | + */ |
|
77 | + public function view(string $id): Response { |
|
78 | + $currentUser = $this->userSession->getUser(); |
|
79 | + if (!$currentUser instanceof IUser) { |
|
80 | + return new RedirectResponse( |
|
81 | + $this->urlGenerator->linkToRoute('core.login.showLoginForm', [ |
|
82 | + 'redirect_url' => $this->urlGenerator->linkToRoute( |
|
83 | + 'comments.Notifications.view', |
|
84 | + ['id' => $id] |
|
85 | + ), |
|
86 | + ]) |
|
87 | + ); |
|
88 | + } |
|
89 | 89 | |
90 | - try { |
|
91 | - $comment = $this->commentsManager->get($id); |
|
92 | - if ($comment->getObjectType() !== 'files') { |
|
93 | - return new NotFoundResponse(); |
|
94 | - } |
|
95 | - $userFolder = $this->rootFolder->getUserFolder($currentUser->getUID()); |
|
96 | - $files = $userFolder->getById((int)$comment->getObjectId()); |
|
90 | + try { |
|
91 | + $comment = $this->commentsManager->get($id); |
|
92 | + if ($comment->getObjectType() !== 'files') { |
|
93 | + return new NotFoundResponse(); |
|
94 | + } |
|
95 | + $userFolder = $this->rootFolder->getUserFolder($currentUser->getUID()); |
|
96 | + $files = $userFolder->getById((int)$comment->getObjectId()); |
|
97 | 97 | |
98 | - $this->markProcessed($comment, $currentUser); |
|
98 | + $this->markProcessed($comment, $currentUser); |
|
99 | 99 | |
100 | - if (empty($files)) { |
|
101 | - return new NotFoundResponse(); |
|
102 | - } |
|
100 | + if (empty($files)) { |
|
101 | + return new NotFoundResponse(); |
|
102 | + } |
|
103 | 103 | |
104 | - $url = $this->urlGenerator->linkToRouteAbsolute( |
|
105 | - 'files.viewcontroller.showFile', |
|
106 | - [ 'fileid' => $comment->getObjectId() ] |
|
107 | - ); |
|
104 | + $url = $this->urlGenerator->linkToRouteAbsolute( |
|
105 | + 'files.viewcontroller.showFile', |
|
106 | + [ 'fileid' => $comment->getObjectId() ] |
|
107 | + ); |
|
108 | 108 | |
109 | - return new RedirectResponse($url); |
|
110 | - } catch (\Exception $e) { |
|
111 | - return new NotFoundResponse(); |
|
112 | - } |
|
113 | - } |
|
109 | + return new RedirectResponse($url); |
|
110 | + } catch (\Exception $e) { |
|
111 | + return new NotFoundResponse(); |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Marks the notification about a comment as processed |
|
117 | - */ |
|
118 | - protected function markProcessed(IComment $comment, IUser $currentUser): void { |
|
119 | - $notification = $this->notificationManager->createNotification(); |
|
120 | - $notification->setApp('comments') |
|
121 | - ->setObject('comment', $comment->getId()) |
|
122 | - ->setSubject('mention') |
|
123 | - ->setUser($currentUser->getUID()); |
|
124 | - $this->notificationManager->markProcessed($notification); |
|
125 | - } |
|
115 | + /** |
|
116 | + * Marks the notification about a comment as processed |
|
117 | + */ |
|
118 | + protected function markProcessed(IComment $comment, IUser $currentUser): void { |
|
119 | + $notification = $this->notificationManager->createNotification(); |
|
120 | + $notification->setApp('comments') |
|
121 | + ->setObject('comment', $comment->getId()) |
|
122 | + ->setSubject('mention') |
|
123 | + ->setUser($currentUser->getUID()); |
|
124 | + $this->notificationManager->markProcessed($notification); |
|
125 | + } |
|
126 | 126 | } |
@@ -44,91 +44,91 @@ |
||
44 | 44 | use OCP\IUserSession; |
45 | 45 | |
46 | 46 | class PreviewController extends Controller { |
47 | - /** @var IRootFolder */ |
|
48 | - private $rootFolder; |
|
49 | - |
|
50 | - /** @var ITrashManager */ |
|
51 | - private $trashManager; |
|
52 | - |
|
53 | - /** @var IUserSession */ |
|
54 | - private $userSession; |
|
55 | - |
|
56 | - /** @var IMimeTypeDetector */ |
|
57 | - private $mimeTypeDetector; |
|
58 | - |
|
59 | - /** @var IPreview */ |
|
60 | - private $previewManager; |
|
61 | - |
|
62 | - /** @var ITimeFactory */ |
|
63 | - private $time; |
|
64 | - |
|
65 | - public function __construct( |
|
66 | - string $appName, |
|
67 | - IRequest $request, |
|
68 | - IRootFolder $rootFolder, |
|
69 | - ITrashManager $trashManager, |
|
70 | - IUserSession $userSession, |
|
71 | - IMimeTypeDetector $mimeTypeDetector, |
|
72 | - IPreview $previewManager, |
|
73 | - ITimeFactory $time |
|
74 | - ) { |
|
75 | - parent::__construct($appName, $request); |
|
76 | - |
|
77 | - $this->trashManager = $trashManager; |
|
78 | - $this->rootFolder = $rootFolder; |
|
79 | - $this->userSession = $userSession; |
|
80 | - $this->mimeTypeDetector = $mimeTypeDetector; |
|
81 | - $this->previewManager = $previewManager; |
|
82 | - $this->time = $time; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @NoAdminRequired |
|
87 | - * @NoCSRFRequired |
|
88 | - * |
|
89 | - * @return DataResponse|Http\FileDisplayResponse |
|
90 | - */ |
|
91 | - public function getPreview( |
|
92 | - int $fileId = -1, |
|
93 | - int $x = 128, |
|
94 | - int $y = 128 |
|
95 | - ) { |
|
96 | - if ($fileId === -1 || $x === 0 || $y === 0) { |
|
97 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
98 | - } |
|
99 | - |
|
100 | - try { |
|
101 | - $file = $this->trashManager->getTrashNodeById($this->userSession->getUser(), $fileId); |
|
102 | - if ($file === null) { |
|
103 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
104 | - } |
|
105 | - if ($file instanceof Folder) { |
|
106 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
107 | - } |
|
108 | - |
|
109 | - $pathParts = pathinfo($file->getName()); |
|
110 | - $extension = $pathParts['extension'] ?? ''; |
|
111 | - $fileName = $pathParts['filename']; |
|
112 | - /* |
|
47 | + /** @var IRootFolder */ |
|
48 | + private $rootFolder; |
|
49 | + |
|
50 | + /** @var ITrashManager */ |
|
51 | + private $trashManager; |
|
52 | + |
|
53 | + /** @var IUserSession */ |
|
54 | + private $userSession; |
|
55 | + |
|
56 | + /** @var IMimeTypeDetector */ |
|
57 | + private $mimeTypeDetector; |
|
58 | + |
|
59 | + /** @var IPreview */ |
|
60 | + private $previewManager; |
|
61 | + |
|
62 | + /** @var ITimeFactory */ |
|
63 | + private $time; |
|
64 | + |
|
65 | + public function __construct( |
|
66 | + string $appName, |
|
67 | + IRequest $request, |
|
68 | + IRootFolder $rootFolder, |
|
69 | + ITrashManager $trashManager, |
|
70 | + IUserSession $userSession, |
|
71 | + IMimeTypeDetector $mimeTypeDetector, |
|
72 | + IPreview $previewManager, |
|
73 | + ITimeFactory $time |
|
74 | + ) { |
|
75 | + parent::__construct($appName, $request); |
|
76 | + |
|
77 | + $this->trashManager = $trashManager; |
|
78 | + $this->rootFolder = $rootFolder; |
|
79 | + $this->userSession = $userSession; |
|
80 | + $this->mimeTypeDetector = $mimeTypeDetector; |
|
81 | + $this->previewManager = $previewManager; |
|
82 | + $this->time = $time; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @NoAdminRequired |
|
87 | + * @NoCSRFRequired |
|
88 | + * |
|
89 | + * @return DataResponse|Http\FileDisplayResponse |
|
90 | + */ |
|
91 | + public function getPreview( |
|
92 | + int $fileId = -1, |
|
93 | + int $x = 128, |
|
94 | + int $y = 128 |
|
95 | + ) { |
|
96 | + if ($fileId === -1 || $x === 0 || $y === 0) { |
|
97 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
98 | + } |
|
99 | + |
|
100 | + try { |
|
101 | + $file = $this->trashManager->getTrashNodeById($this->userSession->getUser(), $fileId); |
|
102 | + if ($file === null) { |
|
103 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
104 | + } |
|
105 | + if ($file instanceof Folder) { |
|
106 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
107 | + } |
|
108 | + |
|
109 | + $pathParts = pathinfo($file->getName()); |
|
110 | + $extension = $pathParts['extension'] ?? ''; |
|
111 | + $fileName = $pathParts['filename']; |
|
112 | + /* |
|
113 | 113 | * Files in the root of the trashbin are timetamped. |
114 | 114 | * So we have to strip that in order to properly detect the mimetype of the file. |
115 | 115 | */ |
116 | - if (preg_match('/d\d+/', $extension)) { |
|
117 | - $mimeType = $this->mimeTypeDetector->detectPath($fileName); |
|
118 | - } else { |
|
119 | - $mimeType = $this->mimeTypeDetector->detectPath($file->getName()); |
|
120 | - } |
|
121 | - |
|
122 | - $f = $this->previewManager->getPreview($file, $x, $y, true, IPreview::MODE_FILL, $mimeType); |
|
123 | - $response = new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); |
|
124 | - |
|
125 | - // Cache previews for 24H |
|
126 | - $response->cacheFor(3600 * 24); |
|
127 | - return $response; |
|
128 | - } catch (NotFoundException $e) { |
|
129 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
130 | - } catch (\InvalidArgumentException $e) { |
|
131 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
132 | - } |
|
133 | - } |
|
116 | + if (preg_match('/d\d+/', $extension)) { |
|
117 | + $mimeType = $this->mimeTypeDetector->detectPath($fileName); |
|
118 | + } else { |
|
119 | + $mimeType = $this->mimeTypeDetector->detectPath($file->getName()); |
|
120 | + } |
|
121 | + |
|
122 | + $f = $this->previewManager->getPreview($file, $x, $y, true, IPreview::MODE_FILL, $mimeType); |
|
123 | + $response = new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); |
|
124 | + |
|
125 | + // Cache previews for 24H |
|
126 | + $response->cacheFor(3600 * 24); |
|
127 | + return $response; |
|
128 | + } catch (NotFoundException $e) { |
|
129 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
130 | + } catch (\InvalidArgumentException $e) { |
|
131 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
132 | + } |
|
133 | + } |
|
134 | 134 | } |
@@ -7,7 +7,7 @@ |
||
7 | 7 | require_once '../../lib/base.php'; |
8 | 8 | |
9 | 9 | $urlGenerator = \OC::$server->getURLGenerator(); |
10 | - header('Location: ' . $urlGenerator->getAbsoluteURL('/')); |
|
10 | + header('Location: '.$urlGenerator->getAbsoluteURL('/')); |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | // @codeCoverageIgnoreEnd |
@@ -4,11 +4,11 @@ |
||
4 | 4 | /** @var \OCP\Defaults $theme */ |
5 | 5 | // @codeCoverageIgnoreStart |
6 | 6 | if (!isset($_)) {//standalone page is not supported anymore - redirect to / |
7 | - require_once '../../lib/base.php'; |
|
7 | + require_once '../../lib/base.php'; |
|
8 | 8 | |
9 | - $urlGenerator = \OC::$server->getURLGenerator(); |
|
10 | - header('Location: ' . $urlGenerator->getAbsoluteURL('/')); |
|
11 | - exit; |
|
9 | + $urlGenerator = \OC::$server->getURLGenerator(); |
|
10 | + header('Location: ' . $urlGenerator->getAbsoluteURL('/')); |
|
11 | + exit; |
|
12 | 12 | } |
13 | 13 | // @codeCoverageIgnoreEnd |
14 | 14 | ?> |
@@ -14,10 +14,13 @@ |
||
14 | 14 | ?> |
15 | 15 | <?php if (isset($_['content'])): ?> |
16 | 16 | <?php print_unescaped($_['content']) ?> |
17 | -<?php else: ?> |
|
17 | +<?php else { |
|
18 | + : ?> |
|
18 | 19 | <div class="body-login-container update"> |
19 | 20 | <div class="icon-big icon-search"></div> |
20 | - <h2><?php p($l->t('Page not found')); ?></h2> |
|
21 | + <h2><?php p($l->t('Page not found')); |
|
22 | +} |
|
23 | +?></h2> |
|
21 | 24 | <p class="infogroup"><?php p($l->t('The page could not be found on the server.')); ?></p> |
22 | 25 | <p><a class="button primary" href="<?php p(\OC::$server->getURLGenerator()->linkTo('', 'index.php')) ?>"> |
23 | 26 | <?php p($l->t('Back to %s', [$theme->getName()])); ?> |
@@ -30,7 +30,7 @@ |
||
30 | 30 | <h2><?php p($l->t('Connect to your account')) ?></h2> |
31 | 31 | <p class="info"> |
32 | 32 | <?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [ |
33 | - '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
33 | + '<strong>'.\OCP\Util::sanitizeHTML($_['client']).'</strong>', |
|
34 | 34 | \OCP\Util::sanitizeHTML($_['instanceName']) |
35 | 35 | ])) ?> |
36 | 36 | </p> |
@@ -31,9 +31,9 @@ |
||
31 | 31 | <h2><?php p($l->t('Connect to your account')) ?></h2> |
32 | 32 | <p class="info"> |
33 | 33 | <?php print_unescaped($l->t('Please log in before granting %1$s access to your %2$s account.', [ |
34 | - '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
35 | - \OCP\Util::sanitizeHTML($_['instanceName']) |
|
36 | - ])) ?> |
|
34 | + '<strong>' . \OCP\Util::sanitizeHTML($_['client']) . '</strong>', |
|
35 | + \OCP\Util::sanitizeHTML($_['instanceName']) |
|
36 | + ])) ?> |
|
37 | 37 | </p> |
38 | 38 | |
39 | 39 | <div class="notecard warning"> |
@@ -17,8 +17,11 @@ discard block |
||
17 | 17 | <?php if (is_array($err)):?> |
18 | 18 | <?php p($err['error']); ?> |
19 | 19 | <span class='hint'><?php p($err['hint']); ?></span> |
20 | - <?php else: ?> |
|
21 | - <?php p($err); ?> |
|
20 | + <?php else { |
|
21 | + : ?> |
|
22 | + <?php p($err); |
|
23 | +} |
|
24 | +?> |
|
22 | 25 | <?php endif; ?> |
23 | 26 | </p> |
24 | 27 | <?php endforeach; ?> |
@@ -90,11 +93,14 @@ discard block |
||
90 | 93 | <?php p($l->t('For more details check out the documentation.')); ?> ↗</a> |
91 | 94 | </p> |
92 | 95 | <input type="hidden" id="dbtype" name="dbtype" value="<?php p($type) ?>"> |
93 | - <?php else: ?> |
|
96 | + <?php else { |
|
97 | + : ?> |
|
94 | 98 | <input type="radio" name="dbtype" value="<?php p($type) ?>" id="<?php p($type) ?>" |
95 | 99 | <?php print_unescaped($_['dbtype'] === $type ? 'checked="checked" ' : '') ?>/> |
96 | 100 | <label class="<?php p($type) ?>" for="<?php p($type) ?>"><?php p($label) ?></label> |
97 | - <?php endif; ?> |
|
101 | + <?php endif; |
|
102 | +} |
|
103 | +?> |
|
98 | 104 | <?php endforeach; ?> |
99 | 105 | </div> |
100 | 106 | </fieldset> |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | <legend><strong><?php p($l->t('Security warning'));?></strong></legend> |
28 | 28 | <p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.'));?><br> |
29 | 29 | <?php print_unescaped($l->t( |
30 | - 'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.', |
|
31 | - [link_to_docs('admin-install')] |
|
32 | - )); ?></p> |
|
30 | + 'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.', |
|
31 | + [link_to_docs('admin-install')] |
|
32 | + )); ?></p> |
|
33 | 33 | </fieldset> |
34 | 34 | <?php endif; ?> |
35 | 35 | <fieldset id="adminaccount"> |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | <?php if (!$_['dbIsSet'] or count($_['errors']) > 0): ?> |
74 | 74 | <fieldset id='databaseBackend'> |
75 | 75 | <?php if ($_['hasMySQL'] or $_['hasPostgreSQL'] or $_['hasOracle']) { |
76 | - $hasOtherDB = true; |
|
77 | - } else { |
|
78 | - $hasOtherDB = false; |
|
79 | - } //other than SQLite?> |
|
76 | + $hasOtherDB = true; |
|
77 | + } else { |
|
78 | + $hasOtherDB = false; |
|
79 | + } //other than SQLite?> |
|
80 | 80 | <legend><?php p($l->t('Configure the database')); ?></legend> |
81 | 81 | <div id="selectDbType"> |
82 | 82 | <?php foreach ($_['databases'] as $type => $label): ?> |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | <input type="hidden" name="install" value="true"> |
10 | 10 | <?php if (count($_['errors']) > 0): ?> |
11 | 11 | <fieldset class="warning"> |
12 | - <legend><strong><?php p($l->t('Error'));?></strong></legend> |
|
12 | + <legend><strong><?php p($l->t('Error')); ?></strong></legend> |
|
13 | 13 | <?php foreach ($_['errors'] as $err): ?> |
14 | 14 | <p> |
15 | 15 | <?php if (is_array($err)):?> |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | <?php endif; ?> |
25 | 25 | <?php if (!$_['htaccessWorking']): ?> |
26 | 26 | <fieldset class="warning"> |
27 | - <legend><strong><?php p($l->t('Security warning'));?></strong></legend> |
|
28 | - <p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.'));?><br> |
|
27 | + <legend><strong><?php p($l->t('Security warning')); ?></strong></legend> |
|
28 | + <p><?php p($l->t('Your data directory and files are probably accessible from the internet because the .htaccess file does not work.')); ?><br> |
|
29 | 29 | <?php print_unescaped($l->t( |
30 | 30 | 'For information how to properly configure your server, please see the <a href="%s" target="_blank" rel="noreferrer noopener">documentation</a>.', |
31 | 31 | [link_to_docs('admin-install')] |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | <?php if (!$_['dbIsSet'] or count($_['errors']) > 0): ?> |
149 | 149 | <div id="sqliteInformation" class="notecard warning"> |
150 | - <legend><?php p($l->t('Performance warning'));?></legend> |
|
151 | - <p><?php p($l->t('You chose SQLite as database.'));?></p> |
|
152 | - <p><?php p($l->t('SQLite should only be used for minimal and development instances. For production we recommend a different database backend.'));?></p> |
|
150 | + <legend><?php p($l->t('Performance warning')); ?></legend> |
|
151 | + <p><?php p($l->t('You chose SQLite as database.')); ?></p> |
|
152 | + <p><?php p($l->t('SQLite should only be used for minimal and development instances. For production we recommend a different database backend.')); ?></p> |
|
153 | 153 | <p><?php p($l->t('If you use clients for file syncing, the use of SQLite is highly discouraged.')); ?></p> |
154 | 154 | </div> |
155 | 155 | <?php endif ?> |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | <p class="info"> |
162 | 162 | <span class="icon-info-white"></span> |
163 | - <?php p($l->t('Need help?'));?> |
|
164 | - <a target="_blank" rel="noreferrer noopener" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation'));?> ↗</a> |
|
163 | + <?php p($l->t('Need help?')); ?> |
|
164 | + <a target="_blank" rel="noreferrer noopener" href="<?php p(link_to_docs('admin-install')); ?>"><?php p($l->t('See the documentation')); ?> ↗</a> |
|
165 | 165 | </p> |
166 | 166 | </form> |
@@ -6,7 +6,7 @@ |
||
6 | 6 | <p><?php p($error['error']) ?></p> |
7 | 7 | <?php if (isset($error['hint']) && $error['hint']): ?> |
8 | 8 | <p class='hint'><?php p($error['hint']) ?></p> |
9 | - <?php endif;?> |
|
9 | + <?php endif; ?> |
|
10 | 10 | </li> |
11 | 11 | <?php endforeach ?> |
12 | 12 | </ul> |
@@ -27,11 +27,15 @@ discard block |
||
27 | 27 | <?php p($l->t('Set up two-factor authentication')) ?> |
28 | 28 | </a> |
29 | 29 | <?php } ?> |
30 | - <?php else: ?> |
|
30 | + <?php else { |
|
31 | + : ?> |
|
31 | 32 | <strong><?php p($l->t('Two-factor authentication is enforced but has not been configured on your account. Use one of your backup codes to log in or contact your admin for assistance.')) ?></strong> |
32 | - <?php endif; ?> |
|
33 | + <?php endif; |
|
34 | +} |
|
35 | +?> |
|
33 | 36 | </p> |
34 | - <?php else: ?> |
|
37 | + <?php else { |
|
38 | + : ?> |
|
35 | 39 | <ul> |
36 | 40 | <?php foreach ($_['providers'] as $provider): ?> |
37 | 41 | <li> |
@@ -45,6 +49,7 @@ discard block |
||
45 | 49 | <?php |
46 | 50 | if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
47 | 51 | $icon = $provider->getLightIcon(); |
52 | +} |
|
48 | 53 | } else { |
49 | 54 | $icon = image_path('core', 'actions/password-white.svg'); |
50 | 55 | } |
@@ -61,7 +66,8 @@ discard block |
||
61 | 66 | <?php endif ?> |
62 | 67 | <?php if (!is_null($_['backupProvider'])): ?> |
63 | 68 | <p> |
64 | - <a class="<?php if ($noProviders): ?>button primary two-factor-primary<?php else: ?>two-factor-secondary<?php endif ?>" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge', |
|
69 | + <a class="<?php if ($noProviders): ?>button primary two-factor-primary<?php else { |
|
70 | + : ?>two-factor-secondary<?php endif ?>" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge', |
|
65 | 71 | [ |
66 | 72 | 'challengeProviderId' => $_['backupProvider']->getId(), |
67 | 73 | 'redirect_url' => $_['redirect_url'], |
@@ -70,7 +76,9 @@ discard block |
||
70 | 76 | <?php p($l->t('Use backup code')) ?> |
71 | 77 | </a> |
72 | 78 | </p> |
73 | - <?php endif; ?> |
|
79 | + <?php endif; |
|
80 | +} |
|
81 | +?> |
|
74 | 82 | <p><a class="two-factor-secondary" href="<?php print_unescaped($_['logout_url']); ?>"> |
75 | 83 | <?php p($l->t('Cancel login')) ?> |
76 | 84 | </a></p> |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | <?php } else { ?> |
21 | 21 | <strong><?php p($l->t('Two-factor authentication is enforced but has not been configured on your account. Please continue to setup two-factor authentication.')) ?></strong> |
22 | 22 | <a class="button primary two-factor-primary" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.setupProviders', |
23 | - [ |
|
24 | - 'redirect_url' => $_['redirect_url'], |
|
25 | - ] |
|
26 | - )) ?>"> |
|
23 | + [ |
|
24 | + 'redirect_url' => $_['redirect_url'], |
|
25 | + ] |
|
26 | + )) ?>"> |
|
27 | 27 | <?php p($l->t('Set up two-factor authentication')) ?> |
28 | 28 | </a> |
29 | 29 | <?php } ?> |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | <li> |
38 | 38 | <a class="two-factor-provider" |
39 | 39 | href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge', |
40 | - [ |
|
41 | - 'challengeProviderId' => $provider->getId(), |
|
42 | - 'redirect_url' => $_['redirect_url'], |
|
43 | - ] |
|
44 | - )) ?>"> |
|
40 | + [ |
|
41 | + 'challengeProviderId' => $provider->getId(), |
|
42 | + 'redirect_url' => $_['redirect_url'], |
|
43 | + ] |
|
44 | + )) ?>"> |
|
45 | 45 | <?php |
46 | - if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
|
47 | - $icon = $provider->getLightIcon(); |
|
48 | - } else { |
|
49 | - $icon = image_path('core', 'actions/password-white.svg'); |
|
50 | - } |
|
51 | - ?> |
|
46 | + if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) { |
|
47 | + $icon = $provider->getLightIcon(); |
|
48 | + } else { |
|
49 | + $icon = image_path('core', 'actions/password-white.svg'); |
|
50 | + } |
|
51 | + ?> |
|
52 | 52 | <img src="<?php p($icon) ?>" alt="" /> |
53 | 53 | <div> |
54 | 54 | <h3><?php p($provider->getDisplayName()) ?></h3> |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | <?php if (!is_null($_['backupProvider'])): ?> |
63 | 63 | <p> |
64 | 64 | <a class="<?php if ($noProviders): ?>button primary two-factor-primary<?php else: ?>two-factor-secondary<?php endif ?>" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge', |
65 | - [ |
|
66 | - 'challengeProviderId' => $_['backupProvider']->getId(), |
|
67 | - 'redirect_url' => $_['redirect_url'], |
|
68 | - ] |
|
69 | - )) ?>"> |
|
65 | + [ |
|
66 | + 'challengeProviderId' => $_['backupProvider']->getId(), |
|
67 | + 'redirect_url' => $_['redirect_url'], |
|
68 | + ] |
|
69 | + )) ?>"> |
|
70 | 70 | <?php p($l->t('Use backup code')) ?> |
71 | 71 | </a> |
72 | 72 | </p> |