|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Music app |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Pauli Järvinen <[email protected]> |
|
10
|
|
|
* @copyright Pauli Järvinen 2021 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace OCA\Music\Command; |
|
14
|
|
|
|
|
15
|
|
|
use OCA\Music\Utility\PodcastService; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
|
|
19
|
|
|
class PodcastReset extends BaseCommand { |
|
20
|
|
|
|
|
21
|
|
|
/** @var PodcastService */ |
|
22
|
|
|
private $podcastService; |
|
23
|
|
|
|
|
24
|
|
|
public function __construct( |
|
25
|
|
|
\OCP\IUserManager $userManager, |
|
26
|
|
|
\OCP\IGroupManager $groupManager, |
|
27
|
|
|
PodcastService $podcastService) { |
|
28
|
|
|
$this->podcastService = $podcastService; |
|
29
|
|
|
parent::__construct($userManager, $groupManager); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
protected function doConfigure() { |
|
33
|
|
|
$this |
|
34
|
|
|
->setName('music:podcast-reset') |
|
35
|
|
|
->setDescription('remove all podcast channels of one or more users') |
|
36
|
|
|
; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
protected function doExecute(InputInterface $input, OutputInterface $output, $users) { |
|
40
|
|
|
if ($input->getOption('all')) { |
|
41
|
|
|
$this->userManager->callForAllUsers(function($user) use ($output) { |
|
42
|
|
|
$this->resetPodcasts($user->getUID(), $output); |
|
43
|
|
|
}); |
|
44
|
|
|
} else { |
|
45
|
|
|
foreach ($users as $userId) { |
|
46
|
|
|
$this->resetPodcasts($userId, $output); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
private function resetPodcasts(string $userId, OutputInterface $output) { |
|
52
|
|
|
$output->writeln("Reset all podcasts of the user <info>$userId</info>"); |
|
53
|
|
|
$this->podcastService->resetAll($userId); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|