Преглед на файлове

Fixed hook_access for all modules. This change supports use of other access permission modules, such as "node privacy by role"

spficklin преди 13 години
родител
ревизия
fb76301d42

+ 0 - 1
tripal_analysis/tripal_analysis.module

@@ -742,7 +742,6 @@ function chado_analysis_access($op, $node, $account){
 			return FALSE;
       }
 	}
-
 	if ($op == 'update') {
 		if (!user_access('edit chado_analysis content', $account)) {
 			return FALSE;

+ 0 - 1
tripal_analysis_blast/tripal_analysis_blast.module

@@ -824,7 +824,6 @@ function chado_analysis_blast_access($op, $node, $account){
 			return FALSE;
       }
 	}
-
 	if ($op == 'update') {
 		if (!user_access('edit chado_analysis_blast content', $account)) {
 			return FALSE;

+ 11 - 10
tripal_analysis_go/tripal_analysis_go.module

@@ -90,25 +90,26 @@ function tripal_analysis_go_perm(){
  */
 function chado_analysis_go_access($op, $node, $account){
    if ($op == 'create') {
-      return user_access('create chado_analysis_go content', $account);
+      if(!user_access('create chado_analysis_go content', $account)){
+         return FALSE;
+      }
    }
-
    if ($op == 'update') {
-      if (user_access('edit chado_analysis_go content', $account)) {
-         return TRUE;
+      if (!user_access('edit chado_analysis_go content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'delete') {
-      if (user_access('delete chado_analysis_go content', $account)) {
-         return TRUE;
+      if (!user_access('delete chado_analysis_go content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'view') {
-      if (user_access('access chado_analysis_go content', $account)) {
-         return TRUE;
+      if (!user_access('access chado_analysis_go content', $account)) {
+         return FALSE;
       }
    }
-   return FALSE;
+   return NULL;
 }
 /*******************************************************************************
  *
@@ -594,4 +595,4 @@ function tripal_analysis_go_job_describe_args($callback,$args){
 
    }
    return $new_args;
-}
+}

+ 1 - 2
tripal_analysis_interpro/tripal_analysis_interpro.module

@@ -640,7 +640,6 @@ function chado_analysis_interpro_access($op, $node, $account){
 			return FALSE;
       }
 	}
-
 	if ($op == 'update') {
 		if (!user_access('edit chado_analysis_interpro content', $account)) {
 			return FALSE;
@@ -780,4 +779,4 @@ function tripal_analysis_interpro_extract_keywords ($analysis_id) {
 	
 	print "Finished.\n";
 	
-}
+}

+ 0 - 1
tripal_analysis_kegg/tripal_analysis_kegg.module

@@ -80,7 +80,6 @@ function chado_analysis_kegg_access($op, $node, $account){
 			return FALSE;
       }
 	}
-
 	if ($op == 'update') {
 		if (!user_access('edit chado_analysis_kegg content', $account)) {
 			return FALSE;

+ 0 - 1
tripal_analysis_unigene/tripal_analysis_unigene.module

@@ -45,7 +45,6 @@ function chado_analysis_unigene_access($op, $node, $account){
 			return FALSE;
       }
 	}
-
 	if ($op == 'update') {
 		if (!user_access('edit chado_analysis_unigene content', $account)) {
 			return FALSE;

+ 11 - 9
tripal_bulk_loader/tripal_bulk_loader.module

@@ -137,24 +137,26 @@ function tripal_bulk_loader_list () {
  */
 function tripal_bulk_loader_access($op, $node, $account){
 	if ($op == 'create') {
-		return user_access('create tripal_bulk_loader', $account);
+		if(!user_access('create tripal_bulk_loader', $account)){
+         return FALSE;
+      }
 	}
 	if ($op == 'update') {
-		if (user_access('edit tripal_bulk_loader', $account)) {
-			return TRUE;
+		if (!user_access('edit tripal_bulk_loader', $account)) {
+			return FALSE;
 		}
 	}
 	if ($op == 'delete') {
-		if (user_access('delete tripal_bulk_loader', $account)) {
-			return TRUE;
+		if (!user_access('delete tripal_bulk_loader', $account)) {
+			return FALSE;
 		}
 	}
 	if ($op == 'view') {
-		if (user_access('access tripal_bulk_loader', $account)) {
-			return TRUE;
+		if (!user_access('access tripal_bulk_loader', $account)) {
+			return FALSE;
 		}
 	}
-	return FALSE;
+	return NULL;
 }
 
 /**
@@ -385,4 +387,4 @@ function tripal_bulk_loader_job_describe_args($callback,$args){
     return $new_args;
   }
   
-}
+}

+ 10 - 9
tripal_cv/tripal_cv.module

@@ -166,25 +166,26 @@ function tripal_cv_menu() {
  */
 function chado_cv_access($op, $node, $account){
   if ($op == 'create') {
-      return user_access('create chado_cv content', $account);
+      if(!user_access('create chado_cv content', $account)){
+         return FALSE;
+      }
    }
-
    if ($op == 'update') {
-      if (user_access('edit chado_cv content', $account)) {
-         return TRUE;
+      if (!user_access('edit chado_cv content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'delete') {
-      if (user_access('delete chado_cv content', $account)) {
-         return TRUE;
+      if (!user_access('delete chado_cv content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'view') {
-      if (user_access('access chado_cv content', $account)) {
-         return TRUE;
+      if (!user_access('access chado_cv content', $account)) {
+         return FALSE;
       }
    }
-   return FALSE;
+   return NULL;
 }
 
 /**

+ 11 - 8
tripal_gbrowse/tripal_gbrowse.module

@@ -810,21 +810,24 @@ function tripal_gbrowse_perm(){
 function tripal_gbrowse_access($op, $node, $account) {
 
   if($op == 'create') {
-  
     // Only users with permission to do so may create this node type.
-    return user_access('create tripal_gbrowse', $account);
-  
+    if(!user_access('create tripal_gbrowse', $account)){
+       return FALSE;
+    }  
   }
 
   // Users who create a node may edit or delete it later, assuming they have the
   // necessary permissions.
-  if($op == 'update' || $op == 'delete') {
-    
-    if(user_access('edit own tripal_gbrowse',$account) && ($account->uid == $node->uid)) {
-      
-      return TRUE;
+  if($op == 'update' || $op == 'delete') {   
+    if(!user_access('edit own tripal_gbrowse',$account)){
+       return FALSE;
+    } 
+    if(user_access('edit own tripal_gbrowse',$account) && 
+       $account->uid != $node->uid){
+      return FALSE;
     }
   }
+  return NULL;
 }
 
 

+ 28 - 18
tripal_library/tripal_library.module

@@ -74,25 +74,26 @@ function tripal_library_perm(){
  */
 function chado_library_access($op, $node, $account) {
    if ($op == 'create') {
-      return user_access('create chado_library content', $account);
+      if(!user_access('create chado_library content', $account)){
+         return FALSE;
+      }
    }
-
    if ($op == 'update') {
-      if (user_access('edit chado_library content', $account)) {
-         return TRUE;
+      if (!user_access('edit chado_library content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'delete') {
-      if (user_access('delete chado_library content', $account)) {
-         return TRUE;
+      if (!user_access('delete chado_library content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'view') {
-      if (user_access('access chado_library content', $account)) {
-         return TRUE;
+      if (!user_access('access chado_library content', $account)) {
+         return FALSE;
       }
    }
-   return FALSE;
+   return NULL;
 }
 /**
  * Menu items are automatically added for the new node types created
@@ -833,24 +834,33 @@ function tripal_library_cron (){
  */
 function tripal_library_library_access($op, $node, $account){
    if ($op == 'create') {
-      return user_access('create chado_library content', $account);
+      if(!user_access('create chado_library content', $account)){
+        return FALSE;
+      }
    }
 
    if ($op == 'update') {
-      if (user_access('edit any chado_library content', $account) ||
-      (user_access('edit own chado_library content', $account) &&
-      ($account->uid == $node->uid))){
-         return TRUE;
+      if (!user_access('edit any chado_library content', $account) &&
+         (!user_access('edit own chado_library content', $account)){
+          return FALSE;
+      }
+      if(user_access('edit own chado_library content', $account)
+        ($account->uid != $node->uid)){
+         return FALSE;
       }
    }
 
    if ($op == 'delete') {
-      if (user_access('delete any chado_library content', $account) ||
-      (user_access('delete own chado_library content', $account) &&
-      ($account->uid == $node->uid))) {
-         return TRUE;
+      if (!user_access('delete any chado_library content', $account) &&
+         (!user_access('delete own chado_library content', $account)){
+         return FALSE;
+      } 
+      if (user_access('delete own chado_library content', $account) &&
+         ($account->uid != $node->uid)) {
+         return FALSE;
       }
    }
+   return NULL;
 }
 /**
  *  validates submission of form when adding or updating a library node

+ 0 - 1
tripal_organism/tripal_organism.module

@@ -135,7 +135,6 @@ function chado_organism_access($op, $node, $account){
 			return FALSE;
       }
 	}
-
 	if ($op == 'update') {
 		if (!user_access('edit chado_organism content', $account)) {
 			return FALSE;

+ 14 - 6
tripal_project/tripal_project.module

@@ -130,8 +130,10 @@ function tripal_project_help($path, $arg) {
  */
 function tripal_project_perm() {
 
-  return array('create tripal_project', 'edit own tripal_project');
-  
+  return array(
+    'create tripal_project', 
+    'edit own tripal_project'
+  );
 }
 
 
@@ -158,17 +160,23 @@ function tripal_project_access($op, $node, $account) {
   if ($op == 'create') {
   
     // Only users with permission to do so may create this node type.
-    return user_access('create tripal_project', $account);
+    if(!user_access('create tripal_project', $account)){
+      return FALSE;
+    }
   }
 
   // Users who create a node may edit or delete it later, assuming they have the necessary permissions.
   if ($op == 'update' || $op == 'delete') {
   
-    if (user_access('edit own tripal_project',$account) && ($account->uid == $node->uid)) {
-    
-      return TRUE;
+    if(!user_access('edit own tripal_project',$account){
+       return FALSE;
+    }
+    if(user_access('edit own tripal_project',$account) &&
+       $account->uid != $node->uid){
+      return FALSE;
     }
   }
+  return NULL;
 }
 
 

+ 9 - 3
tripal_pub/tripal_pub.module

@@ -247,16 +247,22 @@ function tripal_pub_access($op, $node, $account) {
 
   if ($op == 'create') {
     // Only users with permission to do so may create this node type.
-    return user_access('create tripal_pub', $account);
+    if(!user_access('create tripal_pub', $account){
+      return FALSE;
+    }
   }
 
   // Users who create a node may edit or delete it later, assuming they have the
   // necessary permissions.
   if ($op == 'update' || $op == 'delete') {
-    if (user_access('edit own tripal_pub',$account) && ($account->uid == $node->uid)) {
-      return TRUE;
+    if (!user_access('edit own tripal_pub',$account)) {
+      return FALSE;
+    }
+    if (user_access('edit own tripal_pub',$account) && ($account->uid != $node->uid)) {
+      return FALSE;
     }
   }
+  return NULL;
 }
 
 

+ 11 - 10
tripal_stock/tripal_stock.module

@@ -194,25 +194,26 @@ function tripal_stock_perm() {
  */
 function chado_stock_access($op, $node, $account) {
    if ($op == 'create') {
-      return user_access('create chado_stock content', $account);
+      if(!user_access('create chado_stock content', $account)){
+        return FALSE;
+      }
    }
-
    if ($op == 'update') {
-      if (user_access('edit chado_stock content', $account)) {
-         return TRUE;
+      if (!user_access('edit chado_stock content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'delete') {
-      if (user_access('delete chado_stock content', $account)) {
-         return TRUE;
+      if (!user_access('delete chado_stock content', $account)) {
+         return FALSE;
       }
    }
    if ($op == 'view') {
-      if (user_access('access chado_stock content', $account)) {
-         return TRUE;
+      if (!user_access('access chado_stock content', $account)) {
+         return FALSE;
       }
    }
-   return FALSE;
+   return NULL;
 }
 
 /**
@@ -961,4 +962,4 @@ function tripal_stock_block ($op = 'list', $delta = 0, $edit=array()) {
 				return $block;
 			}
 	}
-}
+}