Thread: Administrative and Maintenance Tools - Zoints Private Thread Comments for Staff
View Single Post
  #94  
Old 01-06-2012, 05:06 PM
OcR Envy's Avatar
OcR Envy OcR Envy is offline
 
Join Date: May 2008
Location: Boston
Posts: 248
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone inteterested:

PHP Code:
$show['threadcomments'] = false;
if (
$vbulletin->options['threadcomments'])
{
    if (
$vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['ismoderator'])
    {
        
$show['threadcomments'] = true;
    }
    
    if (
$vbulletin->options['threadcomment_moderator'] AND can_moderate($threadinfo['forumid']))
    {
        
$show['threadcomments'] = true;
    }
    
    
$vbulletin->input->clean_array_gpc('r', array(
        
'page'            => TYPE_UINT,
        
'showall'        => TYPE_BOOL,
        
'deletecomment' => TYPE_BOOL,
        
'commentid'     => TYPE_UINT
    
));
    
    if (
$vbulletin->GPC['deletecomment'])
    {
        
$threadcomment $db->query_first("SELECT * FROM " TABLE_PREFIX "threadcomment WHERE threadcommentid = " $vbulletin->GPC['commentid']);
        
        if (
$threadcomment AND (
            
$threadcomment['userid'] == $vbulletin->userinfo['userid'] OR 
            
$permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']
        ))
        {
            
$db->query_write("DELETE FROM " TABLE_PREFIX "threadcomment WHERE threadcommentid = $threadcomment[threadcommentid]");
            
$threadman =& datamanager_init('Thread'$vbulletinERRTYPE_ARRAY'threadpost');
            
$threadman->set_existing($threadinfo);
            
$threadman->set('threadcomments'$threadinfo['threadcomments'] - 1);
            
$threadman->save();
            eval(
exec_header_redirect("showthread.php?$session[sessionurl]t=$threadinfo[threadid]iif($vbulletin->GPC['page'],"page=" $vbulletin->GPC['page'])));
        }
        else
        {
            eval(
print_no_permission());
        }
    }
    
    
    if (
$show['threadcomments'])
    {
        if (
$threadinfo['threadcomments'])
        {
            
$limit '';
            
            if (!
$vbulletin->GPC['showall'] AND $threadinfo['threadcomments'] > $vbulletin->options['threadcomments_maxcomments'])
            {
                
$limit 'LIMIT ' . ($threadinfo['threadcomments'] - $vbulletin->options['threadcomments_maxcomments']) . ',' $vbulletin->options['threadcomments_maxcomments'];
                
$show['morethreadcomments'] = true;
            }
            
            
$commentbits '';
            
$allcomments $db->query_read("
                SELECT * FROM " 
TABLE_PREFIX "threadcomment
                WHERE threadid = 
$threadinfo[threadid]
                ORDER BY dateline ASC
                
$limit
            "
);
            
            while (
$comment $db->fetch_array($allcomments))
            {
                
$show['threadcommentdelete'] = $permissions['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel'] ? true false;
                if (
$comment['userid'] == $vbulletin->userinfo['userid'])
                {
                    
$show['threadcommentdelete'] = true;
                }
                
$comment['date'] = vbdate($vbulletin->options['dateformat'], $comment['dateline'], true) . ' ' vbdate($vbulletin->options['timeformat'], $comment['dateline']);
                
$templater vB_Template::create('threadcommentbit');
                
$templater->register('comment'$comment);
                
$templater->register('threadinfo'$threadinfo);
                
$commentbits $templater->render();    
            }
        }
        
        
$page $vbulletin->GPC['page'];
        
$templater vB_Template::create('THREADCOMMENT');
        
$templater->register('commentbits'$commentbits);
        
$templater->register('page'$page);
        
$templater->register('threadinfo'$threadinfo);
        
$threadcomments $templater->render();        
        
$template_hook[showthread_above_posts] .= $threadcomments
    }
    
    
$vbulletin->input->clean_array_gpc('p', array(
        
'addcomment' => TYPE_BOOL,
        
'threadcomment' => TYPE_STR_NOHTML
    
));
    
    if (
$vbulletin->GPC['addcomment'])
    {
        require_once(
DIR '/includes/class_bbcode.php');
        
$bbcode_parser =& new vB_BbCodeParser($vbulletinfetch_tag_list());
        
$vbulletin->GPC['threadcomment'] = $bbcode_parser->parse($vbulletin->GPC['threadcomment'], $threadinfo['forumid']);
        
        
$db->query_write("
            INSERT INTO " 
TABLE_PREFIX "threadcomment
                (threadid, userid, username, dateline, comment)
            VALUES (
                
$threadinfo[threadid],
                " 
$vbulletin->userinfo['userid'] . ",
                '" 
$db->escape_string(htmlspecialchars_uni($vbulletin->userinfo['username'])) . "',
                " 
TIMENOW ",
                '" 
$db->escape_string($vbulletin->GPC['threadcomment']) . "'
        )"
);
        
        
$threadman =& datamanager_init('Thread'$vbulletinERRTYPE_ARRAY'threadpost');
        
$threadman->set_existing($threadinfo);
        
$threadman->set('threadcomments'$threadinfo['threadcomments'] + 1);
        
$threadman->save();
        
        eval(
exec_header_redirect("showthread.php?$session[sessionurl]t=$threadinfo[threadid]iif(intval($_REQUEST['page']),"page=" intval($_REQUEST['page']))));
    }

Updating the templates shouldn't be too hard. Shame Zoints didn't mark this as reusable else I'd release it again for 4.x
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01280 seconds
  • Memory Usage 1,884KB
  • 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