diff --git a/appinfo/info.xml b/appinfo/info.xml
index 01cdcd4..307c3de 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -4,7 +4,7 @@
Minimal Profile
Hides profile fields to create a minimal user profile
Allows administrators to hide profile fields like pronouns, social links, etc.
- 1.0.20
+ 1.0.21
AGPL
Your Name
MinimalProfile
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 92a6bf3..e995418 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -9,6 +9,7 @@ use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\IConfig;
use OCP\Util;
class Application extends App implements IBootstrap {
@@ -20,17 +21,41 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
- // Register event listener - this fires on EVERY page render after template is built
+ $context->registerService(IConfig::class, function($c) {
+ return $c->get(IConfig::class);
+ });
+
$context->registerEventListener(
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
function() {
Util::addStyle('minimalprofile', 'minimalprofile');
}
);
-
- file_put_contents('/tmp/minimalprofile.log', date('Y-m-d H:i:s') . ' register, event registered' . "\n", FILE_APPEND);
}
public function boot(IBootContext $context): void {
+ $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);
}
}
\ No newline at end of file