summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-16 16:08:07 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-16 16:08:07 +0100
commitf0d0bd6451fc0fc08c919a2208a9ac6bee3657a1 (patch)
tree9fb535bacf3a53ed37f1e0ace51e1f427beb8fc3
parent7907cccc55a0e5c3e23164344843c44ec5f28d7f (diff)
downloadblogs-f0d0bd6451fc0fc08c919a2208a9ac6bee3657a1.tar.gz
blogs-f0d0bd6451fc0fc08c919a2208a9ac6bee3657a1.tar.bz2
blogs-f0d0bd6451fc0fc08c919a2208a9ac6bee3657a1.zip
Access blog posts history which is all contained in the database already
-rw-r--r--post_history.php41
-rwxr-xr-xtemplates/blog_list_post.tpl1
-rw-r--r--templates/post_history.tpl120
-rwxr-xr-xtemplates/view_blog_post.tpl1
4 files changed, 163 insertions, 0 deletions
diff --git a/post_history.php b/post_history.php
new file mode 100644
index 0000000..c750492
--- /dev/null
+++ b/post_history.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @package blogs
+ * @subpackage functions
+ */
+
+require_once '../kernel/includes/setup_inc.php';
+use Bitweaver\KernelTools;
+
+$gBitSystem->verifyPackage( 'blogs' );
+
+include BLOGS_PKG_INCLUDE_PATH.'lookup_post_inc.php';
+
+if( !$gContent->isValid() || empty( $gContent->mInfo ) ) {
+ $gBitSystem->fatalError( KernelTools::tra( "Unknown post" ));
+}
+
+$gContent->verifyViewPermission();
+
+$gBitSmarty->assign( 'postInfo', $gContent->mInfo );
+
+if( !empty( $_REQUEST['rollback_preview'] )) {
+ $gBitSmarty->assign( 'rollback_preview', $_REQUEST['rollback_preview'] );
+}
+
+$smartyContentRef = 'postInfo';
+$rollbackPerm = 'p_blogs_update';
+include_once LIBERTY_PKG_INCLUDE_PATH.'content_history_inc.php';
+
+$gBitSmarty->assign( 'page', $page = !empty( $_REQUEST['page'] ) ? $_REQUEST['page'] : 1 );
+if( !empty( $_REQUEST['list_page'] )) {
+ $gBitSmarty->assign( 'page', $page = !empty( $_REQUEST['list_page'] ) ? $_REQUEST['list_page'] : 1 );
+}
+
+$offset = ( $page - 1 ) * $gBitSystem->getConfig( 'max_records' );
+$history = $gContent->getHistory( null, null, $offset, $gBitSystem->getConfig( 'max_records' ) );
+$gBitSmarty->assign( 'data', $history['data'] );
+$gBitSmarty->assign( 'listInfo', $history['listInfo'] );
+
+$gBitSmarty->assign( 'gContent', $gContent );
+$gBitSystem->display( 'bitpackage:blogs/post_history.tpl', null, [ 'display_mode' => 'display' ]);
diff --git a/templates/blog_list_post.tpl b/templates/blog_list_post.tpl
index c77e1ff..fd7c337 100755
--- a/templates/blog_list_post.tpl
+++ b/templates/blog_list_post.tpl
@@ -19,6 +19,7 @@
{if ($aPost.ownsblog eq 'y') || ($gBitUser->mUserId && $aPost.user_id eq $gBitUser->mUserId) || $gBitUser->hasPermission( 'p_blogs_admin' )}
<a title="{tr}Edit{/tr}" href="{$smarty.const.BLOGS_PKG_URL}post.php?blog_id={$aPost.blog_id|default:0}&amp;post_id={$aPost.post_id}">{booticon iname="icon-edit" ipackage="icons" iexplain="edit"}</a>
+ <a title="{tr}History{/tr}" href="{$smarty.const.BLOGS_PKG_URL}post_history.php?content_id={$aPost.content_id}">{booticon iname="fa-clock" iexplain="History"}</a>
<a title="{tr}Remove{/tr}" href="{$smarty.const.BLOGS_PKG_URL}post.php?action=remove&amp;post_id={$aPost.post_id}">{booticon iname="icon-trash" ipackage="icons" iexplain="delete"}</a>
{/if}
</div>
diff --git a/templates/post_history.tpl b/templates/post_history.tpl
new file mode 100644
index 0000000..beacc2f
--- /dev/null
+++ b/templates/post_history.tpl
@@ -0,0 +1,120 @@
+{strip}
+<div class="admin blogs">
+ <div class="header">
+ <h1>{tr}History of{/tr} <a href="{$gContent->mInfo.display_url}">{$gContent->mInfo.title|escape}</a></h1>
+ </div>
+
+ <div class="body">
+ {if $version}
+ <h2>{tr}Version{/tr} {$version}</h2>
+ {/if}
+
+ {if $smarty.request.preview ?? false}
+ {include file="bitpackage:blogs/blog_post.tpl"}
+ {/if}
+
+ {if $source}
+ <div class="content">{$sourcev}</div>
+ {/if}
+
+ {if $compare eq 'y'}
+ <table class="table data">
+ <caption>{tr}Comparing versions{/tr}</caption>
+ <tr>
+ <th width="50%">{tr}Version {$version_from}{/tr}</td>
+ <th></th>
+ <th width="50%">{tr}Current version{/tr}</td>
+ </tr>
+ <tr class="aligntop">
+ <td><div class="content">{$diff_from}</div></td>
+ <td>&nbsp;</td>
+ <td><div class="content">{$diff_to}</div></td>
+ </tr>
+ </table>
+ {/if}
+
+ {if $diff2 eq 'y'}
+ <h2>{tr}Differences from version{/tr} {$version_from} to {$version_to}</h2>
+
+ {if $gContent->mInfo.format_guid eq 'bithtml'}
+ {$diffdata|html_entity_decode}
+ {else}
+ {$diffdata}
+ {/if}
+
+ {/if}
+
+ {form}
+ <input type="hidden" name="content_id" value="{$gContent->mInfo.content_id}" />
+ <input type="hidden" name="page" value="{$page}" />
+
+ <table class="table data">
+ <caption>{tr}Post History{/tr}</caption>
+ <tr>
+ <th style="width:70%;">{tr}Date{/tr}/{tr}Comment{/tr}</th>
+ <th style="width:10%;">{tr}User{/tr}</th>
+ <th style="width:10%;">{tr}IP{/tr}</th>
+ <th style="width:10%;">{tr}Version{/tr}</th>
+ </tr>
+
+ <tr class="odd">
+ <td>
+ {$gContent->mInfo.last_modified|bit_short_datetime}
+ <br />
+ {$gContent->mInfo.edit_comment|escape|default:"&mdash;"}
+ </td>
+ <td>{displayname link_label=$gContent->mInfo.modifier_real_name user=$gContent->mInfo.modifier_user user_id=$gContent->mInfo.modifier_user_id real_name=$gContent->mInfo.modifier_real_name}</td>
+ <td style="text-align:right;">{$gContent->mInfo.ip}</td>
+ <td style="text-align:right;">{$gContent->mInfo.version}</td>
+ </tr>
+
+ <tr class="odd">
+ <td colspan="4">
+ <a href="{$gContent->mInfo.display_url}">{tr}Current{/tr}</a>
+ &nbsp;&bull;&nbsp;{smartlink ititle="Source" content_id=$gContent->mInfo.content_id source="current"}
+ </td>
+ </tr>
+
+ {foreach from=$data item=item}
+ <tr class="{cycle values='even,odd' advance=false}">
+ <td><label for="hist_{$item.version}">{$item.last_modified|bit_short_datetime}<br />{$item.history_comment|escape|default:"&mdash;"}</label></td>
+ <td>{displayname hash=$item link_label=$item.modifier_real_name}</td>
+ <td style="text-align:right;">{$item.ip}</td>
+ <td style="text-align:right;">{$item.version}</td>
+ </tr>
+ <tr class="{cycle values='even,odd'}">
+ <td colspan="3">
+ {smartlink ititle="View" content_id=$gContent->mInfo.content_id preview=$item.version}
+ &nbsp;&bull;&nbsp;{smartlink ititle="Compare" content_id=$gContent->mInfo.content_id compare=$item.version}
+ &nbsp;&bull;&nbsp;{smartlink ititle="Difference" content_id=$gContent->mInfo.content_id diff2=$item.version}
+ &nbsp;&bull;&nbsp;{smartlink ititle="Source" content_id=$gContent->mInfo.content_id source=$item.version}
+ {if $gBitUser->hasPermission( 'p_blogs_update' )}
+ &nbsp;&bull;&nbsp;{smartlink ititle="Rollback" content_id=$gContent->mInfo.content_id rollback=$item.version}
+ {/if}
+ </td>
+ <td style="text-align:right;">
+ {if $gBitUser->hasPermission( 'p_blogs_admin' )}
+ <input type="checkbox" name="hist[{$item.version}]" id="hist_{$item.version}" />
+ {/if}
+ </td>
+ </tr>
+ {foreachelse}
+ <tr class="norecords">
+ <td colspan="4">
+ {tr}No records found{/tr}
+ </td>
+ </tr>
+ {/foreach}
+ </table>
+
+ {if $gBitUser->hasPermission( 'p_blogs_admin' )}
+ <div style="text-align:right;">
+ <input type="submit" class="btn btn-default" name="delete" value="{tr}Delete selected versions{/tr}" />
+ </div>
+ {/if}
+ {/form}
+
+ {pagination content_id=$gContent->mInfo.content_id}
+ </div><!-- end .body -->
+</div><!-- end .blogs -->
+{/strip}
diff --git a/templates/view_blog_post.tpl b/templates/view_blog_post.tpl
index 05a7170..d1c8f52 100755
--- a/templates/view_blog_post.tpl
+++ b/templates/view_blog_post.tpl
@@ -38,6 +38,7 @@
{if $gContent->hasUpdatePermission()}
<a title="{tr}Edit{/tr}" href="{$smarty.const.BLOGS_PKG_URL}post.php?blog_id={$post_info.blog_id|default:0}&amp;post_id={$post_info.post_id}">{booticon iname="icon-edit" ipackage="icons" iexplain="edit"}</a>
+ <a title="{tr}History{/tr}" href="{$smarty.const.BLOGS_PKG_URL}post_history.php?content_id={$post_info.content_id}">{booticon iname="fa-clock" iexplain="History"}</a>
{/if}
{if $gContent->hasUserPermission( 'p_blogs_admin' )}
<a title="{tr}Remove{/tr}" href="{$smarty.const.BLOGS_PKG_URL}post.php?action=remove&amp;post_id={$post_info.post_id}&amp;status_id=300">{booticon iname="icon-trash" ipackage="icons" iexplain="delete"}</a>