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 16:03:37 +02:00
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
2026-04-16 16:16:33 +02:00
|
|
|
use OCP\IConfig;
|
2026-04-16 16:03:37 +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 16:16:33 +02:00
|
|
|
$context->registerService(IConfig::class, function($c) {
|
|
|
|
|
return $c->get(IConfig::class);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-16 16:03:37 +02:00
|
|
|
$context->registerEventListener(
|
|
|
|
|
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
|
|
|
|
function() {
|
|
|
|
|
Util::addStyle('minimalprofile', 'minimalprofile');
|
|
|
|
|
}
|
|
|
|
|
);
|
2026-04-16 14:01:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function boot(IBootContext $context): void {
|
2026-04-16 16:16:33 +02:00
|
|
|
$config = $context->getAppContainer()->query(IConfig::class);
|
|
|
|
|
$value = $config->getAppValue('minimalprofile', 'hidden_fields', '');
|
|
|
|
|
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
|
|
|
|
|
|
|
|
|
$css = '';
|
|
|
|
|
if (!empty($hidden)) {
|
|
|
|
|
$selectors = [
|
|
|
|
|
'pronouns' => '#account-property-pronouns',
|
|
|
|
|
'role' => '#account-property-role',
|
|
|
|
|
'headline' => '#account-property-headline',
|
|
|
|
|
];
|
|
|
|
|
foreach ($hidden as $field) {
|
|
|
|
|
if (isset($selectors[$field])) {
|
|
|
|
|
$css .= $selectors[$field] . ' { display: none !important; }' . "\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($css) {
|
|
|
|
|
Util::addInlineStyle($css);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file_put_contents('/tmp/mp_loaded.log', date('Y-m-d H:i:s') . ' boot ran, hidden: ' . print_r($hidden, true) . ", css: $css\n", FILE_APPEND);
|
2026-04-16 14:50:02 +02:00
|
|
|
}
|
2026-04-16 14:01:13 +02:00
|
|
|
}
|