Ghan_04
07-20-2008, 07:27 AM
I have a nice plugin here. Actually, I altered the main file itself first before I realized I could even put this in the plugin. Now, after copying my code over, it refuses to work, and I have no idea why. (It was working as a direct php page modification.)
The relevant info:
Hook location: can_moderate_forum
The code:
global $db;
if ($do != '' && $forumid != -1 && $userid != 0)
{
$query = 'SELECT name FROM ghan_modperms AS a LEFT JOIN ghan_modperms_user AS b ON(a.permid = b.permid) WHERE b.userid = ' . $userid . ' AND b.forumid = ' . $forumid . ' AND name LIKE \'' . $db->escape_string_like($do) . '\'';
$result = mysql_fetch_array($db->query_read($query));
if (strpos($result['name'], $do) !== false)
{
return true;
}
}
The known info:
The plugin DOES run. It does NOT give any database or PHP errors. It just hits the first "IF" condition and dies. $do is the issue. So, here's the deal. This code goes in the function can_moderate. This function gets called several times when some page is loaded, sometimes with something in $do, sometimes with it left blank. I'm only concerned with when it has something in it, hence the condition and the reason that my SQL query checks for it.
I suspect that it is only running this plugin one time - the first time that can_moderate is called. But I'm not sure, and I have no idea how to fix this even if that is indeed the problem.
I've searched around a bit in vain. So I'm wondering if anyone can help me with this problem.... On a related note, I am VERY new at this, so go easy on me. :)
The relevant info:
Hook location: can_moderate_forum
The code:
global $db;
if ($do != '' && $forumid != -1 && $userid != 0)
{
$query = 'SELECT name FROM ghan_modperms AS a LEFT JOIN ghan_modperms_user AS b ON(a.permid = b.permid) WHERE b.userid = ' . $userid . ' AND b.forumid = ' . $forumid . ' AND name LIKE \'' . $db->escape_string_like($do) . '\'';
$result = mysql_fetch_array($db->query_read($query));
if (strpos($result['name'], $do) !== false)
{
return true;
}
}
The known info:
The plugin DOES run. It does NOT give any database or PHP errors. It just hits the first "IF" condition and dies. $do is the issue. So, here's the deal. This code goes in the function can_moderate. This function gets called several times when some page is loaded, sometimes with something in $do, sometimes with it left blank. I'm only concerned with when it has something in it, hence the condition and the reason that my SQL query checks for it.
I suspect that it is only running this plugin one time - the first time that can_moderate is called. But I'm not sure, and I have no idea how to fix this even if that is indeed the problem.
I've searched around a bit in vain. So I'm wondering if anyone can help me with this problem.... On a related note, I am VERY new at this, so go easy on me. :)