|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace OCA\Chat\Command; |
|
4
|
|
|
|
|
5
|
|
|
use \OCP\App\IAppManager; |
|
6
|
|
|
use \OCP\IDb; |
|
7
|
|
|
use \Symfony\Component\Console\Command\Command; |
|
8
|
|
|
use \Symfony\Component\Console\Input\InputInterface; |
|
9
|
|
|
use \Symfony\Component\Console\Output\OutputInterface; |
|
10
|
|
|
|
|
11
|
|
|
class UnInstall extends Command { |
|
12
|
|
|
|
|
13
|
|
|
private $appManager; |
|
14
|
|
|
|
|
15
|
|
|
private $db; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct(IAppManager $appManager, IDb $db){ |
|
18
|
|
|
$this->appManager = $appManager; |
|
19
|
|
|
$this->db = $db; |
|
20
|
|
|
parent::__construct(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function configure(){ |
|
24
|
|
|
$this->setName('chat:uninstall') |
|
25
|
|
|
->setDescription('Completely uninstalls the Chat app. WARNING: ALL Chat DATA WILL BE LOST!') |
|
26
|
|
|
; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function execute(InputInterface $input, OutputInterface $output){ |
|
30
|
|
|
$this->appManager->disableApp('chat'); |
|
31
|
|
|
$output->writeln("Chat app disabled"); |
|
32
|
|
|
$queries = array( |
|
33
|
|
|
"DROP TABLE *PREFIX*chat_attachments;", |
|
34
|
|
|
"DROP TABLE *PREFIX*chat_config;", |
|
35
|
|
|
"DROP TABLE *PREFIX*chat_och_conversations;", |
|
36
|
|
|
"DROP TABLE *PREFIX*chat_och_messages;", |
|
37
|
|
|
"DROP TABLE *PREFIX*chat_och_push_messages;", |
|
38
|
|
|
"DROP TABLE *PREFIX*chat_och_users_online;", |
|
39
|
|
|
"DROP TABLE *PREFIX*chat_och_users_in_conversation;", |
|
40
|
|
|
"DELETE FROM *PREFIX*appconfig WHERE appid='chat';" |
|
41
|
|
|
); |
|
42
|
|
|
foreach ($queries as $qeury) { |
|
43
|
|
|
$this->db->executeQuery($qeury); |
|
44
|
|
|
} |
|
45
|
|
|
$output->writeln("Database cleaned up"); |
|
46
|
|
|
$output->writeln("Chat uninstalled"); |
|
47
|
|
|
} |
|
48
|
|
|
} |