From 1a2c97886f7335509ed1e1f65aff4464a32e01eb Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 23 Feb 2013 08:49:08 -0500 Subject: Fixes #5012 drafts are private now --- mod/blog/actions/blog/save.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'mod/blog/actions/blog/save.php') diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 070c96398..6da70462a 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) { -- cgit v1.2.3 From f350d90e384a03629f95b1b5be9b7ad603438f46 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 23 Feb 2013 09:21:44 -0500 Subject: Fixes #4802 notifications sent when status is newly set to published --- mod/blog/actions/blog/save.php | 5 +++++ mod/blog/start.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'mod/blog/actions/blog/save.php') diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 6da70462a..910da9838 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -158,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', 'blog', $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/start.php b/mod/blog/start.php index a6ff84355..4bd19b40f 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', 'blog', 'object_notifications'); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'blog_notify_message'); // add blog link to -- cgit v1.2.3 From f35cd7f855b60b1c572cd0aee2273a313c85ad53 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 5 Mar 2013 06:59:38 -0500 Subject: made the event more general for future support of objects with draft/publish status --- mod/blog/actions/blog/save.php | 2 +- mod/blog/start.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'mod/blog/actions/blog/save.php') diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 910da9838..9256610cc 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -160,7 +160,7 @@ if (!$error) { // we only want notifications sent when post published register_notification_object('object', 'blog', elgg_echo('blog:newpost')); - elgg_trigger_event('publish', 'blog', $blog); + elgg_trigger_event('publish', 'object', $blog); // reset the creation time for posts that move from draft to published if ($guid) { diff --git a/mod/blog/start.php b/mod/blog/start.php index 4bd19b40f..25cd81935 100644 --- a/mod/blog/start.php +++ b/mod/blog/start.php @@ -42,7 +42,7 @@ function blog_init() { elgg_register_entity_url_handler('object', 'blog', 'blog_url_handler'); // notifications - need to register for unique event because of draft/published status - elgg_register_event_handler('publish', 'blog', 'object_notifications'); + elgg_register_event_handler('publish', 'object', 'object_notifications'); elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'blog_notify_message'); // add blog link to -- cgit v1.2.3 From 1c78d41f46f71a32cde84841ab03eac13113b20e Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Wed, 5 Jun 2013 20:20:59 -0400 Subject: Fixes #5601 allowing empty tags to pass through to clear previous tags --- mod/blog/actions/blog/save.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'mod/blog/actions/blog/save.php') diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 9256610cc..658f83580 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -79,11 +79,7 @@ foreach ($values as $name => $default) { switch ($name) { case 'tags': - if ($value) { - $values[$name] = string_to_tag_array($value); - } else { - unset ($values[$name]); - } + $values[$name] = string_to_tag_array($value); break; case 'excerpt': -- cgit v1.2.3 From 8dbdf2f72c9dccbbd471e805fbd112c6817cdcec Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Wed, 5 Jun 2013 20:28:29 -0400 Subject: removed crazy code that doesn't do anything useful - only fires when $blog->foo = false --- mod/blog/actions/blog/save.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'mod/blog/actions/blog/save.php') diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 658f83580..82a9e6c51 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -121,10 +121,7 @@ if ($values['status'] == 'draft') { // assign values to the entity, stopping on error. if (!$error) { foreach ($values as $name => $value) { - if (FALSE === ($blog->$name = $value)) { - $error = elgg_echo('blog:error:cannot_save' . "$name=$value"); - break; - } + $blog->$name = $value; } } -- cgit v1.2.3