Merge pull request #7080 from Fledermaus-20/main

Add OCC commands for global calendar feature opt-in and opt-out in Deck
This commit is contained in:
Luka Trovic
2025-07-21 13:58:09 +02:00
committed by GitHub
3 changed files with 69 additions and 1 deletions

View File

@@ -62,6 +62,7 @@
<command>OCA\Deck\Command\UserExport</command>
<command>OCA\Deck\Command\BoardImport</command>
<command>OCA\Deck\Command\TransferOwnership</command>
<command>OCA\Deck\Command\CalendarToggle</command>
</commands>
<activity>
<settings>

2
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6950663d9d213151028e780637480220",
"content-hash": "2a3a67d1b7c70fe1cee2183c26b0c906",
"packages": [
{
"name": "justinrainbow/json-schema",

View File

@@ -0,0 +1,67 @@
<?php
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Deck\Command;
use OCP\IConfig;
use OCP\IUserManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class CalendarToggle extends Command {
private IUserManager $userManager;
private IConfig $config;
public function __construct(IUserManager $userManager, IConfig $config) {
parent::__construct();
$this->userManager = $userManager;
$this->config = $config;
}
protected function configure() {
$this
->setName('deck:calendar-toggle')
->setDescription('Enable or disable Deck calendar/tasks integration for all existing users. Users can still change their own setting afterwards. Only affects users that already exist at the time of execution.')
->addOption(
'on',
null,
InputOption::VALUE_NONE,
'Enable calendar/tasks integration for all existing users (users can opt-out later)'
)
->addOption(
'off',
null,
InputOption::VALUE_NONE,
'Disable calendar/tasks integration for all existing users (users can opt-in later)'
);
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$enable = $input->getOption('on');
$disable = $input->getOption('off');
if ($enable && $disable) {
$output->writeln('<error>Cannot use --on and --off together.</error>');
return 1;
}
if (!$enable && !$disable) {
$output->writeln('<error>Please specify either --on or --off.</error>');
return 1;
}
$value = $enable ? 'yes' : '';
$users = $this->userManager->search('');
$count = 0;
foreach ($users as $user) {
$uid = $user->getUID();
$this->config->setUserValue($uid, 'deck', 'calendar', $value);
$output->writeln("Set calendar integration to '" . ($enable ? 'on' : 'off') . "' for user: $uid");
$count++;
}
$output->writeln("Done. Updated $count existing users.");
return 0;
}
}