• Welcome to Simple Machines Community Forum. Please login or sign up.
September 28, 2021, 12:39:22 PM

News:

Wondering if this will always be free?  See why free is better.


Staff and User Menus

Started by shadav, February 19, 2021, 02:32:58 PM

Previous topic - Next topic

shadav

Link to Mod

This will add 2 new menu items
Staff Menu
User Menu

it will move the admin and moderator menus into the new Staff Menu
it will move the profile and my messages menus into the new User Menu

this only modifies subs.php, so backup Sources/Subs.php before installing just in case :)
and adds 2 lines to Modifications.english.php and Modifications.english-utf8.php (if you have them)

to translate
$txt['staff_menu'] = 'Staff Menu';
$txt['user_menu'] = 'User Menu';


The staff menu will only show to those who have permission to view the moderation center
The user menu will only show to those who have permission to edit their profiles

thanks to vbgamer for bring up a point about the user menu
I had just used if allowed to edit profile then show the menu but should also add if allowed pm to show the menu

so changed the show in to an array
'show' => allowedTo(array('allow_edit_profile', 'allow_pm')),
this way also if you add other menus into the the user menu you can add it's show setting into the array

mickjav

Hi Just tried adding this with Package Manager but just gave me a white box end of menu.

I do have other mods like the homepage mod and I've added and removed options so will try a manual install later today.

been looking for a way to do what this mod does as seems a waist of space to have 4 options when you can cut it down to 2.

thanks mick
Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

shadav

more than likely it's an issue with a mod that changed the menu in some way
if the homepage mod added a button into the mix it may have messed this up
might have to move it somewhere else in the Sources/Subs.php file so it's not lumped in with the staff or user menu buttons

mickjav

Thanks Will look into it and let you know the result.

mick
Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

mickjav

Sorry it's taken a while before getting to this but have done a manual Install and works perfectly On Admin Account.

Checked on my test Regular Members Account But There is no user menu Have checked the permissions and access to profile and messages are set.

When I view admin I've attached a picture so you can see the white block on end.

You cannot see attachments on this board.
Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

mickjav

September 16, 2021, 04:27:38 PM #5 Last Edit: September 16, 2021, 04:43:46 PM by mickjav
I have mad the following changes which seem to Have worked as all members can use there correct menu plus the admin button no longer shows for global mods

I changed this
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
For This as the admin button was showing for Global Mods
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => allowedTo('admin_forum'),

And For the Staff menu I changes
// Begin User Menu.
'usermenu' => array(
'title' => $txt['user_menu'],
'href' => $scripturl . '?action=profile',
'show' => allowedTo(array('allow_edit_profile', 'allow_pm')),
For
'usermenu' => array(
'title' => $txt['user_menu'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],

Haven't taken into account the pm's but all my members can send pm's so not really an issue for me.

They seem to be working for all member groups correctly now other than the issue with the admin seems to work perfectly thanks mick

EDIT: Just tested the Number of new pm's number which would normally be tagged on end of messages  it's no longer showing?
Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

shadav

I'll look into it, need to fix a few uncaught errors on my site

as far as the permissions went I didn't change anything on the admin I just wrapped it around with the staff menu code

as for the user menu permission I set it that way on recommendation of vbgammer
QuoteInstalls fine. Only comment I have is the permission check since you combine the profile/pm's

I would also check if  $context['allow_pm']  is set to allow just in case profile isn't set to edit.
so that it shouldn't cause any issues

also so if you add other mods to the user menu you can add it's permissions easily
for example if you use the bookmark mod and have it inside the user menu you can add it's permissions as
'show' => allowedTo(array('allow_edit_profile', 'allow_pm', 'make_bookmarks')),
not sure why the number isn't showing up, again I didn't touch that code just wrapped it into the user menu
but once I'm able to play with it I'll check and see

mickjav

I'm still trying to understand PHP.

so not 100% sure why this didn't work correctly after changing the level of Admin button for main bar to second level?

$context['allow_admin']
but this did

allowedTo('admin_forum')
Quote from: shadav on September 16, 2021, 08:32:35 PM'show' => allowedTo(array('allow_edit_profile', 'allow_pm', 'make_bookmarks')),

From my understanding of code sequencing the above will only display the user menu if all conditions are true but again new to php and haven't looked at the allowedTo function.

the permissions for each level like for the bookmarks are set at that level for those requiring permissions like
'show' => allowedTo('make_bookmarks'),
This has saved me a lot of space on the menu and is easy to add options too so love it.

thanks mick


Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

Arantor

Because more permissions allow access to the admin panel than just admin_forum. At a minimum, edit_news, manage_permissions, manage_boards, and likely more I'm not remembering right now.

That's why $context['allow_admin'] is used, because it's a composite of all the permissions someone could have that would let them have something to do in the admin panel.
No good deed goes unpunished
All helpful urges should be circumvented

mickjav

Quote from: Arantor on September 17, 2021, 03:57:30 AMBecause more permissions allow access to the admin panel than just admin_forum. At a minimum, edit_news, manage_permissions, manage_boards, and likely more I'm not remembering right now.

That's why $context['allow_admin'] is used, because it's a composite of all the permissions someone could have that would let them have something to do in the admin panel.
Thanks I'll change that back as the global mods might have access to one or more blocks
Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

Arantor

Also for note, if you pass a list of things to allowedTo, it will be true/all good if the user has any of the permissions in the list, not requiring all of the list.
No good deed goes unpunished
All helpful urges should be circumvented

mickjav

Quote from: Arantor on September 17, 2021, 06:22:46 AMAlso for note, if you pass a list of things to allowedTo, it will be true/all good if the user has any of the permissions in the list, not requiring all of the list.

Thanks Now I have to Figure out why my user menu wont display with the array even though they have pemissions for both.

Again it might be another mod but I can't see what would prevent it from displaying.

mick
Database Dreams - music and charts, Home of Chart Tracker Elite, Apollo & DJ 2020.
Coming soon The Librarian.

Advertisement: