2011-08-03, 08:37 PM
I'm working on a little plugin that has a setting to set which forums the plugin should be executed on. You simply enter the fids of those forums, separated by a comma, in the setting and it works great. But I am wondering how I could return all the fids from the mybb_forums table if the admin sets the setting to "0". I've indicated that in the description, but I'm not being able to get it to work. Can someone please have a look at my code?
That unfortunately doesn't work. I believe the problem is within the while statement, because I don't fully understand them yet and I'm probably making a very silly mistake. Is what I'm doing even a good idea? (i.e. run a query to get the fids from the database) If not, is there another way?
global $mybb, $db, $fid;
if ($mybb->settings['example_forums'] != "0")
{
$affected_forums = explode(",",$mybb->settings['example_forums']);
}
else
{
$query = $db->query("SELECT fid FROM ".TABLE_PREFIX."forums");
while($fetch_fids = $db->fetch_array($query))
{
$fetch_fids['fid'] .= ",";
$affected_forums = $fetch_fids['fid'];
$affected_forums = explode(",",$affected_forums);
}
}
if (in_array($fid, $affected_forums))
{
// Run plugin code
}
That unfortunately doesn't work. I believe the problem is within the while statement, because I don't fully understand them yet and I'm probably making a very silly mistake. Is what I'm doing even a good idea? (i.e. run a query to get the fids from the database) If not, is there another way?