From bcb92af4fa80cebd1888a578cab9d3c9ac062afe Mon Sep 17 00:00:00 2001 From: Darko Date: Fri, 10 Jul 2015 14:13:22 +0200 Subject: [PATCH] Move error message to disableIfNotExist function. --- newznab/controllers/Binaries.php | 7 +------ newznab/controllers/Groups.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/newznab/controllers/Binaries.php b/newznab/controllers/Binaries.php index e96a8cdc8..31add2da4 100644 --- a/newznab/controllers/Binaries.php +++ b/newznab/controllers/Binaries.php @@ -259,12 +259,7 @@ class Binaries if ($this->_nntp->isError($groupNNTP)) { $groupNNTP = $this->_nntp->dataError($this->_nntp, $groupMySQL['name']); if ($groupNNTP->code == 411) { - $this->_groups->disableIfNotExist($groupMySQL['name']); - $this->_colorCLI->doEcho( - $this->_colorCLI->error( - 'Group ' . $groupMySQL['name'] . ' does not exist on server, disabling' - ) - ); + $this->_groups->disableIfNotExist($groupMySQL['id']); } if ($this->_nntp->isError($groupNNTP)) { return; diff --git a/newznab/controllers/Groups.php b/newznab/controllers/Groups.php index 09f82609d..f67697839 100644 --- a/newznab/controllers/Groups.php +++ b/newznab/controllers/Groups.php @@ -21,11 +21,13 @@ class Groups public function __construct(array $options = []) { $defaults = [ - 'Settings' => null + 'Settings' => null, + 'ColorCLI' => null ]; $options += $defaults; $this->pdo = ($options['Settings'] instanceof Settings ? $options['Settings'] : new Settings()); + $this->colorCLI = ($options['ColorCLI'] instanceof \ColorCLI ? $options['ColorCLI'] : new \ColorCLI()); } /** @@ -682,13 +684,17 @@ class Groups /** * @note Disable group that does not exist on USP server - * @param string $groupname + * @param $id * * @return string */ - public function disableIfNotExist($groupname) + public function disableIfNotExist($id) { - $id = $this->getIDByName($groupname); $this->pdo->queryExec(sprintf("UPDATE groups SET active = 0 WHERE id = %d", $id)); + $this->colorCLI->doEcho( + $this->colorCLI->error( + 'Group does not exist on server, disabling' + ) + ); } } \ No newline at end of file