aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/actions/blog/save.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/blog/actions/blog/save.php')
-rw-r--r--mod/blog/actions/blog/save.php33
1 files changed, 19 insertions, 14 deletions
diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php
index 070c96398..82a9e6c51 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
*/
@@ -73,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':
@@ -99,11 +101,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,13 +112,16 @@ 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) {
- if (FALSE === ($blog->$name = $value)) {
- $error = elgg_echo('blog:error:cannot_save' . "$name=$value");
- break;
- }
+ $blog->$name = $value;
}
}
@@ -151,6 +151,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();