瀏覽代碼

Add permission to view excluded embedded pages.

Lacey Sanderson 4 年之前
父節點
當前提交
e57f041fda
共有 1 個文件被更改,包括 29 次插入12 次删除
  1. 29 12
      tripal_jbrowse_page/tripal_jbrowse_page.module

+ 29 - 12
tripal_jbrowse_page/tripal_jbrowse_page.module

@@ -23,19 +23,22 @@ function tripal_jbrowse_page_menu() {
   $instances = tripal_jbrowse_mgmt_get_instances();
   foreach ($instances as $instance) {
 
-    if (tripal_jbrowse_page_is_instance_public($instance->id)) {
+    // Create the menu item.
+    $path = 'jbrowse/'.$instance->organism->genus . '-' . $instance->organism->species;
+    $items[$path] = [
+      'title' => $instance->title,
+      'description' => $instance->description,
+      'page callback' => 'tripal_jbrowse_page_page',
+      'page arguments' => [1, 2],
+      'file' => 'includes/tripal_jbrowse_page.page.inc',
+      'type' => MENU_SUGGESTED_ITEM,
+    ];
 
-      // Create the menu item.
-      $path = 'jbrowse/'.$instance->organism->genus . '-' . $instance->organism->species;
-      $items[$path] = [
-        'title' => $instance->title,
-        'description' => $instance->description,
-        'page callback' => 'tripal_jbrowse_page_page',
-        'page arguments' => [1, 2],
-        'access arguments' => ['access content'],
-        'file' => 'includes/tripal_jbrowse_page.page.inc',
-        'type' => MENU_SUGGESTED_ITEM,
-      ];
+    if (tripal_jbrowse_page_is_instance_public($instance->id)) {
+      $items[$path]['access arguments'] = ['access content'];
+    }
+    else {
+      $items[$path]['access arguments'] = ['view private jbrowse page'];
     }
   }
 
@@ -76,3 +79,17 @@ function tripal_jbrowse_page_theme($existing, $type, $theme, $path) {
 
   return $items;
 }
+
+/**
+ * Implements hook_permission().
+ */
+function tripal_jbrowse_page_permissions() {
+  $items = [];
+
+  $items['view private jbrowse page'] = [
+    'title' => t('View excluded JBrowse pages'),
+    'description' => t('If users have this permission and know the link to the page, they will be able to see it. The instance will still not be included in the JBrowse instances list.'),
+  ];
+
+  return $items;
+}