You are here

function book_copy_book_process_book_copy in Book Copy 7.2

Same name and namespace in other branches
  1. 7 book_copy.module \book_copy_book_process_book_copy()

Callback for book_copy ajax call from outline designer.

1 string reference to 'book_copy_book_process_book_copy'
book_copy_outline_designer_operations_alter in ./book_copy.module
Implements hook_outline_designer_operations_alter().

File

./book_copy.module, line 444
Book copy, copy book outlines

Code

function book_copy_book_process_book_copy($nid, $new_title) {

  // need to account for the 3 weird characters in URLs
  $new_title = str_replace("@2@F@", '/', $new_title);
  $new_title = str_replace("@2@3@", '#', $new_title);
  $new_title = str_replace("@2@B@", '+', $new_title);
  $new_title = str_replace("@2@6@", '&', $new_title);
  $node = node_load($nid);

  // verify that they can create / view the first item, administer outlines, add to books and copy books
  // this is probably a bit overkill but outline designer is for those with lots and lots of permissions
  if (node_access('create', $node) && _book_outline_access($node) && user_access('add content to books') && user_access('copy books')) {

    // run the bulk job in the background
    book_copy_process_copy($nid, '', $new_title, FALSE);
    return 1;
  }
  else {
    drupal_set_message(t('Outline copy denied because of permissions (need admin outline, create / view on the node, add to books and ability to copy).'));
    return 0;
  }
}