diff options
Diffstat (limited to 'mod/blog')
-rw-r--r-- | mod/blog/actions/blog/save.php | 22 | ||||
-rw-r--r-- | mod/blog/lib/blog.php | 8 | ||||
-rw-r--r-- | mod/blog/start.php | 18 |
3 files changed, 37 insertions, 11 deletions
diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 070c96398..9256610cc 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -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) { @@ -151,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', 'object', $blog); + + // reset the creation time for posts that move from draft to published if ($guid) { $blog->time_created = time(); $blog->save(); diff --git a/mod/blog/lib/blog.php b/mod/blog/lib/blog.php index 3c71dfbab..9753f27a8 100644 --- a/mod/blog/lib/blog.php +++ b/mod/blog/lib/blog.php @@ -39,8 +39,8 @@ function blog_get_page_content_read($guid = NULL) { elgg_push_breadcrumb($blog->title); $return['content'] = elgg_view_entity($blog, array('full_view' => true)); - //check to see if comment are on - if ($blog->comments_on != 'Off') { + // check to see if we should allow comments + if ($blog->comments_on != 'Off' && $blog->status == 'published') { $return['content'] .= elgg_view_comments($blog); } @@ -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')) { diff --git a/mod/blog/start.php b/mod/blog/start.php index 8cbaf5cca..25cd81935 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -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', 'object', 'object_notifications'); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'blog_notify_message'); // add blog link to @@ -124,9 +124,12 @@ function blog_page_handler($page) { $params = blog_get_page_content_archive($user->guid, $page[2], $page[3]); break; case 'view': - case 'read': // Elgg 1.7 compatibility $params = blog_get_page_content_read($page[1]); break; + case 'read': // Elgg 1.7 compatibility + register_error(elgg_echo("changebookmark")); + forward("blog/view/{$page[1]}"); + break; case 'add': gatekeeper(); $params = blog_get_page_content_edit($page_type, $page[1]); @@ -211,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', |