Skip to content

Commit a3deb21

Browse files
authored
Merge pull request #16334 from nextcloud/feature/noid/enterprise-logo
Add enterprise logo
2 parents 89e8b29 + b732f51 commit a3deb21

File tree

6 files changed

+122
-0
lines changed

6 files changed

+122
-0
lines changed

core/img/logo/logo-enterprise.png

10.1 KB
Loading

core/img/logo/logo-enterprise.svg

Lines changed: 1 addition & 0 deletions
Loading

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@
10671067
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => $baseDir . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
10681068
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => $baseDir . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
10691069
'OC\\Repair\\NC16\\RemoveCypressFiles' => $baseDir . '/lib/private/Repair/NC16/RemoveCypressFiles.php',
1070+
'OC\\Repair\\NC17\\SetEnterpriseLogo' => $baseDir . '/lib/private/Repair/NC17/SetEnterpriseLogo.php',
10701071
'OC\\Repair\\NC17\\SwitchUpdateChannel' => $baseDir . '/lib/private/Repair/NC17/SwitchUpdateChannel.php',
10711072
'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php',
10721073
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => $baseDir . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
11011101
'OC\\Repair\\NC16\\AddClenupLoginFlowV2BackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/AddClenupLoginFlowV2BackgroundJob.php',
11021102
'OC\\Repair\\NC16\\CleanupCardDAVPhotoCache' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php',
11031103
'OC\\Repair\\NC16\\RemoveCypressFiles' => __DIR__ . '/../../..' . '/lib/private/Repair/NC16/RemoveCypressFiles.php',
1104+
'OC\\Repair\\NC17\\SetEnterpriseLogo' => __DIR__ . '/../../..' . '/lib/private/Repair/NC17/SetEnterpriseLogo.php',
11041105
'OC\\Repair\\NC17\\SwitchUpdateChannel' => __DIR__ . '/../../..' . '/lib/private/Repair/NC17/SwitchUpdateChannel.php',
11051106
'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php',
11061107
'OC\\Repair\\Owncloud\\DropAccountTermsTable' => __DIR__ . '/../../..' . '/lib/private/Repair/Owncloud/DropAccountTermsTable.php',

lib/private/Repair.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use OC\Repair\NC16\AddClenupLoginFlowV2BackgroundJob;
4444
use OC\Repair\NC16\CleanupCardDAVPhotoCache;
4545
use OC\Repair\NC16\RemoveCypressFiles;
46+
use OC\Repair\NC17\SetEnterpriseLogo;
4647
use OC\Repair\NC17\SwitchUpdateChannel;
4748
use OC\Repair\OldGroupMembershipShares;
4849
use OC\Repair\Owncloud\DropAccountTermsTable;
@@ -151,6 +152,7 @@ public static function getRepairSteps() {
151152
new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
152153
\OC::$server->query(RemoveCypressFiles::class),
153154
\OC::$server->query(SwitchUpdateChannel::class),
155+
\OC::$server->query(SetEnterpriseLogo::class),
154156
];
155157
}
156158

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
declare(strict_types=1);
3+
/**
4+
* @copyright Copyright (c) 2019, Morris Jobke <hey@morrisjobke.de>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
namespace OC\Repair\NC17;
24+
25+
use OC\Files\AppData\Factory;
26+
use OC\Template\SCSSCacher;
27+
use OCA\Theming\ThemingDefaults;
28+
use OCP\Files\IAppData;
29+
use OCP\Files\NotFoundException;
30+
use OCP\IConfig;
31+
use OCP\Migration\IOutput;
32+
use OCP\Migration\IRepairStep;
33+
use OCP\Support\Subscription\IRegistry;
34+
35+
/**
36+
* @deprecated - can be removed in 18
37+
*/
38+
class SetEnterpriseLogo implements IRepairStep {
39+
40+
/** @var IConfig $config */
41+
private $config;
42+
43+
/** @var IRegistry $subscriptionRegistry */
44+
private $subscriptionRegistry;
45+
46+
/** @var IAppData $appData */
47+
private $appData;
48+
49+
/** @var SCSSCacher $scssCacher */
50+
private $scssCacher;
51+
52+
/** @var \OC_Defaults|ThemingDefaults */
53+
private $themingDefaults;
54+
55+
public function getName(): string {
56+
return 'Sets the enterprise logo';
57+
}
58+
59+
public function __construct(
60+
IConfig $config,
61+
IRegistry $subscriptionRegistry,
62+
Factory $appDataFactory,
63+
SCSSCacher $SCSSCacher,
64+
$ThemingDefaults
65+
) {
66+
$this->config = $config;
67+
$this->subscriptionRegistry = $subscriptionRegistry;
68+
$this->appData = $appDataFactory->get('theming');
69+
$this->scssCacher = $SCSSCacher;
70+
$this->themingDefaults = $ThemingDefaults;
71+
}
72+
73+
public function run(IOutput $output): void {
74+
// only run once
75+
if ($this->config->getAppValue('core', 'enterpriseLogoChecked') === 'yes') {
76+
$output->info('Repair step already executed');
77+
return;
78+
}
79+
80+
if (!$this->subscriptionRegistry->delegateHasValidSubscription()) {
81+
// no need to set the enterprise logo
82+
$this->config->setAppValue('core', 'enterpriseLogoChecked', 'yes');
83+
return;
84+
}
85+
86+
if ($this->themingDefaults instanceof ThemingDefaults) {
87+
$output->info('Theming is enabled - trying to set logo.');
88+
try {
89+
$folder = $this->appData->getFolder('images');
90+
} catch (NotFoundException $e) {
91+
$folder = $this->appData->newFolder('images');
92+
}
93+
94+
if (!$folder->fileExists('logo') || $folder->getFile('logo')->getSize() === 0) {
95+
$output->info('Logo does not exist yet - setting it.');
96+
97+
if ($folder->fileExists('logo')) {
98+
$folder->getFile('logo')->delete();
99+
}
100+
$target = $folder->newFile('logo');
101+
102+
$target->putContent(file_get_contents(__DIR__ . '/../../../../core/img/logo/logo-enterprise.png'));
103+
104+
$this->themingDefaults->set('logoMime', 'image/png');
105+
106+
$this->scssCacher->process(\OC::$SERVERROOT, 'core/css/css-variables.scss', 'core');
107+
} else {
108+
$output->info('Logo already set - skipping.');
109+
}
110+
} else {
111+
$output->info('Theming is not enabled - skipping.');
112+
}
113+
114+
// if all were done, no need to redo the repair during next upgrade
115+
$this->config->setAppValue('core', 'enterpriseLogoChecked', 'yes');
116+
}
117+
}

0 commit comments

Comments
 (0)