Advanced search  

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

Pages: [1]   Go Down

Author Topic: Menu only visible for admin  (Read 3900 times)

0 Members and 1 Guest are viewing this topic.

Henni

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 3
Menu only visible for admin
« on: December 15, 2005, 03:16:50 pm »

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?
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Menu only visible for admin
« Reply #1 on: December 18, 2005, 03:02:37 am »

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:
Code: [Select]
// 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 19 queries.