Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2022-08-21 10:44:07 +0300
committerdartcafe <github@dartcafe.de>2022-08-21 10:44:07 +0300
commitd2b00a1e2c7daf0c3159bd499314d18c4f86ebc6 (patch)
tree05078e43e57c8688c010e3c673709f3133dd1326
parent9c18920914e70b44585a7a9e7c104840b4c21a03 (diff)
evaluate language and locale from transFactory
Signed-off-by: dartcafe <github@dartcafe.de>
-rw-r--r--lib/Controller/PublicController.php5
-rw-r--r--lib/Controller/ShareController.php47
-rw-r--r--lib/Service/ShareService.php5
-rw-r--r--lib/Service/UserService.php16
4 files changed, 41 insertions, 32 deletions
diff --git a/lib/Controller/PublicController.php b/lib/Controller/PublicController.php
index a76f3727..eecdc6f6 100644
--- a/lib/Controller/PublicController.php
+++ b/lib/Controller/PublicController.php
@@ -367,10 +367,9 @@ class PublicController extends BaseController {
* @PublicPage
*/
public function register(string $token, string $userName, string $emailAddress = '', string $timeZone = ''): JSONResponse {
- $language = explode(',', $this->request->getHeader('Accept-Language'))[0];
-
+ // $language = explode(',', $this->request->getHeader('Accept-Language'))[0];
return $this->responseCreate(fn () => [
- 'share' => $this->shareService->register($this->shareService->get($token), $userName, $emailAddress, $language, $language, $timeZone)
+ 'share' => $this->shareService->register($this->shareService->get($token), $userName, $emailAddress, $timeZone)
], $token);
}
diff --git a/lib/Controller/ShareController.php b/lib/Controller/ShareController.php
index 50e34d47..e95a2f59 100644
--- a/lib/Controller/ShareController.php
+++ b/lib/Controller/ShareController.php
@@ -104,31 +104,28 @@ class ShareController extends BaseController {
]);
}
- /**
- * Create a personal share from a public share
- * or update an email share with the username
- * @deprecated not used?
- * @NoAdminRequired
- */
- public function register(
- string $token,
- string $userName,
- string $emailAddress = '',
- string $timeZone = ''
- ): JSONResponse {
- $language = explode(',', $this->request->getHeader('Accept-Language'))[0];
-
- return $this->responseCreate(fn () =>
- ['share' => $this->shareService->register(
- $this->shareService->get($token),
- $userName,
- $emailAddress,
- $language,
- $language,
- $timeZone
- )]
- );
- }
+ // /**
+ // * Create a personal share from a public share
+ // * or update an email share with the username
+ // * @deprecated not used?
+ // * @NoAdminRequired
+ // */
+ // public function register(
+ // string $token,
+ // string $userName,
+ // string $emailAddress = '',
+ // string $timeZone = ''
+ // ): JSONResponse {
+
+ // return $this->responseCreate(fn () =>
+ // ['share' => $this->shareService->register(
+ // $this->shareService->get($token),
+ // $userName,
+ // $emailAddress,
+ // $timeZone
+ // )]
+ // );
+ // }
/**
* Delete share
diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php
index 27106e4d..9b23def4 100644
--- a/lib/Service/ShareService.php
+++ b/lib/Service/ShareService.php
@@ -277,8 +277,6 @@ class ShareService {
Share $share,
string $userName,
string $emailAddress = '',
- string $language = '',
- string $locale = '',
string $timeZone = ''
): Share {
$this->share = $share;
@@ -288,6 +286,7 @@ class ShareService {
$this->systemService->validateEmailAddress($emailAddress, $this->share->getPublicPollEmail() !== Share::EMAIL_MANDATORY);
}
+ $language = $this->userService->getGenericLanguage();
$userId = $this->generatePublicUserId();
if ($this->share->getType() === Share::TYPE_PUBLIC) {
@@ -295,7 +294,7 @@ class ShareService {
// prevent invtation sending, when no email address is given
$this->createNewShare(
$this->share->getPollId(),
- $this->userService->getUser(Share::TYPE_EXTERNAL, $userId, $userName, $emailAddress, $language, $locale, $timeZone),
+ $this->userService->getUser(Share::TYPE_EXTERNAL, $userId, $userName, $emailAddress, $language, $language, $timeZone),
!$emailAddress,
$timeZone
);
diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php
index 049c16f0..3c268f36 100644
--- a/lib/Service/UserService.php
+++ b/lib/Service/UserService.php
@@ -42,15 +42,19 @@ use OCP\Collaboration\Collaborators\ISearch;
use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\L10N\IFactory;
use OCP\Share\IShare;
class UserService {
/** @var ShareMapper */
private $shareMapper;
-
+
/** @var ISession */
private $session;
+ /** @var IFactory */
+ private $transFactory;
+
/** @var IUserManager */
private $userManager;
@@ -64,6 +68,7 @@ class UserService {
private $voteMapper;
public function __construct(
+ IFactory $transFactory,
ISearch $userSearch,
ISession $session,
IUserSession $userSession,
@@ -71,6 +76,7 @@ class UserService {
ShareMapper $shareMapper,
VoteMapper $voteMapper
) {
+ $this->transFactory = $transFactory;
$this->userSearch = $userSearch;
$this->session = $session;
$this->shareMapper = $shareMapper;
@@ -102,6 +108,14 @@ class UserService {
}
/**
+ * find appropriate language
+ */
+
+ public function getGenericLanguage() {
+ return $this->transFactory->findGenericLanguage('polls');
+ }
+
+ /**
* evaluateUser - Get user by name and poll in case of a share user of the particulair poll
*/