removing My Gallery link from menu removing My Gallery link from menu
 

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

removing My Gallery link from menu

Started by nyltak, May 22, 2011, 01:49:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nyltak

sry bout that last post...

The 'My Gallery' link disappears when I am in admin mode, but when I log in as a test user, the My Gallery link remains. I have the setting the same for both types of user.

Αndré

Please post a link to your gallery and a screen-shot where we can see all permissions of the admin group.

What happens if you hide the admin controls?

nyltak

test user doesnt have admin level authority, is just a registered user. No link to hide admin controls for registered users. If I comment out  
addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer);

I get the following:
Template error
Failed to find block 'my_gallery' (#<!-- BEGIN my_gallery -->(.*?)<!-- END my_gallery -->#s) in :

             <!-- BEGIN allow_memberlist -->
       <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}" >{MEMBERLIST_LNK}</a> |
 <!-- END allow_memberlist -->          <!-- BEGIN upload_pic -->
       <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}" >{UPL_PIC_LNK}</a> |
 <!-- END upload_pic -->  <!-- BEGIN register -->
       <a href="{REGISTER_TGT}" title="{REGISTER_TITLE}" >{REGISTER_LNK}</a> |
 <!-- END register -->  <!-- BEGIN login -->
       <a href="{LOGIN_TGT}" title="{LOGIN_TITLE}" >{LOGIN_LNK}</a>
 <!-- END login -->



theme.php


/******************************************************************************
** Section <<<assemble_template_buttons>>> - START
******************************************************************************/
// Creates buttons from a template using an array of tokens
// this function is used in this file it needs to be declared before being called.
function assemble_template_buttons($template_buttons,$buttons)
{
   $counter=0;
   $output='';

   foreach ($buttons as $button)  {
       if (isset($button[4])) {
           $spacer=$button[4];
       } else {
           $spacer='';
       }

       $params = array(
           '{SPACER}'     => $spacer,
           '{BLOCK_ID}'   => $button[3],
           '{HREF_TGT}'   => $button[2],
           '{HREF_TITLE}' => $button[1],
           '{HREF_LNK}'   => $button[0],
           '{HREF_ATTRIBUTES}'   => $button[5]
           );
       $output.=template_eval($template_buttons, $params);
   }
   return $output;
}
/******************************************************************************
** Section <<<assemble_template_buttons>>> - END
******************************************************************************/




/******************************************************************************
** Section <<<addbutton>>> - START
******************************************************************************/
// Creates an array of tokens to be used with function assemble_template_buttons
// this function is used in this file it needs to be declared before being called.
function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer,$href_attrib='')
{
   $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer,$href_attrib);
}
/******************************************************************************
** Section <<<addbutton>>> - END
******************************************************************************/




/******************************************************************************
** Section <<<$template_sys_menu>>> - START
******************************************************************************/
// HTML template for sys_menu
$template_sys_menu = <<<EOT
         {BUTTONS}
EOT;
/******************************************************************************
** Section <<<$template_sys_menu>>> - END
******************************************************************************/



/******************************************************************************
** Section <<<$template_sub_menu>>> - START
******************************************************************************/
// HTML template for sub_menu
$template_sub_menu = $template_sys_menu;


if (!defined('THEME_HAS_NO_SYS_MENU_BUTTONS')) {

 // HTML template for template sys_menu spacer
$template_sys_menu_spacer = '|';



// HTML template for template sys_menu buttons

 $template_sys_menu_button = <<<EOT
 <!-- BEGIN {BLOCK_ID} -->
       <a href="{HREF_TGT}" title="{HREF_TITLE}" {HREF_ATTRIBUTES}>{HREF_LNK}</a> {SPACER}
 <!-- END {BLOCK_ID} -->
EOT;

 // HTML template for template sys_menu buttons

   // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}{HREF_ATTRIBUTES}
   
//addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{CONTACT_LNK}','{CONTACT_TITLE}','{CONTACT_TGT}','contact',$template_sys_menu_spacer);
     addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer);
  addbutton($sys_menu_buttons,'{MEMBERLIST_LNK}','{MEMBERLIST_TITLE}','{MEMBERLIST_TGT}','allow_memberlist',$template_sys_menu_spacer);
   if (array_key_exists('allowed_albums', $USER_DATA) && is_array($USER_DATA['allowed_albums']) && count($USER_DATA['allowed_albums'])) {
     addbutton($sys_menu_buttons,'{UPL_APP_LNK}','{UPL_APP_TITLE}','{UPL_APP_TGT}','upload_approval',$template_sys_menu_spacer);
   }
   addbutton($sys_menu_buttons,'{MY_PROF_LNK}','{MY_PROF_TITLE}','{MY_PROF_TGT}','my_profile',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{ADM_MODE_LNK}','{ADM_MODE_TITLE}','{ADM_MODE_TGT}','enter_admin_mode',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{USR_MODE_LNK}','{USR_MODE_TITLE}','{USR_MODE_TGT}','leave_admin_mode',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{SIDEBAR_LNK}','{SIDEBAR_TITLE}','{SIDEBAR_TGT}','sidebar',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{UPL_PIC_LNK}','{UPL_PIC_TITLE}','{UPL_PIC_TGT}','upload_pic',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer);
      addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
   addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');    // Login and Logout don't have a spacer as only one is shown, and either would be the last option.



 $sys_menu_buttons = CPGPluginAPI::filter('sys_menu',$sys_menu_buttons);
 $params = array('{BUTTONS}' => assemble_template_buttons($template_sys_menu_button,$sys_menu_buttons));
 $template_sys_menu = template_eval($template_sys_menu,$params);
}
/******************************************************************************
** Section <<<$template_sub_menu>>> - END
******************************************************************************/

/******************************************************************************
** Section <<<THEME_HAS_NO_SUB_MENU_BUTTONS>>> - START
******************************************************************************/
if (!defined('THEME_HAS_NO_SUB_MENU_BUTTONS')) {

   // HTML template for template sub_menu spacer

   $template_sub_menu_spacer = $template_sys_menu_spacer;

   // HTML template for template sub_menu buttons

   $template_sub_menu_button = $template_sys_menu_button;

   // HTML template for template sub_menu buttons

   // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}{HREF_ATTRIBUTES}
   addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{ALB_LIST_LNK}','{ALB_LIST_TITLE}','{ALB_LIST_TGT}','album_list',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{LASTUP_LNK}','{LASTUP_TITLE}','{LASTUP_TGT}','lastup',$template_sub_menu_spacer,'rel="nofollow"');
   //addbutton($sub_menu_buttons,'{LASTCOM_LNK}','{LASTCOM_TITLE}','{LASTCOM_TGT}','lastcom',$template_sub_menu_spacer,'rel="nofollow"');
   addbutton($sub_menu_buttons,'{TOPN_LNK}','{TOPN_TITLE}','{TOPN_TGT}','topn',$template_sub_menu_spacer,'rel="nofollow"');
   //addbutton($sub_menu_buttons,'{TOPRATED_LNK}','{TOPRATED_TITLE}','{TOPRATED_TGT}','toprated',$template_sub_menu_spacer,'rel="nofollow"');
   //addbutton($sub_menu_buttons,'{FAV_LNK}','{FAV_TITLE}','{FAV_TGT}','favpics',$template_sub_menu_spacer,'rel="nofollow"');
   if ($CONFIG['browse_by_date'] != 0) {
       addbutton($sub_menu_buttons, '{BROWSEBYDATE_LNK}', '{BROWSEBYDATE_TITLE}', '{BROWSEBYDATE_TGT}', 'browse_by_date', $template_sub_menu_spacer, 'rel="nofollow" class="greybox"');
   }
   addbutton($sub_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','');


 $sub_menu_buttons = CPGPluginAPI::filter('sub_menu',$sub_menu_buttons);
   $params = array('{BUTTONS}' => assemble_template_buttons($template_sub_menu_button,$sub_menu_buttons));
   $template_sub_menu = template_eval($template_sub_menu,$params);
}
/******************************************************************************
** Section <<<THEME_HAS_NO_SUB_MENU_BUTTONS>>> - END
******************************************************************************/




Αndré

Seems that I misunderstood your 'question' (actually you just explained what happens). Do you want to hide that button for all users or do you want to display it for the admin user? I guess you want to hide it for the test user, too. If so, you have to copy the function theme_main_menu from themes/sample/theme.php to your theme.php file and replace
    if (!USER_CAN_CREATE_ALBUMS) {
        template_extract_block($template_sys_menu, 'my_gallery');
    }

with
    //if (!USER_CAN_CREATE_ALBUMS) {
        template_extract_block($template_sys_menu, 'my_gallery');
    //}