Create delete_operator function

This commit is contained in:
Dmitriy Simushev 2013-04-25 12:39:33 +00:00
parent 6954c598a3
commit 935ad85fd5
2 changed files with 29 additions and 9 deletions

View File

@ -259,6 +259,34 @@ function create_operator($login, $email, $password, $localename, $commonname, $a
); );
} }
/**
* Delete operator
*
* This function remove operator and associations with groups for this operator
* from datatabse.
* It trigger 'operatorDelete' event and pass to event listeners associative
* array with following keys:
* - 'id': int, deleted operator ID.
*
* @param int $operator_id Operator ID
*/
function delete_operator($operator_id) {
$db = Database::getInstance();
$db->query(
"delete from {chatgroupoperator} where operatorid = ?",
array($operator_id)
);
$db->query(
"delete from {chatoperator} where operatorid = ?",
array($operator_id)
);
// Trigger 'operatorDelete' event
$dispatcher = EventDispatcher::getInstance();
$args = array('id' => $operator_id);
$dispatcher->triggerEvent('operatorDelete', $args);
}
/** /**
* Set current status of the operator('available' or 'away') * Set current status of the operator('available' or 'away')
* *

View File

@ -48,15 +48,7 @@ if (isset($_GET['act'])) {
} }
if (count($errors) == 0) { if (count($errors) == 0) {
$db = Database::getInstance(); delete_operator($operatorid);
$db->query(
"delete from {chatgroupoperator} where operatorid = ?",
array($operatorid)
);
$db->query(
"delete from {chatoperator} where operatorid = ?",
array($operatorid)
);
header("Location: $webimroot/operator/operators.php"); header("Location: $webimroot/operator/operators.php");
exit; exit;
} }