v1.0.25 - write to data dir
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<name>Minimal Profile</name>
|
<name>Minimal Profile</name>
|
||||||
<summary>Hides profile fields to create a minimal user profile</summary>
|
<summary>Hides profile fields to create a minimal user profile</summary>
|
||||||
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
<description>Allows administrators to hide profile fields like pronouns, social links, etc.</description>
|
||||||
<version>1.0.24</version>
|
<version>1.0.25</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Your Name</author>
|
<author>Your Name</author>
|
||||||
<namespace>MinimalProfile</namespace>
|
<namespace>MinimalProfile</namespace>
|
||||||
|
|||||||
@@ -13,43 +13,23 @@ use OCP\Util;
|
|||||||
|
|
||||||
class Application extends App implements IBootstrap {
|
class Application extends App implements IBootstrap {
|
||||||
|
|
||||||
public const APP_ID = 'minimalprofile';
|
|
||||||
|
|
||||||
public function __construct(array $urlParams = []) {
|
public function __construct(array $urlParams = []) {
|
||||||
parent::__construct(self::APP_ID, $urlParams);
|
parent::__construct('minimalprofile', $urlParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(IRegistrationContext $context): void {
|
public function register(IRegistrationContext $context): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function boot(IBootContext $context): void {
|
public function boot(IBootContext $context): void {
|
||||||
$container = $context->getAppContainer();
|
// Write to Nextcloud data directory
|
||||||
$config = $container->query(IConfig::class);
|
$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', '');
|
// Load CSS
|
||||||
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||||
|
|
||||||
$css = '';
|
// Store result
|
||||||
if (!empty($hidden)) {
|
@file_put_contents($dataDir . '/mp_result.log', date('Y-m-d H:i:s') . ' result: ' . ($result ?: 'failed') . "\n", FILE_APPEND);
|
||||||
$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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user