@@ -32,56 +32,56 @@ |
||
32 | 32 | * @since 11.0.0 |
33 | 33 | */ |
34 | 34 | interface ISimpleFolder { |
35 | - /** |
|
36 | - * Get all the files in a folder |
|
37 | - * |
|
38 | - * @return ISimpleFile[] |
|
39 | - * @since 11.0.0 |
|
40 | - */ |
|
41 | - public function getDirectoryListing(); |
|
35 | + /** |
|
36 | + * Get all the files in a folder |
|
37 | + * |
|
38 | + * @return ISimpleFile[] |
|
39 | + * @since 11.0.0 |
|
40 | + */ |
|
41 | + public function getDirectoryListing(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Check if a file with $name exists |
|
45 | - * |
|
46 | - * @param string $name |
|
47 | - * @return bool |
|
48 | - * @since 11.0.0 |
|
49 | - */ |
|
50 | - public function fileExists($name); |
|
43 | + /** |
|
44 | + * Check if a file with $name exists |
|
45 | + * |
|
46 | + * @param string $name |
|
47 | + * @return bool |
|
48 | + * @since 11.0.0 |
|
49 | + */ |
|
50 | + public function fileExists($name); |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the file named $name from the folder |
|
54 | - * |
|
55 | - * @param string $name |
|
56 | - * @return ISimpleFile |
|
57 | - * @throws NotFoundException |
|
58 | - * @since 11.0.0 |
|
59 | - */ |
|
60 | - public function getFile($name); |
|
52 | + /** |
|
53 | + * Get the file named $name from the folder |
|
54 | + * |
|
55 | + * @param string $name |
|
56 | + * @return ISimpleFile |
|
57 | + * @throws NotFoundException |
|
58 | + * @since 11.0.0 |
|
59 | + */ |
|
60 | + public function getFile($name); |
|
61 | 61 | |
62 | - /** |
|
63 | - * Creates a new file with $name in the folder |
|
64 | - * |
|
65 | - * @param string $name |
|
66 | - * @return ISimpleFile |
|
67 | - * @throws NotPermittedException |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function newFile($name); |
|
62 | + /** |
|
63 | + * Creates a new file with $name in the folder |
|
64 | + * |
|
65 | + * @param string $name |
|
66 | + * @return ISimpleFile |
|
67 | + * @throws NotPermittedException |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function newFile($name); |
|
71 | 71 | |
72 | - /** |
|
73 | - * Remove the folder and all the files in it |
|
74 | - * |
|
75 | - * @throws NotPermittedException |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function delete(); |
|
72 | + /** |
|
73 | + * Remove the folder and all the files in it |
|
74 | + * |
|
75 | + * @throws NotPermittedException |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function delete(); |
|
79 | 79 | |
80 | - /** |
|
81 | - * Get the folder name |
|
82 | - * |
|
83 | - * @return string |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function getName(); |
|
80 | + /** |
|
81 | + * Get the folder name |
|
82 | + * |
|
83 | + * @return string |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function getName(); |
|
87 | 87 | } |
@@ -27,15 +27,15 @@ |
||
27 | 27 | */ |
28 | 28 | class StorageConnectionException extends StorageNotAvailableException { |
29 | 29 | |
30 | - /** |
|
31 | - * StorageConnectionException constructor. |
|
32 | - * |
|
33 | - * @param string $message |
|
34 | - * @param \Exception|null $previous |
|
35 | - * @since 9.0.0 |
|
36 | - */ |
|
37 | - public function __construct($message = '', \Exception $previous = null) { |
|
38 | - $l = \OC::$server->getL10N('core'); |
|
39 | - parent::__construct($l->t('Storage connection error. %s', [$message]), self::STATUS_NETWORK_ERROR, $previous); |
|
40 | - } |
|
30 | + /** |
|
31 | + * StorageConnectionException constructor. |
|
32 | + * |
|
33 | + * @param string $message |
|
34 | + * @param \Exception|null $previous |
|
35 | + * @since 9.0.0 |
|
36 | + */ |
|
37 | + public function __construct($message = '', \Exception $previous = null) { |
|
38 | + $l = \OC::$server->getL10N('core'); |
|
39 | + parent::__construct($l->t('Storage connection error. %s', [$message]), self::STATUS_NETWORK_ERROR, $previous); |
|
40 | + } |
|
41 | 41 | } |
@@ -37,144 +37,144 @@ |
||
37 | 37 | * @package OC\Settings\Controller |
38 | 38 | */ |
39 | 39 | class CertificateController extends Controller { |
40 | - /** @var ICertificateManager */ |
|
41 | - private $userCertificateManager; |
|
42 | - /** @var ICertificateManager */ |
|
43 | - private $systemCertificateManager; |
|
44 | - /** @var IL10N */ |
|
45 | - private $l10n; |
|
46 | - /** @var IAppManager */ |
|
47 | - private $appManager; |
|
48 | - |
|
49 | - /** |
|
50 | - * @param string $appName |
|
51 | - * @param IRequest $request |
|
52 | - * @param ICertificateManager $userCertificateManager |
|
53 | - * @param ICertificateManager $systemCertificateManager |
|
54 | - * @param IL10N $l10n |
|
55 | - * @param IAppManager $appManager |
|
56 | - */ |
|
57 | - public function __construct($appName, |
|
58 | - IRequest $request, |
|
59 | - ICertificateManager $userCertificateManager, |
|
60 | - ICertificateManager $systemCertificateManager, |
|
61 | - IL10N $l10n, |
|
62 | - IAppManager $appManager) { |
|
63 | - parent::__construct($appName, $request); |
|
64 | - $this->userCertificateManager = $userCertificateManager; |
|
65 | - $this->systemCertificateManager = $systemCertificateManager; |
|
66 | - $this->l10n = $l10n; |
|
67 | - $this->appManager = $appManager; |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Add a new personal root certificate to the users' trust store |
|
72 | - * |
|
73 | - * @NoAdminRequired |
|
74 | - * @NoSubadminRequired |
|
75 | - * @return DataResponse |
|
76 | - */ |
|
77 | - public function addPersonalRootCertificate() { |
|
78 | - return $this->addCertificate($this->userCertificateManager); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Add a new root certificate to a trust store |
|
83 | - * |
|
84 | - * @param ICertificateManager $certificateManager |
|
85 | - * @return DataResponse |
|
86 | - */ |
|
87 | - private function addCertificate(ICertificateManager $certificateManager) { |
|
88 | - $headers = []; |
|
89 | - |
|
90 | - if ($this->isCertificateImportAllowed() === false) { |
|
91 | - return new DataResponse(['message' => 'Individual certificate management disabled'], Http::STATUS_FORBIDDEN, $headers); |
|
92 | - } |
|
93 | - |
|
94 | - $file = $this->request->getUploadedFile('rootcert_import'); |
|
95 | - if (empty($file)) { |
|
96 | - return new DataResponse(['message' => 'No file uploaded'], Http::STATUS_UNPROCESSABLE_ENTITY, $headers); |
|
97 | - } |
|
98 | - |
|
99 | - try { |
|
100 | - $certificate = $certificateManager->addCertificate(file_get_contents($file['tmp_name']), $file['name']); |
|
101 | - return new DataResponse( |
|
102 | - [ |
|
103 | - 'name' => $certificate->getName(), |
|
104 | - 'commonName' => $certificate->getCommonName(), |
|
105 | - 'organization' => $certificate->getOrganization(), |
|
106 | - 'validFrom' => $certificate->getIssueDate()->getTimestamp(), |
|
107 | - 'validTill' => $certificate->getExpireDate()->getTimestamp(), |
|
108 | - 'validFromString' => $this->l10n->l('date', $certificate->getIssueDate()), |
|
109 | - 'validTillString' => $this->l10n->l('date', $certificate->getExpireDate()), |
|
110 | - 'issuer' => $certificate->getIssuerName(), |
|
111 | - 'issuerOrganization' => $certificate->getIssuerOrganization(), |
|
112 | - ], |
|
113 | - Http::STATUS_OK, |
|
114 | - $headers |
|
115 | - ); |
|
116 | - } catch (\Exception $e) { |
|
117 | - return new DataResponse(['An error occurred.'], Http::STATUS_UNPROCESSABLE_ENTITY, $headers); |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Removes a personal root certificate from the users' trust store |
|
123 | - * |
|
124 | - * @NoAdminRequired |
|
125 | - * @NoSubadminRequired |
|
126 | - * @param string $certificateIdentifier |
|
127 | - * @return DataResponse |
|
128 | - */ |
|
129 | - public function removePersonalRootCertificate($certificateIdentifier) { |
|
130 | - |
|
131 | - if ($this->isCertificateImportAllowed() === false) { |
|
132 | - return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); |
|
133 | - } |
|
134 | - |
|
135 | - $this->userCertificateManager->removeCertificate($certificateIdentifier); |
|
136 | - return new DataResponse(); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * check if certificate import is allowed |
|
141 | - * |
|
142 | - * @return bool |
|
143 | - */ |
|
144 | - protected function isCertificateImportAllowed() { |
|
145 | - $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external'); |
|
146 | - if ($externalStorageEnabled) { |
|
147 | - /** @var \OCA\Files_External\Service\BackendService $backendService */ |
|
148 | - $backendService = \OC_Mount_Config::$app->getContainer()->query('\OCA\Files_External\Service\BackendService'); |
|
149 | - if ($backendService->isUserMountingAllowed()) { |
|
150 | - return true; |
|
151 | - } |
|
152 | - } |
|
153 | - return false; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Add a new personal root certificate to the system's trust store |
|
158 | - * |
|
159 | - * @return DataResponse |
|
160 | - */ |
|
161 | - public function addSystemRootCertificate() { |
|
162 | - return $this->addCertificate($this->systemCertificateManager); |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Removes a personal root certificate from the users' trust store |
|
167 | - * |
|
168 | - * @param string $certificateIdentifier |
|
169 | - * @return DataResponse |
|
170 | - */ |
|
171 | - public function removeSystemRootCertificate($certificateIdentifier) { |
|
172 | - |
|
173 | - if ($this->isCertificateImportAllowed() === false) { |
|
174 | - return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); |
|
175 | - } |
|
176 | - |
|
177 | - $this->systemCertificateManager->removeCertificate($certificateIdentifier); |
|
178 | - return new DataResponse(); |
|
179 | - } |
|
40 | + /** @var ICertificateManager */ |
|
41 | + private $userCertificateManager; |
|
42 | + /** @var ICertificateManager */ |
|
43 | + private $systemCertificateManager; |
|
44 | + /** @var IL10N */ |
|
45 | + private $l10n; |
|
46 | + /** @var IAppManager */ |
|
47 | + private $appManager; |
|
48 | + |
|
49 | + /** |
|
50 | + * @param string $appName |
|
51 | + * @param IRequest $request |
|
52 | + * @param ICertificateManager $userCertificateManager |
|
53 | + * @param ICertificateManager $systemCertificateManager |
|
54 | + * @param IL10N $l10n |
|
55 | + * @param IAppManager $appManager |
|
56 | + */ |
|
57 | + public function __construct($appName, |
|
58 | + IRequest $request, |
|
59 | + ICertificateManager $userCertificateManager, |
|
60 | + ICertificateManager $systemCertificateManager, |
|
61 | + IL10N $l10n, |
|
62 | + IAppManager $appManager) { |
|
63 | + parent::__construct($appName, $request); |
|
64 | + $this->userCertificateManager = $userCertificateManager; |
|
65 | + $this->systemCertificateManager = $systemCertificateManager; |
|
66 | + $this->l10n = $l10n; |
|
67 | + $this->appManager = $appManager; |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Add a new personal root certificate to the users' trust store |
|
72 | + * |
|
73 | + * @NoAdminRequired |
|
74 | + * @NoSubadminRequired |
|
75 | + * @return DataResponse |
|
76 | + */ |
|
77 | + public function addPersonalRootCertificate() { |
|
78 | + return $this->addCertificate($this->userCertificateManager); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Add a new root certificate to a trust store |
|
83 | + * |
|
84 | + * @param ICertificateManager $certificateManager |
|
85 | + * @return DataResponse |
|
86 | + */ |
|
87 | + private function addCertificate(ICertificateManager $certificateManager) { |
|
88 | + $headers = []; |
|
89 | + |
|
90 | + if ($this->isCertificateImportAllowed() === false) { |
|
91 | + return new DataResponse(['message' => 'Individual certificate management disabled'], Http::STATUS_FORBIDDEN, $headers); |
|
92 | + } |
|
93 | + |
|
94 | + $file = $this->request->getUploadedFile('rootcert_import'); |
|
95 | + if (empty($file)) { |
|
96 | + return new DataResponse(['message' => 'No file uploaded'], Http::STATUS_UNPROCESSABLE_ENTITY, $headers); |
|
97 | + } |
|
98 | + |
|
99 | + try { |
|
100 | + $certificate = $certificateManager->addCertificate(file_get_contents($file['tmp_name']), $file['name']); |
|
101 | + return new DataResponse( |
|
102 | + [ |
|
103 | + 'name' => $certificate->getName(), |
|
104 | + 'commonName' => $certificate->getCommonName(), |
|
105 | + 'organization' => $certificate->getOrganization(), |
|
106 | + 'validFrom' => $certificate->getIssueDate()->getTimestamp(), |
|
107 | + 'validTill' => $certificate->getExpireDate()->getTimestamp(), |
|
108 | + 'validFromString' => $this->l10n->l('date', $certificate->getIssueDate()), |
|
109 | + 'validTillString' => $this->l10n->l('date', $certificate->getExpireDate()), |
|
110 | + 'issuer' => $certificate->getIssuerName(), |
|
111 | + 'issuerOrganization' => $certificate->getIssuerOrganization(), |
|
112 | + ], |
|
113 | + Http::STATUS_OK, |
|
114 | + $headers |
|
115 | + ); |
|
116 | + } catch (\Exception $e) { |
|
117 | + return new DataResponse(['An error occurred.'], Http::STATUS_UNPROCESSABLE_ENTITY, $headers); |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Removes a personal root certificate from the users' trust store |
|
123 | + * |
|
124 | + * @NoAdminRequired |
|
125 | + * @NoSubadminRequired |
|
126 | + * @param string $certificateIdentifier |
|
127 | + * @return DataResponse |
|
128 | + */ |
|
129 | + public function removePersonalRootCertificate($certificateIdentifier) { |
|
130 | + |
|
131 | + if ($this->isCertificateImportAllowed() === false) { |
|
132 | + return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); |
|
133 | + } |
|
134 | + |
|
135 | + $this->userCertificateManager->removeCertificate($certificateIdentifier); |
|
136 | + return new DataResponse(); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * check if certificate import is allowed |
|
141 | + * |
|
142 | + * @return bool |
|
143 | + */ |
|
144 | + protected function isCertificateImportAllowed() { |
|
145 | + $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external'); |
|
146 | + if ($externalStorageEnabled) { |
|
147 | + /** @var \OCA\Files_External\Service\BackendService $backendService */ |
|
148 | + $backendService = \OC_Mount_Config::$app->getContainer()->query('\OCA\Files_External\Service\BackendService'); |
|
149 | + if ($backendService->isUserMountingAllowed()) { |
|
150 | + return true; |
|
151 | + } |
|
152 | + } |
|
153 | + return false; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Add a new personal root certificate to the system's trust store |
|
158 | + * |
|
159 | + * @return DataResponse |
|
160 | + */ |
|
161 | + public function addSystemRootCertificate() { |
|
162 | + return $this->addCertificate($this->systemCertificateManager); |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Removes a personal root certificate from the users' trust store |
|
167 | + * |
|
168 | + * @param string $certificateIdentifier |
|
169 | + * @return DataResponse |
|
170 | + */ |
|
171 | + public function removeSystemRootCertificate($certificateIdentifier) { |
|
172 | + |
|
173 | + if ($this->isCertificateImportAllowed() === false) { |
|
174 | + return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); |
|
175 | + } |
|
176 | + |
|
177 | + $this->systemCertificateManager->removeCertificate($certificateIdentifier); |
|
178 | + return new DataResponse(); |
|
179 | + } |
|
180 | 180 | } |
@@ -33,46 +33,46 @@ |
||
33 | 33 | |
34 | 34 | class ContactsMenuController extends Controller { |
35 | 35 | |
36 | - /** @var Manager */ |
|
37 | - private $manager; |
|
36 | + /** @var Manager */ |
|
37 | + private $manager; |
|
38 | 38 | |
39 | - /** @var IUserSession */ |
|
40 | - private $userSession; |
|
39 | + /** @var IUserSession */ |
|
40 | + private $userSession; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IRequest $request |
|
44 | - * @param IUserSession $userSession |
|
45 | - * @param Manager $manager |
|
46 | - */ |
|
47 | - public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) { |
|
48 | - parent::__construct('core', $request); |
|
49 | - $this->userSession = $userSession; |
|
50 | - $this->manager = $manager; |
|
51 | - } |
|
42 | + /** |
|
43 | + * @param IRequest $request |
|
44 | + * @param IUserSession $userSession |
|
45 | + * @param Manager $manager |
|
46 | + */ |
|
47 | + public function __construct(IRequest $request, IUserSession $userSession, Manager $manager) { |
|
48 | + parent::__construct('core', $request); |
|
49 | + $this->userSession = $userSession; |
|
50 | + $this->manager = $manager; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @NoAdminRequired |
|
55 | - * |
|
56 | - * @param string|null filter |
|
57 | - * @return \JsonSerializable[] |
|
58 | - */ |
|
59 | - public function index($filter = null) { |
|
60 | - return $this->manager->getEntries($this->userSession->getUser(), $filter); |
|
61 | - } |
|
53 | + /** |
|
54 | + * @NoAdminRequired |
|
55 | + * |
|
56 | + * @param string|null filter |
|
57 | + * @return \JsonSerializable[] |
|
58 | + */ |
|
59 | + public function index($filter = null) { |
|
60 | + return $this->manager->getEntries($this->userSession->getUser(), $filter); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @NoAdminRequired |
|
65 | - * |
|
66 | - * @param integer $shareType |
|
67 | - * @param string $shareWith |
|
68 | - * @return JSONResponse|\JsonSerializable |
|
69 | - */ |
|
70 | - public function findOne($shareType, $shareWith) { |
|
71 | - $contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith); |
|
63 | + /** |
|
64 | + * @NoAdminRequired |
|
65 | + * |
|
66 | + * @param integer $shareType |
|
67 | + * @param string $shareWith |
|
68 | + * @return JSONResponse|\JsonSerializable |
|
69 | + */ |
|
70 | + public function findOne($shareType, $shareWith) { |
|
71 | + $contact = $this->manager->findOne($this->userSession->getUser(), $shareType, $shareWith); |
|
72 | 72 | |
73 | - if ($contact) { |
|
74 | - return $contact; |
|
75 | - } |
|
76 | - return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
77 | - } |
|
73 | + if ($contact) { |
|
74 | + return $contact; |
|
75 | + } |
|
76 | + return new JSONResponse([], Http::STATUS_NOT_FOUND); |
|
77 | + } |
|
78 | 78 | } |
@@ -32,52 +32,52 @@ |
||
32 | 32 | |
33 | 33 | class Notifier implements INotifier { |
34 | 34 | |
35 | - /** @var IFactory */ |
|
36 | - protected $l10nFactory; |
|
35 | + /** @var IFactory */ |
|
36 | + protected $l10nFactory; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param IFactory $l10nFactory |
|
40 | - */ |
|
41 | - public function __construct(\OCP\L10N\IFactory $l10nFactory) { |
|
42 | - $this->l10nFactory = $l10nFactory; |
|
43 | - } |
|
38 | + /** |
|
39 | + * @param IFactory $l10nFactory |
|
40 | + */ |
|
41 | + public function __construct(\OCP\L10N\IFactory $l10nFactory) { |
|
42 | + $this->l10nFactory = $l10nFactory; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param INotification $notification |
|
47 | - * @param string $languageCode The code of the language that should be used to prepare the notification |
|
48 | - * @return INotification |
|
49 | - * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
50 | - */ |
|
51 | - public function prepare(INotification $notification, $languageCode) { |
|
52 | - if ($notification->getApp() !== 'user_ldap') { |
|
53 | - // Not my app => throw |
|
54 | - throw new \InvalidArgumentException(); |
|
55 | - } |
|
45 | + /** |
|
46 | + * @param INotification $notification |
|
47 | + * @param string $languageCode The code of the language that should be used to prepare the notification |
|
48 | + * @return INotification |
|
49 | + * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
50 | + */ |
|
51 | + public function prepare(INotification $notification, $languageCode) { |
|
52 | + if ($notification->getApp() !== 'user_ldap') { |
|
53 | + // Not my app => throw |
|
54 | + throw new \InvalidArgumentException(); |
|
55 | + } |
|
56 | 56 | |
57 | - // Read the language from the notification |
|
58 | - $l = $this->l10nFactory->get('user_ldap', $languageCode); |
|
57 | + // Read the language from the notification |
|
58 | + $l = $this->l10nFactory->get('user_ldap', $languageCode); |
|
59 | 59 | |
60 | - switch ($notification->getSubject()) { |
|
61 | - // Deal with known subjects |
|
62 | - case 'pwd_exp_warn_days': |
|
63 | - $params = $notification->getSubjectParameters(); |
|
64 | - $days = (int) $params[0]; |
|
65 | - if ($days === 2) { |
|
66 | - $notification->setParsedSubject($l->t('Your password will expire tomorrow.')); |
|
67 | - } else if ($days === 1) { |
|
68 | - $notification->setParsedSubject($l->t('Your password will expire today.')); |
|
69 | - } else { |
|
70 | - $notification->setParsedSubject($l->n( |
|
71 | - 'Your password will expire within %n day.', |
|
72 | - 'Your password will expire within %n days.', |
|
73 | - $days |
|
74 | - )); |
|
75 | - } |
|
76 | - return $notification; |
|
60 | + switch ($notification->getSubject()) { |
|
61 | + // Deal with known subjects |
|
62 | + case 'pwd_exp_warn_days': |
|
63 | + $params = $notification->getSubjectParameters(); |
|
64 | + $days = (int) $params[0]; |
|
65 | + if ($days === 2) { |
|
66 | + $notification->setParsedSubject($l->t('Your password will expire tomorrow.')); |
|
67 | + } else if ($days === 1) { |
|
68 | + $notification->setParsedSubject($l->t('Your password will expire today.')); |
|
69 | + } else { |
|
70 | + $notification->setParsedSubject($l->n( |
|
71 | + 'Your password will expire within %n day.', |
|
72 | + 'Your password will expire within %n days.', |
|
73 | + $days |
|
74 | + )); |
|
75 | + } |
|
76 | + return $notification; |
|
77 | 77 | |
78 | - default: |
|
79 | - // Unknown subject => Unknown notification => throw |
|
80 | - throw new \InvalidArgumentException(); |
|
81 | - } |
|
82 | - } |
|
78 | + default: |
|
79 | + // Unknown subject => Unknown notification => throw |
|
80 | + throw new \InvalidArgumentException(); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | return [ |
24 | - 'routes' => [ |
|
25 | - ['name' => 'Notifications#view', 'url' => '/notifications/view/{id}', 'verb' => 'GET'], |
|
26 | - ] |
|
24 | + 'routes' => [ |
|
25 | + ['name' => 'Notifications#view', 'url' => '/notifications/view/{id}', 'verb' => 'GET'], |
|
26 | + ] |
|
27 | 27 | ]; |
@@ -57,110 +57,110 @@ |
||
57 | 57 | */ |
58 | 58 | class Backend implements \JsonSerializable { |
59 | 59 | |
60 | - use VisibilityTrait; |
|
61 | - use FrontendDefinitionTrait; |
|
62 | - use PriorityTrait; |
|
63 | - use DependencyTrait; |
|
64 | - use StorageModifierTrait; |
|
65 | - use IdentifierTrait; |
|
66 | - |
|
67 | - /** @var string storage class */ |
|
68 | - private $storageClass; |
|
69 | - |
|
70 | - /** @var array 'scheme' => true, supported authentication schemes */ |
|
71 | - private $authSchemes = []; |
|
72 | - |
|
73 | - /** @var AuthMechanism|callable authentication mechanism fallback */ |
|
74 | - private $legacyAuthMechanism; |
|
75 | - |
|
76 | - /** |
|
77 | - * @return string |
|
78 | - */ |
|
79 | - public function getStorageClass() { |
|
80 | - return $this->storageClass; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string $class |
|
85 | - * @return $this |
|
86 | - */ |
|
87 | - public function setStorageClass($class) { |
|
88 | - $this->storageClass = $class; |
|
89 | - return $this; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return array |
|
94 | - */ |
|
95 | - public function getAuthSchemes() { |
|
96 | - if (empty($this->authSchemes)) { |
|
97 | - return [AuthMechanism::SCHEME_NULL => true]; |
|
98 | - } |
|
99 | - return $this->authSchemes; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $scheme |
|
104 | - * @return self |
|
105 | - */ |
|
106 | - public function addAuthScheme($scheme) { |
|
107 | - $this->authSchemes[$scheme] = true; |
|
108 | - return $this; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @param array $parameters storage parameters, for dynamic mechanism selection |
|
113 | - * @return AuthMechanism |
|
114 | - */ |
|
115 | - public function getLegacyAuthMechanism(array $parameters = []) { |
|
116 | - if (is_callable($this->legacyAuthMechanism)) { |
|
117 | - return call_user_func($this->legacyAuthMechanism, $parameters); |
|
118 | - } |
|
119 | - return $this->legacyAuthMechanism; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @param AuthMechanism $authMechanism |
|
124 | - * @return self |
|
125 | - */ |
|
126 | - public function setLegacyAuthMechanism(AuthMechanism $authMechanism) { |
|
127 | - $this->legacyAuthMechanism = $authMechanism; |
|
128 | - return $this; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @param callable $callback dynamic auth mechanism selection |
|
133 | - * @return self |
|
134 | - */ |
|
135 | - public function setLegacyAuthMechanismCallback(callable $callback) { |
|
136 | - $this->legacyAuthMechanism = $callback; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Serialize into JSON for client-side JS |
|
141 | - * |
|
142 | - * @return array |
|
143 | - */ |
|
144 | - public function jsonSerialize() { |
|
145 | - $data = $this->jsonSerializeDefinition(); |
|
146 | - $data += $this->jsonSerializeIdentifier(); |
|
147 | - |
|
148 | - $data['backend'] = $data['name']; // legacy compat |
|
149 | - $data['priority'] = $this->getPriority(); |
|
150 | - $data['authSchemes'] = $this->getAuthSchemes(); |
|
151 | - |
|
152 | - return $data; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Check if parameters are satisfied in a StorageConfig |
|
157 | - * |
|
158 | - * @param StorageConfig $storage |
|
159 | - * @return bool |
|
160 | - */ |
|
161 | - public function validateStorage(StorageConfig $storage) { |
|
162 | - return $this->validateStorageDefinition($storage); |
|
163 | - } |
|
60 | + use VisibilityTrait; |
|
61 | + use FrontendDefinitionTrait; |
|
62 | + use PriorityTrait; |
|
63 | + use DependencyTrait; |
|
64 | + use StorageModifierTrait; |
|
65 | + use IdentifierTrait; |
|
66 | + |
|
67 | + /** @var string storage class */ |
|
68 | + private $storageClass; |
|
69 | + |
|
70 | + /** @var array 'scheme' => true, supported authentication schemes */ |
|
71 | + private $authSchemes = []; |
|
72 | + |
|
73 | + /** @var AuthMechanism|callable authentication mechanism fallback */ |
|
74 | + private $legacyAuthMechanism; |
|
75 | + |
|
76 | + /** |
|
77 | + * @return string |
|
78 | + */ |
|
79 | + public function getStorageClass() { |
|
80 | + return $this->storageClass; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string $class |
|
85 | + * @return $this |
|
86 | + */ |
|
87 | + public function setStorageClass($class) { |
|
88 | + $this->storageClass = $class; |
|
89 | + return $this; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return array |
|
94 | + */ |
|
95 | + public function getAuthSchemes() { |
|
96 | + if (empty($this->authSchemes)) { |
|
97 | + return [AuthMechanism::SCHEME_NULL => true]; |
|
98 | + } |
|
99 | + return $this->authSchemes; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $scheme |
|
104 | + * @return self |
|
105 | + */ |
|
106 | + public function addAuthScheme($scheme) { |
|
107 | + $this->authSchemes[$scheme] = true; |
|
108 | + return $this; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @param array $parameters storage parameters, for dynamic mechanism selection |
|
113 | + * @return AuthMechanism |
|
114 | + */ |
|
115 | + public function getLegacyAuthMechanism(array $parameters = []) { |
|
116 | + if (is_callable($this->legacyAuthMechanism)) { |
|
117 | + return call_user_func($this->legacyAuthMechanism, $parameters); |
|
118 | + } |
|
119 | + return $this->legacyAuthMechanism; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @param AuthMechanism $authMechanism |
|
124 | + * @return self |
|
125 | + */ |
|
126 | + public function setLegacyAuthMechanism(AuthMechanism $authMechanism) { |
|
127 | + $this->legacyAuthMechanism = $authMechanism; |
|
128 | + return $this; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @param callable $callback dynamic auth mechanism selection |
|
133 | + * @return self |
|
134 | + */ |
|
135 | + public function setLegacyAuthMechanismCallback(callable $callback) { |
|
136 | + $this->legacyAuthMechanism = $callback; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Serialize into JSON for client-side JS |
|
141 | + * |
|
142 | + * @return array |
|
143 | + */ |
|
144 | + public function jsonSerialize() { |
|
145 | + $data = $this->jsonSerializeDefinition(); |
|
146 | + $data += $this->jsonSerializeIdentifier(); |
|
147 | + |
|
148 | + $data['backend'] = $data['name']; // legacy compat |
|
149 | + $data['priority'] = $this->getPriority(); |
|
150 | + $data['authSchemes'] = $this->getAuthSchemes(); |
|
151 | + |
|
152 | + return $data; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Check if parameters are satisfied in a StorageConfig |
|
157 | + * |
|
158 | + * @param StorageConfig $storage |
|
159 | + * @return bool |
|
160 | + */ |
|
161 | + public function validateStorage(StorageConfig $storage) { |
|
162 | + return $this->validateStorageDefinition($storage); |
|
163 | + } |
|
164 | 164 | |
165 | 165 | } |
166 | 166 |
@@ -31,129 +31,129 @@ |
||
31 | 31 | */ |
32 | 32 | trait FrontendDefinitionTrait { |
33 | 33 | |
34 | - /** @var string human-readable mechanism name */ |
|
35 | - private $text; |
|
36 | - |
|
37 | - /** @var DefinitionParameter[] parameters for mechanism */ |
|
38 | - private $parameters = []; |
|
39 | - |
|
40 | - /** @var string[] custom JS */ |
|
41 | - private $customJs = []; |
|
42 | - |
|
43 | - /** |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - public function getText() { |
|
47 | - return $this->text; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $text |
|
52 | - * @return $this |
|
53 | - */ |
|
54 | - public function setText($text) { |
|
55 | - $this->text = $text; |
|
56 | - return $this; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @param FrontendDefinitionTrait $a |
|
61 | - * @param FrontendDefinitionTrait $b |
|
62 | - * @return int |
|
63 | - */ |
|
64 | - public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) { |
|
65 | - return strcmp($a->getText(), $b->getText()); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * @return DefinitionParameter[] |
|
70 | - */ |
|
71 | - public function getParameters() { |
|
72 | - return $this->parameters; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @param DefinitionParameter[] $parameters |
|
77 | - * @return self |
|
78 | - */ |
|
79 | - public function addParameters(array $parameters) { |
|
80 | - foreach ($parameters as $parameter) { |
|
81 | - $this->addParameter($parameter); |
|
82 | - } |
|
83 | - return $this; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @param DefinitionParameter $parameter |
|
88 | - * @return self |
|
89 | - */ |
|
90 | - public function addParameter(DefinitionParameter $parameter) { |
|
91 | - $this->parameters[$parameter->getName()] = $parameter; |
|
92 | - return $this; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @return string[] |
|
97 | - */ |
|
98 | - public function getCustomJs() { |
|
99 | - return $this->customJs; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $custom |
|
104 | - * @return self |
|
105 | - */ |
|
106 | - public function addCustomJs($custom) { |
|
107 | - $this->customJs[] = $custom; |
|
108 | - return $this; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @param string $custom |
|
113 | - * @return self |
|
114 | - * @deprecated 9.1.0, use addCustomJs() instead |
|
115 | - */ |
|
116 | - public function setCustomJs($custom) { |
|
117 | - $this->customJs = [$custom]; |
|
118 | - return $this; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Serialize into JSON for client-side JS |
|
123 | - * |
|
124 | - * @return array |
|
125 | - */ |
|
126 | - public function jsonSerializeDefinition() { |
|
127 | - $configuration = []; |
|
128 | - foreach ($this->getParameters() as $parameter) { |
|
129 | - $configuration[$parameter->getName()] = $parameter; |
|
130 | - } |
|
131 | - |
|
132 | - $data = [ |
|
133 | - 'name' => $this->getText(), |
|
134 | - 'configuration' => $configuration, |
|
135 | - 'custom' => $this->getCustomJs(), |
|
136 | - ]; |
|
137 | - return $data; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Check if parameters are satisfied in a StorageConfig |
|
142 | - * |
|
143 | - * @param StorageConfig $storage |
|
144 | - * @return bool |
|
145 | - */ |
|
146 | - public function validateStorageDefinition(StorageConfig $storage) { |
|
147 | - foreach ($this->getParameters() as $name => $parameter) { |
|
148 | - $value = $storage->getBackendOption($name); |
|
149 | - if (!is_null($value) || !$parameter->isOptional()) { |
|
150 | - if (!$parameter->validateValue($value)) { |
|
151 | - return false; |
|
152 | - } |
|
153 | - $storage->setBackendOption($name, $value); |
|
154 | - } |
|
155 | - } |
|
156 | - return true; |
|
157 | - } |
|
34 | + /** @var string human-readable mechanism name */ |
|
35 | + private $text; |
|
36 | + |
|
37 | + /** @var DefinitionParameter[] parameters for mechanism */ |
|
38 | + private $parameters = []; |
|
39 | + |
|
40 | + /** @var string[] custom JS */ |
|
41 | + private $customJs = []; |
|
42 | + |
|
43 | + /** |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + public function getText() { |
|
47 | + return $this->text; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $text |
|
52 | + * @return $this |
|
53 | + */ |
|
54 | + public function setText($text) { |
|
55 | + $this->text = $text; |
|
56 | + return $this; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @param FrontendDefinitionTrait $a |
|
61 | + * @param FrontendDefinitionTrait $b |
|
62 | + * @return int |
|
63 | + */ |
|
64 | + public static function lexicalCompare(FrontendDefinitionTrait $a, FrontendDefinitionTrait $b) { |
|
65 | + return strcmp($a->getText(), $b->getText()); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * @return DefinitionParameter[] |
|
70 | + */ |
|
71 | + public function getParameters() { |
|
72 | + return $this->parameters; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @param DefinitionParameter[] $parameters |
|
77 | + * @return self |
|
78 | + */ |
|
79 | + public function addParameters(array $parameters) { |
|
80 | + foreach ($parameters as $parameter) { |
|
81 | + $this->addParameter($parameter); |
|
82 | + } |
|
83 | + return $this; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @param DefinitionParameter $parameter |
|
88 | + * @return self |
|
89 | + */ |
|
90 | + public function addParameter(DefinitionParameter $parameter) { |
|
91 | + $this->parameters[$parameter->getName()] = $parameter; |
|
92 | + return $this; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @return string[] |
|
97 | + */ |
|
98 | + public function getCustomJs() { |
|
99 | + return $this->customJs; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $custom |
|
104 | + * @return self |
|
105 | + */ |
|
106 | + public function addCustomJs($custom) { |
|
107 | + $this->customJs[] = $custom; |
|
108 | + return $this; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @param string $custom |
|
113 | + * @return self |
|
114 | + * @deprecated 9.1.0, use addCustomJs() instead |
|
115 | + */ |
|
116 | + public function setCustomJs($custom) { |
|
117 | + $this->customJs = [$custom]; |
|
118 | + return $this; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Serialize into JSON for client-side JS |
|
123 | + * |
|
124 | + * @return array |
|
125 | + */ |
|
126 | + public function jsonSerializeDefinition() { |
|
127 | + $configuration = []; |
|
128 | + foreach ($this->getParameters() as $parameter) { |
|
129 | + $configuration[$parameter->getName()] = $parameter; |
|
130 | + } |
|
131 | + |
|
132 | + $data = [ |
|
133 | + 'name' => $this->getText(), |
|
134 | + 'configuration' => $configuration, |
|
135 | + 'custom' => $this->getCustomJs(), |
|
136 | + ]; |
|
137 | + return $data; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Check if parameters are satisfied in a StorageConfig |
|
142 | + * |
|
143 | + * @param StorageConfig $storage |
|
144 | + * @return bool |
|
145 | + */ |
|
146 | + public function validateStorageDefinition(StorageConfig $storage) { |
|
147 | + foreach ($this->getParameters() as $name => $parameter) { |
|
148 | + $value = $storage->getBackendOption($name); |
|
149 | + if (!is_null($value) || !$parameter->isOptional()) { |
|
150 | + if (!$parameter->validateValue($value)) { |
|
151 | + return false; |
|
152 | + } |
|
153 | + $storage->setBackendOption($name, $value); |
|
154 | + } |
|
155 | + } |
|
156 | + return true; |
|
157 | + } |
|
158 | 158 | |
159 | 159 | } |
@@ -29,15 +29,15 @@ |
||
29 | 29 | * Authentication mechanism or backend has insufficient data |
30 | 30 | */ |
31 | 31 | class InsufficientDataForMeaningfulAnswerException extends StorageNotAvailableException { |
32 | - /** |
|
33 | - * StorageNotAvailableException constructor. |
|
34 | - * |
|
35 | - * @param string $message |
|
36 | - * @param int $code |
|
37 | - * @param \Exception|null $previous |
|
38 | - * @since 6.0.0 |
|
39 | - */ |
|
40 | - public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) { |
|
41 | - parent::__construct($message, $code, $previous); |
|
42 | - } |
|
32 | + /** |
|
33 | + * StorageNotAvailableException constructor. |
|
34 | + * |
|
35 | + * @param string $message |
|
36 | + * @param int $code |
|
37 | + * @param \Exception|null $previous |
|
38 | + * @since 6.0.0 |
|
39 | + */ |
|
40 | + public function __construct($message = '', $code = self::STATUS_INDETERMINATE, \Exception $previous = null) { |
|
41 | + parent::__construct($message, $code, $previous); |
|
42 | + } |
|
43 | 43 | } |