blogs
[ class tree: blogs ] [ index: blogs ] [ all elements ]

Source for file mod_last_blog_posts.php

Documentation is available at mod_last_blog_posts.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package blogs
  5.  * @subpackage modules
  6.  */
  7.  
  8. /**
  9.  * required setup
  10.  */
  11. include_once( BLOGS_PKG_PATH.'BitBlogPost.php' );
  12. //require_once( USERS_PKG_PATH.'BitUser.php' );
  13.  
  14. // moduleParams contains lots of goodies: extract for easier handling
  15. extract( $moduleParams );
  16.  
  17. $date_start = NULL;
  18. if( !empty($module_params['date_start_offset']) ){
  19.     //offset is passed as number of hours
  20.     $date_start = time() - ( $module_params['date_start_offset'] * 3600 );
  21. }
  22.  
  23. $defaultsHash = array(
  24.     'sort_mode'   => ( !empty( $module_params['sort_mode'] ) ? $module_params['sort_mode'] : 'publish_date_desc' ),
  25.     'max_records' => $module_rows,
  26.     'parse_data'  => TRUE,
  27.     'user'        => ( !empty( $module_params['user'] ) ? $module_params['user'] : NULL ),
  28.     'blog_id'     => ( @BitBase::verifyId( $module_params['blog_id'] ) ? $module_params['blog_id'] : NULL ),
  29.     'role_id'     => ( @BitBase::verifyId( $module_params['role_id'] ) ? $module_params['role_id'] : NULL ),
  30.     'group_id'    => ( @BitBase::verifyId( $module_params['group_id'] ) ? $module_params['group_id'] : NULL ),
  31.     'date_start'  =>  $date_start,
  32.     'offset'      => ( !empty( $module_params['offset'] ) ? $module_params['offset'] : 0 ),
  33. );
  34.  
  35. $listHash = array_merge($module_params, $defaultsHash);
  36.  
  37. if(( empty( $module_params['include'] ) || $module_params['include'] != 'all' ) && !empty( $gQueryUserId )) {
  38.     $listHash['user_id'] = $gQueryUserId;
  39. }
  40.  
  41. if( !$gBitUser->hasPermission( 'p_blogs_admin' )) {
  42.     $listHash['content_perm_name'] = 'p_blogs_view';
  43. }
  44.  
  45. // we dont want admin drafts included in regular lists if we are enforcing content status
  46. $listHash['enforce_status'] = TRUE;
  47.  
  48. if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){
  49.     // if we are getting drafts then get future posts too
  50.     $listHash['show_future'] = TRUE;
  51.     $listHash['min_status_id'] = -6;
  52.     $listHash['max_status_id'] = -4;
  53.     $listHash['min_owner_status_id'] = -6;
  54.     // limit by user
  55.     $listHash['user_id'] = $gBitUser->mUserId;
  56. }else{
  57.     $listHash['min_owner_status_id'] = 0;
  58. }
  59.  
  60.  
  61. $blogPost = new BitBlogPost();
  62. $blogPosts = $blogPost->getList( $listHash );
  63.  
  64. $descriptionLength = ( !empty( $module_params['max_preview_length'] ) ? $module_params['max_preview_length'] : 500 );
  65.  
  66. $_template->tpl_vars['blogPostsFormat'] = new Smarty_variable( (empty($module_params['format']) ) );
  67. $_template->tpl_vars['descriptionLength'] = new Smarty_variable( $descriptionLength );
  68. $_template->tpl_vars['modLastBlogPosts'] = new Smarty_variable( $blogPosts["data"] );

Documentation generated on Wed, 29 Jul 2015 13:57:11 +0000 by phpDocumentor 1.5.0-lsces