diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-07-29 11:42:02 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-07-29 11:42:02 -0300 |
commit | bb3c9a26bb75c76c5934d327548bf08606467b9f (patch) | |
tree | 26760aa866799fc70683ef6845bf54fb17bdc955 /mod/blog | |
parent | 2feedf39f6484879333a7b77fdc3c184150db8c7 (diff) | |
parent | 398572fd96c72b363fd5a252fb9cbe1cecab1e04 (diff) | |
download | elgg-bb3c9a26bb75c76c5934d327548bf08606467b9f.tar.gz elgg-bb3c9a26bb75c76c5934d327548bf08606467b9f.tar.bz2 |
Merge branch 'floxglove-3' into saravea
Conflicts:
.gitmodules
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 | 13 | ||||
-rw-r--r-- | mod/blog/views/default/blog/sidebar/archives.php | 9 |
4 files changed, 39 insertions, 13 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 eb6eee05f..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 @@ -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', diff --git a/mod/blog/views/default/blog/sidebar/archives.php b/mod/blog/views/default/blog/sidebar/archives.php index 3d8f28ca4..030261094 100644 --- a/mod/blog/views/default/blog/sidebar/archives.php +++ b/mod/blog/views/default/blog/sidebar/archives.php @@ -3,9 +3,12 @@ * Blog archives */ -$loggedin_user = elgg_get_logged_in_user_entity(); $page_owner = elgg_get_page_owner_entity(); +if (!$page_owner) { + return true; +} + if (elgg_instanceof($page_owner, 'user')) { $url_segment = 'blog/archive/' . $page_owner->username; } else { @@ -15,7 +18,7 @@ if (elgg_instanceof($page_owner, 'user')) { // This is a limitation of the URL schema. if ($page_owner && $vars['page'] != 'friends') { $dates = get_entity_dates('object', 'blog', $page_owner->getGUID()); - + if ($dates) { $title = elgg_echo('blog:archives'); $content = '<ul class="blog-archives">'; @@ -31,4 +34,4 @@ if ($page_owner && $vars['page'] != 'friends') { echo elgg_view_module('aside', $title, $content); } -}
\ No newline at end of file +} |