Try EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN in register
This commit is contained in:
@@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace OCA\MinimalProfile\AppInfo;
|
namespace OCA\MinimalProfile\AppInfo;
|
||||||
|
|
||||||
use OCA\MinimalProfile\Service\Config;
|
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||||
@@ -24,37 +23,13 @@ class Application extends App implements IBootstrap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function register(IRegistrationContext $context): void {
|
public function register(IRegistrationContext $context): void {
|
||||||
$context->registerService(Config::class, function($c) {
|
|
||||||
return new Config($c->get(IConfig::class));
|
|
||||||
});
|
|
||||||
|
|
||||||
$context->registerEventListener(
|
$context->registerEventListener(
|
||||||
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS,
|
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN,
|
||||||
TemplateListener::class
|
function(Event $event) {
|
||||||
);
|
if ($event instanceof TemplateResponse) {
|
||||||
}
|
$config = $event->getAppContainer()->query(IConfig::class);
|
||||||
|
$value = $config->getAppValue('minimalprofile', 'hidden_fields', '');
|
||||||
public function boot(IBootContext $context): void {
|
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TemplateListener implements IEventListener {
|
|
||||||
|
|
||||||
private Config $config;
|
|
||||||
|
|
||||||
public function __construct(Config $config) {
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle(Event $event): void {
|
|
||||||
if (!($event instanceof TemplateResponse)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$hidden = $this->config->getHiddenFields();
|
|
||||||
|
|
||||||
$debugCss = '#content { border: 30px solid cyan !important; }';
|
|
||||||
Util::addInlineStyle($debugCss);
|
|
||||||
|
|
||||||
$css = '';
|
$css = '';
|
||||||
if (!empty($hidden)) {
|
if (!empty($hidden)) {
|
||||||
@@ -66,6 +41,7 @@ class TemplateListener implements IEventListener {
|
|||||||
foreach ($hidden as $field) {
|
foreach ($hidden as $field) {
|
||||||
if (isset($selectors[$field])) {
|
if (isset($selectors[$field])) {
|
||||||
$css .= $selectors[$field] . ' { display: none !important; }' . "\n";
|
$css .= $selectors[$field] . ' { display: none !important; }' . "\n";
|
||||||
|
$css .= '.personal-settings-setting-box:has(' . $selectors[$field] . ') { display: none !important; }' . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,6 +50,12 @@ class TemplateListener implements IEventListener {
|
|||||||
Util::addInlineStyle($css);
|
Util::addInlineStyle($css);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents('/tmp/minimalprofile_debug.log', date('Y-m-d H:i:s') . ' TemplateListener ran, hidden: ' . print_r($hidden, true) . "\n", FILE_APPEND);
|
file_put_contents('/tmp/minimalprofile.log', date('Y-m-d H:i:s') . ' EVENT fired, hidden: ' . print_r($hidden, true) . "\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot(IBootContext $context): void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user