Thread: vBulletin Blog - Latest Blogs on Home Page
View Single Post
  #75  
Old 10-11-2007, 06:53 PM
zCarot's Avatar
zCarot zCarot is offline
 
Join Date: Jul 2007
Location: Lol'sk
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I made fix for private blog entries. Not good (I just cut some code form blog_functions), but works =)
PHP Code:
//Latest Blogs

require_once(DIR '/includes/blog_functions_shared.php');

$having_or = array();
    if (!
can_moderate_blog())
    {
        if (
$vbulletin->userinfo['userid'])
        {
            
$having_or[] = "userid = " $vbulletin->userinfo['userid'];
            
$having_or[] = "(bu.options_ignore & " $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND ignoreid IS NOT NULL)";
            
$having_or[] = "(bu.options_buddy & " $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND buddyid IS NOT NULL)";
            
$having_or[] = "(bu.options_everyone & " $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " AND (bu.options_buddy & " $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR buddyid IS NULL) AND (bu.options_ignore & " $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'] . " OR ignoreid IS NULL))";
        }
        else
        {
            
$having_or[] = "bu.options_everyone & " $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
        }
    }

    
$having_join = array();
    
$having_select = array();
    if (
$vbulletin->userinfo['userid'])
    {
        
$having_join[] = "LEFT JOIN " TABLE_PREFIX "userlist AS buddy ON (buddy.userid = blog.userid AND buddy.relationid = " $vbulletin->userinfo['userid'] . " AND buddy.type = 'buddy')";
        
$having_join[] = "LEFT JOIN " TABLE_PREFIX "userlist AS ignored ON (ignored.userid = blog.userid AND ignored.relationid = " $vbulletin->userinfo['userid'] . " AND ignored.type = 'ignore')";
        
$having_select[] = "ignored.relationid AS ignoreid, buddy.relationid AS buddyid";
    }

$latestblogs $db->query(
    SELECT blog.blogid, blog.title, blog.username, blog.dateline, blog.userid, blog.views, options_everyone, options_buddy
    " 
. (!empty($having_select) ? ", " implode(", "$having_select) : "") . "
    FROM " 
TABLE_PREFIX "blog as blog
    LEFT JOIN " 
TABLE_PREFIX "blog_user as bu ON (bu.bloguserid = blog.userid)
    " 
. (!empty($having_join) ? implode("\r\n"$having_join) : "") . "
    WHERE blog.state='visible' AND blog.pending='0'
    " 
. (!empty($having_or) ? "HAVING " implode("\r\n\tOR "$having_or) : "") . "
    ORDER BY blog.dateline DESC 
    LIMIT 10 
"
); 
while (
$showblogs=$db->fetch_array($latestblogs)) 

    
$showblogsprivate false;
    if (
can_moderate() AND $showblogs['userid'] != $vbulletin->userinfo['userid'])
    {
        
$everyoneelsecanview $showblogs['options_everyone'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
        
$buddiescanview $showblogs['options_buddy'] & $vbulletin->bf_misc_vbblogsocnetoptions['canviewmyblog'];
        if (!
$everyoneelsecanview AND (!$showblogs['buddyid'] OR !$buddiescanview))
        {
            
$showblogsprivate true;
        }
    }

    
$counter++; 
    
$blog_userid $showblogs['userid'];
    
$blogid $showblogs['blogid'];
    
$blog_title $showblogs['title'];
    
$blog_views $showblogs['views'];
    
$blog_username $showblogs['username'];
    
$blog_dateline vbdate($vbulletin->options['dateformat'], $showblogs['dateline']);
   
    if (
$showblogsprivate)
        
$spitblogs_title .= '<img class="inlineimg" src="/images/misc/blog/key.gif" alt="Private Entry"  border="0" />'// very bad code =)
    
$spitblogs_title .= "<a href=\"blog.php?b=$blogid\">$blog_title</a>";
    
$spitblogs_title .= "<br /> ";
    
$spitblogs_views .= $blog_views;
    
$spitblogs_views .= "<br /> ";
    
$spitblogs_username .= "<a href=\"blog.php?u=$blog_userid\">$blog_username</a>";
    
$spitblogs_username .= "<br /> ";
    
$spitblogs_date .= $blog_dateline;
    
$spitblogs_date .= "<br /> ";
    
    if (
$counter 5
    { 
        
$spitblogs .= "<br /> "
    } 
    elseif (
$counter == 5)
    {
        break;
    }
}
//Latest Blogs 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01274 seconds
  • Memory Usage 1,865KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete