public function manage_shout($message, $shoutid = 0, $type = 1, $dofetch = true, $userid = 0, $id = 0)
{
global $vbphrase;
$message = str_replace("\n", ' ', trim(convert_urlencoded_unicode($message)));
if ($this->registry->options['dbtech_vbshout_maxchars'] != 0 AND ($postlength = vbstrlen($message)) > $this->registry->options['dbtech_vbshout_maxchars'])
{
$this->fetched['error'] = construct_phrase($vbphrase['dbtech_vbshout_charlimit'], $postlength, $this->registry->options['dbtech_vbshout_maxchars']);
return false;
}
require_once(DIR . '/includes/functions_misc.php');
require_once(DIR . '/includes/class_bbcode_alt.php');
$bbcode_parser = new vB_BbCodeParser_ImgCheck($this->registry, fetch_tag_list());
$bbcode_parser->set_parse_userinfo($this->registry->userinfo);
if ($this->registry->options['dbtech_vbshout_maximages'])
{
$imagecount = fetch_character_count($bbcode_parser->parse($message, 'nonforum', $this->registry->options['dbtech_vbshout_allowsmilies'], true), '<img');
if ($imagecount > $this->registry->options['dbtech_vbshout_maximages'])
{
$this->fetched['error'] = construct_phrase($vbphrase['dbtech_vbshout_imagelimit'], $imagecount, $this->registry->options['dbtech_vbshout_maximages']);
return false;
}
}
if ($this->registry->options['dbtech_vbshout_maxsize'])
{
$message = preg_replace("#\[size=(\d+)\]#ie", "\$this->process_bbcode_size('\\1')", $message);
}
$fetch_shout_args = array();
if ($shoutid)
{
if (!$exists = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "dbtech_vbshout_shout WHERE shoutid = " . $this->registry->db->sql_prepare($shoutid)))
{
}
else
{
$type = $exists['type'];
$id = $exists['id'];
$userid = $exists['userid'];
if ($exists['userid'] == $this->registry->userinfo['userid'] AND !$this->permissions['caneditown'])
{
$this->fetched['error'] = $vbphrase['dbtech_vbshout_may_not_edit_own'];
return false;
}
if ($exists['userid'] != $this->registry->userinfo['userid'] AND !$this->permissions['caneditothers'])
{
$this->fetched['error'] = $vbphrase['dbtech_vbshout_may_not_edit_others'];
return false;
}
if ($type != $this->shouttypes['me'] AND $type != $this->shouttypes['notif'])
{
list($type, $id, $userid) = $this->parse_action_codes($message, $type, $exists['id'], $exists['userid']);
}
if ($message)
{
$this->registry->db->query_write("
UPDATE " . TABLE_PREFIX . "dbtech_vbshout_shout
SET
message = " . $this->registry->db->sql_prepare($message) . ",
type = " . $type . ",
userid = " . $userid . ",
id = " . $id . "
WHERE shoutid = " . $this->registry->db->sql_prepare($shoutid)
);
}
($hook = vBulletinHook::fetch_hook('dbtech_vbshout_shout_edit')) ? eval($hook) : false;
$this->log_command('shoutedit', serialize(array('old' => $exists['message'], 'new' => $message)));
$this->fetched['success'] = $vbphrase['dbtech_vbshout_edited_shout_successfully'];
}
}
else
{
if (!$this->permissions['canshout'])
{
$this->fetched['error'] = $vbphrase['dbtech_vbshout_may_not_shout'];
return false;
}
if ($type == $this->shouttypes['shout'])
{
list($type, $id, $userid) = $this->parse_action_codes($message, $type, $id, $userid);
}
if ($type == $this->shouttypes['pm'] AND !$id)
{
$id = $this->registry->input->clean_gpc($this->fetchtype, 'userid', TYPE_UINT);
if (!$exists = $this->registry->db->query_first_slave("
SELECT userid
FROM " . TABLE_PREFIX . "user
WHERE userid = " . $this->registry->db->sql_prepare($id)
))
{
$this->fetched['error'] = $vbphrase['dbtech_vbshout_invalid_user'];
return false;
}
$fetch_shout_args['types'] = $this->shouttypes['pm'];
$fetch_shout_args['onlyuser'] = $id;
}
$userid = ($userid ? $userid : $this->registry->userinfo['userid']);
$id = ($id ? $id : 0);
if ($this->fetched['error'])
{
return false;
}
if ($message)
{
$this->registry->db->query_write("
INSERT INTO " . TABLE_PREFIX . "dbtech_vbshout_shout
(userid, dateline, message, type, id)
VALUES (
" . $userid . ",
" . TIMENOW . ",
" . $this->registry->db->sql_prepare($message) . ",
" . $this->registry->db->sql_prepare($type) . ",
" . $this->registry->db->sql_prepare($id) . "
)
");
$shoutid = $this->registry->db->insert_id();
($hook = vBulletinHook::fetch_hook('dbtech_vbshout_shout_insert')) ? eval($hook) : false;
if ($userid > 0)
{
$this->registry->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET dbtech_vbshout_shouts = dbtech_vbshout_shouts + 1
WHERE userid = $userid
");
}
}
}
if ($type == $this->shouttypes['notif'])
{
return;
}
if ($message)
{
$this->set_aop();
}
if ($dofetch)
{
$this->fetch_shouts($fetch_shout_args);
$this->fetched['clear'] = 'editor';
}
}