In #1336994: Contextual links for Webform Blocks and Nodes, webform-related contextual links were added to the module. However, I'm running into a problem with this because the links are displaying even to users who do not have permission to visit the "Webform" or "Results" pages (so that when they click on the corresponding contextual link they get taken to an access denied page).

The attached patch fixes this by using hook_menu() to define the contextual links, which also simplifies the required code a fair amount.

A side effect (new behavior) of this patch is that on webform blocks, the standard node-related contextual links (e.g. "Edit" and "Delete") are also going to start appearing, in addition to the "Webform" and "Results" links. I think that's probably OK; the webform node is being displayed in the block in a teaser-like format, so it probably makes sense to show all the contextual links that would normally be attached there. If we want to hide "Edit" and/or "Delete" instead, though, it's pretty easy to do that in hook_contextual_links_view_alter(). I actually have some code in the Media Gallery module that more or less does the same thing and which could be ported here if necessary.

CommentFileSizeAuthor
webform-contextual-links.patch2.12 KBDavid_Rothstein

Comments

quicksketch’s picture

Sweet, thanks David.

quicksketch’s picture

Status: Needs review » Needs work

Hmm, this patch makes it so that the Webform-provided blocks no longer have links to edit the Webform or view results. Can this code work with blocks also, or is some combination of both approached necessary?

quicksketch’s picture

Status: Needs work » Fixed

Ah, nevermind. I had the block set to show the "Form only". Behavior before and after the patch is identical. Great patch, thanks much David! Committed to 7.x branch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.