HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Tutorial - How to add an option to the flyout menu in 2.1 and add link in dashboard as well.

peregrineperegrine MVP
edited June 2014 in Tutorials

this is an example of how to add a link to the messages option in the dashboard for Moderators to use.

you can add these functions to your plugin or theme hooks.

public function Base_FlyoutMenu_Handler($Sender) {
$Session = Gdn::Session();
// check if role has Moderation manage permissions.  if so add the option in flyout button.
if ($Session->CheckPermission('Garden.Moderation.Manage')) {
  // add the link to dashboard/messages that has the name "Manage Messages (which is translateable via definitions)
  echo Wrap(Anchor(Sprite('SpMod').' '.T('Manage Messages'), '/dashboard/message'), 'li');
  }
}

to translate the definition would be

$Definition['Manage Messages'] = "Manage The Messages";


this will add a link called Messages in the Moderation Section of the Dashboard Menu Items Panel

public function Base_GetAppSettingsMenuItems_Handler($Sender) {
$Menu = $Sender->EventArguments['SideMenu'];
$Menu->AddLink('Moderation', 'Messages', 'dashboard/message', 'Garden.Moderation.Manage');
}

in add link moderation say to add to Moderation category. the next item say go to /dashboard messages when user clicks link.

and Garden.Moderation.Manage means link will appear for roles with Moderation.Manage checked.

I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Comments

  • hgtonighthgtonight ∞ · New Moderator

    This is a great tutorial!

    But the /dashboard/message page requires the 'Garden.Messages.Manage' permission.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • peregrineperegrine MVP
    edited June 2014

    @hgtonight said:
    This is a great tutorial!

    But the /dashboard/message page requires the 'Garden.Messages.Manage' permission.

    thx for clarifying...

    yes, that is true. any page you want to get to must have permissions to use it.

    this tutorial was to add links. based on moderation manage permssions. Of course if the moderators don't have permission to get to the target link where you send them then you will not be able to view that specific page.
    So yes, if you leave the code exactly as is, the moderators must also be checked off with manage message permissions in the dashboard.

    you could also change the permissions all around from Garden.Moderation.Manage' to Garden.Messages.Manage

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.