diff options
-rw-r--r-- | lib/Controller/PublicController.php | 5 | ||||
-rw-r--r-- | lib/Controller/ShareController.php | 47 | ||||
-rw-r--r-- | lib/Service/ShareService.php | 5 | ||||
-rw-r--r-- | lib/Service/UserService.php | 16 |
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 */ |