From d9b94048812df447edbc3ac7c973f9700dde6dd1 Mon Sep 17 00:00:00 2001 From: ROBERT PATRICK CAREY III Date: Thu, 5 Sep 2019 13:52:33 -0400 Subject: [PATCH] Fix: Exception: in Drupal\book\BookExport->bookExport() --- modules/user_preferences/user_preferences.module | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/user_preferences/user_preferences.module b/modules/user_preferences/user_preferences.module index 10ac4c0..882c604 100644 --- a/modules/user_preferences/user_preferences.module +++ b/modules/user_preferences/user_preferences.module @@ -45,6 +45,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a $user = \Drupal::currentUser(); $is_admin = in_array('administrator', $user->getRoles()); $is_front = \Drupal::service('path.matcher')->isFrontPage(); + $is_book = isset($node->book['bid']); if(!$is_admin){ $can_add_child_page = in_array('Add content and child pages to books and manage their hierarchies', user_role_permissions($user->getRoles())); @@ -122,7 +123,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a 'aria-label' => 'Toggle fullscreen', ] ]; - if($is_admin || $can_add_child_page){ + if(($is_admin || $can_add_child_page) && $is_book){ $link['addPage'] = [ 'title' => t(' @@ -155,7 +156,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a ]; */ } - if(!$is_front){ + if(!$is_front && $is_book){ $link['printerFriendly'] = [ 'title' => t(' '), 'url' => Url::fromUri('internal:/book/export/html/'.$nid), @@ -164,7 +165,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a 'data-toggle' => 'tooltip', 'data-tippy-content' => t('Printer friendly version'), 'aria-label' => 'Printer friendly version', - ] + ] ]; } } -- GitLab