aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/actions/blog/save.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-01 05:47:52 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-03-01 05:47:52 +0000
commit3504042929dc5b8b4d52c59d9f85611a6c44cdb6 (patch)
tree5da8b1d5072985cf3949a0d1e0094a3841f2c7bd /mod/blog/actions/blog/save.php
parentfeb06b06a6c4267b52394d6345c31e4fc94d8479 (diff)
downloadelgg-3504042929dc5b8b4d52c59d9f85611a6c44cdb6.tar.gz
elgg-3504042929dc5b8b4d52c59d9f85611a6c44cdb6.tar.bz2
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
Diffstat (limited to 'mod/blog/actions/blog/save.php')
-rw-r--r--mod/blog/actions/blog/save.php26
1 files 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 {