Download & Extend

Access Denied error with Organic Groups User Roles

Project:Outline
Version:6.x-0.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

When using organic groups user roles, the add child page link produces an access denied error for users who do not have permission to create the content type outside of the context of the group.

My solution was to modify outline.module's outline_link function to include the gid in the query for the add child link:

<?php
    
if (module_exists('og') && module_exists('og_user_roles') && $thegroup = og_get_group_context()) {
         
$gidpath = '&gids[]='.$thegroup->nid;
     }
          if (
node_access('create', $child_type) && 1 == $node->status && $node->book['depth'] < MENU_MAX_DEPTH) {
           
$links['outline_add_child'] = array(
             
'title' => t('Add child !node_type', array( '!node_type' => node_get_types('name', $child_type))),
             
'href' => "node/add/". str_replace('_', '-', $child_type),
            
'query' => "parent=". $node->book['mlid'].$gidpath,
            );
          }
?>