]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added metadata 'new_post' when autosaving blogs to help with river / revision logic...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 7 Jun 2010 19:36:47 +0000 (19:36 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 7 Jun 2010 19:36:47 +0000 (19:36 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6388 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/blog/actions/blog/auto_save_revision.php
mod/blog/actions/blog/save.php

index ce35c1295d2c3a8a34e20f7a559ba8fddc2e7fcf..00b24acce36a3a646b0968fa1d8082c35b4ee72c 100644 (file)
@@ -44,6 +44,11 @@ if ($title && $description) {
                $blog->excerpt = elgg_make_excerpt($excerpt);
                // must be present or doesn't show up when metadata sorting.
                $blog->publish_date = time();
+
+               // mark this as a brand new post so we can work out the
+               // river / revision logic in the real save action.
+               $blog->new_post = TRUE;
+
                if (!$blog->save()) {
                        $error = elgg_echo('blog:error:cannot_save');
                }
index 138c32bda82c63f112e3897348d1554c0d36dd7f..2647e7b9a62e8b3ddda655b17aeb2b42b9189771 100644 (file)
@@ -31,8 +31,8 @@ if ($guid) {
        $success_forward_url = get_input('forward', $blog->getURL());
 
        // save some data for revisions once we save the new edit
-       $revision_value = $blog->description;
-       $new_post = FALSE;
+       $revision_text = $blog->description;
+       $new_post = $blog->new_post;
 } else {
        $blog = new ElggBlog();
        $blog->subtype = 'blog';
@@ -140,13 +140,16 @@ if (!$error) {
                // remove autosave draft if exists
                $blog->clearAnnotations('blog_auto_save');
 
-               // if this was an edit, create a revision
-               if (!$new_post && $revision_value) {
-                       // create a revision annotation
-                       $blog->annotate('blog_revision', $revision_value);
+               // no longer a brand new post.
+               $blog->clearMetadata('new_post');
+
+               // if this was an edit, create a revision annotation
+               if (!$new_post && $revision_text) {
+                       $blog->annotate('blog_revision', $revision_text);
                }
 
                system_message(elgg_echo('blog:message:saved'));
+
                // @todo do we want to alert on updates?
                if ($new_post && $blog->status == 'published') {
                        add_to_river('river/object/blog/create', 'create', get_loggedin_userid(), $blog->getGUID());