Procházet zdrojové kódy

Fixed bug with node permissions

Stephen Ficklin před 9 roky
rodič
revize
3e42625d8b

+ 1 - 1
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -618,7 +618,7 @@ function chado_analysis_load($nodes) {
  *
  * @ingroup tripal_analysis
  */
-function chado_analysis_node_access($node, $op, $account) {
+function tripal_analysis_node_access($node, $op, $account) {
 
   $node_type = $node;
   if (is_object($node)) {

+ 1 - 1
tripal_contact/includes/tripal_contact.chado_node.inc

@@ -317,7 +317,7 @@ function chado_contact_validate($node, $form, &$form_state) {
  *
  * @ingroup tripal_contact
  */
-function chado_contact_node_access($node, $op, $account ) {
+function tripal_contact_node_access($node, $op, $account ) {
 
   $node_type = $node;
   if (is_object($node)) {

+ 3 - 1
tripal_core/api/tripal_core.chado_query.api.inc

@@ -803,6 +803,8 @@ function chado_update_record($table, $match, $values, $options = NULL) {
  */
 function chado_delete_record($table, $match, $options = NULL) {
 
+  $print_errors = (isset($options['print_errors'])) ? $options['print_errors'] : FALSE;
+
   if (!is_array($match)) {
     tripal_report_error('tripal_core', TRIPAL_ERROR,
       'Cannot pass non array as values for matching.', array());
@@ -826,7 +828,7 @@ function chado_delete_record($table, $match, $options = NULL) {
   $table_desc = chado_get_schema($table);
   $fields = $table_desc['fields'];
   if (empty($table_desc)) {
-    tripal_report_error('tripal_core', TRIPAL_WARNING,
+    chado_delete_record('tripal_core', TRIPAL_WARNING,
       'chado_insert_record; There is no table description for !table_name',
       array('!table_name' => $table), array('print' => $print_errors)
     );

+ 1 - 1
tripal_example/includes/tripal_example.chado_node.inc

@@ -70,7 +70,7 @@ function tripal_example_node_info() {
  * value is TRUE then access is granted regardless of any other rules that might
  * be implemented by other modules.
  */
-function chado_example_node_access($node, $op, $account) {
+function tripal_example_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;

+ 1 - 1
tripal_feature/api/tripal_feature.api.inc

@@ -202,7 +202,7 @@ function tripal_get_feature_sequences($feature, $options) {
   $parent_sql ='
     SELECT featureloc_id, srcname, srcfeature_id, strand, srctypename, typename,
       fmin, fmax, upstream, downstream, adjfmin, adjfmax,
-      substring(residues from (adjfmin + 1) for (upstream + (fmax - fmin) + downstream))  as residues,
+      substring(residues from cast((adjfmin + 1) as int) for cast((upstream + (fmax - fmin) + downstream) as int))  as residues,
       genus, species
     FROM (
       SELECT

+ 4 - 5
tripal_feature/includes/tripal_feature.chado_node.inc

@@ -370,12 +370,11 @@ function chado_feature_validate($node, $form, &$form_state) {
  *
  * @ingroup tripal_feature
  */
-function chado_feature_node_access($node, $op, $account) {
+function tripal_feature_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;
   }
-
   if($node_type == 'chado_feature') {
     if ($op == 'create') {
       if (!user_access('create chado_feature content', $account)) {
@@ -434,10 +433,10 @@ function chado_feature_insert($node) {
 
     // get the feature type id
     $values = array(
-        'cv_id' => array(
+      'cv_id' => array(
             'name' => 'sequence'
-        ),
-        'name' => $node->feature_type
+      ),
+      'name' => $node->feature_type
     );
     $type = chado_select_record('cvterm', array('cvterm_id'), $values);
 

+ 2 - 2
tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -172,7 +172,7 @@ function chado_featuremap_validate($node, $form, &$form_state) {
   if ($node->unittype_id == 0) {
     form_set_error('unittype_id', 'Please provide a unit type for this map.');
   }
-  
+
   // trim white space from text fields
   $node->fmapname = property_exists($node, 'fmapname') ? trim($node->fmapname) : '';
 
@@ -221,7 +221,7 @@ function chado_featuremap_validate($node, $form, &$form_state) {
  *
  * @ingroup tripal_featuremap
  */
-function chado_featuremap_node_access($node, $op, $account) {
+function tripal_featuremap_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;

+ 1 - 1
tripal_library/includes/tripal_library.chado_node.inc

@@ -490,7 +490,7 @@ function chado_library_delete(&$node) {
  *
  * @ingroup tripal_library
  */
-function chado_library_node_access($node, $op, $account) {
+function tripal_library_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;

+ 1 - 1
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -61,7 +61,7 @@ function tripal_organism_node_info() {
  *
  * @ingroup tripal_organism
  */
-function chado_organism_node_access($node, $op, $account) {
+function tripal_organism_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;

+ 1 - 1
tripal_project/includes/tripal_project.chado_node.inc

@@ -445,7 +445,7 @@ function chado_project_load($nodes) {
  *
  * @ingroup tripal_project
  */
-function chado_project_node_access($node, $op, $account) {
+function tripal_project_node_access($node, $op, $account) {
 
   $node_type = $node;
   if (is_object($node)) {

+ 5 - 5
tripal_pub/includes/tripal_pub.chado_node.inc

@@ -543,7 +543,7 @@ function chado_pub_validate_check_duplicate($title, $pyear, $series_name, $cvter
  *
  * @ingroup tripal_pub
  */
-function chado_pub_node_access($node, $op, $account) {
+function tripal_pub_node_access($node, $op, $account) {
   $node_type = $node;
   if (is_object($node)) {
     $node_type = $node->type;
@@ -551,23 +551,23 @@ function chado_pub_node_access($node, $op, $account) {
 
   if($node_type == 'chado_pub') {
     if ($op == 'create') {
-      if (!user_access('create chado_pub', $account)) {
+      if (!user_access('create chado_pub content', $account)) {
         return NODE_ACCESS_DENY;
       }
       return NODE_ACCESS_ALLOW;
     }
     if ($op == 'update') {
-      if (!user_access('edit chado_pub', $account)) {
+      if (!user_access('edit chado_pub content', $account)) {
         return NODE_ACCESS_DENY;
       }
     }
     if ($op == 'delete') {
-      if (!user_access('delete chado_pub', $account)) {
+      if (!user_access('delete chado_pub content', $account)) {
         return NODE_ACCESS_DENY;
       }
     }
     if ($op == 'view') {
-      if (!user_access('access chado_pub', $account)) {
+      if (!user_access('access chado_pub content', $account)) {
         return NODE_ACCESS_DENY;
       }
     }

+ 25 - 18
tripal_stock/tripal_stock.module

@@ -205,29 +205,36 @@ function tripal_stock_permission() {
  *
  * @ingroup tripal_stock
  */
-function chado_stock_node_access($node, $op, $account) {
-  if ($op == 'create') {
-    if (!user_access('create chado_stock content', $account)) {
-      return FALSE;
-    }
-    return TRUE;
+function tripal_stock_node_access($node, $op, $account) {
+  $node_type = $node;
+  if (is_object($node)) {
+    $node_type = $node->type;
   }
-  if ($op == 'update') {
-    if (!user_access('edit chado_stock content', $account)) {
-      return FALSE;
+
+  if($node_type == 'chado_stock') {
+    if ($op == 'create') {
+      if (!user_access('create chado_stock content', $account)) {
+        return NODE_ACCESS_DENY;
+      }
+      return NODE_ACCESS_ALLOW;
     }
-  }
-  if ($op == 'delete') {
-    if (!user_access('delete chado_stock content', $account)) {
-      return FALSE;
+    if ($op == 'update') {
+      if (!user_access('edit chado_stock content', $account)) {
+        return NODE_ACCESS_DENY;
+      }
     }
-  }
-  if ($op == 'view') {
-    if (!user_access('access chado_stock content', $account)) {
-      return FALSE;
+    if ($op == 'delete') {
+      if (!user_access('delete chado_stock content', $account)) {
+        return NODE_ACCESS_DENY;
+      }
+    }
+    if ($op == 'view') {
+      if (!user_access('access chado_stock content', $account)) {
+        return NODE_ACCESS_DENY;
+      }
     }
+    return NODE_ACCESS_IGNORE;
   }
-  return NULL;
 }
 
 /**