3 namespace Friendica\Core\Console;
\r
5 use Friendica\Core\L10n;
\r
6 use Friendica\Model\Contact;
\r
9 * Description of GlobalCommunityBlock
\r
11 * @author Hypolite Petovan <mrpetovan@gmail.com>
\r
13 class GlobalCommunityBlock extends \Asika\SimpleConsole\Console
\r
15 protected $helpOptions = ['h', 'help', '?'];
\r
17 protected function getHelp()
\r
20 console globalcommunityblock - Silence remote profile from global community page
\r
22 bin/console globalcommunityblock <profile_url> [-h|--help|-?] [-v]
\r
25 bin/console globalcommunityblock <profile_url>
\r
26 Silences the provided remote profile URL from the global community page
\r
29 -h|--help|-? Show help information
\r
30 -v Show more debug information.
\r
35 protected function doExecute()
\r
37 if ($this->getOption('v')) {
\r
38 $this->out('Class: ' . __CLASS__);
\r
39 $this->out('Arguments: ' . var_export($this->args, true));
\r
40 $this->out('Options: ' . var_export($this->options, true));
\r
43 if (count($this->args) == 0) {
\r
44 $this->out($this->getHelp());
\r
48 if (count($this->args) > 1) {
\r
49 throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
\r
52 require_once '.htconfig.php';
\r
53 $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
\r
54 unset($db_host, $db_user, $db_pass, $db_data);
\r
57 throw new \RuntimeException('Unable to connect to database');
\r
60 $contact_id = Contact::getIdForURL($argv[1]);
\r
62 throw new \RuntimeException(L10n::t('Could not find any contact entry for this URL (%s)', $nurl));
\r
64 Contact::block($contact_id);
\r
65 $this->out(L10n::t('The contact has been blocked from the node'));
\r