From 3504042929dc5b8b4d52c59d9f85611a6c44cdb6 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 1 Mar 2011 05:47:52 +0000 Subject: Fixes #2425, #2427. Blog status for published and draft correctly set the river items. git-svn-id: http://code.elgg.org/elgg/trunk@8529 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/blog/actions/blog/save.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 18ddce786..ecf6c9b51 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -34,6 +34,9 @@ if ($guid) { $new_post = TRUE; } +// set the previous status for the hooks to update the time_created and river entries +$old_status = $blog->status; + // set defaults and required values. $values = array( 'title' => '', @@ -144,10 +147,29 @@ if (!$error) { system_message(elgg_echo('blog:message:saved')); - // @todo do we want to alert on updates? - if ($new_post && $blog->status == 'published') { + $status = $blog->status; + $db_prefix = elgg_get_config('dbprefix'); + + // add to river if changing status or published, regardless of new post + // because we remove it for drafts. + if (($new_post || $old_status == 'draft') && $status == 'published') { add_to_river('river/object/blog/create', 'create', elgg_get_logged_in_user_guid(), $blog->getGUID()); + + $date = $blog->publish_date; + + $q = "UPDATE {$db_prefix}entities SET time_created = '$date' + WHERE guid = $guid"; + update_data($q); + + $q = "UPDATE {$db_prefix}river SET posted = '$date' + WHERE object_guid = $guid AND action_type = 'create'"; + update_data($q); + } elseif ($old_status == 'published' && $status == 'draft') { + $q = "DELETE FROM {$db_prefix}river + WHERE object_guid = $blog->guid AND action_type = 'create'"; + delete_data($q); } + if ($blog->status == 'published') { forward($blog->getURL()); } else { -- cgit v1.2.3