Quote:
Originally Posted by Simon2323
thank you for your answer, is there a place to get your mod? are you willing to share it?
|
It's in vBAnalytics. It offers more than a forumjump constructor but the below code extracted should work if you follow the steps below.
Code:
function createSelectOptions($array, $selectedid = '', $htmlise = false)
{
if (!is_array($array))
{
return '';
}
$options = '';
foreach ($array as $key => $val)
{
if (is_array($val))
{
// Create the template
$templater = vB_Template::create('optgroup');
$templater->register('optgroup_label', ($htmlise ? htmlspecialchars_uni($key) : $key));
$templater->register('optgroup_options', createSelectOptions($val, $selectedid, $tabindex, $htmlise));
$options .= $templater->render();
}
else
{
if (is_array($selectedid))
{
$selected = iif(in_array($key, $selectedid), ' selected="selected"', '');
}
else
{
$selected = iif($key == $selectedid, ' selected="selected"', '');
}
$templater = vB_Template::create('option');
$templater->register('optionvalue', ($key !== 'no_value' ? $key : ''));
$templater->register('optionselected', $selected);
$templater->register('optiontitle', ($htmlise ? htmlspecialchars_uni($val) : $val));
$options .= $templater->render();
}
}
return $options;
}
function construct_forums()
{
global $vbulletin, $vbphrase;
if (empty($vbulletin->iforumcache))
{
cache_ordered_forums(0, 1);
}
$forums = array(0 => $vbphrase['total']);
foreach ($vbulletin->iforumcache AS $parentid => $forums_arr)
{
$forumperms = $vbulletin->userinfo['forumpermissions']["$parentid"];
if ($parentid == -1
OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview'])
AND ($vbulletin->forumcache["$parentid"]['showprivate'] == 1
OR (!$vbulletin->forumcache["$parentid"]['showprivate'] AND !$vbulletin->options['showprivateforums'])))
OR !($vbulletin->forumcache["$parentid"]['options'] & $vbulletin->bf_misc_forumoptions['showonforumjump'])
OR !$vbulletin->forumcache["$parentid"]['displayorder']
OR !($vbulletin->forumcache["$parentid"]['options'] & $vbulletin->bf_misc_forumoptions['active'])
)
{
continue;
}
$forum = $vbulletin->forumcache["$parentid"];
$forums[$parentid] = $forum['title'];
foreach ($forums_arr AS $forumid)
{
$forumperms = $vbulletin->userinfo['forumpermissions']["$forumid"];
if ((!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) AND ($vbulletin->forumcache["$forumid"]['showprivate'] == 1 OR (!$vbulletin->forumcache["$forumid"]['showprivate'] AND !$vbulletin->options['showprivateforums']))) OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['showonforumjump']) OR !$vbulletin->forumcache["$forumid"]['displayorder'] OR !($vbulletin->forumcache["$forumid"]['options'] & $vbulletin->bf_misc_forumoptions['active']))
{
continue;
}
else
{
$forum = $vbulletin->forumcache["$forumid"];
$forums[$forumid] = $forum['title'];
}
}
}
return $forums;
}
Add the above code to a hook, such as global_start.
Then you can create the the forumjump with:
Code:
$forumjump = createSelectOptions(construct_forums());
This should result in $forumjump having a list of forums available based on forum permissions for the logged-in user. This is for vB4 not vB3 btw.
Untested.