Move error message to disableIfNotExist function.

This commit is contained in:
Darko
2015-07-10 14:13:22 +02:00
parent 5fa13e457a
commit bcb92af4fa
2 changed files with 11 additions and 10 deletions
+1 -6
View File
@@ -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;
+10 -4
View File
@@ -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'
)
);
}
}