Parcourir la source

Updated get blast database API function to respect node access to that we can use any node access module to restrict the blast databases available :) Tested & works with Simple Access

Lacey Sanderson il y a 10 ans
Parent
commit
ec260c7170
1 fichiers modifiés avec 17 ajouts et 1 suppressions
  1. 17 1
      api/blast_ui.api.inc

+ 17 - 1
api/blast_ui.api.inc

@@ -16,9 +16,25 @@
  *   An array where the nid is the key and the value is the human-readable name of the option
  */
 function get_blast_database_options($type) {
+  global $user;
+
+  // Use the Entity API to get a list of BLAST Nodes to load
+  // We use this function in order respect node access control so that
+  // administrators can use this module in combination with a node access module
+  // of their choice to limit access to specific BLAST databases.
+  $query = new EntityFieldQuery();
+  $query->entityCondition('entity_type', 'node')
+    // Restrict to BLASTDB nodes.
+    ->entityCondition('bundle', 'blastdb')
+    // Restrict to Published nodes.
+    ->propertyCondition('status', 1)
+    // Restrict to nodes the current user has permission to view.
+    ->addTag('node_access');
+  $entities = $query->execute();
+
 
   // Get all BlastDB nodes
-  $nodes  = node_load_multiple(array(), array('type'=> 'blastdb'));
+  $nodes  = node_load_multiple(array_keys($entities['node']));
 
   // Support obsolete database type n/p
   $obs_type = '';