From 7dd46222a86a54be9d268a36291b795087fbd5c8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 13 Aug 2010 11:21:07 -0700 Subject: [PATCH] add StartNoticeSaveWeb and EndNoticeSaveWeb to hook web-based UI for notices --- EVENTS.txt | 11 +++++++++++ actions/newnotice.php | 14 +++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/EVENTS.txt b/EVENTS.txt index 7784e7d42e..f34fcc3da0 100644 --- a/EVENTS.txt +++ b/EVENTS.txt @@ -1045,3 +1045,14 @@ StartActivityEnd: before the closing in a notice activity entry (last c EndActivityEnd: after the closing in a notice activity entry - &$notice: notice being output - &$xs: XMLStringer for output + +StartNoticeSaveWeb: before saving a notice through the Web interface +- $action: action being executed (instance of NewNoticeAction) +- &$authorId: integer ID of the author +- &$text: text of the notice +- &$options: additional options (location, replies, etc.) + +EndNoticeSaveWeb: after saving a notice through the Web interface +- $action: action being executed (instance of NewNoticeAction) +- $notice: notice that was saved + diff --git a/actions/newnotice.php b/actions/newnotice.php index 748d104ff9..ca6355cbff 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -203,10 +203,18 @@ class NewnoticeAction extends Action $options = array_merge($options, $locOptions); } - $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options); + $author_id = $user->id; + $text = $content_shortened; - if (isset($upload)) { - $upload->attachToNotice($notice); + if (Event::handle('StartNoticeSaveWeb', array($this, &$author_id, &$text, &$options))) { + + $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options); + + if (isset($upload)) { + $upload->attachToNotice($notice); + } + + Event::handle('EndNoticeSaveWeb', array($this, $notice)); } if ($this->boolean('ajax')) {