3 namespace Friendica\Core\Console;
\r
5 use Friendica\Core\L10n;
\r
6 use Friendica\Model\Contact;
\r
9 * @brief tool to block an account from the node
\r
11 * With this tool, you can block an account in such a way, that no postings
\r
12 * or comments this account writes are accepted to the node.
\r
14 * License: AGPLv3 or later, same as Friendica
\r
16 * @author Tobias Diekershoff <mrpetovan@gmail.com>
\r
17 * @author Hypolite Petovan <mrpetovan@gmail.com>
\r
19 class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
\r
21 protected $helpOptions = ['h', 'help', '?'];
\r
23 protected function getHelp()
\r
26 console globalcommunityblock - Block remote profile from interacting with this node
\r
28 bin/console globalcommunityblock <profile_url> [-h|--help|-?] [-v]
\r
31 Blocks an account in such a way that no postings or comments this account writes are accepted to this node.
\r
34 -h|--help|-? Show help information
\r
35 -v Show more debug information.
\r
40 protected function doExecute()
\r
42 if ($this->getOption('v')) {
\r
43 $this->out('Class: ' . __CLASS__);
\r
44 $this->out('Arguments: ' . var_export($this->args, true));
\r
45 $this->out('Options: ' . var_export($this->options, true));
\r
48 if (count($this->args) == 0) {
\r
49 $this->out($this->getHelp());
\r
53 if (count($this->args) > 1) {
\r
54 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
\r
57 require_once '.htconfig.php';
\r
58 $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
\r
59 unset($db_host, $db_user, $db_pass, $db_data);
\r
62 throw new \RuntimeException('Unable to connect to database');
\r
65 $contact_id = Contact::getIdForURL($this->getArgument(0));
\r
67 throw new \RuntimeException(L10n::t('Could not find any contact entry for this URL (%s)', $nurl));
\r
69 if(Contact::block($contact_id)) {
\r
70 $this->out(L10n::t('The contact has been blocked from the node'));
\r
72 throw new \RuntimeException('The contact block failed.');
\r