aboutsummaryrefslogtreecommitdiff
path: root/mod/blog
diff options
context:
space:
mode:
Diffstat (limited to 'mod/blog')
-rw-r--r--mod/blog/actions/blog/save.php17
-rw-r--r--mod/blog/views/default/forms/blog/save.php21
2 files changed, 31 insertions, 7 deletions
diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php
index c42845037..8be67ec6c 100644
--- a/mod/blog/actions/blog/save.php
+++ b/mod/blog/actions/blog/save.php
@@ -8,6 +8,9 @@
// start a new sticky form session in case of failure
elgg_make_sticky_form('blog');
+// save or preview
+$save = (bool)get_input('save');
+
// store errors to pass along
$error = FALSE;
$error_forward_url = REFERER;
@@ -106,6 +109,11 @@ foreach ($values as $name => $default) {
}
}
+// if preview, force status to be draft
+if ($save == false) {
+ $values['status'] = 'draft';
+}
+
// assign values to the entity, stopping on error.
if (!$error) {
foreach ($values as $name => $value) {
@@ -148,12 +156,13 @@ if (!$error) {
$blog->save();
}
} elseif ($old_status == 'published' && $status == 'draft') {
- $q = "DELETE FROM {$db_prefix}river
- WHERE object_guid = $blog->guid AND action_type = 'create'";
- delete_data($q);
+ elgg_delete_river(array(
+ 'object_guid' => $blog->guid,
+ 'action_type' => 'create',
+ ));
}
- if ($blog->status == 'published') {
+ if ($blog->status == 'published' || $save == false) {
forward($blog->getURL());
} else {
forward("blog/edit/$blog->guid");
diff --git a/mod/blog/views/default/forms/blog/save.php b/mod/blog/views/default/forms/blog/save.php
index cf5a4032e..d99f45f01 100644
--- a/mod/blog/views/default/forms/blog/save.php
+++ b/mod/blog/views/default/forms/blog/save.php
@@ -5,6 +5,8 @@
* @package Blog
*/
+$blog = get_entity($vars['guid']);
+
$draft_warning = $vars['draft_warning'];
if ($draft_warning) {
$draft_warning = '<span class="message warning">' . $draft_warning . '</span>';
@@ -12,6 +14,7 @@ if ($draft_warning) {
$action_buttons = '';
$delete_link = '';
+$preview_button = '';
if ($vars['guid']) {
// add a delete button if editing
@@ -19,12 +22,24 @@ if ($vars['guid']) {
$delete_link = elgg_view('output/confirmlink', array(
'href' => $delete_url,
'text' => elgg_echo('delete'),
- 'class' => 'elgg-button elgg-button-delete elgg-state-disabled'
+ 'class' => 'elgg-button elgg-button-delete elgg-state-disabled float-alt'
));
}
-$save_button = elgg_view('input/submit', array('value' => elgg_echo('save')));
-$action_buttons = $save_button . $delete_link;
+// published blogs do not get the preview button
+if (!$vars['guid'] || ($blog && $blog->status != 'published')) {
+ $preview_button = elgg_view('input/submit', array(
+ 'value' => elgg_echo('preview'),
+ 'name' => 'preview',
+ 'class' => 'mls',
+ ));
+}
+
+$save_button = elgg_view('input/submit', array(
+ 'value' => elgg_echo('save'),
+ 'name' => 'save',
+));
+$action_buttons = $save_button . $preview_button . $delete_link;
$title_label = elgg_echo('title');
$title_input = elgg_view('input/text', array(