PDA

View Full Version : Integration with vBulletin - vBShout Customization


jamesk
11-22-2006, 10:00 PM
I wanted to have vBShout on just certain "community" pages, namely: index.php (aka FORUMHOME), forumdisplay.php, showthread.php and showpost.php while not displaying on the remaining pages.

In order to do this I modified the code in vBShout [Template Alteration] to:


$Used = 0;
$UsedArr = array();
$smilies = $db->query_read("
SELECT smilieid, smilietext, smiliepath, smilie.title,
imagecategory.title AS category
FROM " . TABLE_PREFIX . "smilie AS smilie
LEFT JOIN " . TABLE_PREFIX . "imagecategory AS imagecategory USING(imagecategoryid)
ORDER BY imagecategory.displayorder, smilie.displayorder
");
$Smilie_Build = '';
$Total_Smilies = $db->num_rows($smilies);

if ($Total_Smilies > 0)
{
while ($emo = $db->fetch_array($smilies))
{
if ($vbulletin->options['shout_smilies_show'] > 0)
{
$Smilie_Cache[] = $emo;
}
else
{
$Smilie_Build .= '<a href="#" onclick="return sb_Smilie(\''.$emo['smilietext'].'\')"><img src="'.$emo['smiliepath'].'" alt="'.$emo['title'].'" border="0" /></a> ';
}
}

if ($vbulletin->options['shout_smilies_show'] > $Total_Smilies)
{
$vbulletin->options['shout_smilies_show'] = $Total_Smilies;
}

if ($vbulletin->options['shout_smilies_show'] > 0)
{
while ($Used < $vbulletin->options['shout_smilies_show'])
{
$GetEmo = $Total_Smilies;
$GetEmo = rand(0, $GetEmo);

if (!in_array($GetEmo, $UsedArr) && $Smilie_Cache[$GetEmo])
{
$Used++;
$GetEmo = $Smilie_Cache[$GetEmo];
$Smilie_Build .= '<a href="#" onclick="return sb_Smilie(\''.$GetEmo['smilietext'].'\')"><img src="'.$GetEmo['smiliepath'].'" alt="'.$GetEmo['title'].'" border="0" /></a> ';
}
}
}
}
else
{
$Smilie_Build = 'No Emoticons Available';
}

$Options_DropDown = array(); // Items included will be parsed to create drop down menus
$DropDowns = array(); // Completed constructed drop down menus

$Options_DropDown['font_selector'] = array('Default', 'Arial', 'Arial Black', 'Arial Narrow', 'Book Antiqua', 'Century Gothic', 'Comic Sans MS', 'Courier New', 'Fixedsys', 'Franklin Gothic Medium', 'Garamond', 'Georgia', 'Impact', 'Lucida Console', 'Lucida Sans Unicode', 'Microsoft Sans Serif', 'Palatino Linotype', 'System', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana');
$Options_DropDown['color_selector'] = array();
$Options_DropDown['color_selector'][] = 'Default';

$hex = array();
$hex[] = '0';
$hex[] = '3';
$hex[] = '6';
$hex[] = '9';
$hex[] = 'C';
$hex[] = 'F';

for ($a = 0; $a < 6; $a++)
{
for ($b = 0; $b < 6; $b++)
{
for ($c = 0; $c < 6; $c++)
{
$Options_DropDown['color_selector'][] = '#' . $hex[$a].$hex[$a].$hex[$b].$hex[$b].$hex[$c].$hex[$c];
}
}
}

if (is_array($Options_DropDown))
{
foreach ($Options_DropDown as $Menu => $Options)
{
$DropDowns[$Menu] = '';
if (is_array($Options))
{
foreach ($Options as $Selection)
{
if (preg_match("#^\#([a-z0-9]+)$#i", $Selection))
{
$Extra = ' style="color:'.$Selection.';"';
}
else
{
$Extra = '';
}

if ($Selection == 'Default')
{
$Text = (($Menu == 'color_selector') ? 'Color' : 'Font Face') . ' [Default]';
}
else
{
$Text = $Selection;
}

$DropDowns[$Menu] .= '<option value="'.$Selection.'"'.$Extra.'>'.$Text.'</option>' . "\n";
}
}
}
}

#function isBanned($user)
#{
# return (isBanned_Check($user['userid'], 'shout_banned_users') || isBanned_Check($user['usergroupid'], 'shout_banned_usergroups'));
#}

#function isBanned_Check($bash, $against)
#{
# global $vbulletin;
# return in_array($bash, iif($vbulletin->options[$against], explode(',', $vbulletin->options[$against]), array()));
#}

#if ($vbulletin->options['shout_banned_perms'] == 2 && isBanned($vbulletin->userinfo))
#{
# $Shoutox = '';
#}
#else
#{
eval('$Shoutbox = "' . fetch_template('forumhome_vbshout') . '";');
#}

switch ($vbulletin->options['shout_position'])
{
case 1:
$Position = '<!-- what\'s going on box -->';
break;

case 2:
$Position = '<!-- end what\'s going on box -->';
break;

case 4:
$Position = '<!-- main -->';
break;

default:
$Position = '$navbar';
break;
}

if (THIS_SCRIPT == "index") {
$vbulletin->templatecache['FORUMHOME'] = str_replace($Position, $Position . ' $Shoutbox', $vbulletin->templatecache['FORUMHOME']);
}
if (THIS_SCRIPT == "forumdisplay") {
$vbulletin->templatecache['FORUMDISPLAY'] = str_replace('$navbar', '$navbar' . ' $Shoutbox', $vbulletin->templatecache['FORUMDISPLAY']);
}
if (THIS_SCRIPT == "showthread") {
$vbulletin->templatecache['SHOWTHREAD'] = str_replace('$navbar', '$navbar' . ' $Shoutbox', $vbulletin->templatecache['SHOWTHREAD']);
}
if (THIS_SCRIPT == "showpost") {
$vbulletin->templatecache['SHOWTHREAD_SHOWPOST'] = str_replace('$navbar', '$navbar' . ' $Shoutbox', $vbulletin->templatecache['SHOWTHREAD_SHOWPOST']);
}


I removed the "banned user" support (you can leave it in if you wish).

Assumption: for pages other than FORUMHOME it will display under the navbar (no options coded into this code). you can still "move" the index page's positioning. Needs a better method of determining where to insert the vBShout template into the vbulletin page templates.

modified the code in vBShout [Template Cache] to:


if (THIS_SCRIPT == "index" | THIS_SCRIPT == "forumdisplay" | THIS_SCRIPT == "showthread" | THIS_SCRIPT == "showpost")
{
global $globaltemplates;

$globaltemplates = array_merge($globaltemplates, array('forumhome_vbshout'));
}


Added 3 "New Plug In"s as:

vBShout [forumdisplay alteration] with hook being forumdisplay_complete
vBShout [showpost alteration] with hook being showpost_complete
vBShout [showthread alteration] with hook being showthread_complete

the code for each being the first code pasted exactly the same into each.

now the vBShout shoutbox displays on any page of these 4 types and nowhere else.

I am certain this could be "hacked" further and better. so, please, easy with the flame posts. :p

Ronak
11-24-2006, 12:51 AM
gud hack but this shud been posted in Template Modifications :)

JamieLee2k
11-24-2006, 09:38 AM
I really think you need to explain this better, I wouldn't know where to start, what to edit?, where to edit?

This hack is very useful to me.

Thanks
JamieLee2k

Calibre_k
11-24-2006, 12:21 PM
Would I be able to have this on a forums & sub forums?

bollyzone.net
11-25-2006, 06:11 AM
can i see demo plz?

Shazz
11-25-2006, 06:46 AM
A screen shot of a demo would be nice :)

JamieLee2k
11-25-2006, 01:26 PM
how to install would be nice

Terminatoronly
11-27-2006, 06:56 AM
thanks alot working fine with me :)

emmanuel132
12-03-2006, 04:44 AM
i dont see install man

wolfyman
12-03-2006, 05:29 PM
can anybody tell me how I could use this, but make the shoutbox automatically close at certain hours? Like from 8-midnight?

iran.gs
12-27-2006, 02:14 PM
why no one has made a purge for the shoutbox so it will delete old shouts ???

Feckie (Roger)
12-27-2006, 02:22 PM
why no one has made a purge for the shoutbox so it will delete old shouts ???

/prune