]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #5012 drafts are private now
authorCash Costello <cash.costello@gmail.com>
Sat, 23 Feb 2013 13:49:08 +0000 (08:49 -0500)
committerCash Costello <cash.costello@gmail.com>
Sat, 23 Feb 2013 13:49:08 +0000 (08:49 -0500)
mod/blog/actions/blog/save.php
mod/blog/lib/blog.php
mod/blog/start.php

index 070c96398e81152957cfff83d7bf25bf50a95217..6da70462a4714e02ff250ac758b6c5506575974a 100644 (file)
@@ -2,6 +2,12 @@
 /**
  * Save blog entity
  *
+ * Can be called by clicking save button or preview button. If preview button,
+ * we automatically save as draft. The preview button is only available for
+ * non-published drafts.
+ *
+ * Drafts are saved with the access set to private.
+ *
  * @package Blog
  */
 
@@ -99,11 +105,6 @@ foreach ($values as $name => $default) {
                        }
                        break;
 
-               // don't try to set the guid
-               case 'guid':
-                       unset($values['guid']);
-                       break;
-
                default:
                        $values[$name] = $value;
                        break;
@@ -115,6 +116,12 @@ if ($save == false) {
        $values['status'] = 'draft';
 }
 
+// if draft, set access to private and cache the future access
+if ($values['status'] == 'draft') {
+       $values['future_access'] = $values['access_id'];
+       $values['access_id'] = ACCESS_PRIVATE;
+}
+
 // assign values to the entity, stopping on error.
 if (!$error) {
        foreach ($values as $name => $value) {
index 3c71dfbab4514e6954b19146be5c0a2de2cd7d1d..8f15bd3475e13179ff6d22cd77e18cb6cf484e60 100644 (file)
@@ -363,6 +363,10 @@ function blog_prepare_form_vars($post = NULL, $revision = NULL) {
                                $values[$field] = $post->$field;
                        }
                }
+
+               if ($post->status == 'draft') {
+                       $values['access_id'] = $post->future_access;
+               }
        }
 
        if (elgg_is_sticky_form('blog')) {
index eb6eee05f5f19eb0e5dd4f4db5ea4a16e0105e0e..a6ff84355e0a5abab5250d5e0eb707fdf396ac94 100644 (file)
@@ -214,7 +214,14 @@ function blog_entity_menu_setup($hook, $type, $return, $params) {
                return $return;
        }
 
-       if ($entity->canEdit() && $entity->status != 'published') {
+       if ($entity->status != 'published') {
+               // draft status replaces access
+               foreach ($return as $index => $item) {
+                       if ($item->getName() == 'access') {
+                               unset($return[$index]);
+                       }
+               }
+
                $status_text = elgg_echo("blog:status:{$entity->status}");
                $options = array(
                        'name' => 'published_status',