Commit d9b94048 authored by ROBERT PATRICK CAREY III's avatar ROBERT PATRICK CAREY III 🗿

Fix: Exception: in Drupal\book\BookExport->bookExport()

parent d8cf6bce
...@@ -45,6 +45,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a ...@@ -45,6 +45,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a
$user = \Drupal::currentUser(); $user = \Drupal::currentUser();
$is_admin = in_array('administrator', $user->getRoles()); $is_admin = in_array('administrator', $user->getRoles());
$is_front = \Drupal::service('path.matcher')->isFrontPage(); $is_front = \Drupal::service('path.matcher')->isFrontPage();
$is_book = isset($node->book['bid']);
if(!$is_admin){ 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())); $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 ...@@ -122,7 +123,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a
'aria-label' => 'Toggle fullscreen', 'aria-label' => 'Toggle fullscreen',
] ]
]; ];
if($is_admin || $can_add_child_page){ if(($is_admin || $can_add_child_page) && $is_book){
$link['addPage'] = [ $link['addPage'] = [
'title' => t(' 'title' => t('
<span class="fa-layers"> <span class="fa-layers">
...@@ -155,7 +156,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a ...@@ -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'] = [ $link['printerFriendly'] = [
'title' => t('<i class="fal fa-print">&nbsp;</i>'), 'title' => t('<i class="fal fa-print">&nbsp;</i>'),
'url' => Url::fromUri('internal:/book/export/html/'.$nid), 'url' => Url::fromUri('internal:/book/export/html/'.$nid),
...@@ -164,7 +165,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a ...@@ -164,7 +165,7 @@ function user_preferences_node_links_alter(array &$links, NodeInterface $node, a
'data-toggle' => 'tooltip', 'data-toggle' => 'tooltip',
'data-tippy-content' => t('Printer friendly version'), 'data-tippy-content' => t('Printer friendly version'),
'aria-label' => 'Printer friendly version', 'aria-label' => 'Printer friendly version',
] ]
]; ];
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment