Created
July 1, 2016 19:06
-
-
Save Tustin/e3e65786f99e3e87618edf228f2699ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fetch_shouts(&$shoutobj, $limit = 20, $archive = false, $search_terms = false, $single_only = false) | |
{ | |
$settings = $this->fetch_user_settings($this->vbulletin->userinfo['userid']); | |
$ignored = explode(',', $settings['s_ignored']); | |
$ignored[] = '-1'; | |
$this->clean_array($ignored); | |
$ignored = implode(',', $ignored); | |
$template = !$archive ? 'inferno_shoutbox_shout' : 'inferno_shoutbox_archive_shout'; | |
switch ($_REQUEST['fetchtype']) | |
{ | |
case 'pmonly': | |
{ | |
$sqlcond = "and | |
( | |
(s.s_private = '" . intval($_REQUEST['pmid']) . "' and s.s_user = '{$this->vbulletin->userinfo['userid']}') | |
or | |
(s.s_private = '{$this->vbulletin->userinfo['userid']}' && s.s_user = '" . intval($_REQUEST['pmid']) . "') | |
)"; | |
$ispmwindow = true; | |
} | |
break; | |
default: | |
{ | |
$sqlcond = ''; | |
} | |
} | |
$this->fetch_filters($settings); | |
if ($settings['s_f_me']) | |
{ | |
$sqlcond .= ' and s.s_me <> \'1\''; | |
} | |
if ($settings['s_f_pm'] && intval($_REQUEST['pmid']) < 1) // don't hide PMs in PM windows | |
{ | |
$sqlcond .= ' and s.s_private = \'-1\''; | |
} | |
if ($single_only) | |
{ | |
$sqlcond .= ' and s.sid = \'' . $single_only . '\''; | |
} | |
if ($search_terms) | |
{ | |
$search_time = TIMENOW - ((60 * 60) * $search_terms['time']); | |
$sqlcond .= " | |
and s.s_shout like '%{$search_terms['phrase']}%' | |
and u.username like '%" . htmlspecialchars_uni($search_terms['username']) . "%' | |
and s.s_time > $search_time | |
"; | |
} | |
$build = ''; | |
$shouts = $this->vbulletin->db->query(" | |
select s.*, u.username, u.displaygroupid, u.usergroupid, u.userid, o.* | |
from " . TABLE_PREFIX . "infernoshout s | |
left join " . TABLE_PREFIX . "user u on (u.userid = s.s_user) | |
left join " . TABLE_PREFIX . "infernoshoutusers o on (o.s_user = s.s_user) | |
where | |
( | |
(s.s_private = -1) | |
OR | |
(s.s_private = '{$this->vbulletin->userinfo['userid']}') | |
OR | |
(s.s_private <> -1 AND s.s_user = '{$this->vbulletin->userinfo['userid']}') | |
) | |
and u.userid not in ($ignored) | |
and | |
( | |
o.s_silenced = '0' | |
OR | |
(o.s_silenced <> '0' AND u.userid = '{$this->vbulletin->userinfo['userid']}') | |
) | |
$sqlcond | |
order by s.s_time " . (($search_terms) ? (($search_terms['sort'] == 'new') ? 'desc' : 'asc') : 'desc') . " | |
" . ((trim($limit) != '--nolim--') ? "limit $limit" : '') . " | |
"); | |
if ($this->is_banned()) | |
{ | |
$shout = array( | |
's_notice' => 1, | |
's_shout' => 'You are currently banned from the shoutbox.', | |
'musername' => '<span style="font-weight: bold; color: '.$this->vbulletin->options['ishout_time_pm_color'].';">Notice</span>', | |
); | |
$shoutobj->parse($shout['s_shout']); | |
$templater = vB_Template::create($template); | |
$templater->register('shout',$shout); | |
$build = $templater->render(); | |
return $build; | |
} | |
if ($this->vbulletin->options['ishout_notice'] != '' && !$archive) | |
{ | |
$shout = array( | |
's_notice' => 1, | |
's_shout' => $this->vbulletin->options['ishout_notice'], | |
'musername' => '<b><span style="font-weight: bold; color: '.$this->vbulletin->options['ishout_time_pm_color'].';">Notice</span></b>', | |
); | |
$shoutobj->parse($shout['s_shout']); | |
$templater = vB_Template::create($template); | |
$templater->register('shout',$shout); | |
$build .= $templater->render(); | |
} | |
$canadmin = $this->is_in_ug_list($this->vbulletin->options['ishout_admincommands']); | |
if (!function_exists('convert_url_to_bbcode')) | |
{ | |
require_once(DIR . '/includes/functions_newpost.php'); | |
} | |
while ($shout = $this->vbulletin->db->fetch_array($shouts)) | |
{ | |
if ($this->vbulletin->options['ishout_bbcodes'] & 64) | |
{ | |
$shout['s_shout'] = convert_url_to_bbcode($shout['s_shout']); | |
} | |
$shout[canmod] = $canadmin || $shout['userid'] == $this->vbulletin->userinfo['userid']; | |
$this->wrap_tag($shout['s_shout'], $shout['s_bold'], 'b'); | |
$this->wrap_tag($shout['s_shout'], $shout['s_italic'], 'i'); | |
$this->wrap_tag($shout['s_shout'], $shout['s_underline'], 'u'); | |
$this->wrap_tag($shout['s_shout'], $shout['s_font'], 'font', true); | |
$this->wrap_tag($shout['s_shout'], $shout['s_color'], 'color', true); | |
if ($settings['s_f_bbcode']) | |
{ | |
$shout['s_shout'] = strip_bbcode($shout['s_shout']); | |
} | |
$shoutobj->parse($shout['s_shout']); | |
$shout[date] = vbdate($this->vbulletin->options['dateformat'], $shout['s_time'], $this->vbulletin->options['yestoday']); | |
$shout[time] = vbdate($this->vbulletin->options['timeformat'], $shout['s_time'], $this->vbulletin->options['yestoday']); | |
fetch_musername($shout); | |
$shout['javascript_name'] = addslashes($shout['username']); | |
if (!$this->vbulletin->options['ishout_shoutorder'] || $archive) | |
{ | |
$templater = vB_Template::create($template); | |
$templater->register('shout',$shout); | |
$build .= $templater->render(); | |
} | |
else | |
{ | |
$templater = vB_Template::create($template); | |
$templater->register('shout',$shout); | |
$build = $templater->render() . $builder; | |
} | |
} | |
if ($this->vbulletin->options['ishout_largertext']) | |
{ | |
$build = str_replace('smallfont', '', $build); | |
} | |
if ($archive) | |
{ | |
return $build; | |
} | |
return $build . $this->parsebreaker . $this->fetch_activity(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment