Here is my completed plugin. Please let me know if it can be 'condensed'.
here is the scenario, i have 51 'top level' forums that will always be, and never change or have any forums added to. But of those 51 forums, I may add/remove multiple sub-forums and don't want to keep adding COUNTLESS id's to the plugin. (there are hundreds of subforums).
Code:
if (is_member_of($vbulletin->userinfo, 6)) {
/* These are the main top-category forums aka states */
$main_forums = array(18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68);
/*get all ids of all sub-forums aka cities of top-level states */
foreach ($main_forums AS $state => $forumid) {
$s[] = $vbulletin->db->query_first('SELECT `childlist` FROM ' . TABLE_PREFIX . 'forum WHERE `forumid` IN (' . $forumid . ')');
}
/* convert multi-arrays into single string */
$imploded = array();
foreach($s as $ss) {
$imploded[] = implode('~', $ss);
}
$sub_forums = implode(",", $imploded);
/* remove the stupid '-1,' and ',-1' id's */
$sub_forums = str_replace("-1,", "", $sub_forums);
$sub_forums = str_replace(",-1", "", $sub_forums);
/* convert back to array :) */
$main_all_array = explode( ',', $sub_forums );
#print_r($main_all_array);
GLOBAL $foruminfo;
if (THIS_SCRIPT == "forumdisplay") {
if (in_array($foruminfo['forumid'], $main_all_array)) {
$find = 'Post New Thread';
$replace = 'Create a Listing';
$output = str_replace($find, $replace, $output);
}
}
} #END ADMIN GROUP
i have is wrapped in "admin" so guests don't see it while im testing
--------------- Added [DATE]1360187715[/DATE] at [TIME]1360187715[/TIME] ---------------
i may be overcomplicating it a bit, but i am not a professional with php. as is, it works.