Create separate function for enable/disable operators

This commit is contained in:
Dmitriy Simushev 2014-10-27 11:55:29 +00:00
parent 38769615ac
commit b7bf41a191
2 changed files with 28 additions and 10 deletions

View File

@ -172,11 +172,7 @@ class ManagementController extends AbstractController
}
// Disable the operator
$db = Database::getInstance();
$db->query(
"update {operator} set idisabled = ? where operatorid = ?",
array('1', $operator_id)
);
disable_operator($operator_id);
// Redirect the current operator to the page with operators list
return $this->redirect($this->generateUrl('operators'));
@ -200,11 +196,7 @@ class ManagementController extends AbstractController
throw new NotFoundException('The operator is not found.');
}
$db = Database::getInstance();
$db->query(
"update {operator} set idisabled = ? where operatorid = ?",
array('0', $operator_id)
);
enable_operator($operator_id);
// Redirect the current operator to the page with operators list
return $this->redirect($this->generateUrl('operators'));

View File

@ -766,3 +766,29 @@ function update_operator_groups($operator_id, $new_value)
);
}
}
/**
* Makes an operator disabled.
*
* @param int $operator_id ID of the operator to disable.
*/
function disable_operator($operator_id)
{
Database::getInstance()->query(
'UPDATE {operator} SET idisabled = ? WHERE operatorid = ?',
array('1', $operator_id)
);
}
/**
* Makes an operator enabled.
*
* @param int $operator_id ID of the operator to enable.
*/
function enable_operator($operator_id)
{
Database::getInstance()->query(
'UPDATE {operator} SET idisabled = ? WHERE operatorid = ?',
array('0', $operator_id)
);
}