Download & Extend

Removal of "Add Child Page" link and "Outline" tab if update permission is not granted on the book

Project:Book access
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi everyone!

I've just created a patch to fix the appearance of the "Outline" tab and the "Add Child Page" link on book pages of books without update permission of the current user.
Patch is build against latest release 6.x-1.0-rc2.

I'm sorry if I made a mistake, this is my first patch and contribution.

Thank you,
Neodym

AttachmentSize
book_access_add_link_outline_tab_fix.patch4.02 KB

Comments

#1

Hi, it's me again.

Discard the patch above, this one is the real version. Tested against latest Drupal 6.9 release.

So long,
Neodym

PS: Why is it not possible to edit one's own filed issue?

AttachmentSize
book_access_link_tab_fix.patch 3.98 KB

#2

Thanks for this, I've modified this patch to "fix" the "Add child page" link display for D5 with a slightly simplified version.

#3

Version:6.x-1.0-rc2» 6.x-1.x-dev
Status:needs review» needs work

The patch should be created for the development snapshot.

The patch as it is doesn't follow the coding standards; then, the code that changes the access callback of the menu should also change the access arguments.

#4

The development snapshot already has the code to remove the link Add child page; therefore that part of the patch is not necessary.

<?php
      $bool
= (
      
$grant_update &&          (
         
user_access('add content to books') ||
         
user_access('administer book outlines')
        ) &&
       
node_access('create', variable_get('book_child_type', 'book')) &&
       
$node->status == 1 &&
       
$node->book['depth'] < MENU_MAX_DEPTH
     
);

      if (!
$bool) {
       
// Remove the link "add child page".
       
unset($node->links['book_add_child']);
      }
      break;
?>

#5

I started to change the code added by the patch, and applying it in chunks.
For now, I moved the code that was in hook_nodeapi() into hook_menu_link_alter(); I also updated the code that verifies if the user has the permission to update the book as granted by the realm book_access_rule.

#6

Status:needs work» fixed

I added the rest of the code, after I changed it to follow more the coding standards, and after I fixed the code (removing a book page from a book doesn't mean to delete it).

Thanks for the report, and the help with the code.

#7

Status:fixed» closed (fixed)

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

nobody click here