function book_helper_display_delete_book_page_warning in Book helper 7
Same name and namespace in other branches
- 6 book_helper.module \book_helper_display_delete_book_page_warning()
Display a warning warning when deleting a book page that has child pages.
1 call to book_helper_display_delete_book_page_warning()
- book_helper_help in ./
book_helper.module - Implements hook_help().
File
- ./
book_helper.module, line 358 - Improves Drupal's core book module's functionality.
Code
function book_helper_display_delete_book_page_warning($nid) {
$node = node_load($nid);
if (isset($node->book) && $node->book['bid'] != $node->nid) {
$book_node = node_load($node->book['bid']);
$query = 'SELECT mlid, link_title AS title, link_path AS href FROM {menu_links} WHERE plid=:plid ORDER BY weight';
$args = array(
':plid' => $node->book['mlid'],
);
$result = db_query($query, $args);
$links = array();
foreach ($result as $record) {
$links[$record->mlid] = (array) $record;
}
if (empty($links)) {
return;
}
$t_args = array(
'!book' => l($book_node->title, 'node' . $book_node->nid),
);
$output = t('The below book pages are not going to be deleted, they will be moved to the root of the !book book.', $t_args) . '<br />' . t('It is recommended that you delete or move these pages before proceeding.') . theme('links', array(
'links' => $links,
));
drupal_set_message($output, 'warning');
}
}