settings['bblanguage'])
{
default:
$lang->post_id = 'URL of post, or pid to bump:';
$lang->must_supply_value = 'Invalid post entered.';
$lang->can_only_bump_own_post = 'Sorry, you can only bump your own posts.';
$lang->post_bumped = 'Successfully bumped post #%1$s';
$lang->post_bumped_log = 'Bumped post %2$s';
}
}
function bumppost_lang_admin()
{
global $mybb, $lang;
switch($mybb->settings['bblanguage'])
{
default:
$lang->bumppost_name = 'Bump Post';
$lang->bumppost_description = 'Allows users to bump one of their posts.';
$lang->item_bumppost_bump_name = 'Bump Post';
$lang->item_bumppost_bump_desc = 'Bump up the dateline of one of your posts.';
}
}
function bumppost_info()
{
return array(
"website" => "http://myplaza.zingaburga.com/",
"author" => "ZiNgA BuRgA",
"authorsite" => "http://zingaburga.com/",
"version" => "1.0",
"compatibility" => array(0.5)
);
}
function bumppost_activate()
{
// stop people trying to activate this module as a MyBB plugin
if(!defined("IN_MYPLAZA_ADMIN"))
cperror('This is not a normal MyBB plugin! Please upload this file to your /inc/plugins/myplaza directory.');
global $lang;
// add our items
myplaza_add_item(array(
"idname" => 'bumppost_bump',
"cost" => 100,
"buylimitamount" => 5,
"buylimittime" => 259200, // 3 days
"htmlextra" => '{$lang->post_id} '
));
}
function bumppost_deactivate()
{
myplaza_remove_module_items();
}
function bumppost_run($item)
{
global $mybb, $lang, $db, $buyRtnMsg, $buyLogMsg;
if(!($p = strtolower($mybb->input['bumppost'])))
{
$buyRtnMsg = $lang->must_supply_value;
return false;
}
if(!($pid = intval($p)))
{
if(!($pid = intval($mybb->input['pid']))) // bugfix for MyPlaza <= v0.53
{
// try parsing the URL
if(strpos($p, 'pid='))
{
$p = substr($p, strpos($p, 'pid=')+4);
$pid = intval($p);
}
elseif(strpos($p, '#pid'))
{
$p = substr($p, strpos($p, '#pid')+4);
$pid = intval($p);
}
}
}
if($pid)
{
// check if thread exists
$post = $db->fetch_array($db->simple_select(MY_TABLE_PREFIX.'posts', 'pid,uid,subject,dateline,tid', 'pid = '.$pid));
}
if(!isset($post) || !$post)
{
$buyRtnMsg = $lang->must_supply_value;
return false;
}
if($post['uid'] != $mybb->user['uid'])
{
$buyRtnMsg = $lang->can_only_bump_own_post;
return false;
}
// all seems okay
$db->update_query(MY_TABLE_PREFIX.'posts', array('dateline' => time()), 'pid = '.$pid);
$buyRtnMsg = sprintf($lang->post_bumped, $pid);
$buyLogMsg = sprintf($lang->post_bumped_log, $mybb->settings['bburl'].'/showthread.php?tid='.$post['tid'].'&pid='.$pid.'#pid'.$pid, $post['subject']);
return true;
}
?>