2026-04-16 14:01:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace OCA\MinimalProfile\AppInfo;
|
|
|
|
|
|
|
|
|
|
use OCP\AppFramework\App;
|
|
|
|
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
|
|
|
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
|
|
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
2026-04-16 14:58:16 +02:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2026-04-16 15:00:27 +02:00
|
|
|
use OCP\IConfig;
|
2026-04-16 14:37:17 +02:00
|
|
|
use OCP\Util;
|
2026-04-16 14:01:13 +02:00
|
|
|
|
|
|
|
|
class Application extends App implements IBootstrap {
|
|
|
|
|
|
|
|
|
|
public const APP_ID = 'minimalprofile';
|
|
|
|
|
|
|
|
|
|
public function __construct(array $urlParams = []) {
|
|
|
|
|
parent::__construct(self::APP_ID, $urlParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function register(IRegistrationContext $context): void {
|
2026-04-16 15:00:27 +02:00
|
|
|
$context->registerService(IConfig::class, function($c) {
|
|
|
|
|
return $c->get(IConfig::class);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-16 14:58:16 +02:00
|
|
|
$context->registerEventListener(
|
|
|
|
|
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
2026-04-16 15:00:27 +02:00
|
|
|
LoadStylesListener::class
|
2026-04-16 14:58:16 +02:00
|
|
|
);
|
2026-04-16 14:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function boot(IBootContext $context): void {
|
2026-04-16 14:50:02 +02:00
|
|
|
}
|
2026-04-16 15:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class LoadStylesListener {
|
|
|
|
|
private IConfig $config;
|
|
|
|
|
|
|
|
|
|
public function __construct(IConfig $config) {
|
|
|
|
|
$this->config = $config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __invoke(): void {
|
|
|
|
|
$value = $this->config->getAppValue('minimalprofile', 'hidden_fields', '');
|
|
|
|
|
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
|
|
|
|
|
|
|
|
|
if (empty($hidden)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$selectors = [
|
|
|
|
|
'pronouns' => '#account-property-pronouns',
|
|
|
|
|
'role' => '#account-property-role',
|
|
|
|
|
'headline' => '#account-property-headline',
|
|
|
|
|
'biography' => '#account-property-biography',
|
|
|
|
|
'organisation' => '#account-property-organisation',
|
|
|
|
|
'phone' => '#account-property-phone',
|
|
|
|
|
'address' => '#account-property-address',
|
|
|
|
|
'birthdate' => '#account-property-birthdate',
|
|
|
|
|
'website' => '#account-property-website',
|
|
|
|
|
'twitter' => '#account-property-twitter',
|
|
|
|
|
'fediverse' => '#account-property-fediverse',
|
|
|
|
|
'location' => '#account-property-location',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$css = '';
|
|
|
|
|
foreach ($hidden as $field) {
|
|
|
|
|
if (isset($selectors[$field])) {
|
|
|
|
|
$css .= '.personal-settings-setting-box:has(' . $selectors[$field] . ') { display: none !important; }' . "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($css) {
|
|
|
|
|
Util::addInlineStyle($css);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-16 14:01:13 +02:00
|
|
|
}
|