summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorwjames5 <will@tekimaki.com>2009-11-12 05:09:05 +0000
committerwjames5 <will@tekimaki.com>2009-11-12 05:09:05 +0000
commitf5b563627cdadb20a86b7256b889f1800e18eae7 (patch)
treef699af460c6d4366baf0d4ca86f0d276f5cbe045 /modules
parent82886ec9d17316e3c2044f899a34fd17b60fb6cc (diff)
downloadblogs-f5b563627cdadb20a86b7256b889f1800e18eae7.tar.gz
blogs-f5b563627cdadb20a86b7256b889f1800e18eae7.tar.bz2
blogs-f5b563627cdadb20a86b7256b889f1800e18eae7.zip
Begin module upgrade - read in modules from both old and new locations and process config files during layout editing. Add an upgrade method for packages which upgrade their modules to call to assist people updating their site. Make some use of the new config data to demonstrate possibilities in layout menu. Include one module update in blog pkg to sketch out how configuration file might look.
Diffstat (limited to 'modules')
-rw-r--r--modules/lastblogposts/config_inc.php26
-rw-r--r--modules/lastblogposts/mod_last_blog_posts.php70
-rw-r--r--modules/lastblogposts/mod_last_blog_posts.tpl16
3 files changed, 112 insertions, 0 deletions
diff --git a/modules/lastblogposts/config_inc.php b/modules/lastblogposts/config_inc.php
new file mode 100644
index 0000000..4c5ad5a
--- /dev/null
+++ b/modules/lastblogposts/config_inc.php
@@ -0,0 +1,26 @@
+<?php
+global $gBitThemes;
+
+$gBitThemes->registerModule( array(
+ 'title' => tra( 'Recent Blog Posts' ),
+ 'description' => tra( 'Displays a list of recent blog posts. The list can be customized by various parameters.' ),
+ 'params' => array(
+ 'user' => array( 'help' => 'Set a user name to limit the list of recent posts to just posts by that user.', ),
+ 'blog_id' => array( 'help' => 'Set a blog_id to limit the list of recent posts to just posts to that blog', ),
+ 'groupd_id' => array( 'help' => 'Set a groupd_id to limit the list of recent posts to just posts by users in that group.', ),
+ 'max_records' => array(),
+ 'offset' => array( 'help' => 'Set offset to offest the start of the list' ),
+ 'status' => array( 'help' => 'Set status to "draft" to display a list of draft posts by the logged in user.',
+ 'select' => array( 'public' => 'Public',
+ 'draft' => 'Draft',
+ ),
+ ),
+ ),
+ 'package' => BLOGS_PKG_NAME,
+ 'directory' => 'lastblogposts',
+ 'handler' => 'mod_last_blog_posts.php',
+ 'template' => 'mod_last_blog_posts.tpl',
+ 'legacy_dir' => 'modules', // force module to show up in correct array during upgrade process
+ 'legacy_prefix' => 'mod_', // force module to show up in correct array during upgrade process
+));
+
diff --git a/modules/lastblogposts/mod_last_blog_posts.php b/modules/lastblogposts/mod_last_blog_posts.php
new file mode 100644
index 0000000..d828ab4
--- /dev/null
+++ b/modules/lastblogposts/mod_last_blog_posts.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * @version $Header: /cvsroot/bitweaver/_bit_blogs/modules/lastblogposts/mod_last_blog_posts.php,v 1.1 2009/11/12 05:09:05 wjames5 Exp $
+ * @package blogs
+ * @subpackage modules
+ */
+
+/**
+ * required setup
+ */
+include_once( BLOGS_PKG_PATH.'BitBlogPost.php' );
+require_once( USERS_PKG_PATH.'BitUser.php' );
+
+// moduleParams contains lots of goodies: extract for easier handling
+extract( $moduleParams );
+
+$date_start = NULL;
+if( !empty($module_params['date_start_offset']) ){
+ //offset is passed as number of hours
+ $date_start = time() - ( $module_params['date_start_offset'] * 3600 );
+}
+
+$defaultsHash = array(
+ 'sort_mode' => ( !empty( $module_params['sort_mode'] ) ? $module_params['sort_mode'] : 'publish_date_desc' ),
+ 'max_records' => $module_rows,
+ 'parse_data' => TRUE,
+ 'user' => ( !empty( $module_params['user'] ) ? $module_params['user'] : NULL ),
+ 'blog_id' => ( @BitBase::verifyId( $module_params['blog_id'] ) ? $module_params['blog_id'] : NULL ),
+ 'group_id' => ( @BitBase::verifyId( $module_params['group_id'] ) ? $module_params['group_id'] : NULL ),
+ 'date_start' => $date_start,
+ 'offset' => ( !empty( $module_params['offset'] ) ? $module_params['offset'] : 0 ),
+);
+
+$listHash = array_merge($module_params, $defaultsHash);
+
+if(( empty( $module_params['include'] ) || $module_params['include'] != 'all' ) && !empty( $gQueryUserId )) {
+ $listHash['user_id'] = $gQueryUserId;
+}
+
+if( !$gBitUser->hasPermission( 'p_blogs_admin' )) {
+ $listHash['content_perm_name'] = 'p_blogs_view';
+}
+
+// we dont want admin drafts included in regular lists if we are enforcing content status
+$listHash['enforce_status'] = TRUE;
+
+if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){
+ // if we are getting drafts then get future posts too
+ $listHash['show_future'] = TRUE;
+ $listHash['min_status_id'] = -6;
+ $listHash['max_status_id'] = -4;
+ $listHash['min_owner_status_id'] = -6;
+ // limit by user
+ $listHash['user_id'] = $gBitUser->mUserId;
+}else{
+ $listHash['min_owner_status_id'] = 0;
+}
+
+
+$blogPost = new BitBlogPost();
+$blogPosts = $blogPost->getList( $listHash );
+
+$descriptionLength = ( !empty( $module_params['max_preview_length'] ) ? $module_params['max_preview_length'] : 500 );
+
+$gBitSmarty->assign( 'blogPostsFormat', (empty($module_params['format']) ? 'list' : $module_params['format']) );
+$gBitSmarty->assign( 'descriptionLength', $descriptionLength );
+$gBitSmarty->assign_by_ref( 'modLastBlogPosts', $blogPosts["data"] );
+// not sure what this is, but using title doesn't work cos that will rename the moduleTitle
+//$gBitSmarty->assign( 'modLastBlogPostsTitle', ( isset( $module_params["title"] ) ? $module_params["title"]:"" ));
+?>
diff --git a/modules/lastblogposts/mod_last_blog_posts.tpl b/modules/lastblogposts/mod_last_blog_posts.tpl
new file mode 100644
index 0000000..6c921e4
--- /dev/null
+++ b/modules/lastblogposts/mod_last_blog_posts.tpl
@@ -0,0 +1,16 @@
+{* $Header: /cvsroot/bitweaver/_bit_blogs/modules/lastblogposts/mod_last_blog_posts.tpl,v 1.1 2009/11/12 05:09:05 wjames5 Exp $ *}
+{strip}
+{if $gBitSystem->isPackageActive('blogs')}
+ {bitmodule title="$moduleTitle" name="last_blog_posts"}
+ {if $blogPostsFormat == 'full'}
+ <div class="blog">
+ {foreach from=$modLastBlogPosts item=aPost}
+ {include file="bitpackage:blogs/blog_list_post.tpl"}
+ {/foreach}
+ </div>
+ {else}
+ {include file="bitpackage:blogs/list_posts.tpl" blogPosts=$modLastBlogPosts}
+ {/if}
+ {/bitmodule}
+{/if}
+{/strip}