Add "groupUpdate" event

This commit is contained in:
Dmitriy Simushev 2014-10-27 10:00:27 +00:00
parent 7af300b8f5
commit 0a3207e879
2 changed files with 35 additions and 0 deletions

View File

@ -59,6 +59,16 @@ final class Events
*/
const GROUP_CREATE = 'groupCreate';
/**
* A group is updated.
*
* This event is triggered after a group is saved. An associative array with
* the following items is passed to the event handlers:
* - "group": array, the state of the group after update.
* - "original_group": array, the state of the group before update.
*/
const GROUP_UPDATE = 'groupUpdate';
/**
* A group is deleted.
*

View File

@ -374,6 +374,9 @@ function update_group($group)
{
check_group_params($group, array('id'));
// Get the original state of the group to trigger the "update" event later.
$original_group = group_by_id($group['id']);
$db = Database::getInstance();
$db->query(
("UPDATE {opgroup} SET "
@ -404,6 +407,28 @@ function update_group($group)
array($group['id'])
);
}
// Get the current state of the group
$current_group = array(
'groupid' => $group['id'],
'parent' => ($group['parent'] ? (int) $group['parent'] : null),
'vclocalname' => $group['name'],
'vclocaldescription' => $group['description'],
'vccommonname' => $group['commonname'],
'vccommondescription' => $group['commondescription'],
'vcemail' => $group['email'],
'vctitle' => $group['title'],
'vcchattitle' => $group['chattitle'],
'vchosturl' => $group['hosturl'],
'vclogo' => $group['logo'],
'iweight' => $group['weight'],
);
$args = array(
'group' => $current_group,
'original_group' => $original_group,
);
EventDispatcher::getInstance()->triggerEvent(Events::GROUP_UPDATE, $args);
}
/**