summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-02-13 10:52:26 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-02-13 10:52:26 -0500
commit4ad5d55ecf65fb1c9f58211b37f8f111e9ca0c7b (patch)
treeb1ccd94f9114696d07de76f87e0c0627dd0a9f6c /classes
parent47c5d508b36d4351f2bd94e7b36738fdf040b0aa (diff)
Add events for filtering and logging new notices
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php43
1 files changed, 24 insertions, 19 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 329988368..6db59c96e 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -154,32 +154,37 @@ class Notice extends Memcached_DataObject
$notice->source = $source;
$notice->uri = $uri;
- $id = $notice->insert();
+ if (Event::handle('StartNoticeSave', array(&$notice))) {
- if (!$id) {
- common_log_db_error($notice, 'INSERT', __FILE__);
- return _('Problem saving notice.');
- }
-
- # Update the URI after the notice is in the database
- if (!$uri) {
- $orig = clone($notice);
- $notice->uri = common_notice_uri($notice);
+ $id = $notice->insert();
- if (!$notice->update($orig)) {
- common_log_db_error($notice, 'UPDATE', __FILE__);
+ if (!$id) {
+ common_log_db_error($notice, 'INSERT', __FILE__);
return _('Problem saving notice.');
}
- }
- # XXX: do we need to change this for remote users?
+ # Update the URI after the notice is in the database
+ if (!$uri) {
+ $orig = clone($notice);
+ $notice->uri = common_notice_uri($notice);
+
+ if (!$notice->update($orig)) {
+ common_log_db_error($notice, 'UPDATE', __FILE__);
+ return _('Problem saving notice.');
+ }
+ }
+
+ # XXX: do we need to change this for remote users?
- $notice->saveReplies();
- $notice->saveTags();
- $notice->saveGroups();
+ $notice->saveReplies();
+ $notice->saveTags();
+ $notice->saveGroups();
- $notice->addToInboxes();
- $notice->query('COMMIT');
+ $notice->addToInboxes();
+ $notice->query('COMMIT');
+
+ Event::handle('EndNoticeSave', array($notice));
+ }
# Clear the cache for subscribed users, so they'll update at next request
# XXX: someone clever could prepend instead of clearing the cache