2012-09-23, 08:49 PM
There can't be warn for new replies, so the best option could be to stick $post['pwn'] = ''; to the top of my code. Editpost should probably have a special attention though, I updated my last post code.
(2012-09-23, 09:19 PM)Trickshot Wrote: [ -> ]Your ACP theme is so sexy, can I have?
(2012-09-23, 08:32 PM)Omar G. Wrote: [ -> ]<?Yeah, I failed to remember that it does fetch the fid.
static $pwn_cache = null; if(!isset($pwn_cache)) { $pwn_cache = array(); $where = ''; if(THIS_SCRIPT == 'showthread.php' && $GLOBALS['pids']) { $where = $GLOBALS['pids']; } elseif(THIS_SCRIPT == 'editpost.php') { $where = "pid='{$post['pid']}' AND uid='{$post['uid']}'"; } else { //remove hook and return } $query = $db->simple_select('warnings', 'pid, uid', $GLOBALS['pids']); while($warn = $db->fetch_field($query)) { $pwn_cache[$warn['pid']] = $warn['uid']; } } if(isset($pwn_cache[$post['pid']]) && $pwn_cache[$post['pid']] == $post['uid']) { // so something }
Also, you don't need to get the thread to know the fid, just use $post['fid']
while($warn = $db->fetch_field($query))
while($warn = $db->fetch_array($query))
function pwn(&$post)
{
global $mybb, $db, $pids;
$post['pwn'] = '';
$fid = $post['fid'];
static $pwn_cache = null;
if(!isset($pwn_cache))
{
$pwn_cache = array();
$where = '';
if(THIS_SCRIPT == 'showthread.php' && $GLOBALS['pids'])
{
$where = $GLOBALS['pids'];
}
elseif(THIS_SCRIPT == 'editpost.php')
{
$where = "pid='{$post['pid']}' AND uid='{$post['uid']}'";
}
else
{
//remove hook and return
}
$query = $db->simple_select('warnings', 'pid, uid, expired', $GLOBALS['pids']);
while($warn = $db->fetch_array($query))
{
$pwn_cache[$warn['pid']] = $warn['uid'];
}
}
if(isset($pwn_cache[$post['pid']]) && $pwn_cache[$warn['expired']] == 0 && $pwn_cache[$post['pid']] == $post['uid'] && is_moderator($fid))
{
$warning_title = "This user is currently warned for this post.";
$post['pwn'] = '
<img src="images/pwn.png" title="'.$warning_title.'" />
';
}
}
Quote:and that works great. Just wanted to confirm if I can fetch it & store as an array?
global $mybb, $db, $pids;
global $lang;
isset($lang->pwn_mylangstring) or $lang->pwn_mylangstring = 'This user is currently warned for this post.';
$post['pwn'] = '
<img src="images/pwn.png" title="'.$lang->pwn_mylangstring.'" />
';
$l['pwn_mylangstring'] = 'Usuario advertido. (Spanish blablabla)';