Menu only visible for admin Menu only visible for admin
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Menu only visible for admin

Started by Henni, December 15, 2005, 03:16:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Henni

Hi,

I´d like to make themenu only visible to the admin user - I searched the forum and found this: http://forum.coppermine-gallery.net/index.php?topic=23771.0
But somehow this is not working - I´m using 1.4.2 and the solution was for 1.3.x -

I changed the line in themes.inc.php to         '{SUB_MENU}' => USER_IS_ADMIN ? theme_main_menu() : '',
but it didn´t work...

any ideas?

donnoman

I see two problems with your modifcation.

#1  theme_main_menu()  needs to know which menu you actually want returned ie: theme_main_menu('sub_menu')
#2 Your editing themes.inc.php which is a No-No. (Why? because your mod will break any theme that uses the sub_menu to unhide the sys_menu like mac_ox_x)

Any time developers are tempted to look at editing themes.inc.php you should look at using a plugin instead.

In this particular case if you intend on making this work for themes like mac_ox_x it really is a requirement.

heres the suggested codebase:

// Add a filter
$thisplugin->add_filter('template_html','nosubmenu');

function nosubmenu($html)
{   
    if (!USER_IS_ADMIN) {
        if (strstr($html,'MM_showHideLayers')) {
            if (strstr($html,'id="SUB_MENU"')) {
               $html=str_replace('{SYS_MENU}',"{SYS_MENU}<script type=\"text/JavaScript\">MM_showHideLayers('SYS_MENU','','show')</script>",$html);
            } elseif (strstr($html,'id="Menu1"')) {
               $html=str_replace('{SYS_MENU}',"{SYS_MENU}<script type=\"text/JavaScript\">MM_showHideLayers('Menu1','','show')</script>",$html);
            }
            $html=str_replace('{SUB_MENU}','<div style="visibility:hidden">{SUB_MENU}</div>',$html);
        } else {
            $html=str_replace('{SUB_MENU}','',$html);
        }
    }
    return $html;
}


plugin attached.