Sfoglia il codice sorgente

Fixed bug in permissions for all modules that create node types. When testing if a node type should be created the function should always return true if the permission is set

spficklin 11 anni fa
parent
commit
98edb56e8d

+ 21 - 3
tripal_analysis/tripal_analysis.module

@@ -461,8 +461,25 @@ function tripal_analysis_help($path, $arg) {
 }
 
 /**
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
+ * Implement hook_access().
+ *
+ * This hook allows node modules to limit access to the node types they define.
+ *
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  * @ingroup tripal_analysis
  */
@@ -471,7 +488,8 @@ function chado_analysis_access($op, $node, $account) {
   if ($op == 'create') {
     if (!user_access('create chado_analysis content', $account)) {
       return FALSE;
-      }
+    }
+    return TRUE;
   }
   if ($op == 'update') {
     if (!user_access('edit chado_analysis content', $account)) {

+ 19 - 1
tripal_bulk_loader/tripal_bulk_loader.module

@@ -195,8 +195,25 @@ function tripal_bulk_loader_theme() {
 }
 
 /**
- *  Implements hook_access
+ * Implement hook_access().
  *
+ * This hook allows node modules to limit access to the node types they define.
+ *
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  * @ingroup tripal_bulk_loader
  */
 function tripal_bulk_loader_access($op, $node, $account) {
@@ -204,6 +221,7 @@ function tripal_bulk_loader_access($op, $node, $account) {
     if (!user_access('create tripal_bulk_loader', $account)) {
       return FALSE;
     }
+    return TRUE;
   }
   if ($op == 'update') {
     if (!user_access('edit tripal_bulk_loader', $account)) {

+ 6 - 2
tripal_contact/tripal_contact.module

@@ -199,14 +199,18 @@ function tripal_contact_perm() {
  *  A user object representing the user for whom the operation is to be performed
  *
  *  @return
- *  TRUE
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  */
 function chado_contact_access($op, $node, $account ) {
   if ($op == 'create') {
     if (!user_access('create chado_contact content', $account)) {
       return FALSE;
-      }
+    }
+    return TRUE;
   }
 
   if ($op == 'update') {

+ 21 - 2
tripal_feature/tripal_feature.module

@@ -117,15 +117,34 @@ function tripal_feature_perm() {
 }
 
 /**
- *  Set the permission types that the module uses.
+ * Implement hook_access().
  *
+ * This hook allows node modules to limit access to the node types they define.
+ *
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
+ *  
  * @ingroup tripal_feature
  */
 function chado_feature_access($op, $node, $account) {
   if ($op == 'create') {
     if (!user_access('create chado_feature content', $account)) {
       return FALSE;
-      }
+    }
+    return TRUE;
   }
 
   if ($op == 'update') {

+ 20 - 2
tripal_featuremap/tripal_featuremap.module

@@ -275,8 +275,25 @@ function tripal_featuremap_cron() {
 
 }
 /**
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
+ * Implement hook_access().
+ *
+ * This hook allows node modules to limit access to the node types they define.
+ *
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  * @ingroup tripal_featuremap
  */
@@ -285,6 +302,7 @@ function tripal_featuremap_map_access($op, $node, $account) {
     if (!user_access('create chado_featuremap content', $account)) {
       return FALSE;
     }
+    return TRUE;
   }
 
   if ($op == 'update') {

+ 20 - 1
tripal_library/tripal_library.module

@@ -70,7 +70,25 @@ function tripal_library_perm() {
   );
 }
 /**
- *  Set the permission types that the module uses.
+ * Implement hook_access().
+ *
+ * This hook allows node modules to limit access to the node types they define.
+ *
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  * @ingroup tripal_library
  */
@@ -79,6 +97,7 @@ function chado_library_access($op, $node, $account) {
     if (!user_access('create chado_library content', $account)) {
       return FALSE;
     }
+    return TRUE;
   }
   if ($op == 'update') {
     if (!user_access('edit chado_library content', $account)) {

+ 22 - 4
tripal_organism/tripal_organism.module

@@ -25,7 +25,7 @@ function tripal_organism_init() {
  *
  * @ingroup tripal_organism
  */
-function tripal_organism_node_info() {
+function tripal_org_acanism_node_info() {
   $nodes = array();
   $nodes['chado_organism'] = array(
     'name' => t('Organism'),
@@ -152,8 +152,25 @@ function tripal_organism_theme() {
   );
 }
 /**
- *  The following function proves access control for users trying to
- *  perform actions on data managed by this module
+ * Implement hook_access().
+ *
+ * This hook allows node modules to limit access to the node types they define.
+ *
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  * @ingroup tripal_organism
  */
@@ -161,7 +178,8 @@ function chado_organism_access($op, $node, $account) {
   if ($op == 'create') {
     if (!user_access('create chado_organism content', $account)) {
       return FALSE;
-      }
+    }
+    return TRUE;
   }
   if ($op == 'update') {
     if (!user_access('edit chado_organism content', $account)) {

+ 15 - 11
tripal_project/tripal_project.module

@@ -77,23 +77,26 @@ function tripal_project_perm() {
 }
 
 /**
- * Implements hook_access()
+ * Implement hook_access().
  *
- *  This function sets the access permission for operations on the database.
+ * This hook allows node modules to limit access to the node types they define.
  *
- *  @parm $op
- *    The operation that is to be performed
+ *  @param $op
+ *  The operation to be performed
  *
- *  @parm $node
- *    The specific node that is to have the operation performed
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
  *
- *  @parm $account
- *    The account of the user that is performing the operations
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
  *
  *  @return
- *    True if a operation was performed
- *
- *
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
+ *  
  * @ingroup tripal_project
  */
 function chado_project_access($op, $node, $account) {
@@ -102,6 +105,7 @@ function chado_project_access($op, $node, $account) {
     if (!user_access('create chado_projects content', $account)) {
       return FALSE;
     }
+    return TRUE;
   }
   if ($op == 'update') {
     if (!user_access('edit chado_projects content', $account)) {

+ 5 - 1
tripal_pub/tripal_pub.module

@@ -274,7 +274,10 @@ function tripal_pub_perm() {
  *  A user object representing the user for whom the operation is to be performed
  *
  *  @return
- *  TRUE
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  */
 function chado_pub_access($op, $node, $account ) {
@@ -282,6 +285,7 @@ function chado_pub_access($op, $node, $account ) {
     if (!user_access('create chado_pub content', $account)) {
       return FALSE;
     }
+    return TRUE;
   }
 
   if ($op == 'update') {

+ 18 - 9
tripal_stock/tripal_stock.module

@@ -167,17 +167,25 @@ function tripal_stock_perm() {
 }
 
 /**
- * Implements hook_access(): Maps permission catagories to actions
+ * Implement hook_access().
  *
- * @param $op
- *   The operation current operation: one of create, update, delete
- * @param $node
- *   The node object the current operation is being performed on
- * @param $account
- *   A user object representing the user for whom the operation is to be performed
+ * This hook allows node modules to limit access to the node types they define.
  *
- * @return
- *   TRUE grants access; FALSE denies it
+ *  @param $op
+ *  The operation to be performed
+ *
+ *  @param $node
+ *  The node on which the operation is to be performed, or, if it does not yet exist, the
+ *  type of node to be created
+ *
+ *  @param $account
+ *  A user object representing the user for whom the operation is to be performed
+ *
+ *  @return
+ *  If the permission for the specified operation is not set then return FALSE. If the
+ *  permission is set then return NULL as this allows other modules to disable
+ *  access.  The only exception is when the $op == 'create'.  We will always 
+ *  return TRUE if the permission is set.
  *
  * @ingroup tripal_stock
  */
@@ -186,6 +194,7 @@ function chado_stock_access($op, $node, $account) {
     if (!user_access('create chado_stock content', $account)) {
       return FALSE;
     }
+    return TRUE;
   }
   if ($op == 'update') {
     if (!user_access('edit chado_stock content', $account)) {