mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-28 09:04:33 +03:00
Add "operatorUpdate" event
This commit is contained in:
parent
65d7cb3823
commit
297377b0fd
src/mibew/libs
@ -172,6 +172,16 @@ final class Events
|
||||
*/
|
||||
const OPERATOR_CREATE = 'operatorCreate';
|
||||
|
||||
/**
|
||||
* An operator is updated.
|
||||
*
|
||||
* This event is triggered after an operator is saved. An associative array
|
||||
* with the following items is passed to the event handlers:
|
||||
* - "operator": array, the state of the operator after update.
|
||||
* - "original_operator": array, the state of the operator before update.
|
||||
*/
|
||||
const OPERATOR_UPDATE = 'operatorUpdate';
|
||||
|
||||
/**
|
||||
* An operator is deleted.
|
||||
*
|
||||
|
@ -275,6 +275,8 @@ function operator_is_disabled($operator)
|
||||
/**
|
||||
* Update existing operator's info.
|
||||
*
|
||||
* Triggers {@link \Mibew\EventDispatcher\Events::OPERATOR_UPDATE} event.
|
||||
*
|
||||
* @param array $operator Associative array of operator's fields. This array
|
||||
* must contain the following keys:
|
||||
* - operatorid,
|
||||
@ -300,6 +302,9 @@ function update_operator($operator)
|
||||
throw new \InvalidArgumentException('Not all operator fields are specified');
|
||||
}
|
||||
|
||||
// Get the original operator to trigger the "update" event later
|
||||
$original_operator = operator_by_id($operator['operatorid']);
|
||||
|
||||
Database::getInstance()->query(
|
||||
('UPDATE {operator} SET vclogin = :login, vcpassword=:password, '
|
||||
. 'vclocalename = :local_name, vccommonname = :common_name, '
|
||||
@ -325,6 +330,12 @@ function update_operator($operator)
|
||||
':code' => $operator['code'],
|
||||
)
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'operator' => $operator,
|
||||
'original_operator' => $original_operator,
|
||||
);
|
||||
EventDispatcher::getInstance()->triggerEvent(Events::OPERATOR_UPDATE, $args);
|
||||
}
|
||||
|
||||
function update_operator_avatar($operator_id, $avatar)
|
||||
|
Loading…
Reference in New Issue
Block a user