mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
Create delete_operator function
This commit is contained in:
parent
6954c598a3
commit
935ad85fd5
@ -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')
|
||||
*
|
||||
|
@ -48,15 +48,7 @@ if (isset($_GET['act'])) {
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
$db = Database::getInstance();
|
||||
$db->query(
|
||||
"delete from {chatgroupoperator} where operatorid = ?",
|
||||
array($operatorid)
|
||||
);
|
||||
$db->query(
|
||||
"delete from {chatoperator} where operatorid = ?",
|
||||
array($operatorid)
|
||||
);
|
||||
delete_operator($operatorid);
|
||||
header("Location: $webimroot/operator/operators.php");
|
||||
exit;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user