v1.0.28 - register calls addScript
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<name>Minimal Profile</name>
|
||||
<summary>Hides profile fields to create a minimal user profile</summary>
|
||||
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
||||
<version>1.0.27</version>
|
||||
<version>1.0.28</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Your Name</author>
|
||||
<namespace>MinimalProfile</namespace>
|
||||
|
||||
@@ -8,49 +8,19 @@ use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\IConfig;
|
||||
use OCP\Util;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
|
||||
public const APP_ID = 'minimalprofile';
|
||||
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct(self::APP_ID, $urlParams);
|
||||
parent::__construct('minimalprofile', $urlParams);
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
Util::addScript('minimalprofile', 'minimalprofile');
|
||||
file_put_contents('/tmp/mp_register.log', date('Y-m-d H:i:s') . ' register added JS' . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
$container = $context->getAppContainer();
|
||||
$config = $container->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";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Debug
|
||||
$css = 'body { border: 40px solid orange !important; }';
|
||||
}
|
||||
|
||||
if ($css) {
|
||||
Util::addInlineStyle($css);
|
||||
}
|
||||
|
||||
// Also log to file as backup
|
||||
file_put_contents('/tmp/minimalprofile_debug.log', date('Y-m-d H:i:s') . ' boot called, hidden: ' . print_r($hidden, true) . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user