summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwjames5 <will@tekimaki.com>2007-11-12 04:00:13 +0000
committerwjames5 <will@tekimaki.com>2007-11-12 04:00:13 +0000
commite09f929fd8e8d97c7d89472babccc5cc8083423d (patch)
tree4706acdfffc461d79ec4010a249f4055995cc9ad
parent42b7ad0c09652625df2e283e54f1a71f81f4a70c (diff)
downloadblogs-e09f929fd8e8d97c7d89472babccc5cc8083423d.tar.gz
blogs-e09f929fd8e8d97c7d89472babccc5cc8083423d.tar.bz2
blogs-e09f929fd8e8d97c7d89472babccc5cc8083423d.zip
overhaul of crossposting options - now you can add a note to each crosspost and edit those notes. still todo would be to support editing the crossposting date, and to be able to assign a format type to the note so you can style the note text inline. crosspost notes are displayed at the top of a blogpost when viewed within the blog crossposted to
-rw-r--r--BitBlogPost.php79
-rw-r--r--crosspost.php40
-rw-r--r--templates/blog_list_post.tpl4
-rw-r--r--templates/crosspost.tpl53
4 files changed, 145 insertions, 31 deletions
diff --git a/BitBlogPost.php b/BitBlogPost.php
index 959c36c..10182d0 100644
--- a/BitBlogPost.php
+++ b/BitBlogPost.php
@@ -1,12 +1,12 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_blogs/BitBlogPost.php,v 1.104 2007/11/06 14:45:00 wjames5 Exp $
+ * $Header: /cvsroot/bitweaver/_bit_blogs/BitBlogPost.php,v 1.105 2007/11/12 04:00:13 wjames5 Exp $
*
* Copyright (c) 2004 bitweaver.org
* All Rights Reserved. See copyright.txt for details and a complete list of authors.
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
*
- * $Id: BitBlogPost.php,v 1.104 2007/11/06 14:45:00 wjames5 Exp $
+ * $Id: BitBlogPost.php,v 1.105 2007/11/12 04:00:13 wjames5 Exp $
*
* Virtual base class (as much as one can have such things in PHP) for all
* derived tikiwiki classes that require database access.
@@ -16,7 +16,7 @@
*
* @author drewslater <andrew@andrewslater.com>, spiderr <spider@steelsun.com>
*
- * @version $Revision: 1.104 $ $Date: 2007/11/06 14:45:00 $ $Author: wjames5 $
+ * @version $Revision: 1.105 $ $Date: 2007/11/12 04:00:13 $ $Author: wjames5 $
*/
/**
@@ -435,7 +435,7 @@ class BitBlogPost extends LibertyAttachable {
// if blog_content_id, then map the post to the relative blogs
if( !empty( $pParamHash['blog_content_id'] )){
- $this->storePostMap( $this->mInfo, $pParamHash['blog_content_id'] );
+ $this->storePostMap( $this->mInfo, $pParamHash['blog_content_id'], NULL, TRUE );
}
// Update post with trackbacks successfully sent
@@ -487,16 +487,31 @@ class BitBlogPost extends LibertyAttachable {
}
+ function loadPostMap( $pPostContentId, $pBlogContentId){
+ $ret = NULL;
+ if( @BitBase::verifyId( $pPostContentId ) ){
+ $this->mDb->StartTrans();
+ $result = $this->mDb->getRow( "SELECT * FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `post_content_id`=? AND `blog_content_id`=?", array( $pPostContentId, $pBlogContentId ) );
+ $this->mDb->CompleteTrans();
+ if ( !empty( $result ) ){
+ $ret = $result;
+ };
+ }
+ return $ret;
+ }
+
/**
* Map a Post to a Blog or multiple Blogs
* @param pPost a Post hash.
* @param pBlogMixed the content_id or and array of ids of the blogs we want the post to show up in.
+ * @param pCrosspostNote text to display with the blog post when viewed in the blog crossposted to.
+ * @param pAutoProcess a bool to distinguish if we are storing from the crosspost interface or from the blog posting interface.
*/
- function storePostMap( $pPost, $pBlogMixed ) {
+ function storePostMap( $pPost, $pBlogMixed, $pCrosspostNote = NULL, $pAutoProcess = FALSE ) {
global $gBitSystem, $gBitUser;
$postContentId = $pPost['content_id'];
- $this->mDb->StartTrans();
if( @$this->verifyId( $postContentId ) ) {
+ $this->mDb->StartTrans();
//this is to set the time we add a post to a blog.
$currTime = $gBitSystem->getUTCTime();
$postTime = $pPost['publish_date'];
@@ -522,29 +537,64 @@ class BitBlogPost extends LibertyAttachable {
}
}
- $removedBlogIds = array_diff( $currentMappings, $blogIds );
+ // Add new mappings for this post
$newBlogIds = array_diff( $blogIds, $currentMappings );
-
- // Remove mappings for this post
- foreach( $removedBlogIds as $blogContentId ) {
- $this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `blog_content_id`=? AND `post_content_id`=?", array( $blogContentId, $postContentId ) );
- }
-
foreach( $newBlogIds as $blogContentId ) {
if( $this->verifyId( $blogContentId ) && $this->checkContentPermission( array( 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ) ) ) {
$result = $this->mDb->associateInsert( BIT_DB_PREFIX."blogs_posts_map", array(
'post_content_id' => $postContentId,
'blog_content_id' => (int)$blogContentId,
'date_added' => $timeStamp,
+ 'crosspost_note' => $pCrosspostNote,
));
}
}
+
+ /* if we are coming form the crossposting form then we
+ * want to update any change to the crosspost note.
+ * we dont want to if we are coming from the blog posting form.
+ */
+ if( !$pAutoProcess ){
+ // Update existing mappings
+ $updateBlogIds = array_intersect( $blogIds, $currentMappings );
+ foreach( $updateBlogIds as $blogContentId ) {
+ if( $this->verifyId( $blogContentId ) && $this->checkContentPermission( array( 'user_id' => $gBitUser->mUserId, 'perm_name'=>'p_blogs_post', 'content_id'=>$blogContentId ) ) ) {
+ $result = $this->mDb->associateUpdate( BIT_DB_PREFIX."blogs_posts_map", array(
+ 'crosspost_note' => $pCrosspostNote,
+ ), array(
+ 'post_content_id' => $postContentId,
+ 'blog_content_id' => (int)$blogContentId,
+ ));
+ }
+ }
+ }
+ $this->mDb->CompleteTrans();
+
+ /* if we are coming from the blog posting form we
+ * want to automatically drop any crossposting if
+ * we have unchecked them there. we ignore this when
+ * coming from the crossposting form.
+ */
+ if ( $pAutoProcess ){
+ // Remove mappings for this post
+ $removedBlogIds = array_diff( $currentMappings, $blogIds );
+ $this->expungePostMap( $postContentId, $removedBlogIds );
+ }
}
- $this->mDb->CompleteTrans();
return ( count( $this->mErrors ) == 0 );
}
+ function expungePostMap( $pPostContentId, $pBlogContentIds ){
+ $this->mDb->StartTrans();
+ if ( !empty($pBlogContentIds) ){
+ foreach( $pBlogContentIds as $blogContentId ) {
+ $this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."blogs_posts_map` WHERE `blog_content_id`=? AND `post_content_id`=?", array( $blogContentId, $pPostContentId ) );
+ }
+ }
+ $this->mDb->CompleteTrans();
+ return ( count( $this->mErrors ) == 0 );
+ }
/**
* Remove complete blog post set and any comments
@@ -726,6 +776,7 @@ class BitBlogPost extends LibertyAttachable {
$this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
if( @$this->verifyId( $pListHash['blog_id'] ) ) {
+ $selectSql .= ', bpm.crosspost_note';
array_push( $bindVars, (int)$pListHash['blog_id'] );
$joinSql .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."blogs_posts_map` bpm ON ( bpm.`post_content_id` = bp.`content_id` ) ";
$joinSql .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."blogs` b ON ( bpm.`blog_content_id`=b.`content_id` ) ";
diff --git a/crosspost.php b/crosspost.php
index b0e68e1..c090ee4 100644
--- a/crosspost.php
+++ b/crosspost.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_blogs/crosspost.php,v 1.4 2007/08/23 17:38:17 wjames5 Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_blogs/crosspost.php,v 1.5 2007/11/12 04:00:13 wjames5 Exp $
* @package blogs
* @subpackage functions
*
@@ -21,14 +21,46 @@ require_once( BLOGS_PKG_PATH.'lookup_post_inc.php' );
require_once( BLOGS_PKG_PATH.'BitBlog.php');
$gBlog = new BitBlog();
+$gBitUser->verifyTicket();
+//if crosspost save store it and send us to the post's page
if( isset( $_REQUEST['crosspost_post']) || isset($_REQUEST['save_post_exit'] ) ) {
- if( $gContent->isValid() && $gContent->storePostMap( $gContent->mInfo, $_REQUEST['blog_content_id'] ) ) {
+ $crosspost_note = isset( $_REQUEST['crosspost_note'] )? $_REQUEST['crosspost_note']:NULL;
+ if( $gContent->isValid() && $gContent->storePostMap( $gContent->mInfo, $_REQUEST['blog_content_id'], $crosspost_note ) ) {
$gContent->load();
bit_redirect( $gContent->getDisplayUrl() );
}
}
+// nuke crosspost if requested
+if( !empty( $_REQUEST['action']) && ($_REQUEST['action'] == 'remove') && $gContent->isValid() ) {
+ // confirm first
+ if( isset( $_REQUEST["confirm"] ) ) {
+ //remove it, then relaod the crossposting form
+ if ( $gContent->expungePostMap( $gContent->mInfo['content_id'], array( $_REQUEST["blog_content_id"] ) ) ){
+ $gContent->load();
+ }else{
+ $feedback['error'] = $gContent->mErrors;
+ }
+ }else{
+ $gBitSystem->setBrowserTitle( 'Confirm removal of \''.$gContent->getTitle().'\' crossposting from Blog \''.'addblognamehere'.'\'' );
+ $formHash['remove'] = TRUE;
+ $formHash['action'] = 'remove';
+ $formHash['post_id'] = $_REQUEST['post_id'];
+ $formHash['blog_content_id'] = $_REQUEST['blog_content_id'];
+ $msgHash = array(
+ 'label' => 'Remove Crossposting of Blog Post:',
+ 'confirm_item' => $gContent->getTitle(),
+ 'warning' => 'This will remove the crossposting, of the above blog post, from the blog \''.'addblognamehere'.'\'. This cannot be undone.',
+ );
+ $gBitSystem->confirmDialog( $formHash, $msgHash );
+ }
+}elseif( isset( $_REQUEST["blog_content_id"] )){
+ //if we are not removing the post but have received a blog_content_id then we want to edit its note, so load it up
+ $crosspost = $gContent->loadPostMap( $gContent->mInfo['content_id'], $_REQUEST["blog_content_id"] );
+ $gBitSmarty->assign('crosspost', $crosspost);
+ $gBitSmarty->assign('blog_content_id', $_REQUEST['blog_content_id'] );
+}
$post_id = $gContent->mPostId;
$gBitSmarty->assign('post_id', $gContent->mPostId );
@@ -36,7 +68,6 @@ $parsed_data = $gContent->parseData();
$gBitSmarty->assign('parsed_data', $parsed_data);
$gBitSmarty->assign('post_info', $gContent->mInfo );
-
// Get List of available blogs
$listHash = array();
$listHash['sort_mode'] = 'title_desc';
@@ -53,9 +84,6 @@ foreach( array_keys( $blogs ) as $blogContentId ) {
$gBitSmarty->assign( 'availableBlogs', $availableBlogs );
$gBitSmarty->assign_by_ref('blogs', $blogs['data']);
-if (isset($_REQUEST['blog_content_id'])) {
- $gBitSmarty->assign('blog_content_id', $_REQUEST['blog_content_id'] );
-}
$gBitSystem->display( 'bitpackage:blogs/crosspost.tpl', "Crosspost Blog Post" );
?> \ No newline at end of file
diff --git a/templates/blog_list_post.tpl b/templates/blog_list_post.tpl
index 889ae09..84c504b 100644
--- a/templates/blog_list_post.tpl
+++ b/templates/blog_list_post.tpl
@@ -50,6 +50,10 @@
<div class="content">
{if $aPost.avatar}<img src="{$aPost.avatar}" class="avatar" />{/if}
{include file="bitpackage:liberty/services_inc.tpl" serviceLocation='body' serviceHash=$aPost}
+
+ {if $aPost.crosspost_note}
+ <div class="crosspost_note">{$aPost.crosspost_note}</div>
+ {/if}
{* deal with the blog post image if there is one *}
{if $gBitSystem->isFeatureActive( 'blog_show_image' ) && $aPost.thumbnail_url}
diff --git a/templates/crosspost.tpl b/templates/crosspost.tpl
index a3fbea7..3cb1b07 100644
--- a/templates/crosspost.tpl
+++ b/templates/crosspost.tpl
@@ -5,33 +5,64 @@
</div>
<div class="body">
-
{form enctype="multipart/form-data" name="blogpost" id="editpageform"}
<input type="hidden" name="post_id" value="{$post_id|escape}" />
<input type="hidden" name="rows" value="{$rows}"/>
- <input type="hidden" name="cols" value="{$cols}"/>
-
+ <input type="hidden" name="cols" value="{$cols}"/>
{legend legend="Crosspost"}
+ {* we loop over this twice because we want two separate lists from the same hash *}
+ {if $availableBlogs}
+ <div class="row">
+ {formlabel label="Blogs this Post is Already Crossposted To" for="blog_id"}
+ {forminput}
+ {foreach from=$availableBlogs key=blogContentId item=availBlogTitle}
+ {if $gContent->mInfo.blogs.$blogContentId && ($blogContentId != $crosspost.blog_content_id) }
+ {assign var="has_crosspost" value=TRUE}
+ {$availBlogTitle|escape}
+ &nbsp;<a title="{tr}Edit{/tr}" href="{$smarty.const.BLOGS_PKG_URL}crosspost.php?blog_content_id={$blogContentId}&amp;post_id={$post_info.post_id}">{biticon ipackage="icons" iname="accessories-text-editor" iexplain="edit crosspost note"}</a>
+ &nbsp;<a title="{tr}Remove{/tr}" href="{$smarty.const.BLOGS_PKG_URL}crosspost.php?action=remove&amp;post_id={$post_info.post_id}&amp;blog_content_id={$blogContentId}&amp;status_id=300">{biticon ipackage="icons" iname="edit-delete" iexplain="delete this crossposting"}</a><br/>
+ {/if}
+ {/foreach}
+ {if !$has_crosspost}
+ {formhelp note="This blog post has not been crossposted to any blogs yet."}
+ {else}
+ {formhelp note=""}
+ {/if}
+ {/forminput}
+ </div><br/>
+ {/if}
+
{if $availableBlogs}
<div class="row">
{formlabel label="Include in Blogs" for="blog_id"}
{forminput}
{foreach from=$availableBlogs key=blogContentId item=availBlogTitle}
- <input name="blog_content_id[]" type="checkbox" option value="{$blogContentId}" {if $gContent->mInfo.blogs.$blogContentId}checked="checked"{/if}>{$availBlogTitle|escape}</option><br/>
+ {if !$gContent->mInfo.blogs.$blogContentId || ($blogContentId == $crosspost.blog_content_id) }
+ {assign var="has_crosspost_option" value=TRUE}
+ <input name="blog_content_id[]" type="checkbox" option value="{$blogContentId}" {if $blogContentId == $crosspost.blog_content_id}checked="checked"{/if}>{$availBlogTitle|escape}</option><br/>
+ {/if}
{/foreach}
- {formhelp note="You can cross post to any and all of the blogs listed above.<br />Just check off the blogs you wish this post to also show up in."}
+ {if !$has_crosspost_option}
+ {formhelp note="This blog post has been crossposted to all blogs you have permission to cross post to."}
+ {else}
+ {formhelp note="You can cross post to any and all of the blogs listed above.<br />Just check off the blogs you wish this post to also show up in."}
+ {/if}
{/forminput}
</div>
{/if}
-
- <div class="row submit">
- <input type="submit" name="preview" value="{tr}Preview{/tr}" />&nbsp;
- <input type="submit" name="save_post_exit" value="{tr}Save{/tr}" />
- </div>
+ {if $has_crosspost_option}
+ {textarea id="crosspost_note" label="Crosspost Note (Optional)" name="crosspost_note" noformat="y" rows=6 help="Add a note you would like to appear above the post when viewed on the crossposted blog. This does not appear on the post page."}{$crosspost.crosspost_note}{/textarea}
+
+ <div class="row submit">
+ <input type="submit" name="preview" value="{tr}Preview{/tr}" />&nbsp;
+ <input type="submit" name="save_post_exit" value="{tr}Save{/tr}" />
+ </div>
+ {/if}
{/legend}
{/form}
-
+
+
{* ------this is the same as the guts of view_blog_post---- *}
<div class="display blogs">