]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4802 notifications sent when status is newly set to published
authorCash Costello <cash.costello@gmail.com>
Sat, 23 Feb 2013 14:21:44 +0000 (09:21 -0500)
committerCash Costello <cash.costello@gmail.com>
Sat, 23 Feb 2013 14:21:44 +0000 (09:21 -0500)
mod/blog/actions/blog/save.php
mod/blog/start.php

index 6da70462a4714e02ff250ac758b6c5506575974a..910da98386363a055695a4750954b77cc03a9c15 100644 (file)
@@ -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();
index a6ff84355e0a5abab5250d5e0eb707fdf396ac94..4bd19b40f53ca2794720006772c7d2e47ffd646b 100644 (file)
@@ -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