To simplify things, it'd be nice to tie panelizer access with access to update the node.

I figured out a semi-hackish way to do it via adding a access plugin that checked node access to current node (via menu_get_object) for current user, http://drupalcode.org/project/openatrium.git/blob/1a1e16d:/modules/featu..., and creating a pipeline that used that access check http://drupalcode.org/project/openatrium.git/blob/1a1e16d:/modules/featu...

So

  1. Possible to pass context to a pipeline access via the variant (so that access plugin can be removed and normal node access [assuming there is one] used instead)? It looks like work on pipelines was semi-abandoned 37 weeks ago based on that pipeline branch in panels and the open issues. (mostly unrelated, there's absolutely no cache on the cache_get level on the default hook, etc., as far as I can tell).
  2. Should panelizer provide a way to do it out of box? Seems very useful.
CommentFileSizeAuthor
#4 panelizer-node-access-2024831-04.patch878 bytesjhedstrom

Comments

merlinofchaos’s picture

Status: Active » Fixed

Panelizer already does this.

In render_entity():

    // If the IPE is enabled, but the user does not have access to edit
    // the entity, load the standard renderer instead.

    // use class_parents so we don't try to autoload the class we
    // are testing.
    $parents = class_parents($renderer);
    if (!empty($parents['panels_renderer_editor']) && (!$this->panelizer_access('content', $entity, $view_mode) || !$this->entity_access('update', $entity))) {
      $renderer = panels_get_renderer_handler('standard', $display);
    }

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

removing extra li

jhedstrom’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

The logic mentioned in #1 always returns the standard renderer unless a user passes that first admin panelizer check since !FALSE evaluates to TRUE, and the operator is OR, the entity-level access check is never called.

    // use class_parents so we don't try to autoload the class we
    // are testing.
    $parents = class_parents($renderer);
    if (!empty($parents['panels_renderer_editor']) && (!$this->panelizer_access('content', $entity, $view_mode) || !$this->entity_access('update', $entity))) {
      $renderer = panels_get_renderer_handler('standard', $display);
    }

The OR operator should be AND. I'll test and provide a patch.

jhedstrom’s picture

Status: Active » Needs review
StatusFileSize
new878 bytes

This patch resolves the issue in my testing. The logic now reads "If this user doesn't have admin access AND they cannot edit the entity THEN use the standard renderer."

jhedstrom’s picture

Category: Support request » Bug report
damienmckenna’s picture

Status: Needs review » Fixed

Committed. Thanks.

  • Commit 953ebdd on 7.x-3.x authored by jhedstrom, committed by DamienMcKenna:
    Issue #2024831 by jhedstrom: Permission fix on node access check when...

Status: Fixed » Closed (fixed)

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