Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable13] add privacy link to theming and fix scrollbars #9586

Merged
merged 3 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/theming/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>Adjust the Nextcloud theme</description>
<licence>AGPL</licence>
<author>Nextcloud</author>
<version>1.4.3</version>
<version>1.4.4</version>
<namespace>Theming</namespace>
<types>
<logging/>
Expand Down
6 changes: 6 additions & 0 deletions apps/theming/css/theming.scss
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@ input.primary,
border: 1px solid #ebebeb;
}
}

@if ($has-legal-links == 'true') {
footer {
height: 92px;
}
}
13 changes: 12 additions & 1 deletion apps/theming/js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ function hideUndoButton(setting, value) {
color: '#0082c9',
logoMime: '',
backgroundMime: '',
imprintUrl: ''
imprintUrl: '',
privacyUrl: ''
};

if (value === themingDefaults[setting] || value === '') {
Expand Down Expand Up @@ -206,6 +207,16 @@ $(document).ready(function () {
}
});

$('#theming-privacyUrl').change(function(e) {
var el = $(this);
$.when(el.focusout()).then(function () {
setThemingValue('privacyUrl', $(this).val());
});
if (e.keyCode == 13) {
setThemingValue('privacyUrl', $(this).val());
}
});

$('#theming-slogan').change(function(e) {
var el = $(this);
$.when(el.focusout()).then(function() {
Expand Down
11 changes: 11 additions & 0 deletions apps/theming/lib/Controller/ThemingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ public function updateStylesheet($setting, $value) {
]);
}
break;
case 'privacyUrl':
if (strlen($value) > 500) {
return new DataResponse([
'data' => [
'message' => $this->l10n->t('The given privacy policy address is too long'),
],
'status' => 'error'
]);
}
break;
case 'slogan':
if (strlen($value) > 500) {
return new DataResponse([
Expand Down Expand Up @@ -470,6 +480,7 @@ public function getJavascript() {
slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ',
color: ' . json_encode($this->themingDefaults->getColorPrimary()) . ',
imprintUrl: ' . json_encode($this->themingDefaults->getImprintUrl()) . ',
privacyUrl: ' . json_encode($this->themingDefaults->getPrivacyUrl()) . ',
inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())) . ',
cacheBuster: ' . json_encode($cacheBusterValue) . '
};
Expand Down
1 change: 1 addition & 0 deletions apps/theming/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function getForm() {
'canThemeIcons' => $this->themingDefaults->shouldReplaceIcons(),
'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'),
'imprintUrl' => $this->themingDefaults->getImprintUrl(),
'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
];

return new TemplateResponse('theming', 'settings-admin', $parameters, '');
Expand Down
45 changes: 36 additions & 9 deletions apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ public function getSlogan() {
}

public function getImprintUrl() {
return $this->config->getAppValue('theming', 'imprintUrl', '');
return (string)$this->config->getAppValue('theming', 'imprintUrl', '');
}

public function getPrivacyUrl() {
return (string)$this->config->getAppValue('theming', 'privacyUrl', '');
}

public function getShortFooter() {
Expand All @@ -152,14 +156,31 @@ public function getShortFooter() {
' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
($slogan !== '' ? ' – ' . $slogan : '');

$imprintUrl = (string)$this->getImprintUrl();
if($imprintUrl !== ''
&& filter_var($imprintUrl, FILTER_VALIDATE_URL, [
'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
])
) {
$footer .= '<br/><a href="' . $imprintUrl . '" class="legal" target="_blank"' .
' rel="noreferrer noopener">' . $this->l->t('Legal notice') . '</a>';
$links = [
[
'text' => $this->l->t('Legal notice'),
'url' => (string)$this->getImprintUrl()
],
[
'text' => $this->l->t('Privacy policy'),
'url' => (string)$this->getPrivacyUrl()
],
];

$legalLinks = ''; $divider = '';
foreach($links as $link) {
if($link['url'] !== ''
&& filter_var($link['url'], FILTER_VALIDATE_URL, [
'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
])
) {
$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
' rel="noreferrer noopener">' . $link['text'] . '</a>';
$divider = ' · ';
}
}
if($legalLinks !== '' ) {
$footer .= '<br/>' . $legalLinks;
}

return $footer;
Expand Down Expand Up @@ -269,6 +290,12 @@ public function getScssVariables() {
if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
$variables['image-login-plain'] = 'true';
}

$variables['has-legal-links'] = 'false';
if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
$variables['has-legal-links'] = 'true';
}

$cache->set('getScssVariables', $variables);
return $variables;
}
Expand Down
11 changes: 9 additions & 2 deletions apps/theming/templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,18 @@
</div>
<div>
<label>
<span><?php p($l->t('Legal notice link')) ?></span>
<input id="theming-imprintUrl" type="text" placeholder="<?php p($l->t('https://…')); ?>" value="<?php p($_['imprintUrl']) ?>" maxlength="500" />
<span><?php p($l->t('Legal notice link')) ?></span>
<input id="theming-imprintUrl" type="text" placeholder="<?php p($l->t('https://…')); ?>" value="<?php p($_['imprintUrl']) ?>" maxlength="500" />
<div data-setting="imprintUrl" data-toggle="tooltip" data-original-title="<?php p($l->t('Reset to default')); ?>" class="theme-undo icon icon-history"></div>
</label>
</div>
<div>
<label>
<span><?php p($l->t('Privacy policy link')) ?></span>
<input id="theming-privacyUrl" type="text" placeholder="<?php p($l->t('https://…')); ?>" value="<?php p($_['privacyUrl']) ?>" maxlength="500" />
<div data-setting="privacyUrl" data-toggle="tooltip" data-original-title="<?php p($l->t('Reset to default')); ?>" class="theme-undo icon icon-history"></div>
</label>
</div>
<div class="theming-hints">
<?php if (!$_['canThemeIcons']) { ?>
<p class="info">
Expand Down
2 changes: 2 additions & 0 deletions apps/theming/tests/Controller/ThemingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ public function testGetJavascript() {
slogan: "",
color: "#000",
imprintUrl: null,
privacyUrl: null,
inverted: false,
cacheBuster: null
};
Expand Down Expand Up @@ -912,6 +913,7 @@ public function testGetJavascriptInverted() {
slogan: "awesome",
color: "#ffffff",
imprintUrl: null,
privacyUrl: null,
inverted: true,
cacheBuster: null
};
Expand Down
10 changes: 10 additions & 0 deletions apps/theming/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public function testGetFormNoErrors() {
->expects($this->once())
->method('getImprintUrl')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getPrivacyUrl')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getSlogan')
Expand Down Expand Up @@ -108,6 +112,7 @@ public function testGetFormNoErrors() {
'canThemeIcons' => null,
'iconDocs' => null,
'imprintUrl' => '',
'privacyUrl' => '',
];

$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
Expand Down Expand Up @@ -137,6 +142,10 @@ public function testGetFormWithErrors() {
->expects($this->once())
->method('getImprintUrl')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getPrivacyUrl')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getSlogan')
Expand Down Expand Up @@ -165,6 +174,7 @@ public function testGetFormWithErrors() {
'canThemeIcons' => null,
'iconDocs' => null,
'imprintUrl' => '',
'privacyUrl' => '',
];

$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
Expand Down
Loading