diff --git a/apps/theming/lib/Capabilities.php b/apps/theming/lib/Capabilities.php
index b43779a27b523..1b6bb8927be5b 100644
--- a/apps/theming/lib/Capabilities.php
+++ b/apps/theming/lib/Capabilities.php
@@ -75,7 +75,7 @@ public function getCapabilities() {
'url' => $this->theming->getBaseUrl(),
'slogan' => $this->theming->getSlogan(),
'color' => $color,
- 'color-text' => $this->util->invertTextColor($color) ? '#000000' : '#FFFFFF',
+ 'color-text' => $this->theming->getTextColorPrimary(),
'color-element' => $this->util->elementColor($color),
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
'background' => $backgroundLogo === 'backgroundColor' ?
diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php
index eb1051b13c8c3..fa43dd50ccd05 100644
--- a/apps/theming/lib/ThemingDefaults.php
+++ b/apps/theming/lib/ThemingDefaults.php
@@ -256,13 +256,8 @@ public function getScssVariables() {
$variables['image-login-plain'] = 'false';
if ($this->config->getAppValue('theming', 'color', null) !== null) {
- if ($this->util->invertTextColor($this->getColorPrimary())) {
- $colorPrimaryText = '#000000';
- } else {
- $colorPrimaryText = '#ffffff';
- }
$variables['color-primary'] = $this->getColorPrimary();
- $variables['color-primary-text'] = $colorPrimaryText;
+ $variables['color-primary-text'] = $this->getTextColorPrimary();
$variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
}
@@ -378,4 +373,13 @@ public function undo($setting) {
return $returnValue;
}
+
+ /**
+ * Color of text in the header and primary buttons
+ *
+ * @return string
+ */
+ public function getTextColorPrimary() {
+ return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
+ }
}
diff --git a/apps/theming/tests/CapabilitiesTest.php b/apps/theming/tests/CapabilitiesTest.php
index 17fc253fa4f8f..c760c896425e0 100644
--- a/apps/theming/tests/CapabilitiesTest.php
+++ b/apps/theming/tests/CapabilitiesTest.php
@@ -65,7 +65,7 @@ protected function setUp() {
public function dataGetCapabilities() {
return [
- ['name', 'url', 'slogan', '#FFFFFF', 'logo', 'background', 'http://absolute/', [
+ ['name', 'url', 'slogan', '#FFFFFF', '#000000', 'logo', 'background', 'http://absolute/', [
'name' => 'name',
'url' => 'url',
'slogan' => 'slogan',
@@ -75,22 +75,22 @@ public function dataGetCapabilities() {
'logo' => 'http://absolute/logo',
'background' => 'http://absolute/background',
]],
- ['name1', 'url2', 'slogan3', '#01e4a0', 'logo5', 'background6', 'http://localhost/', [
+ ['name1', 'url2', 'slogan3', '#01e4a0', '#ffffff', 'logo5', 'background6', 'http://localhost/', [
'name' => 'name1',
'url' => 'url2',
'slogan' => 'slogan3',
'color' => '#01e4a0',
- 'color-text' => '#FFFFFF',
+ 'color-text' => '#ffffff',
'color-element' => '#01e4a0',
'logo' => 'http://localhost/logo5',
'background' => 'http://localhost/background6',
]],
- ['name1', 'url2', 'slogan3', '#000000', 'logo5', 'backgroundColor', 'http://localhost/', [
+ ['name1', 'url2', 'slogan3', '#000000', '#ffffff', 'logo5', 'backgroundColor', 'http://localhost/', [
'name' => 'name1',
'url' => 'url2',
'slogan' => 'slogan3',
'color' => '#000000',
- 'color-text' => '#FFFFFF',
+ 'color-text' => '#ffffff',
'color-element' => '#000000',
'logo' => 'http://localhost/logo5',
'background' => '#000000',
@@ -105,11 +105,12 @@ public function dataGetCapabilities() {
* @param string $slogan
* @param string $color
* @param string $logo
+ * @param string $textColor
* @param string $background
* @param string $baseUrl
* @param string[] $expected
*/
- public function testGetCapabilities($name, $url, $slogan, $color, $logo, $background, $baseUrl, array $expected) {
+ public function testGetCapabilities($name, $url, $slogan, $color, $textColor, $logo, $background, $baseUrl, array $expected) {
$this->config->expects($this->once())
->method('getAppValue')
->willReturn($background);
@@ -128,6 +129,9 @@ public function testGetCapabilities($name, $url, $slogan, $color, $logo, $backgr
$this->theming->expects($this->once())
->method('getLogo')
->willReturn($logo);
+ $this->theming->expects($this->once())
+ ->method('getTextColorPrimary')
+ ->willReturn($textColor);
if($background !== 'backgroundColor') {
$this->theming->expects($this->once())
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php
index 1d905635d551b..0535dabc13e4e 100644
--- a/lib/private/Mail/EMailTemplate.php
+++ b/lib/private/Mail/EMailTemplate.php
@@ -234,7 +234,7 @@ class EMailTemplate implements IEMailTemplate {
@@ -287,7 +287,7 @@ class EMailTemplate implements IEMailTemplate {
@@ -531,8 +531,9 @@ public function addBodyButtonGroup($textLeft,
$this->ensureBodyListClosed();
$color = $this->themingDefaults->getColorPrimary();
+ $textColor = $this->themingDefaults->getTextColorPrimary();
- $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]);
+ $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]);
$this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
@@ -561,7 +562,8 @@ public function addBodyButton($text, $url, $plainText = '') {
}
$color = $this->themingDefaults->getColorPrimary();
- $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]);
+ $textColor = $this->themingDefaults->getTextColorPrimary();
+ $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, htmlspecialchars($text)]);
if ($plainText !== false) {
$this->plainBody .= $plainText . ': ';
diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php
index 8b5cef3643e8c..494c65ef226b7 100644
--- a/lib/private/legacy/defaults.php
+++ b/lib/private/legacy/defaults.php
@@ -50,6 +50,7 @@ class OC_Defaults {
private $defaultDocVersion;
private $defaultSlogan;
private $defaultColorPrimary;
+ private $defaultTextColorPrimary;
public function __construct() {
$this->l = \OC::$server->getL10N('lib');
@@ -66,6 +67,7 @@ public function __construct() {
$this->defaultDocVersion = '12'; // used to generate doc links
$this->defaultSlogan = $this->l->t('a safe home for all your data');
$this->defaultColorPrimary = '#0082c9';
+ $this->defaultTextColorPrimary = '#ffffff';
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
@@ -318,4 +320,11 @@ public function getLogo($useSvg = true) {
}
return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
}
+
+ public function getTextColorPrimary() {
+ if ($this->themeExist('getTextColorPrimary')) {
+ return $this->theme->getTextColorPrimary();
+ }
+ return $this->defaultTextColorPrimary;
+ }
}
diff --git a/lib/public/Defaults.php b/lib/public/Defaults.php
index 4bf638fda9fb5..bf790bb723957 100644
--- a/lib/public/Defaults.php
+++ b/lib/public/Defaults.php
@@ -213,4 +213,13 @@ public function buildDocLinkToKey($key) {
public function getTitle() {
return $this->defaults->getTitle();
}
+
+ /**
+ * Returns primary color
+ * @return string
+ * @since 13.0.0
+ */
+ public function getTextColorPrimary() {
+ return $this->defaults->getTextColorPrimary();
+ }
}
diff --git a/tests/Settings/Mailer/NewUserMailHelperTest.php b/tests/Settings/Mailer/NewUserMailHelperTest.php
index f05a963e5371b..84553cc9007cb 100644
--- a/tests/Settings/Mailer/NewUserMailHelperTest.php
+++ b/tests/Settings/Mailer/NewUserMailHelperTest.php
@@ -157,6 +157,10 @@ public function testGenerateTemplateWithPasswordResetToken() {
->expects($this->any())
->method('getName')
->willReturn('TestCloud');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getTextColorPrimary')
+ ->willReturn('#ffffff');
$expectedHtmlBody = <<
@@ -281,7 +285,7 @@ public function testGenerateTemplateWithPasswordResetToken() {
@@ -390,6 +394,10 @@ public function testGenerateTemplateWithoutPasswordResetToken() {
->expects($this->any())
->method('getName')
->willReturn('TestCloud');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getTextColorPrimary')
+ ->willReturn('#ffffff');
$expectedHtmlBody = <<
@@ -514,7 +522,7 @@ public function testGenerateTemplateWithoutPasswordResetToken() {
diff --git a/tests/data/emails/new-account-email-custom.html b/tests/data/emails/new-account-email-custom.html
index 9d35a7f3515e3..601aa0b63d4a1 100644
--- a/tests/data/emails/new-account-email-custom.html
+++ b/tests/data/emails/new-account-email-custom.html
@@ -120,7 +120,7 @@
- Set your password
+ Set your password
|
diff --git a/tests/data/emails/new-account-email-single-button.html b/tests/data/emails/new-account-email-single-button.html
index 3746d5d2cbb39..db8ab868682c1 100644
--- a/tests/data/emails/new-account-email-single-button.html
+++ b/tests/data/emails/new-account-email-single-button.html
@@ -120,7 +120,7 @@
- Set your password
+ Set your password
|
diff --git a/tests/data/emails/new-account-email.html b/tests/data/emails/new-account-email.html
index d33cb540c38cf..f7ffbb8abf659 100644
--- a/tests/data/emails/new-account-email.html
+++ b/tests/data/emails/new-account-email.html
@@ -120,7 +120,7 @@
- Set your password
+ Set your password
|
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php
index 339cd95defc7d..d4687c44b069d 100644
--- a/tests/lib/Mail/EMailTemplateTest.php
+++ b/tests/lib/Mail/EMailTemplateTest.php
@@ -68,6 +68,10 @@ public function testEMailTemplateCustomFooter() {
->expects($this->any())
->method('getName')
->willReturn('TestCloud');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getTextColorPrimary')
+ ->willReturn('#ffffff');
$this->urlGenerator
->expects($this->once())
->method('getAbsoluteURL')
@@ -109,6 +113,10 @@ public function testEMailTemplateDefaultFooter() {
->expects($this->any())
->method('getLogo')
->willReturn('/img/logo-mail-header.png');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getTextColorPrimary')
+ ->willReturn('#ffffff');
$this->urlGenerator
->expects($this->once())
->method('getAbsoluteURL')
@@ -148,6 +156,10 @@ public function testEMailTemplateSingleButton() {
->expects($this->any())
->method('getLogo')
->willReturn('/img/logo-mail-header.png');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getTextColorPrimary')
+ ->willReturn('#ffffff');
$this->urlGenerator
->expects($this->once())
->method('getAbsoluteURL')
@@ -189,6 +201,10 @@ public function testEMailTemplateAlternativePlainTexts() {
->expects($this->any())
->method('getLogo')
->willReturn('/img/logo-mail-header.png');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getTextColorPrimary')
+ ->willReturn('#ffffff');
$this->urlGenerator
->expects($this->once())
->method('getAbsoluteURL')