X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FConsole%2FGlobalCommunitySilence.php;h=5d1f692634246e01ac2b8d007f20a166e5493f38;hb=d4a5a8051ad34a7be72238967afb3e6b140afdc8;hp=466c1adf5ae7925848b6928288d803ce861d1940;hpb=50fa6b7e02fc96013bb499c5a4a50e1e55c5edf5;p=friendica.git diff --git a/src/Console/GlobalCommunitySilence.php b/src/Console/GlobalCommunitySilence.php index 466c1adf5a..5d1f692634 100644 --- a/src/Console/GlobalCommunitySilence.php +++ b/src/Console/GlobalCommunitySilence.php @@ -1,33 +1,56 @@ . + * + */ namespace Friendica\Console; -use Friendica\BaseObject; -use Friendica\Database\DBA; +use Friendica\App; +use Friendica\Database\Database; use Friendica\Model\Contact; use RuntimeException; /** - * @brief tool to silence accounts on the global community page + * 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 */ class GlobalCommunitySilence extends \Asika\SimpleConsole\Console { protected $helpOptions = ['h', 'help', '?']; + /** + * @var App\Mode + */ + private $appMode; + /** + * @var Database + */ + private $dba; + protected function getHelp() { $help = << [-h|--help|-?] [-v] @@ -44,7 +67,15 @@ HELP; return $help; } - protected function doExecute() + public function __construct(App\Mode $appMode, Database $dba, array $argv = null) + { + parent::__construct($argv); + + $this->appMode = $appMode; + $this->dba =$dba; + } + + protected function doExecute(): int { if ($this->getOption('v')) { $this->out('Class: ' . __CLASS__); @@ -61,13 +92,13 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - if (BaseObject::getApp()->getMode()->isInstall()) { + if ($this->appMode->isInstall()) { throw new RuntimeException('Database isn\'t ready or populated yet'); } $contact_id = Contact::getIdForURL($this->getArgument(0)); if ($contact_id) { - DBA::update('contact', ['hidden' => true], ['id' => $contact_id]); + Contact::update(['hidden' => true], ['id' => $contact_id]); $this->out('The account has been successfully silenced from the global community page.'); } else { throw new RuntimeException('Could not find any public contact entry for this URL (' . $this->getArgument(0) . ')');