diff --git a/core/modules/tour/lib/Drupal/tour/Plugin/Core/Entity/Tour.php b/core/modules/tour/lib/Drupal/tour/Plugin/Core/Entity/Tour.php index 6365ccc..cd6421a 100644 --- a/core/modules/tour/lib/Drupal/tour/Plugin/Core/Entity/Tour.php +++ b/core/modules/tour/lib/Drupal/tour/Plugin/Core/Entity/Tour.php @@ -49,13 +49,6 @@ class Tour extends ConfigEntityBase implements TourInterface { public $module; /** - * The module which this tour is assigned to. - * - * @var string - */ - public $module = 'tour'; - - /** * The label of the tour. * * @var string diff --git a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php index 2821b7e..fb4f224 100644 --- a/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php +++ b/core/modules/tour/lib/Drupal/tour/Tests/TourTest.php @@ -43,7 +43,7 @@ public function testTourFunctionality() { // Navigate to tour-test-1 and verify the tour_test_1 tip is found with appropriate classes. $this->drupalGet('tour-test-1'); $elements = $this->xpath('//li[@data-id=:data_id and @class=:classes and ./h2[contains(., :text)]]', array( - ':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1 even last', + ':classes' => 'tip-module-tour-test tip-type-text tip-tour-test-1 odd first', ':data_id' => 'tour-test-1', ':text' => 'The first tip', )); @@ -100,6 +100,7 @@ public function testTourFunctionality() { // Programmatically create a tour for use through the remainder of the test. entity_create('tour', array( 'id' => 'tour-entity-create-test-en', + 'module' => 'tour', 'label' => 'Tour test english', 'langcode' => 'en', 'paths' => array( diff --git a/core/modules/tour/lib/Drupal/tour/TourRenderController.php b/core/modules/tour/lib/Drupal/tour/TourRenderController.php index e1bf15d..99818c9 100644 --- a/core/modules/tour/lib/Drupal/tour/TourRenderController.php +++ b/core/modules/tour/lib/Drupal/tour/TourRenderController.php @@ -22,10 +22,13 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la $build = array(); foreach ($entities as $entity_id => $entity) { $tips = $entity->getTips(); + $module = $entity->get('module'); $count = count($tips); $list_items = array(); foreach ($tips as $index => $tip) { - if ($output = $tip->getOutput()) { + $tip_permission = $tip->get('permission'); + $tip_permission = !empty($tip_permission) ? $tip_permission : 'view ' . $module . ' tour tips' ; + if ((user_access('view all tour tips') || user_access($tip_permission)) && $output = $tip->getOutput()) { $attributes = array( 'class' => array( 'tip-module-' . drupal_clean_css_identifier($entity->get('module')), diff --git a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml index 86abd83..a254e12 100644 --- a/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml +++ b/core/modules/tour/tests/tour_test/config/tour.tour.tour-test.yml @@ -16,8 +16,17 @@ tips: tour-test-3: id: tour-test-3 plugin: image - label: The awesome image + label: The advanced image url: http://local/image.png weight: "1" attributes: data-id: tour-test-3 + tour-test-4: + id: tour-test-4 + plugin: text + permission: view advanced tour tips + label: The advanced tip + body: A sensational tip. + weight: "2" + attributes: + data-id: tour-test-4