Skip to content
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
1 change: 1 addition & 0 deletions apps/theming/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@

<settings>
<admin>OCA\Theming\Settings\Admin</admin>
<admin-section>OCA\Theming\Settings\Section</admin-section>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref #14402 😉

</settings>
</info>
83 changes: 83 additions & 0 deletions apps/theming/lib/Settings/Section.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
* @author Joas Schilling <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Theming\Settings;

use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\Settings\IIconSection;

class Section implements IIconSection {
/** @var IL10N */
private $l;
/** @var IURLGenerator */
private $url;

/**
* @param IURLGenerator $url
* @param IL10N $l
*/
public function __construct(IURLGenerator $url, IL10N $l) {
$this->url = $url;
$this->l = $l;
}

/**
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
* @returns string
*/
public function getID() {
return 'theming';
}

/**
* returns the translated name as it should be displayed, e.g. 'LDAP / AD
* integration'. Use the L10N service to translate it.
*
* @return string
*/
public function getName() {
return $this->l->t('Theming');
}

/**
* @return int whether the form should be rather on the top or bottom of
* the settings navigation. The sections are arranged in ascending order of
* the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
*/
public function getPriority() {
return 30;
}

/**
* {@inheritdoc}
*/
public function getIcon() {
return $this->url->imagePath('theming', 'app-dark.svg');
}
}
4 changes: 4 additions & 0 deletions apps/theming/tests/ServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
use OCA\Theming\Capabilities;
use OCA\Theming\Controller\ThemingController;
use OCA\Theming\Settings\Admin;
use OCA\Theming\Settings\Section;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCP\AppFramework\App;
use OCP\Capabilities\ICapability;
use OCP\IL10N;
use OCP\Settings\ISection;
use OCP\Settings\ISettings;
use Test\TestCase;

Expand Down Expand Up @@ -70,6 +72,8 @@ public function queryData() {
// Settings
[Admin::class],
[Admin::class, ISettings::class],
[Section::class],
[Section::class, ISection::class],
];
}

Expand Down
77 changes: 77 additions & 0 deletions apps/theming/tests/Settings/SectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* @copyright Copyright (c) 2016 Lukas Reschke <[email protected]>
*
* @author Joas Schilling <[email protected]>
* @author Lukas Reschke <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Theming\Tests\Settings;

use OCA\Theming\Settings\Section;
use OCP\IL10N;
use OCP\IURLGenerator;
use Test\TestCase;

class SectionTest extends TestCase {
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
private $url;
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
private $l;
/** @var Section */
private $section;

public function setUp() {
parent::setUp();
$this->url = $this->createMock(IURLGenerator::class);
$this->l = $this->createMock(IL10N::class);

$this->section = new Section(
$this->url,
$this->l
);
}

public function testGetID() {
$this->assertSame('theming', $this->section->getID());
}

public function testGetName() {
$this->l
->expects($this->once())
->method('t')
->with('Theming')
->willReturn('Theming');

$this->assertSame('Theming', $this->section->getName());
}

public function testGetPriority() {
$this->assertSame(30, $this->section->getPriority());
}

public function testGetIcon() {
$this->url->expects($this->once())
->method('imagePath')
->with('theming', 'app-dark.svg')
->willReturn('icon');

$this->assertSame('icon', $this->section->getIcon());
}
}
8 changes: 4 additions & 4 deletions core/css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ a {
* {
cursor: pointer;
}
}

&.external {
margin: 0 3px;
text-decoration: underline;
}
a.external {
margin: 0 3px;
text-decoration: underline;
}

input {
Expand Down
2 changes: 0 additions & 2 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@
'OC\\Settings\\Controller\\LogSettingsController' => $baseDir . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => $baseDir . '/settings/Controller/MailSettingsController.php',
'OC\\Settings\\Controller\\PersonalSettingsController' => $baseDir . '/settings/Controller/PersonalSettingsController.php',
'OC\\Settings\\Controller\\ServerInfoSettingsController' => $baseDir . '/settings/Controller/ServerInfoSettingsController.php',
'OC\\Settings\\Controller\\TwoFactorSettingsController' => $baseDir . '/settings/Controller/TwoFactorSettingsController.php',
'OC\\Settings\\Controller\\UsersController' => $baseDir . '/settings/Controller/UsersController.php',
'OC\\Settings\\Hooks' => $baseDir . '/settings/Hooks.php',
Expand All @@ -1101,7 +1100,6 @@
'OC\\Settings\\Personal\\Security' => $baseDir . '/lib/private/Settings/Personal/Security.php',
'OC\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/lib/private/Settings/Personal/ServerDevNotice.php',
'OC\\Settings\\Section' => $baseDir . '/lib/private/Settings/Section.php',
'OC\\Settings\\Theming\\ServerInfo' => $baseDir . '/lib/private/Settings/Theming/ServerInfo.php',
'OC\\Setup' => $baseDir . '/lib/private/Setup.php',
'OC\\Setup\\AbstractDatabase' => $baseDir . '/lib/private/Setup/AbstractDatabase.php',
'OC\\Setup\\MySQL' => $baseDir . '/lib/private/Setup/MySQL.php',
Expand Down
2 changes: 0 additions & 2 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/LogSettingsController.php',
'OC\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/MailSettingsController.php',
'OC\\Settings\\Controller\\PersonalSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/PersonalSettingsController.php',
'OC\\Settings\\Controller\\ServerInfoSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/ServerInfoSettingsController.php',
'OC\\Settings\\Controller\\TwoFactorSettingsController' => __DIR__ . '/../../..' . '/settings/Controller/TwoFactorSettingsController.php',
'OC\\Settings\\Controller\\UsersController' => __DIR__ . '/../../..' . '/settings/Controller/UsersController.php',
'OC\\Settings\\Hooks' => __DIR__ . '/../../..' . '/settings/Hooks.php',
Expand All @@ -1131,7 +1130,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Settings\\Personal\\Security' => __DIR__ . '/../../..' . '/lib/private/Settings/Personal/Security.php',
'OC\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/../../..' . '/lib/private/Settings/Personal/ServerDevNotice.php',
'OC\\Settings\\Section' => __DIR__ . '/../../..' . '/lib/private/Settings/Section.php',
'OC\\Settings\\Theming\\ServerInfo' => __DIR__ . '/../../..' . '/lib/private/Settings/Theming/ServerInfo.php',
'OC\\Setup' => __DIR__ . '/../../..' . '/lib/private/Setup.php',
'OC\\Setup\\AbstractDatabase' => __DIR__ . '/../../..' . '/lib/private/Setup/AbstractDatabase.php',
'OC\\Setup\\MySQL' => __DIR__ . '/../../..' . '/lib/private/Setup/MySQL.php',
Expand Down
5 changes: 0 additions & 5 deletions lib/private/Settings/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public function getAdminSections(): array {
1 => [new Section('server', $this->l->t('Basic settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
5 => [new Section('sharing', $this->l->t('Sharing'), 0, $this->url->imagePath('core', 'actions/share.svg'))],
10 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('core', 'actions/password.svg'))],
30 => [new Section('theming', $this->l->t('Theming'), 0, $this->url->imagePath('settings', 'theming-dark.svg'))],
50 => [new Section('groupware', $this->l->t('Groupware'), 0, $this->url->imagePath('core', 'places/contacts.svg'))],
98 => [new Section('additional', $this->l->t('Additional settings'), 0, $this->url->imagePath('core', 'actions/settings-dark.svg'))],
];
Expand Down Expand Up @@ -238,10 +237,6 @@ private function getBuiltInAdminSettings($section): array {
$form = $this->container->query(Admin\Security::class);
$forms[$form->getPriority()] = [$form];
}
if ($section === 'theming') {
$form = $this->container->query(Theming\ServerInfo::class);
$forms[$form->getPriority()] = [$form];
}
if ($section === 'sharing') {
/** @var ISettings $form */
$form = $this->container->query(Admin\Sharing::class);
Expand Down
44 changes: 4 additions & 40 deletions lib/private/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
namespace OC\Settings\Personal;

use OC\Accounts\AccountManager;
use OC\Settings\Theming\ServerInfo;
use OCA\FederatedFileSharing\AppInfo\Application;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\TemplateResponse;
Expand All @@ -39,7 +38,6 @@
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
use OCP\Encryption\IManager as EncryptionManager;

class PersonalInfo implements ISettings {

Expand All @@ -57,18 +55,14 @@ class PersonalInfo implements ISettings {
private $l10nFactory;
/** @var IL10N */
private $l;
/** @var EncryptionManager */
private $encryptionManager;

/**
* @param IConfig $config
* @param IUserManager $userManager
* @param IGroupManager $groupManager
* @param AccountManager $accountManager
* @param IAppManager $appManager
* @param IFactory $l10nFactory
* @param IL10N $l
* @param EncryptionManager $encryptionManager
*/
public function __construct(
IConfig $config,
Expand All @@ -77,8 +71,7 @@ public function __construct(
AccountManager $accountManager,
IAppManager $appManager,
IFactory $l10nFactory,
IL10N $l,
EncryptionManager $encryptionManager
IL10N $l
) {
$this->config = $config;
$this->userManager = $userManager;
Expand All @@ -87,7 +80,6 @@ public function __construct(
$this->appManager = $appManager;
$this->l10nFactory = $l10nFactory;
$this->l = $l;
$this->encryptionManager = $encryptionManager;
}

/**
Expand Down Expand Up @@ -143,38 +135,10 @@ public function getForm() {
'twitterScope' => $userData[AccountManager::PROPERTY_TWITTER]['scope'],
'twitterVerification' => $userData[AccountManager::PROPERTY_TWITTER]['verified'],
'groups' => $this->getGroups($user),
] + $this->getWhereIsYourDataParams() + $messageParameters + $languageParameters + $localeParameters;
] + $messageParameters + $languageParameters + $localeParameters;

return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
}

/**
* Returns the "where is your data" template params.
*
* @return array
*/
private function getWhereIsYourDataParams(): array {

$adminContactConfigId = $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER_ADMIN_CONTACT);
$adminContact = $this->userManager->get($adminContactConfigId);

$params = [
'dataLocation' => $this->config->getSystemValue(ServerInfo::SETTING_LOCATION),
'provider' => $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER),
'providerLink' => $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER_WEBSITE),
'providerPrivacyLink' => $this->config->getSystemValue(ServerInfo::SETTING_PROVIDER_PRIVACY_LINK),
'encryptionEnabled' => $this->encryptionManager->isEnabled(),
'adminName' => $adminContact !== null ? $adminContact->getDisplayName() : '',
'adminMail' => $adminContact !== null ? $adminContact->getEMailAddress() : ''
];

$params['show_where_is_your_data_section'] = empty($params['dataLocation']) === false
|| empty($params['provider']) === false
|| $params['encryptionEnabled'] === true
|| empty($params['adminName']) === false;

return $params;

return new TemplateResponse('settings', 'settings/personal/personal.info', $parameters, '');
}

/**
Expand Down Expand Up @@ -238,7 +202,7 @@ private function getLanguages(IUser $user) {
$userLang = $languages['commonlanguages'][$userLangIndex];
// search in the other languages
if ($userLangIndex === false) {
$userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
$userLangIndex = array_search($userConfLang, array_column($languages['languages'], 'code'));
$userLang = $languages['languages'][$userLangIndex];
}
// if user language is not available but set somehow: show the actual code as name
Expand Down
Loading