-<?php\r
-\r
-namespace Friendica\Core\Console;\r
-\r
-use Friendica\Core\Protocol;\r
-use Friendica\Database\DBM;\r
-use Friendica\Network\Probe;\r
-\r
-require_once 'include/text.php';\r
-\r
-/**\r
- * @brief tool to silence accounts on the global community page\r
- *\r
- * With this tool, you can silence an account on the global community page.\r
- * Postings from silenced accounts will not be displayed on the community\r
- * page. This silencing does only affect the display on the community page,\r
- * accounts following the silenced accounts will still get their postings.\r
- *\r
- * License: AGPLv3 or later, same as Friendica\r
- *\r
- * @author Tobias Diekershoff\r
- * @author Hypolite Petovan <mrpetovan@gmail.com>\r
- */\r
-class GlobalCommunitySilence extends \Asika\SimpleConsole\Console\r
-{\r
- protected $helpOptions = ['h', 'help', '?'];\r
-\r
- protected function getHelp()\r
- {\r
- $help = <<<HELP\r
-console globalcommunitysilence - Silence remote profile from global community page\r
-Usage\r
- bin/console globalcommunitysilence <profile_url> [-h|--help|-?] [-v]\r
-\r
-Description\r
- With this tool, you can silence an account on the global community page.\r
- Postings from silenced accounts will not be displayed on the community page.\r
- This silencing does only affect the display on the community page, accounts\r
- following the silenced accounts will still get their postings.\r
-\r
-Options\r
- -h|--help|-? Show help information\r
- -v Show more debug information.\r
-HELP;\r
- return $help;\r
- }\r
-\r
- protected function doExecute()\r
- {\r
- if ($this->getOption('v')) {\r
- $this->out('Class: ' . __CLASS__);\r
- $this->out('Arguments: ' . var_export($this->args, true));\r
- $this->out('Options: ' . var_export($this->options, true));\r
- }\r
-\r
- if (count($this->args) == 0) {\r
- $this->out($this->getHelp());\r
- return 0;\r
- }\r
-\r
- if (count($this->args) > 1) {\r
- throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');\r
- }\r
-\r
- require_once '.htconfig.php';\r
- $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);\r
- unset($db_host, $db_user, $db_pass, $db_data);\r
-\r
- if (!$result) {\r
- throw new \RuntimeException('Unable to connect to database');\r
- }\r
-\r
- /**\r
- * 1. make nurl from last parameter\r
- * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID\r
- * 3. set the flag hidden=1 for the contact entry with the found ID\r
- * */\r
- $net = Probe::uri($this->getArgument(0));\r
- if (in_array($net['network'], [Protocol::PHANTOM, Protocol::MAIL])) {\r
- throw new \RuntimeException('This account seems not to exist.');\r
- }\r
-\r
- $nurl = normalise_link($net['url']);\r
- $contact = \dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);\r
- if (DBM::is_result($contact)) {\r
- \dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);\r
- $this->out('NOTICE: The account should be silenced from the global community page');\r
- } else {\r
- throw new \RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');\r
- }\r
-\r
- return 0;\r
- }\r
-}\r
+<?php
+
+namespace Friendica\Core\Console;
+
+use Friendica\Core\Protocol;
+use Friendica\Database\DBM;
+use Friendica\Network\Probe;
+
+require_once 'include/text.php';
+
+/**
+ * @brief tool to silence accounts on the global community page
+ *
+ * With this tool, you can silence an account on the global community page.
+ * Postings from silenced accounts will not be displayed on the community
+ * page. This silencing does only affect the display on the community page,
+ * accounts following the silenced accounts will still get their postings.
+ *
+ * License: AGPLv3 or later, same as Friendica
+ *
+ * @author Tobias Diekershoff
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+class GlobalCommunitySilence extends \Asika\SimpleConsole\Console
+{
+ protected $helpOptions = ['h', 'help', '?'];
+
+ protected function getHelp()
+ {
+ $help = <<<HELP
+console globalcommunitysilence - Silence remote profile from global community page
+Usage
+ bin/console globalcommunitysilence <profile_url> [-h|--help|-?] [-v]
+
+Description
+ With this tool, you can silence an account on the global community page.
+ Postings from silenced accounts will not be displayed on the community page.
+ This silencing does only affect the display on the community page, accounts
+ following the silenced accounts will still get their postings.
+
+Options
+ -h|--help|-? Show help information
+ -v Show more debug information.
+HELP;
+ return $help;
+ }
+
+ protected function doExecute()
+ {
+ $a = get_app();
+
+ if ($this->getOption('v')) {
+ $this->out('Class: ' . __CLASS__);
+ $this->out('Arguments: ' . var_export($this->args, true));
+ $this->out('Options: ' . var_export($this->options, true));
+ }
+
+ if (count($this->args) == 0) {
+ $this->out($this->getHelp());
+ return 0;
+ }
+
+ if (count($this->args) > 1) {
+ throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
+ }
+
+ require_once '.htconfig.php';
+ $result = \dba::connect($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+
+ if (!$result) {
+ throw new \RuntimeException('Unable to connect to database');
+ }
+
+ /**
+ * 1. make nurl from last parameter
+ * 2. check DB (contact) if there is a contact with uid=0 and that nurl, get the ID
+ * 3. set the flag hidden=1 for the contact entry with the found ID
+ * */
+ $net = Probe::uri($this->getArgument(0));
+ if (in_array($net['network'], [Protocol::PHANTOM, Protocol::MAIL])) {
+ throw new \RuntimeException('This account seems not to exist.');
+ }
+
+ $nurl = normalise_link($net['url']);
+ $contact = \dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]);
+ if (DBM::is_result($contact)) {
+ \dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]);
+ $this->out('NOTICE: The account should be silenced from the global community page');
+ } else {
+ throw new \RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')');
+ }
+
+ return 0;
+ }
+}