v1.0.22 - appinfo/app.php runs on every request + simplified boot()
This commit is contained in:
6
appinfo/app.php
Normal file
6
appinfo/app.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Legacy app entry point - loads on every page
|
||||
*/
|
||||
\OCP\Util::addStyle('minimalprofile', 'minimalprofile');
|
||||
file_put_contents('/tmp/mp_init.log', date('Y-m-d H:i:s') . ' loaded' . "\n", FILE_APPEND);
|
||||
@@ -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.21</version>
|
||||
<version>1.0.22</version>
|
||||
<licence>AGPL</licence>
|
||||
<author>Your Name</author>
|
||||
<namespace>MinimalProfile</namespace>
|
||||
|
||||
@@ -1,61 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Minimal Profile app bootstrap
|
||||
*/
|
||||
namespace OCA\MinimalProfile\AppInfo;
|
||||
|
||||
use OCP\AppFramework\App;
|
||||
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 {
|
||||
|
||||
public const APP_ID = 'minimalprofile';
|
||||
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct(self::APP_ID, $urlParams);
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerService(IConfig::class, function($c) {
|
||||
return $c->get(IConfig::class);
|
||||
});
|
||||
|
||||
$context->registerEventListener(
|
||||
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
||||
function() {
|
||||
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {}
|
||||
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);
|
||||
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user