Add "groupDelete" action

This commit is contained in:
Dmitriy Simushev 2014-10-20 12:16:17 +00:00
parent 7ce1add5dc
commit 09b3d77b19
2 changed files with 14 additions and 0 deletions

View File

@ -41,6 +41,15 @@ final class Events
*/
const GROUP_CREATE = 'groupCreate';
/**
* A group is deleted.
*
* This event is triggered after a group has been deleted. An associative
* array with the following items is passed to the event handlers:
* - "id": int, deleted group ID.
*/
const GROUP_DELETE = 'groupDelete';
/**
* An operator cannot be authenticated.
*

View File

@ -448,6 +448,8 @@ function update_group_members($group_id, $new_value)
/**
* Deletes a group with specified ID.
*
* Triggers {@link \Mibew\EventDispatcher\Events::GROUP_DELETE} event.
*
* @param int $group_id ID of the group that should be deleted.
*/
function delete_group($group_id)
@ -456,4 +458,7 @@ function delete_group($group_id)
$db->query("DELETE FROM {opgroup} WHERE groupid = ?", array($group_id));
$db->query("DELETE FROM {operatortoopgroup} WHERE groupid = ?", array($group_id));
$db->query("UPDATE {thread} SET groupid = 0 WHERE groupid = ?", array($group_id));
$args = array('id' => $group_id);
EventDispatcher::getInstance()->triggerEvent(Events::GROUP_DELETE, $args);
}