diff --git a/css/flex.scss b/css/flex.scss deleted file mode 100644 index 4c4d731..0000000 --- a/css/flex.scss +++ /dev/null @@ -1,19 +0,0 @@ -.flex-row { - display: flex; - flex-direction: row; - flex-grow: 1; - /* align-items: center; */ - &.align-centered { - align-items: center; - } -} - -.flex-column { - display: flex; - flex-direction: column; - flex-grow: 0; - flex-shrink: 0; - &.align-centered { - align-items: center; - } -} diff --git a/css/icons.scss b/css/icons.scss index d635ad3..0806df4 100644 --- a/css/icons.scss +++ b/css/icons.scss @@ -1,4 +1,26 @@ +/** + * @copyright Copyright (c) 2020 John Molakvoæ + * + * @author John Molakvoæ + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + // Icon definitions @include icon-black-white('forms', 'forms', 3); @include icon-black-white('clone', 'forms', 1); diff --git a/css/main.scss b/css/main.scss deleted file mode 100644 index 7c108b6..0000000 --- a/css/main.scss +++ /dev/null @@ -1,46 +0,0 @@ -h1 { - font-size: 1.8em; - margin-bottom: 5px; -} - -.icon-forms { - background-image: var(--icon-forms); -} - -/* allow horizontal scrollbar - otherwise user management is not usable on mobile */ -@media only screen and (max-width: 768px) { - #app-content { - overflow-x: auto !important; - } -} - -#controls { - // adopted from NC13 for compatibily with OC10 and NC11-NC12 - width: 100%; - position: relative; - top: 4px; - h2 { - margin-top: 12px; - } - .breadcrumb { - flex-grow: 1; - overflow: hidden; - - div.crumb { - overflow: hidden; - white-space: nowrap; - flex-shrink: 0; - } - } -} - -input[type='text'] { - display: block; - width: 100%; -} - -/* OC10 and NC11 fixes*/ -.symbol { - display: inline-block; -} diff --git a/css/public.scss b/css/public.scss index 6d4a8dc..e9700ff 100644 --- a/css/public.scss +++ b/css/public.scss @@ -1,11 +1,31 @@ -#header { - #appmenu, - .header-right, - nav { - display: none; - } -} - -div.crumb { - background-image: none; +/** + * @copyright Copyright (c) 2020 John Molakvoæ + * + * @author John Molakvoæ + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +#header .header-shared-by { + color: var(--color-primary-text); + position: relative; + font-weight: 300; + font-size: 11px; + line-height: 11px; + overflow: hidden; + text-overflow: ellipsis; } diff --git a/css/submit.scss b/css/submit.scss deleted file mode 100644 index bd5be9c..0000000 --- a/css/submit.scss +++ /dev/null @@ -1,73 +0,0 @@ -.app-forms { - margin: auto; - width: 50%; - margin-top: 20px; -} - -.sv-q-description { - font-size: 420px; -} - -/* hotfixcss - setting the width to 70% so it takes a more reasonable place for long titles - line height to 1 so the lines don't overlap - adding a margin-bottom for confort -*/ -.sv_container { - h3 { - width: 70%; - line-height: 1; - margin-bottom: 5%; - font-size: 30px; - } -} - - -/* hotfixcss -changing to color so it matches the header -setting the width to 70% to match the previous fix -setting a more confortable margin-bottom -*/ -.sv_qstn .sq-root { - border: 1px solid gray; - border-left: 4px solid #0082c9; - border-radius: 5px; - padding: 20px; - width: 70%; - margin-bottom: 6%; - font-size: 18px; -} - - -/* hotfixcss -adding a margin -*/ -.sq-title { - font-size: 20px; - margin-left: 20px; - margin-bottom: 2%; -} - -.sq-title-required { - color: black; -} - -/* hotfixcss -display fex and align items center so the radio button is aligned with the text -*/ -.sq-label { - margin-left: 30px; - display: flex; - align-items: center; -} - -.sq-item:nth-child(1) { - margin-bottom: 5px; -} - -/* hotfixcss -adding the checkbox text's class to add a comfort margin -*/ -.sv_q_checkbox_control_label { - margin-left: 1%; -} diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 7ec5242..92316b3 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -28,17 +28,19 @@ namespace OCA\Forms\Controller; use OCA\Forms\Db\Form; use OCA\Forms\Db\FormMapper; -use OCA\Forms\Db\OptionMapper; -use OCA\Forms\Db\QuestionMapper; use OCA\Forms\Service\FormsService; +use OCP\Accounts\IAccountManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Db\DoesNotExistException; +use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\IGroupManager; use OCP\IInitialStateService; +use OCP\IL10N; use OCP\IRequest; -use OCP\IURLGenerator; +use OCP\IUser; +use OCP\IUserManager; use OCP\IUserSession; use OCP\Util; @@ -47,22 +49,28 @@ class PageController extends Controller { /** @var FormMapper */ private $formMapper; + + /** @var FormsService */ + private $formsService; - /** @var IURLGenerator */ - private $urlGenerator; + /** @var IAccountManager */ + protected $accountManager; /** @var IGroupManager */ private $groupManager; + /** @var IInitialStateService */ + private $initialStateService; + + /** @var IL10N */ + private $l10n; + + /** @var IUserManager */ + private $userManager; + /** @var IUserSession */ private $userSession; - /** @var IInitialStateService */ - private $initialStateService; - - /** @var FormsService */ - private $formService; - /** @var Array * * Maximum String lengths, the database is set to store. @@ -77,25 +85,27 @@ class PageController extends Controller { public function __construct(string $appName, IRequest $request, - IGroupManager $groupManager, - IURLGenerator $urlGenerator, FormMapper $formMapper, - QuestionMapper $questionMapper, - OptionMapper $optionMapper, - IUserSession $userSession, + FormsService $formsService, + IAccountManager $accountManager, + IGroupManager $groupManager, IInitialStateService $initialStateService, - FormsService $formsService) { + IL10N $l10n, + IUserManager $userManager, + IUserSession $userSession) { parent::__construct($appName, $request); - $this->groupManager = $groupManager; - $this->urlGenerator = $urlGenerator; $this->appName = $appName; + $this->formMapper = $formMapper; - $this->questionMapper = $questionMapper; - $this->optionMapper = $optionMapper; - $this->userSession = $userSession; - $this->initialStateService = $initialStateService; $this->formsService = $formsService; + + $this->accountManager = $accountManager; + $this->groupManager = $groupManager; + $this->initialStateService = $initialStateService; + $this->l10n = $l10n; + $this->userManager = $userManager; + $this->userSession = $userSession; } /** @@ -198,11 +208,29 @@ class PageController extends Controller { return new TemplateResponse('forms', 'expired'); } - $renderAs = $this->userSession->isLoggedIn() ? 'user' : 'public'; - Util::addScript($this->appName, 'submit'); $this->initialStateService->provideInitialState($this->appName, 'form', $this->formsService->getPublicForm($form->getId())); $this->initialStateService->provideInitialState($this->appName, 'maxStringLengths', $this->maxStringLengths); - return new TemplateResponse($this->appName, 'main', [], $renderAs); + + if (!$this->userSession->isLoggedIn()) { + Util::addStyle($this->appName, 'public'); + $response = new PublicTemplateResponse($this->appName, 'main'); + $response->setHeaderTitle($form->getTitle()); + + // Get owner and check display name privacy settings + $owner = $this->userManager->get($form->getOwnerId()); + if ($owner instanceof IUser) { + $ownerAccount = $this->accountManager->getAccount($owner); + + $ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); + if ($ownerName->getScope() === IAccountManager::VISIBILITY_PUBLIC) { + $response->setHeaderDetails($this->l10n->t('Shared by %s', [$ownerName->getValue()])); + } + } + + return $response; + } + + return new TemplateResponse($this->appName, 'main'); } }