Hi,
I have website with a lot of books.
I want to create a new book to a username ( I will change the author name).
I want to give a permission to specific role ( this username role ) to add a book page content but just to the specific book that I created to him . ( not to all the books )
My goal is to give permission for user to manage just his book.
How can I do that?
Thanks.

CommentFileSizeAuthor
#6 capture.jpg50.48 KBwxman
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ntigh52’s picture

Title: add book page content to specific book » Add book page content to specific book
ntigh52’s picture

Title: Add book page content to specific book » How to give permission creating book child pages within author own book
ntigh52’s picture

Issue summary: View changes

1

ntigh52’s picture

Sorry but I didnt solve this issue.
I need give permission Add content and child pages to books but not to all the book, just own books.
on the Book outline just own parent pages will be.
How can it done?
thanks a lot

wxman’s picture

I think I've tried all the different access modules, but none can solve this problem. I'm going to have to shut off the book creation on my site until this gets solved.

wxman’s picture

I did find a messy workaround by adding this to my node.tpl.php

global $user;
$viewer = $user->uid;
if ($uid == $viewer || $is_admin) {
  /*$ltitle  = $content['links']['book']['#links']['book_add_child']['title']; //This shows the default text */
  $lhref   = $content['links']['book']['#links']['book_add_child']['href'];
  $lparent = $content['links']['book']['#links']['book_add_child']['query']['parent'];
  print '<a href="/'.$lhref.'?parent='.$lparent.'"><span>Add chapter page</span></a>';
}

This makes it so the add chapter/child page link only shows if the viewer is the owner of the node. I still have to figure out how to remove the 'add child page' link from my links.

wxman’s picture

FileSize
50.48 KB

I improved this just a little bit, but it's still messy. I added a DIV around the link.

global $user;
$viewer = $user->uid;
if ($uid == $viewer || $is_admin) {
  $lhref   = $content['links']['book']['#links']['book_add_child']['href'];
  $lparent = $content['links']['book']['#links']['book_add_child']['query']['parent'];
  print '<div class="add-chapter"><a href="/'.$lhref.'?parent='.$lparent.'">Add chapter page</a></div>';
}

I then got rid of the original add child page link using CSS:

.links li.book_add_child {
  visibility: hidden;
  overflow: hidden;
  display: none;
}

I added my own CSS to really make it stand out:

div.add-chapter {
    background-color: white;
    border: 1px solid #CCCCCC !important;
    height: auto;
    overflow: hidden;
    position: relative;
    width: auto;
    font-size: 2em;
    text-align: center;
}

I attached a picture of the finished product.

ntigh52’s picture

@wxman,
thanks,
i think that the good way for thaT is, to check the uid of the bppk parent node and to compare it to the user id ?

$book_parent=node_load($node->book['bid']);
if ( $book_parent->nid == $node->nid ) {
return TRUE;
}
else {
return FALSE;
}

what do you think?
I wish there was support to the module.
Thanks a lot.

ntigh52’s picture

Issue summary: View changes

4

suriyan saychompoo’s picture

Issue summary: View changes

book_Permission to add sub pages Module Should be able to help you

https://www.suriyan.name/Module/book_Permission_to%20add_sub_pages

Version: 7.14 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.