v1.0.25 - write to data dir
This commit is contained in:
@@ -13,43 +13,23 @@ 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 {
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
$container = $context->getAppContainer();
|
||||
$config = $container->query(IConfig::class);
|
||||
// Write to Nextcloud data directory
|
||||
$dataDir = \OCP\Server::get(\OCP\IConfig::class)->getSystemValue('datadirectory');
|
||||
$testFile = $dataDir . '/minimalprofile_test.log';
|
||||
$result = @file_put_contents($testFile, date('Y-m-d H:i:s') . ' boot ran, config: ' . \OCP\Server::get(IConfig::class)->getAppValue('minimalprofile', 'hidden_fields', 'none') . "\n");
|
||||
|
||||
$value = $config->getAppValue('minimalprofile', 'hidden_fields', '');
|
||||
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
||||
// Load CSS
|
||||
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||
|
||||
$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: 30px solid green !important; }';
|
||||
}
|
||||
|
||||
if ($css) {
|
||||
Util::addInlineStyle($css);
|
||||
}
|
||||
|
||||
file_put_contents('/tmp/mp_boot.log', date('Y-m-d H:i:s') . ' boot ran, hidden: ' . print_r($hidden, true) . ", css: $css\n", FILE_APPEND);
|
||||
// Store result
|
||||
@file_put_contents($dataDir . '/mp_result.log', date('Y-m-d H:i:s') . ' result: ' . ($result ?: 'failed') . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user