From f350d90e384a03629f95b1b5be9b7ad603438f46 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 23 Feb 2013 09:21:44 -0500 Subject: Fixes #4802 notifications sent when status is newly set to published --- mod/blog/actions/blog/save.php | 5 +++++ mod/blog/start.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 6da70462a..910da9838 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -158,6 +158,11 @@ if (!$error) { if (($new_post || $old_status == 'draft') && $status == 'published') { add_to_river('river/object/blog/create', 'create', $blog->owner_guid, $blog->getGUID()); + // we only want notifications sent when post published + register_notification_object('object', 'blog', elgg_echo('blog:newpost')); + elgg_trigger_event('publish', 'blog', $blog); + + // reset the creation time for posts that move from draft to published if ($guid) { $blog->time_created = time(); $blog->save(); diff --git a/mod/blog/start.php b/mod/blog/start.php index a6ff84355..4bd19b40f 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -41,8 +41,8 @@ function blog_init() { // override the default url to view a blog object elgg_register_entity_url_handler('object', 'blog', 'blog_url_handler'); - // notifications - register_notification_object('object', 'blog', elgg_echo('blog:newpost')); + // notifications - need to register for unique event because of draft/published status + elgg_register_event_handler('publish', 'blog', 'object_notifications'); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'blog_notify_message'); // add blog link to -- cgit v1.2.3 From f35cd7f855b60b1c572cd0aee2273a313c85ad53 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 5 Mar 2013 06:59:38 -0500 Subject: made the event more general for future support of objects with draft/publish status --- mod/blog/actions/blog/save.php | 2 +- mod/blog/start.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 910da9838..9256610cc 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -160,7 +160,7 @@ if (!$error) { // we only want notifications sent when post published register_notification_object('object', 'blog', elgg_echo('blog:newpost')); - elgg_trigger_event('publish', 'blog', $blog); + elgg_trigger_event('publish', 'object', $blog); // reset the creation time for posts that move from draft to published if ($guid) { diff --git a/mod/blog/start.php b/mod/blog/start.php index 4bd19b40f..25cd81935 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -42,7 +42,7 @@ function blog_init() { elgg_register_entity_url_handler('object', 'blog', 'blog_url_handler'); // notifications - need to register for unique event because of draft/published status - elgg_register_event_handler('publish', 'blog', 'object_notifications'); + elgg_register_event_handler('publish', 'object', 'object_notifications'); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'blog_notify_message'); // add blog link to -- cgit v1.2.3