Thread: Miscellaneous Hacks - CES Parser Permissions
View Single Post
  #66  
Old 05-25-2007, 08:36 PM
BlackNovaYZFR1 BlackNovaYZFR1 is offline
 
Join Date: Jun 2005
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've had to make some modifications to get the member and private scripts to display properly:

Code:
global $vbulletin;

if (THIS_SCRIPT == 'private')
{
	$tempuser=fetch_userinfo($pm['fromuserid']);
	$tempuser['permissions'] = cache_permissions($tempuser);
	$check_ugp = convert_bits_to_array($tempuser['permissions']['ces_parser_permissions'], $vbulletin->bf_ugp['ces_parser_permissions']);
}
elseif (THIS_SCRIPT != 'member')
{
	global $newpost, $postinfo, $post;

	// newthread, newreply uses $newpost
	// editpost uses $postinfo
	// showthread uses $post

	$postusername = '';

	if (THIS_SCRIPT == 'editpost')
	{
		$postusername = $postinfo['username'];
	}

	if (in_array(THIS_SCRIPT, array('newreply', 'newthread')))
	{
		$post = $newpost;

		if ($post['username'] AND ($vbulletin->userinfo['username'] != $post['username']))
		{
			$postusername = $post['username'];
		}
	}

	if (!$post['usergroupid'] AND $postusername != '')
	{
		$userinfo = $vbulletin->db->query_first("
			SELECT userid, usergroupid, membergroupids 
			FROM " . TABLE_PREFIX . "user
			WHERE username = '" . $vbulletin->db->escape_string($postusername) . "'
		");

		if (empty($post['permissions']))
		{
			$grab = true;
		}
		else
		{
			$userinfo['permissions'] = $post['permissions'];
		}
	}
	else if (($post['usergroupid'] > 0))
	{
		$userinfo['userid'] = $post['userid'];
		$userinfo['usergroupid'] = $post['usergroupid'];
		$userinfo['membergroupids'] = $post['membergroupids'];

		if (empty($post['permissions']))
		{
			$grab = true;
		}
		else
		{
			$userinfo['permissions'] = $post['permissions'];
		}
	}
	else if (in_array(THIS_SCRIPT, array('newreply', 'newthread')))
	{
		$userinfo['userid'] = $vbulletin->userinfo['userid'];
		$userinfo['usergroupid'] = $vbulletin->userinfo['usergroupid'];
		$userinfo['membergroupids'] = $vbulletin->userinfo['membergroupids'];

		if (empty($vbulletin->userinfo['permissions']))
		{
			$grab = true;
		}
		else if (empty($userinfo['permissions']))
		{
			$userinfo['permissions'] = $vbulletin->userinfo['permissions'];
		}
	}

	if ($grab)
	{
		$userinfo['permissions'] = cache_permissions($userinfo);
	}


	if ($this->parse_userinfo['permissions'] != $userinfo['permissions'])
	{
		$this->set_parse_userinfo($userinfo, $userinfo['permissions']);
	}

	$check_ugp = convert_bits_to_array($this->parse_userinfo['permissions']['ces_parser_permissions'], $vbulletin->bf_ugp['ces_parser_permissions']);
} else {
	$tempuser=fetch_userinfo($vbulletin->GPC['userid']);
	$tempuser['permissions'] = cache_permissions($tempuser);
	$check_ugp = convert_bits_to_array($tempuser['permissions']['ces_parser_permissions'], $vbulletin->bf_ugp['ces_parser_permissions']);
}
$bad_tags = explode(',', $vbulletin->options['bad_tags']);

$dobbcode = $do_bbcode ? $do_bbcode : $dobbcode;
$dosmilies = $do_smilies ? $do_smilies : $dosmilies;
$dobbimagecode = $do_smilies ? $do_bbimagecode : $dobbimagecode;
$dohtml = $do_html ? $do_html : $dohtml;

$dobbcode = ($check_ugp['can_bbcode_post'] AND $dobbcode);
$dosmilies = ($check_ugp['can_smilies_post'] AND $dosmilies);
$dobbimagecode = ($check_ugp['can_imgcode_post'] AND $dobbimagecode);

$do_bbcode =& $dobbcode;
$do_smilies =& $dosmilies;
$do_bbimagecode =& $dobbimagecode;
$do_html =& $dohtml;

if ($check_ugp['can_html_post'] AND $do_html)
{
	$do_html = true;
	foreach ($bad_tags AS $badtag)
	{
		$badtag = html_entity_decode($badtag);
		$text = str_replace( '<' . trim($badtag), htmlspecialchars('<' . trim($badtag)), $text);
		$text = str_replace( '</' . trim($badtag), htmlspecialchars('</' . trim($badtag)), $text);
	}
	unset($badtag, $badtags);
}
else
{
	$do_html = false;
}
I'm not sure that this is entirely correct, but it's a start for me.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01024 seconds
  • Memory Usage 1,787KB
  • 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_code
  • (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