Browse Source

Merge branch '7.x-2.x' of git.drupal.org:sandbox/spficklin/1337878 into 7.x-2.x

Lacey Sanderson 11 years ago
parent
commit
f13f1597a0
50 changed files with 1627 additions and 1478 deletions
  1. 26 7
      tripal_analysis/includes/tripal_analysis.chado_node.inc
  2. 3 3
      tripal_analysis/tripal_analysis.module
  3. 36 36
      tripal_bulk_loader/api/tripal_bulk_loader.api.templates.inc
  4. 3 3
      tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc
  5. 42 42
      tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc
  6. 37 37
      tripal_bulk_loader/theme/node--tripal-bulk-loader.tpl.php
  7. 24 24
      tripal_bulk_loader/theme/tripal_bulk_loader_template.tpl.php
  8. 22 22
      tripal_contact/includes/tripal_contact.chado_node.inc
  9. 1 1
      tripal_contact/tripal_contact.install
  10. 3 21
      tripal_contact/tripal_contact.module
  11. 26 0
      tripal_core/api/tripal_core.chado_general.api.inc
  12. 1 1
      tripal_core/api/tripal_core.chado_nodes.api.inc
  13. 144 122
      tripal_core/theme/css/tripal.css
  14. 43 50
      tripal_core/theme/node--chado-generic.tpl.php
  15. 75 28
      tripal_core/tripal_core.module
  16. 10 10
      tripal_core/tripal_launch_jobs_multi.php
  17. 78 78
      tripal_cv/theme/js/jquery-treeview/demo/source.php
  18. 25 25
      tripal_cv/theme/js/jsTree/reference/_examples/1_async.php
  19. 358 358
      tripal_cv/theme/js/jsTree/reference/_examples/full/_inc/class.tree.php
  20. 73 73
      tripal_cv/theme/js/jsTree/reference/_examples/full/_inc/database.php
  21. 81 81
      tripal_cv/theme/js/jsTree/reference/_examples/full/server.php
  22. 12 12
      tripal_cv/tripal_cv.module
  23. 2 2
      tripal_db/tripal_db.module
  24. 54 53
      tripal_feature/includes/tripal_feature.blocks.inc
  25. 24 2
      tripal_feature/includes/tripal_feature.chado_node.inc
  26. 5 9
      tripal_feature/includes/tripal_feature.seq_extract.inc
  27. 31 36
      tripal_feature/theme/tripal_organism/tripal_organism_feature_browser.tpl.php
  28. 19 17
      tripal_feature/theme/tripal_organism/tripal_organism_feature_counts.tpl.php
  29. 15 15
      tripal_feature/tripal_feature.module
  30. 34 29
      tripal_featuremap/includes/tripal_featuremap.chado_node.inc
  31. 1 19
      tripal_featuremap/tripal_featuremap.module
  32. 14 0
      tripal_genetic/tripal_genetic.module
  33. 12 4
      tripal_library/includes/tripal_library.chado_node.inc
  34. 8 2
      tripal_library/tripal_library.install
  35. 4 4
      tripal_library/tripal_library.module
  36. 17 3
      tripal_natural_diversity/tripal_natural_diversity.module
  37. 1 1
      tripal_organism/api/tripal_organism.api.inc
  38. 15 6
      tripal_organism/includes/tripal_organism.chado_node.inc
  39. 1 1
      tripal_organism/theme/tripal_organism/tripal_organism_description.tpl.php
  40. 15 0
      tripal_phenotype/tripal_phenotype.module
  41. 25 25
      tripal_project/includes/tripal_project.chado_node.inc
  42. 5 5
      tripal_project/tripal_project.module
  43. 40 40
      tripal_pub/includes/tripal_pub.chado_node.inc
  44. 7 10
      tripal_pub/includes/tripal_pub.pub_search.inc
  45. 94 94
      tripal_pub/theme/tripal_pub_help.tpl.php
  46. 12 29
      tripal_pub/tripal_pub.module
  47. 11 2
      tripal_stock/includes/tripal_stock.chado_node.inc
  48. 1 1
      tripal_stock/theme/tripal_organism/tripal_organism_stocks.tpl.php
  49. 13 11
      tripal_stock/tripal_stock.module
  50. 24 24
      tripal_views/tripal_views.views.inc

+ 26 - 7
tripal_analysis/includes/tripal_analysis.chado_node.inc

@@ -613,17 +613,36 @@ function tripal_analysis_node_view($node, $view_mode, $langcode) {
  * @param $node
  * @param $node
  */
  */
 function tripal_analysis_node_presave($node) {
 function tripal_analysis_node_presave($node) {
-  // If this is an analysis of some type it will should have thre three required
+  // If this is an analysis of some type it will should have three required
   // fields for the Chado analysis table: program, programversion and sourcename.
   // fields for the Chado analysis table: program, programversion and sourcename.
-  // So we will set the title for any node that has these three fields
+  // So we will set the title for any node that has these three fields. Some extension
+  // modules will use this module as a type of "inherited" class, so we don't know
+  // for sure when type of analysis we have.
   if (property_exists($node, 'program') and
   if (property_exists($node, 'program') and
-  property_exists($node, 'programversion') and
-  property_exists($node, 'sourcename')) {
-    if ($node->analysisname) {
-      $node->title = $node->analysisname;
+      property_exists($node, 'programversion') and
+      property_exists($node, 'sourcename')) {
+    $name = '';
+    $program = '';
+    $programversion = '';
+    $sourcename = '';
+    if (property_exists($node, 'analysis')) {
+      $name           = $node->analysis->name;
+      $program        = $node->analysis->program;
+      $programversion = $node->analysis->programversion;
+      $sourcename     = $node->analysis->sourcename;
     }
     }
     else {
     else {
-      $node->title = "$node->program ($node->programversion) $node->sourcename";
+      $name           = $node->analysisname;
+      $program        = $node->program;
+      $programversion = $node->programversion;
+      $sourcename     = $node->sourcename;
+    }
+    // now construct the title
+    if ($name) {
+      $node->title = $name;
+    }
+    else {
+      $node->title = "$program ($programversion) $sourcename";
     }
     }
   }
   }
 }
 }

+ 3 - 3
tripal_analysis/tripal_analysis.module

@@ -39,7 +39,7 @@ function tripal_analysis_menu() {
     'title' => 'Analyses',
     'title' => 'Analyses',
     'description' => 'A bioinformatics analysis producing features.',
     'description' => 'A bioinformatics analysis producing features.',
     'page callback' => 'tripal_analysis_admin_analysis_view',
     'page callback' => 'tripal_analysis_admin_analysis_view',
-    'access arguments' => array('administer tripal analyses'),
+    'access arguments' => array('administer tripal analysis'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
   );
   );
 
 
@@ -48,7 +48,7 @@ function tripal_analysis_menu() {
     'description' => "A description of the Tripal Analysis module including a short description of it's usage.",
     'description' => "A description of the Tripal Analysis module including a short description of it's usage.",
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_analysis_help'),
     'page arguments' => array('tripal_analysis_help'),
-    'access arguments' => array('administer tripal analyses'),
+    'access arguments' => array('administer tripal analysis'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10,
     'weight' => 10,
   );
   );
@@ -58,7 +58,7 @@ function tripal_analysis_menu() {
     'description' => 'Settings for the displays of analysis results.',
     'description' => 'Settings for the displays of analysis results.',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_analysis_admin'),
     'page arguments' => array('tripal_analysis_admin'),
-    'access arguments' => array('administer tripal analyses'),
+    'access arguments' => array('administer tripal analysis'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 5
     'weight' => 5
   );
   );

+ 36 - 36
tripal_bulk_loader/api/tripal_bulk_loader.api.templates.inc

@@ -44,9 +44,9 @@ function tripal_bulk_loader_is_record_name_unique($new_record_name, $template_id
   // Check the new record name is unique
   // Check the new record name is unique
   foreach ($template_array as $priority => $t) {
   foreach ($template_array as $priority => $t) {
     if (strcmp($t['record_id'], $new_record_name) == 0) {
     if (strcmp($t['record_id'], $new_record_name) == 0) {
-    	if (($priority != $current_priority) AND ($current_priority !== NULL)) {
-	      return FALSE;
-	    }
+      if (($priority != $current_priority) AND ($current_priority !== NULL)) {
+        return FALSE;
+      }
     }
     }
   }
   }
   return TRUE;
   return TRUE;
@@ -67,21 +67,21 @@ function tripal_bulk_loader_is_record_name_unique($new_record_name, $template_id
  */
  */
 function tripal_bulk_loader_delete_record($delete_priority, $template_array) {
 function tripal_bulk_loader_delete_record($delete_priority, $template_array) {
 
 
-	if (empty($template_array)) {
-		drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied",'error');
-		return FALSE;
-	}
+  if (empty($template_array)) {
+    drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied",'error');
+    return FALSE;
+  }
 
 
-	$new_template_array = array();
-	$i=0;
-	foreach ($template_array as $priority => $record) {
-		if ($priority != $delete_priority) {
-			$new_template_array[$i] = $record;
-			$i++;
-		}
-	}
+  $new_template_array = array();
+  $i=0;
+  foreach ($template_array as $priority => $record) {
+    if ($priority != $delete_priority) {
+      $new_template_array[$i] = $record;
+      $i++;
+    }
+  }
 
 
-	return $new_template_array;
+  return $new_template_array;
 }
 }
 
 
 /**
 /**
@@ -101,27 +101,27 @@ function tripal_bulk_loader_delete_record($delete_priority, $template_array) {
  */
  */
 function tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) {
 function tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) {
 
 
-	if (empty($template_array)) {
-		drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied",'error');
-		return FALSE;
-	}
+  if (empty($template_array)) {
+    drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied",'error');
+    return FALSE;
+  }
 
 
-	// Re-order the remaining fields of the same record to ensure that the indicies are
-	// 0 to size and. If this is not done, weird behaviour may result
-	$new_template_array = $template_array;
-	$new_template_array[$priority]['fields'] = array();
-	$i=0;
-	foreach ($template_array[$priority]['fields'] as $field_index => $field_details) {
-		if ($field_index != $delete_field_index) {
-			$new_template_array[$priority]['fields'][$i] = $field_details;
-			$i++;
-		}
-	}
+  // Re-order the remaining fields of the same record to ensure that the indicies are
+  // 0 to size and. If this is not done, weird behaviour may result
+  $new_template_array = $template_array;
+  $new_template_array[$priority]['fields'] = array();
+  $i=0;
+  foreach ($template_array[$priority]['fields'] as $field_index => $field_details) {
+    if ($field_index != $delete_field_index) {
+      $new_template_array[$priority]['fields'][$i] = $field_details;
+      $i++;
+    }
+  }
 
 
-	// If this field was the only one in the current record, also delete the record
-	if (empty($new_template_array[$priority]['fields'])) {
-		$new_template_array = tripal_bulk_loader_delete_record($priority, $new_template_array);
-	}
+  // If this field was the only one in the current record, also delete the record
+  if (empty($new_template_array[$priority]['fields'])) {
+    $new_template_array = tripal_bulk_loader_delete_record($priority, $new_template_array);
+  }
 
 
-	return $new_template_array;
+  return $new_template_array;
 }
 }

+ 3 - 3
tripal_bulk_loader/includes/tripal_bulk_loader.admin.templates.inc

@@ -2368,9 +2368,9 @@ function tripal_bulk_loader_delete_template_field_form_submit($form, &$form_stat
     $form_state['storage']['field_id'],
     $form_state['storage']['field_id'],
     $form_state['storage']['template']
     $form_state['storage']['template']
   );
   );
-	if (!empty($new_template)) {
-		$form_state['storage']['template'] = $new_template;
-	}
+  if (!empty($new_template)) {
+    $form_state['storage']['template'] = $new_template;
+  }
   drupal_set_message(t('Deleted Field from Template.'));
   drupal_set_message(t('Deleted Field from Template.'));
 
 
   $record = array(
   $record = array(

+ 42 - 42
tripal_bulk_loader/includes/tripal_bulk_loader.loader.inc

@@ -672,51 +672,51 @@ function process_data_array_for_line($priority, &$data, &$default_data, $addt) {
       // This should have been set on the first round of inserts for this record
       // This should have been set on the first round of inserts for this record
       $match = $data[$priority]['is_duplicate'];
       $match = $data[$priority]['is_duplicate'];
       // However, sometimes there is a pre-existing record before the loader starts
       // However, sometimes there is a pre-existing record before the loader starts
-			// Thus check that this value is set and if not, then generate a match array
-			// based on the unique keys for this record.
-			if (empty($match)) {
-				$match = array();
-				// First check to see if we have fields for the primary key
-				foreach ($table_desc['primary key'] as $k_field) {
-					if (!empty($values[$k_field])) {
-						$match[$k_field] = $values[$k_field];
-					}
-				}
-				// Otherwise check the fields that are part of the unique key
-				if (empty($match)) {
-					foreach ($table_desc['unique keys'] as $u_keys) {
-						foreach ($u_keys as $u_field) {
-							if (!empty($values[$u_field])) {
-								$match[$u_field] = $values[$u_field];
-							}
-						}
-					}
-				}
-			}
-			if (!empty($match)) {
-				// Now we need to check if it already exists via a select
-				$results = tripal_core_chado_select($table, array_keys($table_desc['fields']), $match, array('print_errors' => TRUE));
-				// If not then insert
-				if (empty($results)) {
-					$options['statement_name'] = 'ins_'.$options['statement_name'];
-					$options['print_errors'] = TRUE;
-					$record = tripal_core_chado_insert($table, $values, $options);
-				}
-				else {
-				  $options['return_record'] = TRUE;
-				  $options['print_errors'] = TRUE;
-  		    $record = tripal_core_chado_update($table, $match, $values, $options);
-  		  }
-  	  }
-  	  else {
-  	  	$msg = "\nLine " . $addt->line_num . ' ' . $table_data['record_id'] . ' (' .
+      // Thus check that this value is set and if not, then generate a match array
+      // based on the unique keys for this record.
+      if (empty($match)) {
+        $match = array();
+        // First check to see if we have fields for the primary key
+        foreach ($table_desc['primary key'] as $k_field) {
+          if (!empty($values[$k_field])) {
+            $match[$k_field] = $values[$k_field];
+          }
+        }
+        // Otherwise check the fields that are part of the unique key
+        if (empty($match)) {
+          foreach ($table_desc['unique keys'] as $u_keys) {
+            foreach ($u_keys as $u_field) {
+              if (!empty($values[$u_field])) {
+                $match[$u_field] = $values[$u_field];
+              }
+            }
+          }
+        }
+      }
+      if (!empty($match)) {
+        // Now we need to check if it already exists via a select
+        $results = tripal_core_chado_select($table, array_keys($table_desc['fields']), $match, array('print_errors' => TRUE));
+        // If not then insert
+        if (empty($results)) {
+          $options['statement_name'] = 'ins_'.$options['statement_name'];
+          $options['print_errors'] = TRUE;
+          $record = tripal_core_chado_insert($table, $values, $options);
+        }
+        else {
+          $options['return_record'] = TRUE;
+          $options['print_errors'] = TRUE;
+          $record = tripal_core_chado_update($table, $match, $values, $options);
+        }
+      }
+      else {
+        $msg = "\nLine " . $addt->line_num . ' ' . $table_data['record_id'] . ' (' .
         $table_data['mode'] . ') Unable to update record since none of the unique key or primary key fields were available ' .
         $table_data['mode'] . ') Unable to update record since none of the unique key or primary key fields were available ' .
         ' where values:' . print_r($values, TRUE);
         ' where values:' . print_r($values, TRUE);
 
 
-      	tripal_bulk_loader_throw_error($msg, array(), TRIPAL_ERROR);
-      	$data[$priority]['error'] = TRUE;
-      	$no_errors = FALSE;
-  	  }
+        tripal_bulk_loader_throw_error($msg, array(), TRIPAL_ERROR);
+        $data[$priority]['error'] = TRUE;
+        $no_errors = FALSE;
+      }
     }
     }
     else {
     else {
       $options['print_errors'] = TRUE;
       $options['print_errors'] = TRUE;

+ 37 - 37
tripal_bulk_loader/theme/node--tripal-bulk-loader.tpl.php

@@ -1,45 +1,45 @@
 <div id="tripal_bulk_loader-base-box" class="tripal_bulk_loader-info-box tripal-info-box">
 <div id="tripal_bulk_loader-base-box" class="tripal_bulk_loader-info-box tripal-info-box">
   <div class="tripal_bulk_loader-info-box-title tripal-info-box-title">
   <div class="tripal_bulk_loader-info-box-title tripal-info-box-title">
-  	<?php if ($teaser) { print l($node->title, 'node/'.$node->nid); } ?>
+    <?php if ($teaser) { print l($node->title, 'node/'.$node->nid); } ?>
   </div>
   </div>
   <div class="tripal_bulk_loader-info-box-desc tripal-info-box-desc"></div>
   <div class="tripal_bulk_loader-info-box-desc tripal-info-box-desc"></div>
 
 
-	<table id="tripal_bulk_loader-base-table" class="tripal_bulk_loader-table tripal-table tripal-table-vert">
-		<tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
-			<th>Job Name</th>
-			<td><?php print $node->loader_name;?></td>
-		</tr>
-		<tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
-			<th>Submitted By</th>
-			<td><span class="author"><?php //print theme('username', $node); ?></span></td>
-		</tr>
-		<tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
-			<th>Job Creation Date</th>
-			<td><?php print format_date($node->created, 'custom', "F j, Y, g:i a"); ?></td>
-		</tr>
-		<tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
-			<th>Last Updated</th>
-			<td><?php print format_date($node->changed, 'custom', "F j, Y, g:i a"); ?></td>
-		</tr>
-		<tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
-			<th>Template Name</th>
-			<td><?php print $node->template->name; ?></td>
-		</tr>
-		<tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
-			<th>Data File</th>
-			<td><?php print $node->file;?></td>
-		</tr>
-		<tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
-			<th>Job Status</th>
-			<td><?php print $node->job_status;?></td>
-		</tr>
-		<?php if (isset($node->job)) { if (isset($node->job->progress)) { ?>
-		<tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
-			<th>Job Progress</th>
-			<td><?php print $node->job->progress . '% (' . l('view job', 'admin/tripal/tripal_jobs/view/' . $node->job_id) . ')';?></td>
-		</tr>
-		<?php }} ?>
-	</table>
+  <table id="tripal_bulk_loader-base-table" class="tripal_bulk_loader-table tripal-table tripal-table-vert">
+    <tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
+      <th>Job Name</th>
+      <td><?php print $node->loader_name;?></td>
+    </tr>
+    <tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
+      <th>Submitted By</th>
+      <td><span class="author"><?php //print theme('username', $node); ?></span></td>
+    </tr>
+    <tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
+      <th>Job Creation Date</th>
+      <td><?php print format_date($node->created, 'custom', "F j, Y, g:i a"); ?></td>
+    </tr>
+    <tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
+      <th>Last Updated</th>
+      <td><?php print format_date($node->changed, 'custom', "F j, Y, g:i a"); ?></td>
+    </tr>
+    <tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
+      <th>Template Name</th>
+      <td><?php print $node->template->name; ?></td>
+    </tr>
+    <tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
+      <th>Data File</th>
+      <td><?php print $node->file;?></td>
+    </tr>
+    <tr class="tripal_bulk_loader-table-odd-row tripal-table-odd-row">
+      <th>Job Status</th>
+      <td><?php print $node->job_status;?></td>
+    </tr>
+    <?php if (isset($node->job)) { if (isset($node->job->progress)) { ?>
+    <tr class="tripal_bulk_loader-table-even-row tripal-table-even-row">
+      <th>Job Progress</th>
+      <td><?php print $node->job->progress . '% (' . l('view job', 'admin/tripal/tripal_jobs/view/' . $node->job_id) . ')';?></td>
+    </tr>
+    <?php }} ?>
+  </table>
 </div>
 </div>
 
 
 <?php if (!$teaser) { ?>
 <?php if (!$teaser) { ?>

+ 24 - 24
tripal_bulk_loader/theme/tripal_bulk_loader_template.tpl.php

@@ -10,29 +10,29 @@
   $template->template_array = unserialize($template->template_array);
   $template->template_array = unserialize($template->template_array);
 
 
   // Summarize Template
   // Summarize Template
-	$fields = array();
-	$constants = array();
-	foreach ($template->template_array as $priority => $table_array) {
-		if (!is_array($table_array)) {
-			continue;
-		}
+  $fields = array();
+  $constants = array();
+  foreach ($template->template_array as $priority => $table_array) {
+    if (!is_array($table_array)) {
+      continue;
+    }
 
 
-		$table = $table_array['table'];
-		$record = $table_array['record_id'];
-		foreach ($table_array['fields'] as $field) {
-			if (preg_match('/table field/', $field['type'])) {
-				$field['table'] = $table;
-				$field['record'] = $record;
-				$sheet = 0;//$field['spreadsheet sheet'];
-				$column = $field['spreadsheet column'];
-				$fields[$sheet.'-'.$column][] = $field;
-			} elseif ($field['type'] == 'constant') {
-				$field['table'] = $table;
-				$field['record'] = $record;
-				$constants[] = $field;
-			}
-		}
-	}
+    $table = $table_array['table'];
+    $record = $table_array['record_id'];
+    foreach ($table_array['fields'] as $field) {
+      if (preg_match('/table field/', $field['type'])) {
+        $field['table'] = $table;
+        $field['record'] = $record;
+        $sheet = 0;//$field['spreadsheet sheet'];
+        $column = $field['spreadsheet column'];
+        $fields[$sheet.'-'.$column][] = $field;
+      } elseif ($field['type'] == 'constant') {
+        $field['table'] = $table;
+        $field['record'] = $record;
+        $constants[] = $field;
+      }
+    }
+  }
 ?>
 ?>
 
 
 <div id="tripal_bulk_loader-base-box" class="tripal_bulk_loader-info-box tripal-info-box">
 <div id="tripal_bulk_loader-base-box" class="tripal_bulk_loader-info-box tripal-info-box">
@@ -47,7 +47,7 @@
     <?php $row = 'even' ?>
     <?php $row = 'even' ?>
     <?php foreach ($constants as $field) {?>
     <?php foreach ($constants as $field) {?>
       <tr class="tripal_bulk_loader-table-<?php print $row; ?>-row tripal-table-<?php print $row; ?>-row">
       <tr class="tripal_bulk_loader-table-<?php print $row; ?>-row tripal-table-<?php print $row; ?>-row">
-				<td><?php print $field['record'];?></td>
+        <td><?php print $field['record'];?></td>
         <td><?php print $field['title'];?></td>
         <td><?php print $field['title'];?></td>
         <td><?php print $field['constant value']; ?></td>
         <td><?php print $field['constant value']; ?></td>
         <td><?php print $field['table'];?></td>
         <td><?php print $field['table'];?></td>
@@ -66,7 +66,7 @@
   <?php foreach ($fields as $column) {?>
   <?php foreach ($fields as $column) {?>
     <?php foreach ($column as $field) {?>
     <?php foreach ($column as $field) {?>
     <tr class="tripal_bulk_loader-table-<?php print $row; ?>-row tripal-table-<?php print $row; ?>-row">
     <tr class="tripal_bulk_loader-table-<?php print $row; ?>-row tripal-table-<?php print $row; ?>-row">
-    	<td><?php print $field['record'];?></td>
+      <td><?php print $field['record'];?></td>
       <td><?php print $field['title'];?></td>
       <td><?php print $field['title'];?></td>
       <td><?php print $field['spreadsheet column'];?></td>
       <td><?php print $field['spreadsheet column'];?></td>
       <td><?php print $field['table'];?></td>
       <td><?php print $field['table'];?></td>

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

@@ -549,27 +549,27 @@ function chado_contact_delete(&$node) {
  */
  */
 function tripal_contact_node_view($node, $view_mode, $langcode) {
 function tripal_contact_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
   switch ($node->type) {
-  	case 'chado_contact':
-  	  // Show feature browser and counts
-  	  if ($view_mode == 'full') {
-  	    $node->content['tripal_contact_base'] = array(
-  	      '#value' => theme('tripal_contact_base', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_contact_properties'] = array(
-  	      '#value' => theme('tripal_contact_properties', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_contact_publications'] = array(
-  	      '#value' => theme('tripal_contact_publications', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_contact_relationships'] = array(
-  	      '#value' => theme('tripal_contact_relationships', array('node' => $node)),
-  	    );
-  	  }
-  	  if ($view_mode == 'teaser') {
-  	    $node->content['tripal_contact_teaser'] = array(
-  	      '#value' => theme('tripal_contact_teaser', array('node' => $node)),
-  	    );
-  	  }
-  	  break;
+    case 'chado_contact':
+      // Show feature browser and counts
+      if ($view_mode == 'full') {
+        $node->content['tripal_contact_base'] = array(
+          '#value' => theme('tripal_contact_base', array('node' => $node)),
+        );
+        $node->content['tripal_contact_properties'] = array(
+          '#value' => theme('tripal_contact_properties', array('node' => $node)),
+        );
+        $node->content['tripal_contact_publications'] = array(
+          '#value' => theme('tripal_contact_publications', array('node' => $node)),
+        );
+        $node->content['tripal_contact_relationships'] = array(
+          '#value' => theme('tripal_contact_relationships', array('node' => $node)),
+        );
+      }
+      if ($view_mode == 'teaser') {
+        $node->content['tripal_contact_teaser'] = array(
+          '#value' => theme('tripal_contact_teaser', array('node' => $node)),
+        );
+      }
+      break;
   }
   }
 }
 }

+ 1 - 1
tripal_contact/tripal_contact.install

@@ -48,7 +48,7 @@ function tripal_contact_requirements($phase) {
  */
  */
 function tripal_contact_install() {
 function tripal_contact_install() {
 
 
-	// create the module's data directory
+  // create the module's data directory
   tripal_create_moddir('tripal_contact');
   tripal_create_moddir('tripal_contact');
 
 
   // add the contactprop table to Chado
   // add the contactprop table to Chado

+ 3 - 21
tripal_contact/tripal_contact.module

@@ -62,7 +62,7 @@ function tripal_contact_menu() {
     'title' => 'Contacts',
     'title' => 'Contacts',
     'description' => ('Model persons, institutes, groups, organizations, etc.'),
     'description' => ('Model persons, institutes, groups, organizations, etc.'),
     'page callback' => 'tripal_contact_admin_contact_view',
     'page callback' => 'tripal_contact_admin_contact_view',
-    'access arguments' => array('administer tripal contacts'),
+    'access arguments' => array('administer tripal contact'),
     'type' => MENU_NORMAL_ITEM
     'type' => MENU_NORMAL_ITEM
   );
   );
 
 
@@ -81,7 +81,7 @@ function tripal_contact_menu() {
     'description' => ('Help with the contact module.'),
     'description' => ('Help with the contact module.'),
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_contact_help'),
     'page arguments' => array('tripal_contact_help'),
-    'access arguments' => array('administer tripal contacts'),
+    'access arguments' => array('administer tripal contact'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -91,7 +91,7 @@ function tripal_contact_menu() {
     'description' => 'Sync contacts in Chado with Drupal',
     'description' => 'Sync contacts in Chado with Drupal',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_contact_sync_form'),
     'page arguments' => array('tripal_contact_sync_form'),
-    'access arguments' => array('administer tripal contacts'),
+    'access arguments' => array('administer tripal contact'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 0
     'weight' => 0
   );
   );
@@ -106,24 +106,6 @@ function tripal_contact_menu() {
     'weight' => 2
     'weight' => 2
   );
   );
 
 
-  // AJAX calls for adding/removing properties to a contact
-  $items['tripal_contact/properties/add'] = array(
-    'page callback' => 'tripal_contact_property_add',
-    'access arguments' => array('edit chado_contact content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_contact/properties/description'] = array(
-    'page callback' => 'tripal_contact_property_get_description',
-    'access arguments' => array('edit chado_contact content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_contact/properties/minus/%/%'] = array(
-    'page callback' => 'tripal_contact_property_delete',
-    'page arguments' => array(3, 4),
-    'access arguments' => array('edit chado_contact content'),
-    'type ' => MENU_CALLBACK,
-  );
-
   return $items;
   return $items;
 }
 }
 
 

+ 26 - 0
tripal_core/api/tripal_core.chado_general.api.inc

@@ -246,3 +246,29 @@ function tripal_core_get_max_chado_rank($tablename, $where_options) {
   }
   }
 
 
 }
 }
+
+/**
+ * Use this function to encapsulate text intended to be 
+ * visible only by the site administrator. A small tripal logo
+ * appears alongside the text.  Do not call this function directly, but
+ * rather, use the theme() function:
+ * 
+ *   theme('tripal_admin_message', array('message' => $my_message));
+ * 
+ * @param $message
+ *   The message to be displayed to the site administrator
+ * 
+ * @ingroup tripal_chado_api
+ */
+function theme_tripal_admin_message($variables) {
+  
+  $message = $variables['message'];
+  
+  if (!user_access('access administration pages')) {
+    return ''; 
+  }
+  return "
+    <div class=\"tripal-site-admin-only\">
+      <div class=\"tripal-site-admin-message\">$message</div>
+    </div>";
+}

+ 1 - 1
tripal_core/api/tripal_core.chado_nodes.api.inc

@@ -565,7 +565,7 @@ function tripal_core_chado_node_sync_records($base_table, $max_sync = FALSE, $or
         $new_node->type = 'chado_' . $base_table;
         $new_node->type = 'chado_' . $base_table;
         $new_node->uid = $user->uid;
         $new_node->uid = $user->uid;
         $new_node->{$base_table_id} = $record->{$base_table_id};
         $new_node->{$base_table_id} = $record->{$base_table_id};
-        $new_node->library = $record;
+        $new_node->$base_table = $record;
 
 
         // TODO: should we get rid of this hook and use hook_node_presave() instead?
         // TODO: should we get rid of this hook and use hook_node_presave() instead?
         // allow base module to set additional fields as needed
         // allow base module to set additional fields as needed

+ 144 - 122
tripal_core/theme/css/tripal.css

@@ -1,150 +1,146 @@
-.tripal-info-box {
-   width: 100%;
-   padding-bottom: 10px;
-}
-
-.tripal-info-box-nosidebar {
-   width: 100%;
-   padding-bottom: 10px;
-}
-
-.tripal-info-box-title {
-  font-size: 1.5em;
-  padding-bottom: 15px;
-}
-
-.tripal-info-box-title-nosidebar {
-  font-size: 1.5em;
-  padding-bottom: 15px;
-}
-
-.tripal-info-box-desc {
-  /* padding-bottom: 15px; */
-}
-/* hide the title when inside of a block on a panel */
-.pane-block .tripal-info-box-title {
-   visibility: hidden;
-   padding: 0;
-   margin: 0;
-   height: 0px;
-}
-
-/* no results message */
-.tripal-no-results {
-   font-style: italic;
-   padding: 10px;
-   background-color: #FFEEEE;
-}
 /**
 /**
- * Tripal Contents container: contains both the details 
- * section and the resources sidebar
+ * The Tripal generic node template (node--chado-generc.tpl.php)
+ * has an outer div box with class 'tripal-contents' and with an inner 
+ * table with an id of 'tripal-contents-table'.  The table has a single
+ * row with two columns.  The smaller left column houses the table of 
+ * contents (TOC) for the node data.  The larger right column houses the data:
+ *
+ * |-----------------------------------------------|
+ * |  .tripal-contents                             |
+ * | |-------------------------------------------| |
+ * | | #tripal-contents-table                    | |
+ * | |        |                                  | |
+ * | |        |                                  | |
+ * | | TOC    |          Data                    | |
+ * | | column |          Column                  | |
+ * | |        |                                  | |
+ * | |        |                                  | |
+ * | |        |                                  | |
+ * | |-------------------------------------------| |
+ * |-----------------------------------------------|
+ *
+ * The tripal-contents box and the inner table are designed to fill the width
+ * of the contents section of any theme.  Customize the CSS below to change
+ * the look-and-feel.
+ *
  */
  */
-.tripal_contents {
+
+.tripal-contents {
   width: 100%;
   width: 100%;
-  position: relative;
 }
 }
 
 
-#tripal_contents_table {
+#tripal-contents_table {
   padding: 0px !important;
   padding: 0px !important;
-  margin: 0px !important;
-  
+  margin:  0px !important;
 }
 }
 
 
-#tripal_contents_table tbody {
+/**
+ * The table formatting must override the default theme.  This is because
+ * the table is meant for organizing the sidebar and contents so they don't
+ * slip and slide around as would happen with div boxes that were floated.
+ * Therefore, we use !important to keep the default theme from overrideing
+ * the table settings. 
+ */
+ 
+#tripal-contents-table tbody {
   padding: 0px !important;
   padding: 0px !important;
-  margin: 0px !important;
-  border: 0px solid #FFFFFF;
+  margin:  0px !important;
+  border:  none !important;
+  background-color: transparent !important;
 }
 }
-
-.tripal_contents_table_td { 
-  border: 0px solid #FFFFFF !important;
+.tripal-contents-table-tr {
   padding: 0px !important;
   padding: 0px !important;
-  text-align: left;
-  vertical-align: top;
-}
-.tripal_contents_table_tr {
-background-color: transparent;
+  margin:  0px !important;
+  border:  none !important;
+  background-color: transparent !important;
+}
+.tripal-contents-table-td-toc { 
+  border: 1px solid #888888 !important;
+  margin:  0px !important;
+  padding: 10px !important;
+  background-color: transparent !important;
+  text-align: left !important;
+  vertical-align: top !important;
+}
+.tripal-contents-table-td-data { 
+  border: none !important;
+  margin:  0px !important;
+  padding: 0px 0px 0px 20px !important;
+  background-color: transparent !important;
+  text-align: left !important;
+  vertical-align: top !important;
 }
 }
 
 
 /**
 /**
- * Resources Sidebar
+ * The table of contents is an unordered list. The following can are used
+ * to style the list 
  */
  */
-.tripal_toc {
-  padding: 0px; 
-  margin-right: 0px;
-}
-.tripal_toc ul {
-  margin: 0 !important;
-  padding: 0 !important;
-  list-style-type: none;
-}
-.tripal_toc li {
-	background-color: #EEEEEE;
-  border-style:solid;
-  border-width:1px;
-  border-color: #999999;
-  padding: 3px 20px 3px 20px;
-  margin: 2px 0 2px 0;
-}
-.tripal_toc_title {
-  font-size: 1.5em;
-  line-height: 110%;
-  padding-bottom: 10px;
-}
-.tripal_toc_desc {
+.tripal_toc_list ul {
+
 }
 }
-/**
- * Details Section
- */
-.tripal_details {
-  padding: 0px 20px 20px 20px;
-  min-height: 500px;
-  margin-right: 10px;
-  margin-bottom: 10px;
-  overflow:auto;
+.tripal_toc_list li {
+  padding: 3px 20px 3px 10px !important;
+  margin: 2px 0 2px 0 !important;
 }
 }
 
 
-.tripal_details_full {
-  float: left;
-  background-color: #FFFFFF;
-
-  -moz-border-radius: 15px;
-  -webkit-border-radius: 15px;
-  -khtml-border-radius: 15px;
-  border-radius: 15px;
-
-  -moz-box-shadow: 3px 3px 4px #888888;
-  -webkit-box-shadow: 3px 3px 4px #888888;
-  box-shadow: 3px 3px 4px #888888;
-  padding: 20px;
-  min-height: 500px;
-  margin-right: 10px;
-  margin-bottom: 10px;
-  border-style:solid;
-  border-width:1px;
-  
-  overflow:auto;
-}
-/**
- * Tables
+/******************************************************************************
+ * The links that appear in the TOC section are added dynamically by
+ * JavaScript code found at the top of the node--chado-generc.tpl.php template.
+ * Each link in the TOC cooresponds to a "block" of data added to the Data
+ * Column. Initially, the JavaScript hids all "blocks" except for the "Details"
+ * block.  There will be as many blocks as there are TOC links.
+ *
+ * By default, all blocks have the following layout that consists of a 
+ * container div box with the class 'tripal-info-box', a div box to house the
+ * block title with the class 'tripal-info-box-title', and a div box to
+ * house a brief description about the block with the class 
+ * 'tripal-info-box-desc' 
+ *
+ * |-----------------------------------------------|
+ * |  .tripal-info-box                             |
+ * | |-------------------------------------------| |
+ * | | .tripal-info-box-title                    | |
+ * | |-------------------------------------------| |
+ * | | .tripal-info-box-desc                     | |
+ * | |-------------------------------------------| |
+ * |                                               |
+ * | (Block data goes here)                        |
+ * |                                               |
+ * |                                               |
+ * |                                               |
+ * |                                               |
+ * |-----------------------------------------------|
  */
  */
-.tripal-subtable {
-  border-collapse:collapse;
-  border: 0px solid black;
-  width: auto;
+.tripal-info-box {
+   width: 100%;
+   padding-bottom: 10px;
 }
 }
 
 
-.tripal-subtable td {
-  padding: 0px 5px 5px 0px; 
-  border: 0px solid black;
+.tripal-info-box-title {
+  font-size: 1.5em;
+  padding-bottom: 15px;
 }
 }
 
 
-.tripal-notice {
-  color: red;
+.tripal-info-box-desc {
+
 }
 }
 
 
-/**
- * Teaser
+/******************************************************************************
+ * The teaser appears anywhere that a small snippet of the content is required.
+ * When any node in Drupal is published to the home page a teaser is used.
+ * Teasers can also be used in views to provide lists of content. The 
+ * teaser template is similar to the block but with the following sections and
+ * classes
+ *
+ * |-----------------------------------------------|
+ * |  .tripal-teaser                               |
+ * | |-------------------------------------------| |
+ * | | .tripal-teaser-title                      | |
+ * | |-------------------------------------------| |
+ * | | .tripal-teaser-text                       | |
+ * | |                                           | |
+ * | |-------------------------------------------| |
+ * |-----------------------------------------------|
  */
  */
 .tripal-teaser {
 .tripal-teaser {
   clear_both;
   clear_both;
@@ -158,9 +154,35 @@ background-color: transparent;
   text-align: justify;
   text-align: justify;
   text-justify:inter-word;
   text-justify:inter-word;
 }
 }
+
+/**
+ * some nodes such as the organism node may have images. This class
+ * is used to format any image that appears in the teaser 
+ */
 .tripal-teaser-img {
 .tripal-teaser-img {
   width: 100px; 
   width: 100px; 
   float: left; 
   float: left; 
   padding-right: 10px; 
   padding-right: 10px; 
   padding-bottom: 5px;
   padding-bottom: 5px;
 }
 }
+
+/******************************************************************************
+ * Administrative CSS classes
+ *****************************************************************************/
+ 
+ /**
+  * This class is used when providing hints or other instructions to the 
+  * site administrator
+  */ 
+ 
+.tripal-site-admin-only {
+   background-image: url("../images/TripalLogo-sm.png");
+   background-repeat: no-repeat;
+   background-color: #BBBBFF;
+}
+
+.tripal-site-admin-message {
+   padding: 10px 10px 10px 55px;
+   font-style: italic;
+}
+

+ 43 - 50
tripal_core/theme/node--chado-generic.tpl.php

@@ -23,17 +23,8 @@ else { ?>
 <script type="text/javascript">
 <script type="text/javascript">
 (function ($) {
 (function ($) {
   Drupal.behaviors.<?php print $ttype?>Behavior = {
   Drupal.behaviors.<?php print $ttype?>Behavior = {
-    attach: function (context, settings){ <?php
-      // hide the resource sidbar if requested and strech the details section
-      if ($no_sidebar) { ?>    
-        $(".tripal_toc").hide();
-        $(".tripal_details").addClass("tripal_details_full");
-        $(".tripal_details_full").removeClass("tripal_details"); <?php
-      } 
-      // use default resource sidebar
-      else { ?>        
-        $(".tripal-info-box").hide(); <?php
-      } ?>
+    attach: function (context, settings){ 
+      $(".tripal-info-box").hide();
  
  
       // iterate through all of the info boxes and add their titles
       // iterate through all of the info boxes and add their titles
       // to the table of contents
       // to the table of contents
@@ -79,49 +70,51 @@ else { ?>
 })(jQuery);
 })(jQuery);
 </script>
 </script>
 
 
-<div id="tripal_<?php print $ttype?>_content" class="tripal_contents">
-  <table id="tripal_contents_table">
-    <tr class="tripal_contents_table_tr">
-      <td nowrap class="tripal_contents_table_td"  align="left">
-        <div id="tripal_<?php print $ttype?>_toc" class="tripal_toc">
-          <ul id="tripal_<?php print $ttype?>_toc_list" class="tripal_toc_list">
-          
-           <!-- Resource Links CCK elements --><?php
-           if(property_exists($node, 'field_resource_links')) {
-             for($i = 0; $i < count($node->field_resource_links); $i++){
-               if($node->field_resource_links[$i]['value']){
-                 $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
-                 <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
-               }
+<div id="tripal_<?php print $ttype?>_content" class="tripal-contents"> <?php 
+  if ($page['tripal_sidebar']) { ?>
+    <div id="tripal-sidebar" class="column sidebar">
+      <div class="section">
+        <?php print render($page["chado_" . $ttype . " _toc"]); ?>
+      </div>
+    </div><?php 
+  } ?>
+  <table id="tripal-contents-table">
+    <tr class="tripal-contents-table-tr">
+      <td nowrap class="tripal-contents-table-td tripal-contents-table-td-toc"  align="left">
+        <ul id="tripal_<?php print $ttype?>_toc_list" class="tripal_toc_list">
+        
+         <!-- Resource Links CCK elements --><?php
+         if(property_exists($node, 'field_resource_links')) {
+           for($i = 0; $i < count($node->field_resource_links); $i++){
+             if($node->field_resource_links[$i]['value']){
+               $matches = preg_split("/\|/",$node->field_resource_links[$i]['value']);?>
+               <li><a href="<?php print $matches[1] ?>" target="_blank"><?php print $matches[0] ?></a></li><?php
              }
              }
            }
            }
-           ?> 
-            </ul>
-          </div>
+         }
+         ?> 
+          </ul>
         </td>
         </td>
-        <td class="tripal_contents_table_td" align="left" width="100%">
-          <div id="tripal_<?php print $ttype?>_details" class="tripal_details">
-        
-           <!-- Resource Blocks CCK elements --> <?php
-           if (property_exists($node, 'field_resource_titles')) {
-             for ($i = 0; $i < count($node->field_resource_titles); $i++){
-               if ($node->field_resource_titles[$i]['value']){ ?>
-                 <div id="tripal_<?php print $ttype?>-resource_<?php print $i?>-box" class="tripal_<?php print $ttype?>-info-box tripal-info-box">
-                   <div class="tripal_<?php print $ttype?>-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
-                   <?php print $node->field_resource_blocks[$i]['value']; ?>
-                 </div> <?php
-               }
-             } 
-           }?>
-           <!-- Let modules add more content -->
-           <?php
-             foreach ($content as $key => $values) {
-               if (array_key_exists('#value', $values)) {
-                 print $content[$key]['#value'];
-               }
+        <td class="tripal-contents-table-td-data" align="left" width="100%">
+         <!-- Resource Blocks CCK elements --> <?php
+         if (property_exists($node, 'field_resource_titles')) {
+           for ($i = 0; $i < count($node->field_resource_titles); $i++){
+             if ($node->field_resource_titles[$i]['value']){ ?>
+               <div id="tripal_<?php print $ttype?>-resource_<?php print $i?>-box" class="tripal_<?php print $ttype?>-info-box tripal-info-box">
+                 <div class="tripal_<?php print $ttype?>-info-box-title tripal-info-box-title"><?php print $node->field_resource_titles[$i]['value'] ?></div>
+                 <?php print $node->field_resource_blocks[$i]['value']; ?>
+               </div> <?php
              }
              }
-           ?>
-        </div>
+           } 
+         }?>
+         <!-- Let modules add more content -->
+         <?php
+           foreach ($content as $key => $values) {
+             if (array_key_exists('#value', $values)) {
+               print $content[$key]['#value'];
+             }
+           }
+         ?>
       </td>
       </td>
     </tr>
     </tr>
   </table>
   </table>

+ 75 - 28
tripal_core/tripal_core.module

@@ -150,7 +150,7 @@ function tripal_core_menu() {
     'description' => "Manage the behavior or Tripal and its various modules.",
     'description' => "Manage the behavior or Tripal and its various modules.",
     'weight' => -8,
     'weight' => -8,
     'page callback' => 'system_admin_menu_block_page',
     'page callback' => 'system_admin_menu_block_page',
-    'access arguments' => array('administer site configuration'),
+    'access arguments' => array('administer tripal'),
     'file' => 'system.admin.inc',
     'file' => 'system.admin.inc',
     'file path' => drupal_get_path('module', 'system'),
     'file path' => drupal_get_path('module', 'system'),
   );
   );
@@ -158,26 +158,26 @@ function tripal_core_menu() {
     'title' => 'Chado Schema',
     'title' => 'Chado Schema',
     'description' => "Tools to extend the chado schema through custom tables & materialized views.",
     'description' => "Tools to extend the chado schema through custom tables & materialized views.",
     'weight' => -2,
     'weight' => -2,
-    'access arguments' => array('administer site configuration'),
+    'access arguments' => array('administer tripal'),
   );
   );
   $items['admin/tripal/chado'] = array(
   $items['admin/tripal/chado'] = array(
     'title' => 'Chado Modules',
     'title' => 'Chado Modules',
     'description' => 'Configuration for specific chado data types such as Vocabularies, Features, etc.',
     'description' => 'Configuration for specific chado data types such as Vocabularies, Features, etc.',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -6
     'weight' => -6
   );
   );
   $items['admin/tripal/loaders'] = array(
   $items['admin/tripal/loaders'] = array(
     'title' => 'Chado Data Loaders',
     'title' => 'Chado Data Loaders',
     'description' => 'Tools facilitating loading data into the chado database. Includes a generic tab-delimited loader (Bulk Loader).',
     'description' => 'Tools facilitating loading data into the chado database. Includes a generic tab-delimited loader (Bulk Loader).',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -4
     'weight' => -4
   );
   );
   $items['admin/tripal/extension'] = array(
   $items['admin/tripal/extension'] = array(
     'title' => 'Extension Modules',
     'title' => 'Extension Modules',
     'description' => 'Configuration for Tripal extension modules.',
     'description' => 'Configuration for Tripal extension modules.',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => 0
     'weight' => 0
   );
   );
@@ -186,7 +186,7 @@ function tripal_core_menu() {
   $items['admin/tripal/setup'] = array(
   $items['admin/tripal/setup'] = array(
     'title' => 'Setup Tripal',
     'title' => 'Setup Tripal',
     'description' => 'Tools for initial setup of Tripal',
     'description' => 'Tools for initial setup of Tripal',
-    'access arguments' => array('administer site configuration'),
+    'access arguments' => array('administer tripal'),
     'weight' => -8
     'weight' => -8
   );
   );
   $items['admin/tripal/setup/customize'] = array(
   $items['admin/tripal/setup/customize'] = array(
@@ -194,7 +194,7 @@ function tripal_core_menu() {
     'description' => 'Information on how to customize tripal',
     'description' => 'Information on how to customize tripal',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_core_customize'),
     'page arguments' => array('tripal_core_customize'),
-    'access arguments' => array('administer site configuration'),
+    'access arguments' => array('administer tripal'),
     'weight' => 10
     'weight' => 10
   );
   );
   $items['admin/tripal/setup/chado_install'] = array(
   $items['admin/tripal/setup/chado_install'] = array(
@@ -212,7 +212,7 @@ function tripal_core_menu() {
     'title' => 'Jobs',
     'title' => 'Jobs',
     'description' => 'Jobs managed by Tripal',
     'description' => 'Jobs managed by Tripal',
     'page callback' => 'tripal_jobs_admin_view',
     'page callback' => 'tripal_jobs_admin_view',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -10
     'weight' => -10
   );
   );
@@ -221,7 +221,7 @@ function tripal_core_menu() {
     'description' => 'Help for the tripal job management system',
     'description' => 'Help for the tripal job management system',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_core_job_help'),
     'page arguments' => array('tripal_core_job_help'),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -230,7 +230,7 @@ function tripal_core_menu() {
     'description' => 'Cancel a pending job',
     'description' => 'Cancel a pending job',
     'page callback' => 'tripal_jobs_cancel',
     'page callback' => 'tripal_jobs_cancel',
     'page arguments' => array(4),
     'page arguments' => array(4),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/tripal_jobs/rerun/%'] = array(
   $items['admin/tripal/tripal_jobs/rerun/%'] = array(
@@ -238,7 +238,7 @@ function tripal_core_menu() {
     'description' => 'Re-run an existing job.',
     'description' => 'Re-run an existing job.',
     'page callback' => 'tripal_jobs_rerun',
     'page callback' => 'tripal_jobs_rerun',
     'page arguments' => array(4),
     'page arguments' => array(4),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/tripal_jobs/view/%'] = array(
   $items['admin/tripal/tripal_jobs/view/%'] = array(
@@ -246,14 +246,14 @@ function tripal_core_menu() {
     'description' => 'View job details.',
     'description' => 'View job details.',
     'page callback' => 'tripal_jobs_view',
     'page callback' => 'tripal_jobs_view',
     'page arguments' => array(4),
     'page arguments' => array(4),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/tripal_jobs/views/jobs/enable'] = array(
   $items['admin/tripal/tripal_jobs/views/jobs/enable'] = array(
     'title' => 'Enable Jobs Administrative View',
     'title' => 'Enable Jobs Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_core_admin_jobs', 'admin/tripal/tripal_jobs'),
     'page arguments' => array('tripal_core_admin_jobs', 'admin/tripal/tripal_jobs'),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 
@@ -262,7 +262,7 @@ function tripal_core_menu() {
     'title' => 'Materialized Views',
     'title' => 'Materialized Views',
     'description' => 'Materialized views are used to improve speed of large or complex queries.',
     'description' => 'Materialized views are used to improve speed of large or complex queries.',
     'page callback' => 'tripal_mview_admin_view',
     'page callback' => 'tripal_mview_admin_view',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -10
     'weight' => -10
   );
   );
@@ -271,7 +271,7 @@ function tripal_core_menu() {
     'description' => 'Help for the materialized views management system',
     'description' => 'Help for the materialized views management system',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_core_mviews_help'),
     'page arguments' => array('tripal_core_mviews_help'),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -280,7 +280,7 @@ function tripal_core_menu() {
     'title' => 'List Materialized Views',
     'title' => 'List Materialized Views',
     'description' => 'A list of existing materialized views with the ability to edit & delete existing materialized views.',
     'description' => 'A list of existing materialized views with the ability to edit & delete existing materialized views.',
     'page callback' => 'tripal_mviews_report',
     'page callback' => 'tripal_mviews_report',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -10
     'weight' => -10
   );
   );
@@ -290,7 +290,7 @@ function tripal_core_menu() {
     'description' => 'Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.',
     'description' => 'Materialized views are used to improve speed of large or complex queries. These are database views as compared to Drupal views.',
     'page callback' => 'tripal_mview_report',
     'page callback' => 'tripal_mview_report',
     'page arguments' => array(5),
     'page arguments' => array(5),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/mviews/new'] = array(
   $items['admin/tripal/schema/mviews/new'] = array(
@@ -298,14 +298,14 @@ function tripal_core_menu() {
     'description' => 'Create a new materialized view.',
     'description' => 'Create a new materialized view.',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_mviews_form'),
     'page arguments' => array('tripal_mviews_form'),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/mviews/edit/%'] = array(
   $items['admin/tripal/schema/mviews/edit/%'] = array(
     'title' => 'Edit Materialized View',
     'title' => 'Edit Materialized View',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_mviews_form', 5),
     'page arguments' => array('tripal_mviews_form', 5),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/mviews/action/%/%'] = array(
   $items['admin/tripal/schema/mviews/action/%/%'] = array(
@@ -313,7 +313,7 @@ function tripal_core_menu() {
     'description' => 'Materialized views are used to improve speed of large or complex queries.',
     'description' => 'Materialized views are used to improve speed of large or complex queries.',
     'page callback' => 'tripal_mviews_action',
     'page callback' => 'tripal_mviews_action',
     'page arguments' => array(5, 6, "1"),
     'page arguments' => array(5, 6, "1"),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 
@@ -322,7 +322,7 @@ function tripal_core_menu() {
     'title' => 'Custom Tables',
     'title' => 'Custom Tables',
     'description' => 'Creation of custom tables that are added to Chado database.',
     'description' => 'Creation of custom tables that are added to Chado database.',
     'page callback' => 'tripal_custom_table_admin_view',
     'page callback' => 'tripal_custom_table_admin_view',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -10
     'weight' => -10
   );
   );
@@ -331,7 +331,7 @@ function tripal_core_menu() {
     'description' => 'Help for the tripal job management system',
     'description' => 'Help for the tripal job management system',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_core_job_help'),
     'page arguments' => array('tripal_core_job_help'),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -340,7 +340,7 @@ function tripal_core_menu() {
     'title' => 'List of Custom Tables',
     'title' => 'List of Custom Tables',
     'description' => 'Provides a list of all custom tables created by Tripal and allows for editing or removing existing custom tables.',
     'description' => 'Provides a list of all custom tables created by Tripal and allows for editing or removing existing custom tables.',
     'page callback' => 'tripal_custom_tables_list',
     'page callback' => 'tripal_custom_tables_list',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
     'weight' => -10
     'weight' => -10
   );
   );
@@ -350,21 +350,21 @@ function tripal_core_menu() {
     'description' => 'Custom tables are added to Chado.',
     'description' => 'Custom tables are added to Chado.',
     'page callback' => 'tripal_custom_table_view',
     'page callback' => 'tripal_custom_table_view',
     'page arguments' => array(4),
     'page arguments' => array(4),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/custom_tables/new'] = array(
   $items['admin/tripal/schema/custom_tables/new'] = array(
     'title' => 'Create Custom Table',
     'title' => 'Create Custom Table',
     'description' => 'An interface for creating your own custom tables.',
     'description' => 'An interface for creating your own custom tables.',
     'page callback' => 'tripal_custom_table_new_page',
     'page callback' => 'tripal_custom_table_new_page',
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/custom_tables/edit/%'] = array(
   $items['admin/tripal/schema/custom_tables/edit/%'] = array(
     'title' => 'Edit Custom Table',
     'title' => 'Edit Custom Table',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_custom_tables_form', 4),
     'page arguments' => array('tripal_custom_tables_form', 4),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/custom_tables/action/%/%'] = array(
   $items['admin/tripal/schema/custom_tables/action/%/%'] = array(
@@ -372,14 +372,14 @@ function tripal_core_menu() {
     'description' => 'Custom tables are added to Chado.',
     'description' => 'Custom tables are added to Chado.',
     'page callback' => 'tripal_custom_tables_action',
     'page callback' => 'tripal_custom_tables_action',
     'page arguments' => array(4, 5, "1"),
     'page arguments' => array(4, 5, "1"),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/schema/custom_tables/views/tables/enable'] = array(
   $items['admin/tripal/schema/custom_tables/views/tables/enable'] = array(
     'title' => 'Enable Custom Tables Administrative View',
     'title' => 'Enable Custom Tables Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_core_admin_custom_table', 'admin/tripal/schema/custom_tables'),
     'page arguments' => array('tripal_core_admin_custom_table', 'admin/tripal/schema/custom_tables'),
-    'access arguments' => array('access administration pages'),
+    'access arguments' => array('administer tripal'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 
@@ -399,6 +399,10 @@ function tripal_core_permission() {
       'title' => t('Install Chado'),
       'title' => t('Install Chado'),
       'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
       'description' => t('Allow the user to install or upgrade a Chado database in the existing Drupal database.')
     ),
     ),
+    'administer tripal' => array(
+      'title' => t('Administer Tripal'),
+      'description' => t('Allow the user to access administrative pages of Tripal.')
+    ),
   );
   );
 }
 }
 
 
@@ -449,9 +453,17 @@ function tripal_core_theme($existing, $type, $theme, $path) {
       'function' => 'theme_chado_node_relationships_form_table',
       'function' => 'theme_chado_node_relationships_form_table',
       'render element' => 'element',
       'render element' => 'element',
     ),
     ),
+    
+    // Admin messages theme
+    // --------------------------------
+    'tripal_admin_message' => array(
+      'function' => 'theme_tripal_admin_message',
+      'variables' => array('message' => NULL),
+    )
   );
   );
 }
 }
 
 
+
 /**
 /**
  * Implements hook_job_describe_args().
  * Implements hook_job_describe_args().
  * Describes the arguements for the tripal_update_mview job to allow for greater
  * Describes the arguements for the tripal_update_mview job to allow for greater
@@ -520,4 +532,39 @@ function tripal_core_views_api() {
   return array(
   return array(
     'api' => 3.0,
     'api' => 3.0,
   );
   );
+}
+
+/**
+ * After the node is built, we want to add instructions to each
+ * content section letting the administrator know which template
+ * they can customize
+ * 
+ * @param unknown $build
+ */
+function tripal_core_node_view_alter(&$build) {
+  global $theme;
+  
+
+  $cache = cache_get("theme_registry:$theme", 'cache');
+  $paths = array();
+  foreach ($build as $key => $value) {
+    if (preg_match('/^tripal_/', $key)) {
+      if (array_key_exists($key, $cache->data)) {
+        $paths[$key] = $cache->data[$key]['path'];
+      }
+    }
+  }
+  if (count($paths) > 0) {
+    $message = '<p>The content displayed on this page is provided by the following templates: <ul>';
+    foreach ($paths as $template => $path) {
+      $message .= "<li>$key: $path</li>";
+    }
+    $message .= "</ul>";
+    $build['tripal_template_paths']['#value'] = theme(
+      'theme_tripal_admin_message',
+      array('message' => $message)
+    );
+  }
+  dpm($build);
+  dpm($cache);
 }
 }

+ 10 - 10
tripal_core/tripal_launch_jobs_multi.php

@@ -99,16 +99,16 @@ function runjob($sitename, $username) {
 
 
   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
   drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
 
-	// check to make sure the username is valid
-	$results = db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username));
-	$u = $results->fetchObject();
-	if (!$u) {
-	  fwrite($stdout, "'$username' is not a valid Drupal username. exiting...\n");
-	  exit;
-	}
-	
-	global $user;
-	$user = user_load($u->uid);
+  // check to make sure the username is valid
+  $results = db_query("SELECT * FROM {users} WHERE name = :name", array(':name' => $username));
+  $u = $results->fetchObject();
+  if (!$u) {
+    fwrite($stdout, "'$username' is not a valid Drupal username. exiting...\n");
+    exit;
+  }
+  
+  global $user;
+  $user = user_load($u->uid);
 
 
   tripal_jobs_launch();
   tripal_jobs_launch();
 }
 }

+ 78 - 78
tripal_cv/theme/js/jquery-treeview/demo/source.php

@@ -2,86 +2,86 @@
 if ($_REQUEST['root'] == "source"):
 if ($_REQUEST['root'] == "source"):
 ?>
 ?>
 [
 [
-	{
-		"text": "1. Pre Lunch (120 min)",
-		"expanded": true,
-		"classes": "important",
-		"children":
-		[
-			{
-				"text": "1.1 The State of the Powerdome (30 min)"
-			},
-		 	{
-				"text": "1.2 The Future of jQuery (30 min)"
-			},
-		 	{
-				"text": "1.2 jQuery UI - A step to richnessy (60 min)"
-			}
-		]
-	},
-	{
-		"text": "2. Lunch  (60 min)"
-	},
-	{
-		"text": "3. After Lunch  (120+ min)",
-		"children":
-		[
-			{
-				"text": "3.1 jQuery Calendar Success Story (20 min)"
-			},
-		 	{
-				"text": "3.2 jQuery and Ruby Web Frameworks (20 min)"
-			},
-		 	{
-				"text": "3.3 Hey, I Can Do That! (20 min)"
-			},
-		 	{
-				"text": "3.4 Taconite and Form (20 min)"
-			},
-		 	{
-				"text": "3.5 Server-side JavaScript with jQuery and AOLserver (20 min)"
-			},
-		 	{
-				"text": "3.6 The Onion: How to add features without adding features (20 min)",
-				"id": "36",
-				"hasChildren": true
-			},
-		 	{
-				"text": "3.7 Visualizations with JavaScript and Canvas (20 min)"
-			},
-		 	{
-				"text": "3.8 ActiveDOM (20 min)"
-			},
-		 	{
-				"text": "3.8 Growing jQuery (20 min)"
-			}
-		]
-	}
+  {
+    "text": "1. Pre Lunch (120 min)",
+    "expanded": true,
+    "classes": "important",
+    "children":
+    [
+      {
+        "text": "1.1 The State of the Powerdome (30 min)"
+      },
+       {
+        "text": "1.2 The Future of jQuery (30 min)"
+      },
+       {
+        "text": "1.2 jQuery UI - A step to richnessy (60 min)"
+      }
+    ]
+  },
+  {
+    "text": "2. Lunch  (60 min)"
+  },
+  {
+    "text": "3. After Lunch  (120+ min)",
+    "children":
+    [
+      {
+        "text": "3.1 jQuery Calendar Success Story (20 min)"
+      },
+       {
+        "text": "3.2 jQuery and Ruby Web Frameworks (20 min)"
+      },
+       {
+        "text": "3.3 Hey, I Can Do That! (20 min)"
+      },
+       {
+        "text": "3.4 Taconite and Form (20 min)"
+      },
+       {
+        "text": "3.5 Server-side JavaScript with jQuery and AOLserver (20 min)"
+      },
+       {
+        "text": "3.6 The Onion: How to add features without adding features (20 min)",
+        "id": "36",
+        "hasChildren": true
+      },
+       {
+        "text": "3.7 Visualizations with JavaScript and Canvas (20 min)"
+      },
+       {
+        "text": "3.8 ActiveDOM (20 min)"
+      },
+       {
+        "text": "3.8 Growing jQuery (20 min)"
+      }
+    ]
+  }
 ]
 ]
 <?php else: ?>
 <?php else: ?>
 [
 [
-	{
-		"text": "1. Review of existing structures",
-		"expanded": true,
-		"children":
-		[
-			{
-				"text": "1.1 jQuery core"
-			},
-		 	{
-				"text": "1.2 metaplugins"
-			}
-		]
-	},
-	{
-		"text": "2. Wrapper plugins"
-	},
-	{
-		"text": "3. Summary"
-	},
-	{
-		"text": "4. Questions and answers"
-	}
-	
+  {
+    "text": "1. Review of existing structures",
+    "expanded": true,
+    "children":
+    [
+      {
+        "text": "1.1 jQuery core"
+      },
+       {
+        "text": "1.2 metaplugins"
+      }
+    ]
+  },
+  {
+    "text": "2. Wrapper plugins"
+  },
+  {
+    "text": "3. Summary"
+  },
+  {
+    "text": "4. Questions and answers"
+  }
+  
 ]
 ]
 <?php endif; ?>
 <?php endif; ?>

+ 25 - 25
tripal_cv/theme/js/jsTree/reference/_examples/1_async.php

@@ -1,29 +1,29 @@
 <?
 <?
-	// Make sure nothing is cached
-	header("Cache-Control: must-revalidate");
-	header("Cache-Control: post-check=0, pre-check=0", false);
-	header("Pragma: no-cache");
-	header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")-2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
-	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
+  // Make sure nothing is cached
+  header("Cache-Control: must-revalidate");
+  header("Cache-Control: post-check=0, pre-check=0", false);
+  header("Pragma: no-cache");
+  header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")-2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
+  header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 
 
-	// So that the loading indicator is visible
-	sleep(1);
+  // So that the loading indicator is visible
+  sleep(1);
 
 
-	// The id of the node being opened
-	$id = $_REQUEST["id"];
-	//echo $id;
-	if($id == "0") {
-		echo '['."\n";
-		echo "\t".'{ attributes: { id : "pjson_1" }, state: "closed", data: "Root node 1" },'."\n";
-		echo "\t".'{ attributes: { id : "pjson_5" }, data: "Root node 2" }'."\n";
-		echo ']'."\n";
-	}
-	else {
-		echo '['."\n";
-		echo "\t".'{ attributes: { id : "pjson_2" }, data: { title : "Custom icon", icon : "../media/images/ok.png" } },'."\n";
-		echo "\t".'{ attributes: { id : "pjson_3" }, data: "Child node 2" },'."\n";
-		echo "\t".'{ attributes: { id : "pjson_4" }, data: "Some other child node" }'."\n";
-		echo ']'."\n";
-	}
-	exit();
+  // The id of the node being opened
+  $id = $_REQUEST["id"];
+  //echo $id;
+  if($id == "0") {
+    echo '['."\n";
+    echo "\t".'{ attributes: { id : "pjson_1" }, state: "closed", data: "Root node 1" },'."\n";
+    echo "\t".'{ attributes: { id : "pjson_5" }, data: "Root node 2" }'."\n";
+    echo ']'."\n";
+  }
+  else {
+    echo '['."\n";
+    echo "\t".'{ attributes: { id : "pjson_2" }, data: { title : "Custom icon", icon : "../media/images/ok.png" } },'."\n";
+    echo "\t".'{ attributes: { id : "pjson_3" }, data: "Child node 2" },'."\n";
+    echo "\t".'{ attributes: { id : "pjson_4" }, data: "Some other child node" }'."\n";
+    echo ']'."\n";
+  }
+  exit();
 ?>
 ?>

+ 358 - 358
tripal_cv/theme/js/jsTree/reference/_examples/full/_inc/class.tree.php

@@ -1,362 +1,362 @@
 <?
 <?
 class tree {
 class tree {
-	// Structure table and fields
-	var $s_table	= "";
-	var $s_fields	= array(
-			"id"		=> false,
-			"parent_id"	=> false,
-			"position"	=> false,
-			"left"		=> false,
-			"right"		=> false,
-			"level"		=> false
-		);
-
-	// Additional fields (stored in format `table_name.field_name`)
-	var $d_fields	= array();
-
-	// Tree type (or types)
-	var $adjacency	= false;
-	var $nestedset	= false;
-
-	// Database
-	var $db			= false;
-
-	// Constructor
-	function __construct($tables = array()) {
-		if(!is_array($tables) || !count($tables)) return;
-		foreach($tables as $table_name => $fields) {
-			if(is_array($fields)) {
-				foreach($fields as $key => $field) {
-					switch($key) {
-						case "id":
-						case "parent_id":
-						case "position":
-						case "left":
-						case "right":
-						case "level":
-							$this->s_table = $table_name;
-							$this->s_fields[$key] = $field;
-							break;
-						default:
-							$this->d_fields[] = $table_name.".".$field;
-							break;
-					}
-				}
-			}
-		}
-
-		// Determine what kind of a tree is used (or both)
-		if($this->s_fields["id"] && $this->s_fields["position"])														$this->adjacency = true;
-		if($this->s_fields["id"] && $this->s_fields["left"] && $this->s_fields["right"] && $this->s_fields["level"])	$this->nestedset = true;
-
-		// Database
-		$this->db = new DB;
-	}
-	function tree($tables = array()) { return $this->__construct($tables); } // PHP 4 compatibilty
-
-	// WRITING FUNCTIONS
-	// Function for moving nodes
-	// ID is the node that is being moved - 0 is creating a new NODE
-	// REF_ID is the reference node in the move
-	// TYPE is one of "after", "before" or "inside"
-	function move($id, $ref_id, $type, $mode = "move") {
-		if(!in_array($type, array("after", "before", "inside"))) return false;
-
-		// Queries executed at the end
-		$sql	= array();
-
-		if(!(int)$id) $mode = "create";
-
-		if($mode == "create") {
-			// Fields and values that will be inserted
-			$fields	= array();
-			$values	= array();
-			// Inserting an ID
-			$fields[] = "`".$this->s_fields["id"]."`";
-			$values[] = "NULL";
-		}
-
-		// If the tree maintains an ID->PARENT_ID relation
-		if($this->adjacency) {
-			$this->db->query("SELECT `".$this->s_fields["parent_id"]."`, `".$this->s_fields["position"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$ref_id);
-			$this->db->nextr();
-
-			// Determine new parent and position
-			if($type == "inside") {
-				$new_parent_id = $ref_id;
-				$new_position = 1;
-			}
-			else {
-				$new_parent_id = (int)$this->db->f(0);
-				if($type == "before")	$new_position = $this->db->f(1);
-				if($type == "after")	$new_position = $this->db->f(1) + 1;
-			}
-
-			// Cleanup old parent
-			if($mode == "create") {
-				$old_parent_id	= -1;
-				$old_position	= 0;
-			}
-			else {
-				$this->db->query("SELECT `".$this->s_fields["parent_id"]."`, `".$this->s_fields["position"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$id);
-				$this->db->nextr();
-				$old_parent_id	= $this->db->f(0);
-				$old_position	= $this->db->f(1);
-			}
-
-			// A reorder was made
-			if($old_parent_id == $new_parent_id) {
-				if($new_position > $old_position) {
-					$new_position = $new_position - 1;
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$old_parent_id." AND `".$this->s_fields["position"]."` BETWEEN ".($old_position + 1)." AND ".$new_position;
-				}
-				if($new_position < $old_position) {
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` + 1 WHERE `".$this->s_fields["parent_id"]."` = ".$old_parent_id." AND `".$this->s_fields["position"]."` BETWEEN ".$new_position." AND ".($old_position - 1);
-				}
-			}
-			else {
-				// Fix old parent (move siblings up)
-				$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$old_parent_id." AND `".$this->s_fields["position"]."` > ".$old_position;
-				// Prepare new parent (move sibling down)
-				$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` + 1 WHERE `".$this->s_fields["parent_id"]."` = ".$new_parent_id." AND `".$this->s_fields["position"]."` >".($type != "after" ? "=" : "")." ".$new_position;
-			}
-			// Move the node to the new position
-			if($mode == "create") {
-				$fields[] = "`".$this->s_fields["parent_id"]."`";
-				$fields[] = "`".$this->s_fields["position"]."`";
-				$values[] = $new_parent_id;
-				$values[] = $new_position;
-			}
-			else {
-				$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = ".$new_position.", `".$this->s_fields["parent_id"]."` = ".$new_parent_id." WHERE `".$this->s_fields["id"]."` = ".(int)$id;
-			}
-		}
-
-		// If the tree maintains a nested set
-		if($this->nestedset) {
-			$this->db->query("SELECT `".$this->s_fields["id"]."` AS id, `".$this->s_fields["left"]."` AS lft, `".$this->s_fields["right"]."` AS rgt, `".$this->s_fields["level"]."` AS lvl FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` IN(".(int)$id.",".(int)$ref_id.")");
-			while($this->db->nextr()) {
-				if($id == $this->db->f("id")) {
-					$nod_lft = (int)$this->db->f("lft");
-					$nod_rgt = (int)$this->db->f("rgt");
-					$dif = $nod_rgt - $nod_lft + 1;
-				}
-				if($ref_id == $this->db->f("id")) {
-					$ref_lft = (int)$this->db->f("lft");
-					$ref_rgt = (int)$this->db->f("rgt");
-					$ref_lvl = (int)$this->db->f("lvl");
-				}
-			}
-
-			if($mode == "move") {
-				$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` - ".$dif." WHERE `".$this->s_fields["left"]."` > ".$nod_rgt;
-				$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` - ".$dif." WHERE `".$this->s_fields["right"]."` > ".$nod_rgt;
-				if($ref_lft > $nod_rgt) $ref_lft -= $dif;
-				if($ref_rgt > $nod_rgt) $ref_rgt -= $dif;
-			}
-			else $dif = 2;
-
-			$ids = array();
-			if($mode == "move") {
-				$this->db->query("SELECT `".$this->s_fields["id"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["left"]."` >= ".$nod_lft." AND `".$this->s_fields["right"]."` <= ".$nod_rgt);
-				while($this->db->nextr()) $ids[] = (int)$this->db->f(0);
-			} 
-			else $ids[] = -1;
-
-			switch($type) {
-				case "before":
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + ".$dif." WHERE `".$this->s_fields["left"]."` >= ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + ".$dif." WHERE `".$this->s_fields["right"]."` > ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
-					if($mode == "move") {
-						$dif = $ref_lft - $nod_lft;
-						$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["level"]."` = ".(int)$ref_lvl.", `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + (".$dif."), `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + (".$dif.") WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).") ";
-					}
-					else {
-						$fields[] = "`".$this->s_fields["level"]."`";
-						$fields[] = "`".$this->s_fields["left"]."`";
-						$fields[] = "`".$this->s_fields["right"]."`";
-						$values[] = (int)$ref_lvl;
-						$values[] = (int)$ref_lft;
-						$values[] = ((int)$ref_lft + 2);
-					}
-					break;
-				case "after":
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + ".$dif." WHERE `".$this->s_fields["left"]."` > ".$ref_rgt." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + ".$dif." WHERE `".$this->s_fields["right"]."` > ".$ref_rgt." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
-					if($mode == "move") {
-						$dif = ($ref_rgt + 1) - $nod_lft;
-						$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["level"]."` = ".(int)$ref_lvl.", `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + (".$dif."), `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + (".$dif.") WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).") ";
-					} else {
-						$fields[] = "`".$this->s_fields["level"]."`";
-						$fields[] = "`".$this->s_fields["left"]."`";
-						$fields[] = "`".$this->s_fields["right"]."`";
-						$values[] = (int)$ref_lvl;
-						$values[] = ((int)$ref_rgt + 1);
-						$values[] = ((int)$ref_rgt + 3);
-					}
-					break;
-				case "inside":
-				default:
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + ".$dif." WHERE `".$this->s_fields["left"]."` > ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
-					$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + ".$dif." WHERE `".$this->s_fields["right"]."` > ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
-					if($mode == "move") {
-						$dif = ($ref_lft + 1) - $nod_lft;
-						$sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["level"]."` = ".(int)($ref_lvl + 1).", `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + (".$dif."), `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + (".$dif.") WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).") ";
-					}
-					else {
-						$fields[] = "`".$this->s_fields["level"]."`";
-						$fields[] = "`".$this->s_fields["left"]."`";
-						$fields[] = "`".$this->s_fields["right"]."`";
-						$values[] = ((int)$ref_lvl + 1);
-						$values[] = ((int)$ref_lft + 1);
-						$values[] = ((int)$ref_lft + 3);
-					}
-					break;
-			}
-		}
-		
-		// If creating a new node
-		if($mode == "create") $sql[] = "INSERT INTO `".$this->s_table."` (".implode(",",$fields).") VALUES (".implode(",",$values).")";
-
-		// Applying all changes - there should be a transaction here
-		foreach($sql as $q) { $this->db->query($q); }
-
-		if($mode == "create") return mysql_insert_id();
-	}
-
-	// Function for removing nodes
-	// ID is the node (or array of nodes) that is being removed
-	function remove($id) {
-		if(is_array($id)) {
-			foreach($id as $i) { $this->remove($i); }
-			return;
-		}
-		if(!(int)$id) return false;
-
-		// Take care of nested sets (and adjacency at the same time if applicable)
-		if($this->nestedset) {
-			$this->db->query("SELECT `".$this->s_fields["left"]."` AS lft, `".$this->s_fields["right"]."` AS rgt ".( ($this->adjacency) ? " , `".$this->s_fields["parent_id"]."` AS pid, `".$this->s_fields["position"]."` AS pos " : "" )." FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$id);
-			$this->db->nextr();
-			if($this->adjacency) {
-				$pid = (int)$this->db->f("pid");
-				$pos = (int)$this->db->f("pos");
-			}
-			$lft = (int)$this->db->f("lft");
-			$rgt = (int)$this->db->f("rgt");
-			$dif = $rgt - $lft + 1;
-
-			$this->db->query("DELETE FROM `".$this->s_table."` WHERE `".$this->s_fields["left"]."` >= ".$lft." AND `".$this->s_fields["right"]."` <= ".$rgt);
-			$this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` - ".$dif." WHERE `".$this->s_fields["left"]."` > ".$rgt);
-			$this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` - ".$dif." WHERE `".$this->s_fields["right"]."` > ".$lft);
-			if($this->adjacency) {
-				$this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$pid." AND `".$this->s_fields["position"]."` > ".$pos);
-			}
-			return;
-		}
-		// Only end up here if the tree is adjacency only
-		if($this->adjacency) {
-			$this->db->query("SELECT `".$this->s_fields["parent_id"]."` AS pid, `".$this->s_fields["position"]."` AS pos FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$id);
-			$this->db->nextr();
-			$pid = (int)$this->db->f("pid");
-			$pos = (int)$this->db->f("pos");
-
-			$tmp = array($id);
-			$ids = array($id);
-			while(count($tmp)) {
-				$t = array_shift($tmp);
-				if($t) {
-					$this->db->query("SELECT `".$this->s_fields["id"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["parent_id"]."` = ".(int)$t);
-					while($this->db->nextr()) { 
-						array_push($ids, $this->db->f(0));
-						array_push($tmp, $this->db->f(0));
-					}
-				}
-			}
-			$this->db->query("DELETE FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).")");
-			$this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$pid." AND `".$this->s_fields["position"]."` > ".$pos);
-		}
-	}
-
-	function reconstruct() {
-		if(!$this->adjacency || !$this->nestedset) return;
-
-		// не знам защо да не е persistent
-		$this->db->pcn = false;
-
-		$q = "CREATE TEMPORARY TABLE temp_tree (".$this->s_fields["id"]." INTEGER NOT NULL, ".$this->s_fields["parent_id"]." INTEGER NOT NULL, ". $this->s_fields["position"]." INTEGER NOT NULL) type=HEAP";
-		$this->db->query($q);
-
-		$q = "INSERT INTO temp_tree SELECT ".$this->s_fields["id"].", ".$this->s_fields["parent_id"].", ".$this->s_fields["position"]." FROM ".$this->s_table;
-		$this->db->query($q);
-
-
-		$q = "CREATE TEMPORARY TABLE temp_stack (".$this->s_fields["id"]." INTEGER NOT NULL, ".$this->s_fields["left"]." INTEGER, ".$this->s_fields["right"]." INTEGER, ".$this->s_fields["level"]." INTEGER, stack_top INTEGER NOT NULL, ".$this->s_fields["parent_id"]." INTEGER, ".$this->s_fields["position"]." INTEGER) type=HEAP";
-		$this->db->query($q);
-		$counter = 2;
-
-		$q = "SELECT COUNT(*) as maxcounter FROM temp_tree";
-		$this->db->query($q);
-		$this->db->nextr();
-		$maxcounter = (int) $this->db->f("maxcounter") * 2;
-		$currenttop = 1;
-
-		$q = "INSERT INTO temp_stack SELECT ".$this->s_fields["id"].", 1, NULL, 0, 1, ".$this->s_fields["parent_id"].", ".$this->s_fields["position"]." FROM temp_tree WHERE ".$this->s_fields["parent_id"]." = 0";
-		$this->db->query($q);
-
-		$q = "DELETE FROM temp_tree WHERE ".$this->s_fields["parent_id"]." = 0";
-		$this->db->query($q);
-
-		while ($counter <= $maxcounter) {
-			$q = "SELECT temp_tree.".$this->s_fields["id"]." AS tempmin, temp_tree.".$this->s_fields["parent_id"]." AS pid, temp_tree.".$this->s_fields["position"]." AS lid FROM temp_stack, temp_tree WHERE temp_stack.".$this->s_fields["id"]." = temp_tree.".$this->s_fields["parent_id"]." AND temp_stack.stack_top = ".$currenttop." ORDER BY temp_tree.".$this->s_fields["position"]." ASC LIMIT 1";
-			$this->db->query($q);
-
-			if ($this->db->nextr()) {
-				$tmp = $this->db->f("tempmin");
-
-				$q = "INSERT INTO temp_stack (stack_top, ".$this->s_fields["id"].", ".$this->s_fields["left"].", ".$this->s_fields["right"].", ".$this->s_fields["level"].", ".$this->s_fields["parent_id"].", ".$this->s_fields["position"].") VALUES(".($currenttop + 1).", ".$tmp.", ".$counter.", NULL, ".$currenttop.", ".$this->db->f("pid").", ".$this->db->f("lid").")";
-				$this->db->query($q);
-				$q = "DELETE FROM temp_tree WHERE ".$this->s_fields["id"]." = ".$tmp;
-				$this->db->query($q);
-				$counter++;
-				$currenttop++;
-			}
-			else {
-				$q = "UPDATE temp_stack SET ".$this->s_fields["right"]." = ".$counter.", stack_top = -stack_top WHERE stack_top = ".$currenttop;
-				$this->db->query($q);
-				$counter++;
-				$currenttop--;
-			}
-		}
-
-		$q = "TRUNCATE TABLE ".$this->s_table;
-		$this->db->query($q);
-
-		$q = "INSERT INTO ".$this->s_table." SELECT ".$this->s_fields["id"].", ".$this->s_fields["parent_id"].", ".$this->s_fields["position"].", ".$this->s_fields["left"].", ".$this->s_fields["right"].", ".$this->s_fields["level"]." FROM temp_stack ORDER BY ".$this->s_fields["id"];
-		$this->db->query($q);
-	}
-
-	function analyze() {
-		$this->errors = array();
-		if($this->adjacency) {
-			$this->db->query("SELECT COUNT(*) FROM ".$this->s_table." s WHERE ".$this->s_fields["parent_id"]." != 0 AND (SELECT COUNT(*) FROM ".$this->s_table." WHERE ".$this->s_fields["id"]." = s.".$this->s_fields["parent_id"].") = 0 ");
-			$this->db->nextr();
-			if($this->db->f(0) > 0) $this->errors[] = "Missing parents.";
-		}
-		if($this->nestedset) {
-			$this->db->query("SELECT MAX(".$this->s_fields["right"].") FROM ".$this->s_table);
-			$this->db->nextr();
-			$n = $this->db->f(0);
-			$this->db->query("SELECT COUNT(*) FROM ".$this->s_table);
-			$this->db->nextr();
-			$c = $this->db->f(0);
-			if($n/2 != $c) $this->errors[] = "Right index does not match node count.";
-		}
-		if($this->adjacency && $this->nestedset) {
-			$this->db->query("SELECT COUNT(".$this->s_fields["id"].") FROM ".$this->s_table." s WHERE (SELECT COUNT(*) FROM ".$this->s_table." WHERE ".$this->s_fields["right"]." < s.".$this->s_fields["right"]." AND ".$this->s_fields["left"]." > s.".$this->s_fields["left"]." AND ".$this->s_fields["level"]." = s.".$this->s_fields["level"]." + 1) != (SELECT COUNT(*) FROM ".$this->s_table." WHERE ".$this->s_fields["parent_id"]." = s.".$this->s_fields["id"].") ");
-			$this->db->nextr();
-			if($this->db->f(0) > 0) $this->errors = "Adjacency and nested set do not match.";
-		}
-		return $error;
-	}
+  // Structure table and fields
+  var $s_table  = "";
+  var $s_fields  = array(
+      "id"    => false,
+      "parent_id"  => false,
+      "position"  => false,
+      "left"    => false,
+      "right"    => false,
+      "level"    => false
+    );
+
+  // Additional fields (stored in format `table_name.field_name`)
+  var $d_fields  = array();
+
+  // Tree type (or types)
+  var $adjacency  = false;
+  var $nestedset  = false;
+
+  // Database
+  var $db      = false;
+
+  // Constructor
+  function __construct($tables = array()) {
+    if(!is_array($tables) || !count($tables)) return;
+    foreach($tables as $table_name => $fields) {
+      if(is_array($fields)) {
+        foreach($fields as $key => $field) {
+          switch($key) {
+            case "id":
+            case "parent_id":
+            case "position":
+            case "left":
+            case "right":
+            case "level":
+              $this->s_table = $table_name;
+              $this->s_fields[$key] = $field;
+              break;
+            default:
+              $this->d_fields[] = $table_name.".".$field;
+              break;
+          }
+        }
+      }
+    }
+
+    // Determine what kind of a tree is used (or both)
+    if($this->s_fields["id"] && $this->s_fields["position"])                            $this->adjacency = true;
+    if($this->s_fields["id"] && $this->s_fields["left"] && $this->s_fields["right"] && $this->s_fields["level"])  $this->nestedset = true;
+
+    // Database
+    $this->db = new DB;
+  }
+  function tree($tables = array()) { return $this->__construct($tables); } // PHP 4 compatibilty
+
+  // WRITING FUNCTIONS
+  // Function for moving nodes
+  // ID is the node that is being moved - 0 is creating a new NODE
+  // REF_ID is the reference node in the move
+  // TYPE is one of "after", "before" or "inside"
+  function move($id, $ref_id, $type, $mode = "move") {
+    if(!in_array($type, array("after", "before", "inside"))) return false;
+
+    // Queries executed at the end
+    $sql  = array();
+
+    if(!(int)$id) $mode = "create";
+
+    if($mode == "create") {
+      // Fields and values that will be inserted
+      $fields  = array();
+      $values  = array();
+      // Inserting an ID
+      $fields[] = "`".$this->s_fields["id"]."`";
+      $values[] = "NULL";
+    }
+
+    // If the tree maintains an ID->PARENT_ID relation
+    if($this->adjacency) {
+      $this->db->query("SELECT `".$this->s_fields["parent_id"]."`, `".$this->s_fields["position"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$ref_id);
+      $this->db->nextr();
+
+      // Determine new parent and position
+      if($type == "inside") {
+        $new_parent_id = $ref_id;
+        $new_position = 1;
+      }
+      else {
+        $new_parent_id = (int)$this->db->f(0);
+        if($type == "before")  $new_position = $this->db->f(1);
+        if($type == "after")  $new_position = $this->db->f(1) + 1;
+      }
+
+      // Cleanup old parent
+      if($mode == "create") {
+        $old_parent_id  = -1;
+        $old_position  = 0;
+      }
+      else {
+        $this->db->query("SELECT `".$this->s_fields["parent_id"]."`, `".$this->s_fields["position"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$id);
+        $this->db->nextr();
+        $old_parent_id  = $this->db->f(0);
+        $old_position  = $this->db->f(1);
+      }
+
+      // A reorder was made
+      if($old_parent_id == $new_parent_id) {
+        if($new_position > $old_position) {
+          $new_position = $new_position - 1;
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$old_parent_id." AND `".$this->s_fields["position"]."` BETWEEN ".($old_position + 1)." AND ".$new_position;
+        }
+        if($new_position < $old_position) {
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` + 1 WHERE `".$this->s_fields["parent_id"]."` = ".$old_parent_id." AND `".$this->s_fields["position"]."` BETWEEN ".$new_position." AND ".($old_position - 1);
+        }
+      }
+      else {
+        // Fix old parent (move siblings up)
+        $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$old_parent_id." AND `".$this->s_fields["position"]."` > ".$old_position;
+        // Prepare new parent (move sibling down)
+        $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` + 1 WHERE `".$this->s_fields["parent_id"]."` = ".$new_parent_id." AND `".$this->s_fields["position"]."` >".($type != "after" ? "=" : "")." ".$new_position;
+      }
+      // Move the node to the new position
+      if($mode == "create") {
+        $fields[] = "`".$this->s_fields["parent_id"]."`";
+        $fields[] = "`".$this->s_fields["position"]."`";
+        $values[] = $new_parent_id;
+        $values[] = $new_position;
+      }
+      else {
+        $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = ".$new_position.", `".$this->s_fields["parent_id"]."` = ".$new_parent_id." WHERE `".$this->s_fields["id"]."` = ".(int)$id;
+      }
+    }
+
+    // If the tree maintains a nested set
+    if($this->nestedset) {
+      $this->db->query("SELECT `".$this->s_fields["id"]."` AS id, `".$this->s_fields["left"]."` AS lft, `".$this->s_fields["right"]."` AS rgt, `".$this->s_fields["level"]."` AS lvl FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` IN(".(int)$id.",".(int)$ref_id.")");
+      while($this->db->nextr()) {
+        if($id == $this->db->f("id")) {
+          $nod_lft = (int)$this->db->f("lft");
+          $nod_rgt = (int)$this->db->f("rgt");
+          $dif = $nod_rgt - $nod_lft + 1;
+        }
+        if($ref_id == $this->db->f("id")) {
+          $ref_lft = (int)$this->db->f("lft");
+          $ref_rgt = (int)$this->db->f("rgt");
+          $ref_lvl = (int)$this->db->f("lvl");
+        }
+      }
+
+      if($mode == "move") {
+        $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` - ".$dif." WHERE `".$this->s_fields["left"]."` > ".$nod_rgt;
+        $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` - ".$dif." WHERE `".$this->s_fields["right"]."` > ".$nod_rgt;
+        if($ref_lft > $nod_rgt) $ref_lft -= $dif;
+        if($ref_rgt > $nod_rgt) $ref_rgt -= $dif;
+      }
+      else $dif = 2;
+
+      $ids = array();
+      if($mode == "move") {
+        $this->db->query("SELECT `".$this->s_fields["id"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["left"]."` >= ".$nod_lft." AND `".$this->s_fields["right"]."` <= ".$nod_rgt);
+        while($this->db->nextr()) $ids[] = (int)$this->db->f(0);
+      } 
+      else $ids[] = -1;
+
+      switch($type) {
+        case "before":
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + ".$dif." WHERE `".$this->s_fields["left"]."` >= ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + ".$dif." WHERE `".$this->s_fields["right"]."` > ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
+          if($mode == "move") {
+            $dif = $ref_lft - $nod_lft;
+            $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["level"]."` = ".(int)$ref_lvl.", `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + (".$dif."), `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + (".$dif.") WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).") ";
+          }
+          else {
+            $fields[] = "`".$this->s_fields["level"]."`";
+            $fields[] = "`".$this->s_fields["left"]."`";
+            $fields[] = "`".$this->s_fields["right"]."`";
+            $values[] = (int)$ref_lvl;
+            $values[] = (int)$ref_lft;
+            $values[] = ((int)$ref_lft + 2);
+          }
+          break;
+        case "after":
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + ".$dif." WHERE `".$this->s_fields["left"]."` > ".$ref_rgt." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + ".$dif." WHERE `".$this->s_fields["right"]."` > ".$ref_rgt." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
+          if($mode == "move") {
+            $dif = ($ref_rgt + 1) - $nod_lft;
+            $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["level"]."` = ".(int)$ref_lvl.", `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + (".$dif."), `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + (".$dif.") WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).") ";
+          } else {
+            $fields[] = "`".$this->s_fields["level"]."`";
+            $fields[] = "`".$this->s_fields["left"]."`";
+            $fields[] = "`".$this->s_fields["right"]."`";
+            $values[] = (int)$ref_lvl;
+            $values[] = ((int)$ref_rgt + 1);
+            $values[] = ((int)$ref_rgt + 3);
+          }
+          break;
+        case "inside":
+        default:
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + ".$dif." WHERE `".$this->s_fields["left"]."` > ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
+          $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + ".$dif." WHERE `".$this->s_fields["right"]."` > ".$ref_lft." AND `".$this->s_fields["id"]."` NOT IN(".implode(",",$ids).") ";
+          if($mode == "move") {
+            $dif = ($ref_lft + 1) - $nod_lft;
+            $sql[] = "UPDATE `".$this->s_table."` SET `".$this->s_fields["level"]."` = ".(int)($ref_lvl + 1).", `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` + (".$dif."), `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` + (".$dif.") WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).") ";
+          }
+          else {
+            $fields[] = "`".$this->s_fields["level"]."`";
+            $fields[] = "`".$this->s_fields["left"]."`";
+            $fields[] = "`".$this->s_fields["right"]."`";
+            $values[] = ((int)$ref_lvl + 1);
+            $values[] = ((int)$ref_lft + 1);
+            $values[] = ((int)$ref_lft + 3);
+          }
+          break;
+      }
+    }
+    
+    // If creating a new node
+    if($mode == "create") $sql[] = "INSERT INTO `".$this->s_table."` (".implode(",",$fields).") VALUES (".implode(",",$values).")";
+
+    // Applying all changes - there should be a transaction here
+    foreach($sql as $q) { $this->db->query($q); }
+
+    if($mode == "create") return mysql_insert_id();
+  }
+
+  // Function for removing nodes
+  // ID is the node (or array of nodes) that is being removed
+  function remove($id) {
+    if(is_array($id)) {
+      foreach($id as $i) { $this->remove($i); }
+      return;
+    }
+    if(!(int)$id) return false;
+
+    // Take care of nested sets (and adjacency at the same time if applicable)
+    if($this->nestedset) {
+      $this->db->query("SELECT `".$this->s_fields["left"]."` AS lft, `".$this->s_fields["right"]."` AS rgt ".( ($this->adjacency) ? " , `".$this->s_fields["parent_id"]."` AS pid, `".$this->s_fields["position"]."` AS pos " : "" )." FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$id);
+      $this->db->nextr();
+      if($this->adjacency) {
+        $pid = (int)$this->db->f("pid");
+        $pos = (int)$this->db->f("pos");
+      }
+      $lft = (int)$this->db->f("lft");
+      $rgt = (int)$this->db->f("rgt");
+      $dif = $rgt - $lft + 1;
+
+      $this->db->query("DELETE FROM `".$this->s_table."` WHERE `".$this->s_fields["left"]."` >= ".$lft." AND `".$this->s_fields["right"]."` <= ".$rgt);
+      $this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["left"]."` = `".$this->s_fields["left"]."` - ".$dif." WHERE `".$this->s_fields["left"]."` > ".$rgt);
+      $this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["right"]."` = `".$this->s_fields["right"]."` - ".$dif." WHERE `".$this->s_fields["right"]."` > ".$lft);
+      if($this->adjacency) {
+        $this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$pid." AND `".$this->s_fields["position"]."` > ".$pos);
+      }
+      return;
+    }
+    // Only end up here if the tree is adjacency only
+    if($this->adjacency) {
+      $this->db->query("SELECT `".$this->s_fields["parent_id"]."` AS pid, `".$this->s_fields["position"]."` AS pos FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` = ".(int)$id);
+      $this->db->nextr();
+      $pid = (int)$this->db->f("pid");
+      $pos = (int)$this->db->f("pos");
+
+      $tmp = array($id);
+      $ids = array($id);
+      while(count($tmp)) {
+        $t = array_shift($tmp);
+        if($t) {
+          $this->db->query("SELECT `".$this->s_fields["id"]."` FROM `".$this->s_table."` WHERE `".$this->s_fields["parent_id"]."` = ".(int)$t);
+          while($this->db->nextr()) { 
+            array_push($ids, $this->db->f(0));
+            array_push($tmp, $this->db->f(0));
+          }
+        }
+      }
+      $this->db->query("DELETE FROM `".$this->s_table."` WHERE `".$this->s_fields["id"]."` IN (".implode(",",$ids).")");
+      $this->db->query("UPDATE `".$this->s_table."` SET `".$this->s_fields["position"]."` = `".$this->s_fields["position"]."` - 1 WHERE `".$this->s_fields["parent_id"]."` = ".$pid." AND `".$this->s_fields["position"]."` > ".$pos);
+    }
+  }
+
+  function reconstruct() {
+    if(!$this->adjacency || !$this->nestedset) return;
+
+    // не знам защо да не е persistent
+    $this->db->pcn = false;
+
+    $q = "CREATE TEMPORARY TABLE temp_tree (".$this->s_fields["id"]." INTEGER NOT NULL, ".$this->s_fields["parent_id"]." INTEGER NOT NULL, ". $this->s_fields["position"]." INTEGER NOT NULL) type=HEAP";
+    $this->db->query($q);
+
+    $q = "INSERT INTO temp_tree SELECT ".$this->s_fields["id"].", ".$this->s_fields["parent_id"].", ".$this->s_fields["position"]." FROM ".$this->s_table;
+    $this->db->query($q);
+
+
+    $q = "CREATE TEMPORARY TABLE temp_stack (".$this->s_fields["id"]." INTEGER NOT NULL, ".$this->s_fields["left"]." INTEGER, ".$this->s_fields["right"]." INTEGER, ".$this->s_fields["level"]." INTEGER, stack_top INTEGER NOT NULL, ".$this->s_fields["parent_id"]." INTEGER, ".$this->s_fields["position"]." INTEGER) type=HEAP";
+    $this->db->query($q);
+    $counter = 2;
+
+    $q = "SELECT COUNT(*) as maxcounter FROM temp_tree";
+    $this->db->query($q);
+    $this->db->nextr();
+    $maxcounter = (int) $this->db->f("maxcounter") * 2;
+    $currenttop = 1;
+
+    $q = "INSERT INTO temp_stack SELECT ".$this->s_fields["id"].", 1, NULL, 0, 1, ".$this->s_fields["parent_id"].", ".$this->s_fields["position"]." FROM temp_tree WHERE ".$this->s_fields["parent_id"]." = 0";
+    $this->db->query($q);
+
+    $q = "DELETE FROM temp_tree WHERE ".$this->s_fields["parent_id"]." = 0";
+    $this->db->query($q);
+
+    while ($counter <= $maxcounter) {
+      $q = "SELECT temp_tree.".$this->s_fields["id"]." AS tempmin, temp_tree.".$this->s_fields["parent_id"]." AS pid, temp_tree.".$this->s_fields["position"]." AS lid FROM temp_stack, temp_tree WHERE temp_stack.".$this->s_fields["id"]." = temp_tree.".$this->s_fields["parent_id"]." AND temp_stack.stack_top = ".$currenttop." ORDER BY temp_tree.".$this->s_fields["position"]." ASC LIMIT 1";
+      $this->db->query($q);
+
+      if ($this->db->nextr()) {
+        $tmp = $this->db->f("tempmin");
+
+        $q = "INSERT INTO temp_stack (stack_top, ".$this->s_fields["id"].", ".$this->s_fields["left"].", ".$this->s_fields["right"].", ".$this->s_fields["level"].", ".$this->s_fields["parent_id"].", ".$this->s_fields["position"].") VALUES(".($currenttop + 1).", ".$tmp.", ".$counter.", NULL, ".$currenttop.", ".$this->db->f("pid").", ".$this->db->f("lid").")";
+        $this->db->query($q);
+        $q = "DELETE FROM temp_tree WHERE ".$this->s_fields["id"]." = ".$tmp;
+        $this->db->query($q);
+        $counter++;
+        $currenttop++;
+      }
+      else {
+        $q = "UPDATE temp_stack SET ".$this->s_fields["right"]." = ".$counter.", stack_top = -stack_top WHERE stack_top = ".$currenttop;
+        $this->db->query($q);
+        $counter++;
+        $currenttop--;
+      }
+    }
+
+    $q = "TRUNCATE TABLE ".$this->s_table;
+    $this->db->query($q);
+
+    $q = "INSERT INTO ".$this->s_table." SELECT ".$this->s_fields["id"].", ".$this->s_fields["parent_id"].", ".$this->s_fields["position"].", ".$this->s_fields["left"].", ".$this->s_fields["right"].", ".$this->s_fields["level"]." FROM temp_stack ORDER BY ".$this->s_fields["id"];
+    $this->db->query($q);
+  }
+
+  function analyze() {
+    $this->errors = array();
+    if($this->adjacency) {
+      $this->db->query("SELECT COUNT(*) FROM ".$this->s_table." s WHERE ".$this->s_fields["parent_id"]." != 0 AND (SELECT COUNT(*) FROM ".$this->s_table." WHERE ".$this->s_fields["id"]." = s.".$this->s_fields["parent_id"].") = 0 ");
+      $this->db->nextr();
+      if($this->db->f(0) > 0) $this->errors[] = "Missing parents.";
+    }
+    if($this->nestedset) {
+      $this->db->query("SELECT MAX(".$this->s_fields["right"].") FROM ".$this->s_table);
+      $this->db->nextr();
+      $n = $this->db->f(0);
+      $this->db->query("SELECT COUNT(*) FROM ".$this->s_table);
+      $this->db->nextr();
+      $c = $this->db->f(0);
+      if($n/2 != $c) $this->errors[] = "Right index does not match node count.";
+    }
+    if($this->adjacency && $this->nestedset) {
+      $this->db->query("SELECT COUNT(".$this->s_fields["id"].") FROM ".$this->s_table." s WHERE (SELECT COUNT(*) FROM ".$this->s_table." WHERE ".$this->s_fields["right"]." < s.".$this->s_fields["right"]." AND ".$this->s_fields["left"]." > s.".$this->s_fields["left"]." AND ".$this->s_fields["level"]." = s.".$this->s_fields["level"]." + 1) != (SELECT COUNT(*) FROM ".$this->s_table." WHERE ".$this->s_fields["parent_id"]." = s.".$this->s_fields["id"].") ");
+      $this->db->nextr();
+      if($this->db->f(0) > 0) $this->errors = "Adjacency and nested set do not match.";
+    }
+    return $error;
+  }
 }
 }
 ?>
 ?>

+ 73 - 73
tripal_cv/theme/js/jsTree/reference/_examples/full/_inc/database.php

@@ -1,85 +1,85 @@
 <?
 <?
-define ("server"	, $server );
-define ("db_user"	, $db_user);
-define ("db_pass"	, $db_pass);
-define ("only_db"	, $only_db);
+define ("server"  , $server );
+define ("db_user"  , $db_user);
+define ("db_pass"  , $db_pass);
+define ("only_db"  , $only_db);
 
 
 class DB {
 class DB {
-	var $srv = server;
-	var $usr = db_user;
-	var $pwd = db_pass;
-	var $odb = only_db;
-	var $pcn = false;
-	var $doe = true;
-	var $fel = true;
-	var $error_log = "mysql_errors.log";
+  var $srv = server;
+  var $usr = db_user;
+  var $pwd = db_pass;
+  var $odb = only_db;
+  var $pcn = false;
+  var $doe = true;
+  var $fel = true;
+  var $error_log = "mysql_errors.log";
 
 
-	function connect(){
-		if (!$this->link){
-			$this->link = ($this->pcn) ? mysql_pconnect($this->srv, $this->usr, $this->pwd) : 
-										 mysql_connect( $this->srv, $this->usr, $this->pwd) or 
-										 $this->error();
-		}
-		if (!mysql_select_db($this->odb,$this->link)) $this->error();
-		if($this->link) mysql_query("SET NAMES 'utf8'");
-		return ($this->link) ? true : false;
-	}
+  function connect(){
+    if (!$this->link){
+      $this->link = ($this->pcn) ? mysql_pconnect($this->srv, $this->usr, $this->pwd) : 
+                     mysql_connect( $this->srv, $this->usr, $this->pwd) or 
+                     $this->error();
+    }
+    if (!mysql_select_db($this->odb,$this->link)) $this->error();
+    if($this->link) mysql_query("SET NAMES 'utf8'");
+    return ($this->link) ? true : false;
+  }
 
 
-	function query($sql){
-		if (!$this->link && !$this->connect()) $this->error();
-		if (!($this->result = mysql_query($sql, $this->link))) $this->error($sql);
-		return ($this->result) ? true : false;
-	}
-	
-	function nextr(){
-		if (!$this->result) die ("No query pending");
-		unset($this->row);
-		$this->row = mysql_fetch_array($this->result, MYSQL_BOTH);
-		return ($this->row) ? true : false ;
-	}
+  function query($sql){
+    if (!$this->link && !$this->connect()) $this->error();
+    if (!($this->result = mysql_query($sql, $this->link))) $this->error($sql);
+    return ($this->result) ? true : false;
+  }
+  
+  function nextr(){
+    if (!$this->result) die ("No query pending");
+    unset($this->row);
+    $this->row = mysql_fetch_array($this->result, MYSQL_BOTH);
+    return ($this->row) ? true : false ;
+  }
 
 
-	function f($index){
-		return stripslashes($this->row[$index]);
-	}
+  function f($index){
+    return stripslashes($this->row[$index]);
+  }
 
 
-	function goto($row){
-		if (!$this->result) die ("No query pending");
-		if (!mysql_data_seek($this->result, $row)) $this->error();
-	}
+  function goto($row){
+    if (!$this->result) die ("No query pending");
+    if (!mysql_data_seek($this->result, $row)) $this->error();
+  }
 
 
-	function nf(){
-		if ($numb = mysql_num_rows($this->result) === false) $this->error();
-		return mysql_num_rows($this->result);
-	}
-	function af(){
-		return mysql_affected_rows();
-	}
-	function error($string=""){
-		echo $error = mysql_error();
-		if ($this->fel){
-			$fp = fopen($this->error_log,"a+");
-			fwrite($fp, "[".date("Y-m-d H:i:s")."]<".$error.">$string\n");
-			fclose($fp);
-		}
-		if ($this->doe){
-			if (isset($this->result)) mysql_free_result($this->result);
-			mysql_close($this->link);
-			die();
-		}
-	}
-	function insert_id(){
-		if(!$this->link) return false;
-		return mysql_insert_id();
-	}
-	function escape($string){
-		if(!$this->link) return addslashes($string);
-		return mysql_real_escape_string($string);
-	}
+  function nf(){
+    if ($numb = mysql_num_rows($this->result) === false) $this->error();
+    return mysql_num_rows($this->result);
+  }
+  function af(){
+    return mysql_affected_rows();
+  }
+  function error($string=""){
+    echo $error = mysql_error();
+    if ($this->fel){
+      $fp = fopen($this->error_log,"a+");
+      fwrite($fp, "[".date("Y-m-d H:i:s")."]<".$error.">$string\n");
+      fclose($fp);
+    }
+    if ($this->doe){
+      if (isset($this->result)) mysql_free_result($this->result);
+      mysql_close($this->link);
+      die();
+    }
+  }
+  function insert_id(){
+    if(!$this->link) return false;
+    return mysql_insert_id();
+  }
+  function escape($string){
+    if(!$this->link) return addslashes($string);
+    return mysql_real_escape_string($string);
+  }
 
 
-	function destroy(){
-		if (isset($this->result)) mysql_free_result($this->result);
-		if (isset($this->link_id)) mysql_close($this->link_id);
-	}
+  function destroy(){
+    if (isset($this->result)) mysql_free_result($this->result);
+    if (isset($this->link_id)) mysql_close($this->link_id);
+  }
 
 
 
 
 }
 }

+ 81 - 81
tripal_cv/theme/js/jsTree/reference/_examples/full/server.php

@@ -1,9 +1,9 @@
 <?
 <?
 // Configure database
 // Configure database
-$server		= "localhost";
-$db_user	= "********";
-$db_pass	= "********";
-$only_db	= "********";
+$server    = "localhost";
+$db_user  = "********";
+$db_pass  = "********";
+$only_db  = "********";
 
 
 // Include required classes
 // Include required classes
 require_once("_inc/database.php");
 require_once("_inc/database.php");
@@ -20,86 +20,86 @@ while($db->nextr()) { $languages[$db->f(0)] = array($db->f(1),$db->f(2)); }
 
 
 // SERVER SIDE PART
 // SERVER SIDE PART
 if(isset($_REQUEST["server"])) {
 if(isset($_REQUEST["server"])) {
-	// Make sure nothing is cached
-	header("Cache-Control: must-revalidate");
-	header("Cache-Control: post-check=0, pre-check=0", false);
-	header("Pragma: no-cache");
-	header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")-2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
-	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
+  // Make sure nothing is cached
+  header("Cache-Control: must-revalidate");
+  header("Cache-Control: post-check=0, pre-check=0", false);
+  header("Pragma: no-cache");
+  header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")-2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");
+  header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 
 
-	
-	switch($_REQUEST["type"]) {
-		 case "list":
-			$id = (int)str_replace("node_","",$_REQUEST["id"]);
-			$db->query("SELECT s.id, ( SELECT COUNT(*) FROM structure WHERE parent_id = s.id ) AS children, c.language, c.name FROM structure s LEFT JOIN content c ON c.id = s.id WHERE s.parent_id = ".$id." ORDER BY position");
-			$data = array();
-			$children = array();
-			while($db->nextr()) {
-				$children[$db->f("id")] = (int)$db->f("children");
-				$data[$db->f("id")][$db->f("language")] = $db->f("name");
-			}
-			echo "[\n";
-			$i = 0;
-			foreach($data as $k => $v) {
-				echo "{\n";
-				echo "\tattributes: {\n";
-				echo "\t\tid :  'node_".$k."'\n";
-				echo "\t},\n";
-				if($children[$k]) echo "\tstate: 'closed', \n";
-				echo "\tdata: {\n";
-				$kf = 0;
-				foreach($v as $lang => $name) {
-					if($kf > 0)	echo ",\n";
-					else		echo "\n";
-					$kf ++;
-					echo "\t\t'".$languages[$lang][0]."' : { title : '".$name."' }"; 
-				}
-				echo "\n";
-				echo "\t}\n";
-				echo "}";
-				if(++$i < count($data)) echo ",";
-				echo "\n";
-			}
-			echo "\n]";
-			break;
-		case "delete":
-			$id = (int)str_replace("node_","",$_REQUEST["id"]);
-			$tree->remove($id);
-			$db->query("DELETE FROM content WHERE id = ".$id);
-			echo "OK";
-			break;
+  
+  switch($_REQUEST["type"]) {
+     case "list":
+      $id = (int)str_replace("node_","",$_REQUEST["id"]);
+      $db->query("SELECT s.id, ( SELECT COUNT(*) FROM structure WHERE parent_id = s.id ) AS children, c.language, c.name FROM structure s LEFT JOIN content c ON c.id = s.id WHERE s.parent_id = ".$id." ORDER BY position");
+      $data = array();
+      $children = array();
+      while($db->nextr()) {
+        $children[$db->f("id")] = (int)$db->f("children");
+        $data[$db->f("id")][$db->f("language")] = $db->f("name");
+      }
+      echo "[\n";
+      $i = 0;
+      foreach($data as $k => $v) {
+        echo "{\n";
+        echo "\tattributes: {\n";
+        echo "\t\tid :  'node_".$k."'\n";
+        echo "\t},\n";
+        if($children[$k]) echo "\tstate: 'closed', \n";
+        echo "\tdata: {\n";
+        $kf = 0;
+        foreach($v as $lang => $name) {
+          if($kf > 0)  echo ",\n";
+          else    echo "\n";
+          $kf ++;
+          echo "\t\t'".$languages[$lang][0]."' : { title : '".$name."' }"; 
+        }
+        echo "\n";
+        echo "\t}\n";
+        echo "}";
+        if(++$i < count($data)) echo ",";
+        echo "\n";
+      }
+      echo "\n]";
+      break;
+    case "delete":
+      $id = (int)str_replace("node_","",$_REQUEST["id"]);
+      $tree->remove($id);
+      $db->query("DELETE FROM content WHERE id = ".$id);
+      echo "OK";
+      break;
 
 
-		case "create":
-		case "move":
-			$id		= (int)str_replace("node_","",$_REQUEST["id"]);
-			$ref_id	= (int)str_replace("node_","",$_REQUEST["ref_id"]);
-			$type	= $_REQUEST["move_type"];
-			$result = $tree->move($id,$ref_id,$type);
-			if($id == 0) {
-				foreach($languages as $k => $lang) {
-					$db->query("INSERT INTO content (id,language,name,data) VALUES(".$result.",".$k.",'New folder','')");
-				}
-				echo "node_".$result;
-			}
-			break;
-		case "rename":
-			$sql = "UPDATE content SET name = '".addslashes($_REQUEST["data"])."' WHERE id = ".(int)str_replace("node_","",$_REQUEST["id"])." AND language = ".(int)$_REQUEST["lang"];
-			$db->query($sql);
-			echo $sql;
-			break;
+    case "create":
+    case "move":
+      $id    = (int)str_replace("node_","",$_REQUEST["id"]);
+      $ref_id  = (int)str_replace("node_","",$_REQUEST["ref_id"]);
+      $type  = $_REQUEST["move_type"];
+      $result = $tree->move($id,$ref_id,$type);
+      if($id == 0) {
+        foreach($languages as $k => $lang) {
+          $db->query("INSERT INTO content (id,language,name,data) VALUES(".$result.",".$k.",'New folder','')");
+        }
+        echo "node_".$result;
+      }
+      break;
+    case "rename":
+      $sql = "UPDATE content SET name = '".addslashes($_REQUEST["data"])."' WHERE id = ".(int)str_replace("node_","",$_REQUEST["id"])." AND language = ".(int)$_REQUEST["lang"];
+      $db->query($sql);
+      echo $sql;
+      break;
 
 
 
 
-		case "loadfile":
-			$db->query("SELECT * FROM content WHERE id = ".(int)str_replace("node_","",$_REQUEST["id"])." AND language = ".(int)$_REQUEST["lang"]);
-			$db->nextr();
-			echo $db->f("data");
-			break;
-		case "savefile":
-			$sql = "UPDATE content SET data = '".addslashes($_REQUEST["data"])."' WHERE id = ".(int)str_replace("node_","",$_REQUEST["id"])." AND language = ".(int)$_REQUEST["lang"];
-			$db->query($sql);
-			echo $sql;
-			break;
-	}
-	exit();
+    case "loadfile":
+      $db->query("SELECT * FROM content WHERE id = ".(int)str_replace("node_","",$_REQUEST["id"])." AND language = ".(int)$_REQUEST["lang"]);
+      $db->nextr();
+      echo $db->f("data");
+      break;
+    case "savefile":
+      $sql = "UPDATE content SET data = '".addslashes($_REQUEST["data"])."' WHERE id = ".(int)str_replace("node_","",$_REQUEST["id"])." AND language = ".(int)$_REQUEST["lang"];
+      $db->query($sql);
+      echo $sql;
+      break;
+  }
+  exit();
 }
 }
 ?>
 ?>

+ 12 - 12
tripal_cv/tripal_cv.module

@@ -158,18 +158,6 @@ function tripal_cv_menu() {
     'access arguments' => array('administer controlled vocabularies'),
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
-
-  /*
-   * Charts
-   */
-  $items['tripal_cv_chart'] = array(
-    'path' => 'tripal_cv_chart',
-    'page callback' => 'tripal_cv_chart',
-    'page arguments' => array(1),
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK
-  );
-
   /*
   /*
    * Menu items for enabling views
    * Menu items for enabling views
    */
    */
@@ -187,6 +175,18 @@ function tripal_cv_menu() {
     'access arguments' => array('administer controlled vocabularies'),
     'access arguments' => array('administer controlled vocabularies'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
+  
+  /*
+   * Charts
+  */
+  $items['tripal_cv_chart'] = array(
+    'path' => 'tripal_cv_chart',
+    'page callback' => 'tripal_cv_chart',
+    'page arguments' => array(1),
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK
+  );
+  
 
 
   /*
   /*
    * Menu items for working with CV Trees
    * Menu items for working with CV Trees

+ 2 - 2
tripal_db/tripal_db.module

@@ -74,14 +74,14 @@ function tripal_db_menu() {
     'title' => 'Enable Database Administrative View',
     'title' => 'Enable Database Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_db_admin_dbs', 'admin/tripal/chado/tripal_db'),
     'page arguments' => array('tripal_db_admin_dbs', 'admin/tripal/chado/tripal_db'),
-    'access arguments' => array('administer controlled vocabularies'),
+    'access arguments' => array('administer db cross-references'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/chado/tripal_db/views/dbxrefs/enable'] = array(
   $items['admin/tripal/chado/tripal_db/views/dbxrefs/enable'] = array(
     'title' => 'Enable Reference Administrative View',
     'title' => 'Enable Reference Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_db_admin_dbxrefs', 'admin/tripal/chado/tripal_db'),
     'page arguments' => array('tripal_db_admin_dbxrefs', 'admin/tripal/chado/tripal_db'),
-    'access arguments' => array('administer controlled vocabularies'),
+    'access arguments' => array('administer db cross-references'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 

+ 54 - 53
tripal_feature/includes/tripal_feature.blocks.inc

@@ -42,6 +42,7 @@ function tripal_feature_block_info() {
 
 
   return $blocks;
   return $blocks;
 }
 }
+
 /**
 /**
  *
  *
  *
  *
@@ -55,59 +56,59 @@ function tripal_feature_block_view($delta = '') {
 
 
     $block = array();
     $block = array();
     switch ($delta) {
     switch ($delta) {
-    	case 'references':
-    	  $block['subject'] = t('References');
-    	  $block['content'] = theme('tripal_feature_references', $node);
-    	  break;
-    	case 'base':
-    	  $block['subject'] = t('Feature Details');
-    	  $block['content'] = theme('tripal_feature_base', $node);
-    	  break;
-    	case 'synonyms':
-    	  $block['subject'] = t('Synonyms');
-    	  $block['content'] = theme('tripal_feature_synonyms', $node);
-    	  break;
-    	case 'properties':
-    	  $block['subject'] = t('Properties');
-    	  $block['content'] = theme('tripal_feature_properties', $node);
-    	  break;
-    	case 'terms':
-    	  $block['subject'] = t('Annotated Terms');
-    	  $block['content'] = theme('tripal_feature_terms', $node);
-    	  break;
-    	case 'sequence':
-    	  $block['subject'] = t('Sequence');
-    	  $block['content'] = theme('tripal_feature_sequence', $node);
-    	  break;
-    	case 'featureloc_sequences':
-    	  $block['subject'] = t('Formatted Sequences');
-    	  $block['content'] = theme('tripal_feature_featureloc_sequences', $node);
-    	  break;
-    	case 'alignments':
-    	  $block['subject'] = t('Alignments');
-    	  $block['content'] = theme('tripal_feature_alignments', $node);
-    	  break;
-    	case 'relationships':
-    	  $block['subject'] = t('Relationships');
-    	  $block['content'] = theme('tripal_feature_relationships', $node);
-    	  break;
-    	case 'org_feature_counts':
-    	  $block['subject'] = t('Feature Type Summary');
-    	  $block['content'] = theme('tripal_organism_feature_counts', array('node' => $node));
-    	  break;
-    	case 'org_feature_browser':
-    	  $block['subject'] = t('Feature Browser');
-    	  $block['content'] = theme('tripal_organism_feature_browser', array('node' => $node));
-    	  break;
-    	case 'library_feature_browser':
-    	  $block['subject'] = t('Library Feature Browser');
-    	  $block['content'] = theme('tripal_library_feature_browser', $node);
-    	  break;
-    	case 'analysis_feature_browser':
-    	  $block['subject'] = t('Analysis Feature Browser');
-    	  $block['content'] = theme('tripal_analysis_feature_browser', $node);
-    	  break;
-    	default :
+      case 'references':
+        $block['subject'] = t('References');
+        $block['content'] = theme('tripal_feature_references', $node);
+        break;
+      case 'base':
+        $block['subject'] = t('Feature Details');
+        $block['content'] = theme('tripal_feature_base', $node);
+        break;
+      case 'synonyms':
+        $block['subject'] = t('Synonyms');
+        $block['content'] = theme('tripal_feature_synonyms', $node);
+        break;
+      case 'properties':
+        $block['subject'] = t('Properties');
+        $block['content'] = theme('tripal_feature_properties', $node);
+        break;
+      case 'terms':
+        $block['subject'] = t('Annotated Terms');
+        $block['content'] = theme('tripal_feature_terms', $node);
+        break;
+      case 'sequence':
+        $block['subject'] = t('Sequence');
+        $block['content'] = theme('tripal_feature_sequence', $node);
+        break;
+      case 'featureloc_sequences':
+        $block['subject'] = t('Formatted Sequences');
+        $block['content'] = theme('tripal_feature_featureloc_sequences', $node);
+        break;
+      case 'alignments':
+        $block['subject'] = t('Alignments');
+        $block['content'] = theme('tripal_feature_alignments', $node);
+        break;
+      case 'relationships':
+        $block['subject'] = t('Relationships');
+        $block['content'] = theme('tripal_feature_relationships', $node);
+        break;
+      case 'org_feature_counts':
+        $block['subject'] = t('Feature Type Summary');
+        $block['content'] = theme('tripal_organism_feature_counts', array('node' => $node));
+        break;
+      case 'org_feature_browser':
+        $block['subject'] = t('Feature Browser');
+        $block['content'] = theme('tripal_organism_feature_browser', array('node' => $node));
+        break;
+      case 'library_feature_browser':
+        $block['subject'] = t('Library Feature Browser');
+        $block['content'] = theme('tripal_library_feature_browser', $node);
+        break;
+      case 'analysis_feature_browser':
+        $block['subject'] = t('Analysis Feature Browser');
+        $block['content'] = theme('tripal_analysis_feature_browser', $node);
+        break;
+      default :
     }
     }
     return $block;
     return $block;
   }
   }

+ 24 - 2
tripal_feature/includes/tripal_feature.chado_node.inc

@@ -630,9 +630,31 @@ function tripal_feature_node_presave($node) {
   // set the title to ensure it is always unique
   // set the title to ensure it is always unique
   switch ($node->type) {
   switch ($node->type) {
     case 'chado_feature':
     case 'chado_feature':
-      $values = array('organism_id' => $node->organism_id);
+      // for a form submission the fields part of the node object
+      // but for a sync the feilds are in an object of the node
+      $name = '';
+      $uname = '';
+      $type = ''; 
+      $organism_id = null;
+      if(property_exists($node, 'feature')) {
+        $organism_id = $node->feature->organism_id;
+        $name        = $node->feature->name;
+        $uname       = $node->feature->uniquname;
+        $type_id     = $node->feature->type_id;
+        $values = array('cvterm_id' => $type_id);
+        $ftype = tripal_core_chado_select('cv', array('name'), $values);
+        $type = $ftype[0]->name;
+        
+      }
+      else {
+        $organism_id = $node->organism_id;
+        $name = $node->name;
+        $uname = $node->uniquname;
+        $type = $node->feature_type;
+      }
+      $values = array('organism_id' => $organism_id);
       $organism = tripal_core_chado_select('organism', array('genus', 'species'), $values);
       $organism = tripal_core_chado_select('organism', array('genus', 'species'), $values);
-      $node->title = $node->fname . ', ' . $node->uniquename . ' (' . $node->feature_type . ') ' . $organism[0]->genus . ' ' . $organism[0]->species;
+      $node->title = $fname . ', ' . $uniquename . ' (' . $type . ') ' . $organism[0]->genus . ' ' . $organism[0]->species;
       break;
       break;
   }
   }
 }
 }

+ 5 - 9
tripal_feature/includes/tripal_feature.seq_extract.inc

@@ -38,16 +38,12 @@ function tripal_feature_seq_extract_page() {
   // generate the search form 
   // generate the search form 
   $output .= '';
   $output .= '';
   if (user_access('access administration pages')) { 
   if (user_access('access administration pages')) { 
-    $output .= "
-      <div class=\"tripal-no-results\">
-        <p>Administrators, the " . l('organism_feature_count', 'admin/tripal/mviews') . " and 
-        " . l('analysis_organism', 'admin/tripal/mviews') . " materialized
+    $output .= theme('tripal_admin_message', array('message' => "
+        Administrators, the " . l('organism_feature_count', 'admin/tripal/schema/mviews') . " and 
+        " . l('analysis_organism', 'admin/tripal/schema/mviews') . " materialized
         views must be populated before using this form.  Those views should be re-populated 
         views must be populated before using this form.  Those views should be re-populated 
-        when new data is added.  If you use the " . l('jquery_update module', 'http://drupal.org/project/jquery_update') . ", it may break this form.
-        You will need to update the  jquery_update/replace/jquery.form.js file with " .
-        l('a more recent version', 'https://raw.github.com/malsup/form/master/jquery.form.js') . "</p>         
-      </div>
-    ";
+        when new data is added."
+    ));
   }
   }
   $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
   $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
   $output .= drupal_get_form('tripal_feature_seq_extract_form');  
   $output .= drupal_get_form('tripal_feature_seq_extract_form');  

+ 31 - 36
tripal_feature/theme/tripal_organism/tripal_organism_feature_browser.tpl.php

@@ -73,12 +73,11 @@ if ($enabled) {
       $rows = array();
       $rows = array();
       
       
       // let admins know they can customize the terms that appear in the list
       // let admins know they can customize the terms that appear in the list
-      if (user_access('access administration pages')) { ?>
-         <div class="tripal-no-results">Administrators, you can specify the feature types
-         that should appear in this browser or remove it from the list of resources by navigating to the 
-         <?php print l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))) ?>.  
-         </div><?php 
-      }
+      print theme('tripal_admin_message', array('message' => "
+        Administrators, you can specify the feature types that should appear in 
+        this browser or remove it from the list of resources by navigating to the ". 
+        l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank')))
+      ));
       
       
       foreach ($features as $feature){
       foreach ($features as $feature){
         $fname =  $feature->name;
         $fname =  $feature->name;
@@ -127,36 +126,32 @@ if ($enabled) {
       print theme_pager($pager); ?>
       print theme_pager($pager); ?>
     </div> <?php
     </div> <?php
   } 
   } 
-  else {
-    // if there are no results and this is the admin user then show some instructions
-    // otherwise nothing is shown.
-    if(user_access('access administration pages')){ ?>
-      <div id="tripal_organism-feature_browser-box" class="tripal_organism-info-box tripal-info-box">
-        <div class="tripal_organism-info-box-title tripal-info-box-title">Feature Browser</div>
-        <div class="tripal-no-results">
-          There are no features available for browsing
-          <p><br>Administrators, perform the following to show features in this browser:
-          <ul>
-            <li>Load features for this organism using the 
-            <?php print l("FASTA loader", 'admin/tripal/loaders/fasta_loader'); ?>, 
-            <?php print l("GFF Loader",   'admin/tripal/loaders/gff3_load'); ?> or 
-            <?php print l("Bulk Loader",  'admin/tripal/loaders/bulk'); ?></li>
-            <li>Sync the features that should have pages using the 
-            <?php print l("Sync features page", 'admin/tripal/chado/tripal_feature/sync');?></li>
-            <li>Return to this page to browse features.</li>
-            <li>Ensure the user 
-            <?php print l("has permission", 'admin/people/permissions'); ?> to view the feature content</li>
-          </ul> 
-          <br>
-          <br>
-          You can specify the feature types
-          that should appear in this browser or remove it from the list of resources by navigating to the 
-          <?php print l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank'))) ?>.
-          </p>
-          The feature browser will not appear to site visitors unless features are present.  These instructions only appear to site administrators.
-        </div>         
-      </div><?php
-    }
+  else {  ?>
+    <div id="tripal_organism-feature_browser-box" class="tripal_organism-info-box tripal-info-box">
+      <div class="tripal_organism-info-box-title tripal-info-box-title">Feature Browser</div>
+      <p>There are no results.</p><?php
+      print theme('tripal_admin_message', array('message' => "
+        Administrators, perform the following to show features in this browser:
+        <ul>
+          <li>Load features for this organism using the " .
+            l("FASTA loader", 'admin/tripal/loaders/fasta_loader') . ",  ".
+            l("GFF Loader",   'admin/tripal/loaders/gff3_load') . " or ".
+            l("Bulk Loader",  'admin/tripal/loaders/bulk'). "</li>
+          <li>Sync the features that should have pages using the ".
+            l("Sync features page", 'admin/tripal/chado/tripal_feature/sync'). "</li>
+          <li>Return to this page to browse features.</li>
+          <li>Ensure the user " .
+           l("has permission", 'admin/people/permissions') . " to view the feature content</li>
+        </ul>
+        <br>
+        <br>
+        You can specify the feature types
+        that should appear in this browser or remove it from the list of resources by navigating to the " . 
+        l("Tripal feature settings page", "admin/tripal/chado/tripal_feature/configuration", array('attributes' => array('target' => '_blank')))  . "
+        </p>
+        The feature browser will not appear to site visitors unless features are present. "
+      )); ?>
+    </div><?php
   }
   }
 }
 }
 
 

+ 19 - 17
tripal_feature/theme/tripal_organism/tripal_organism_feature_counts.tpl.php

@@ -17,14 +17,17 @@ if ($enabled) {
       <div class="tripal_organism-info-box-title tripal-info-box-title">Data Type Summary</div>
       <div class="tripal_organism-info-box-title tripal-info-box-title">Data Type Summary</div>
       <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following data types are currently present for this organism</div> <?php
       <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following data types are currently present for this organism</div> <?php
       // let admins know they can customize the terms that appear in the list
       // let admins know they can customize the terms that appear in the list
-      if (user_access('access administration pages')) { ?>
-         <div class="tripal-no-results">Administrators, you can customize the types of terms that appear in this report by 
-         navigating to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal 
-         feature configuration page</a> opening the section "Feature Summary Report" and adding the list of
-         terms you want to appear in the list. You can rename terms as well.  To disable this report and 
-         remove it from the list of resources, navigate to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal feature configuration page</a> 
-         and hide the "Feature Summary". To refresh the data,re-populate the <a href="<?php print url('admin/tripal/mviews');?>" target="_blank">organism_feature_count</a> materialized view. 
-         </div><?php 
+      if (user_access('access administration pages')) { 
+         print theme('tripal_admin_message', array('message' => "
+           Administrators, you can customize the types of terms that appear in this report by 
+           navigating to the " . l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration') . "
+           opening the section \"Feature Summary Report\" and adding the list of
+           terms you want to appear in the list. You can rename terms as well.  To disable this report and 
+           remove it from the list of resources, navigate to the " . 
+           l('Tripal feature configuration page', 'admin/tripal/tripal_feature/configuration') . "
+           and hide the \"Feature Summary\". To refresh the data,re-populate the " .
+           l('organism_feature_count', 'admin/tripal/schema/mviews') . " materialized view.")
+         ); 
       }?>
       }?>
       <table id="tripal_organism-table-feature_counts" class="tripal_organism-table tripal-table tripal-table-horz">     
       <table id="tripal_organism-table-feature_counts" class="tripal_organism-table tripal-table tripal-table-horz">     
         <tr class="tripal_organism-table-odd-row tripal-table-even-row">
         <tr class="tripal_organism-table-odd-row tripal-table-even-row">
@@ -52,20 +55,19 @@ if ($enabled) {
     if (user_access('access administration pages')) { ?>
     if (user_access('access administration pages')) { ?>
       <div id="tripal_organism-feature_counts-box" class="tripal_organism-info-box tripal-info-box">
       <div id="tripal_organism-feature_counts-box" class="tripal_organism-info-box tripal-info-box">
         <div class="tripal_organism-info-box-title tripal-info-box-title">Data Type Summary</div>
         <div class="tripal_organism-info-box-title tripal-info-box-title">Data Type Summary</div>
-        <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following data types are currently present for this organism</div>
-        <div class="tripal-no-results">There are no features available.
-           <p><br>Administrators, to view the feature type report:
+        <div class="tripal_organism-info-box-desc tripal-info-box-desc">The following data types are currently present for this organism</div> <?php 
+        print theme('tripal_admin_message', array('message' => "
+           Administrators, to view the feature type report:
            <ul>
            <ul>
-              <li>Populate the <a href="<?php print url('admin/tripal/mviews');?>" target="_blank">organism_feature_count</a> materialized view</li>
+              <li>Populate the " . l('organism_feature_count', 'admin/tripal/schema/mviews') ." materialized view</li>
               <li>Refresh this page</li>
               <li>Refresh this page</li>
            </ul> 
            </ul> 
-           <br><br>To disable this report and remove it from the list of resources:
+           To disable this report and remove it from the list of resources:
            <ul>
            <ul>
-             <li>Navigate to the <a href="<?php print url('admin/tripal/tripal_feature/configuration') ?>">Tripal feature configuration page</a> and hide the "Feature Summary"</li>
+             <li>Navigate to the " . l('Tripal feature configuration page', 'admin/tripal/chado/tripal_feature/configuration') ." and hide the \"Feature Summary\"</li>
             </ul>
             </ul>
-           </p>
-           This page will not appear to site visitors unless features are present. 
-         </div>
+           </p>")
+        ); ?> 
       </div><?php               
       </div><?php               
     }
     }
   }
   }

+ 15 - 15
tripal_feature/tripal_feature.module

@@ -128,12 +128,20 @@ function tripal_feature_menu() {
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 
+  // the menu link for addressing any feature (by name, uniquename, synonym)
+  $items['feature/%'] = array(
+    'page callback' => 'tripal_feature_match_features_page',
+    'page arguments' => array(1),
+    'access arguments' => array('access chado_feature content'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  
   // the administative settings menu
   // the administative settings menu
   $items['admin/tripal/chado/tripal_feature'] = array(
   $items['admin/tripal/chado/tripal_feature'] = array(
     'title' => 'Features',
     'title' => 'Features',
     'description' => 'A biological sequence or a section of a biological sequence, or a collection of such sections.',
     'description' => 'A biological sequence or a section of a biological sequence, or a collection of such sections.',
     'page callback' => 'tripal_feature_admin_feature_view',
     'page callback' => 'tripal_feature_admin_feature_view',
-    'access arguments' => array('administer tripal features'),
+    'access arguments' => array('administer tripal feature'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
   );
   );
 
 
@@ -142,7 +150,7 @@ function tripal_feature_menu() {
     'description' => 'Delete multiple features from Chado',
     'description' => 'Delete multiple features from Chado',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_feature_delete_form'),
     'page arguments' => array('tripal_feature_delete_form'),
-    'access arguments' => array('administer tripal features'),
+    'access arguments' => array('administer tripal feature'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 2
     'weight' => 2
   );
   );
@@ -160,7 +168,7 @@ function tripal_feature_menu() {
     'description' => 'Configure the Tripal Feature module.',
     'description' => 'Configure the Tripal Feature module.',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_feature_admin'),
     'page arguments' => array('tripal_feature_admin'),
-    'access arguments' => array('administer tripal features'),
+    'access arguments' => array('administer tripal feature'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 5
     'weight' => 5
   );
   );
@@ -169,7 +177,7 @@ function tripal_feature_menu() {
     'description' => 'Help with the Tripal Feature module.',
     'description' => 'Help with the Tripal Feature module.',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_feature_help'),
     'page arguments' => array('tripal_feature_help'),
-    'access arguments' => array('administer tripal features'),
+    'access arguments' => array('administer tripal feature'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' =>  10
     'weight' =>  10
   );
   );
@@ -181,7 +189,7 @@ function tripal_feature_menu() {
     'description' => 'Load sequences from a multi-FASTA file into Chado',
     'description' => 'Load sequences from a multi-FASTA file into Chado',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_feature_fasta_load_form'),
     'page arguments' => array('tripal_feature_fasta_load_form'),
-    'access arguments' => array('administer tripal features'),
+    'access arguments' => array('administer tripal feature'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
   );
   );
   $items['admin/tripal/loaders/gff3_load'] = array(
   $items['admin/tripal/loaders/gff3_load'] = array(
@@ -189,18 +197,10 @@ function tripal_feature_menu() {
     'description' => 'Import a GFF3 file into Chado',
     'description' => 'Import a GFF3 file into Chado',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_feature_gff3_load_form'),
     'page arguments' => array('tripal_feature_gff3_load_form'),
-    'access arguments' => array('administer tripal features'),
+    'access arguments' => array('administer tripal feature'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
   );
   );
 
 
-  // the menu link for addressing any feature (by name, uniquename, synonym)
-  $items['feature/%'] = array(
-    'page callback' => 'tripal_feature_match_features_page',
-    'page arguments' => array(1),
-    'access arguments' => array('access chado_feature content'),
-    'type' => MENU_LOCAL_TASK,
-  );
-
   // Enable admin view
   // Enable admin view
   $items['admin/tripal/chado/tripal_feature/views/features/enable'] = array(
   $items['admin/tripal/chado/tripal_feature/views/features/enable'] = array(
     'title' => 'Enable feature Administrative View',
     'title' => 'Enable feature Administrative View',
@@ -1164,4 +1164,4 @@ function tripal_feature_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == "chado_feature_node_form") {
   if ($form_id == "chado_feature_node_form") {
     $form['actions']['preview']['#access'] = FALSE;
     $form['actions']['preview']['#access'] = FALSE;
   }
   }
-}
+}

+ 34 - 29
tripal_featuremap/includes/tripal_featuremap.chado_node.inc

@@ -424,10 +424,15 @@ function chado_featuremap_delete(&$node) {
  * @param $node
  * @param $node
  */
  */
 function tripal_featuremap_node_presave($node) {
 function tripal_featuremap_node_presave($node) {
-  // if this is a chado_featuremap and the $node->featuremap object is set then we
-  // are syncing and we want to set the node title to be the same as the node name
-  if ($node->type == 'chado_featuremap' and property_exists($node, 'featuremap')) {
-    $node->title = $node->featuremap->name;
+  if ($node->type == 'chado_featuremap') {
+    // for a form submission the fields part of the node object
+    // but for a sync the feilds are in an object of the node
+    if(property_exists($node, 'featuremap')) {
+      $node->title = $node->featuremap->name;
+    }
+    else {
+      // the title is already set in the form
+    }
   }
   }
 }
 }
 /**
 /**
@@ -436,30 +441,30 @@ function tripal_featuremap_node_presave($node) {
  */
  */
 function tripal_featuremap_node_view($node, $view_mode, $langcode) {
 function tripal_featuremap_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
   switch ($node->type) {
-  	case 'chado_featuremap':
-  	  // Show feature browser and counts
-  	  if ($view_mode == 'full') {
-  	    $node->content['tripal_featuremap_base'] = array(
-  	      '#value' => theme('tripal_featuremap_base', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_featuremap_featurepos'] = array(
-  	      '#value' => theme('tripal_featuremap_featurepos', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_featuremap_properties'] = array(
-  	      '#value' => theme('tripal_featuremap_properties', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_featuremap_publication'] = array(
-  	      '#value' => theme('tripal_featuremap_publication', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_featuremap_references'] = array(
-  	      '#value' => theme('tripal_featuremap_references', array('node' => $node)),
-  	    );
-  	  }
-  	  if ($view_mode == 'teaser') {
-  	    $node->content['tripal_featuremap_teaser'] = array(
-  	      '#value' => theme('tripal_featuremap_teaser', array('node' => $node)),
-  	    );
-  	  }
-  	  break;
+    case 'chado_featuremap':
+      // Show feature browser and counts
+      if ($view_mode == 'full') {
+        $node->content['tripal_featuremap_base'] = array(
+          '#value' => theme('tripal_featuremap_base', array('node' => $node)),
+        );
+        $node->content['tripal_featuremap_featurepos'] = array(
+          '#value' => theme('tripal_featuremap_featurepos', array('node' => $node)),
+        );
+        $node->content['tripal_featuremap_properties'] = array(
+          '#value' => theme('tripal_featuremap_properties', array('node' => $node)),
+        );
+        $node->content['tripal_featuremap_publication'] = array(
+          '#value' => theme('tripal_featuremap_publication', array('node' => $node)),
+        );
+        $node->content['tripal_featuremap_references'] = array(
+          '#value' => theme('tripal_featuremap_references', array('node' => $node)),
+        );
+      }
+      if ($view_mode == 'teaser') {
+        $node->content['tripal_featuremap_teaser'] = array(
+          '#value' => theme('tripal_featuremap_teaser', array('node' => $node)),
+        );
+      }
+      break;
   }
   }
 }
 }

+ 1 - 19
tripal_featuremap/tripal_featuremap.module

@@ -122,7 +122,7 @@ function tripal_featuremap_menu() {
     'description' => 'Sync featuremaps from Chado with Drupal',
     'description' => 'Sync featuremaps from Chado with Drupal',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_featuremap', 'chado_featuremap'),
     'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_featuremap', 'chado_featuremap'),
-    'access arguments' => array('administer tripal featuremaps'),
+    'access arguments' => array('administer tripal featuremap'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 0
     'weight' => 0
   );
   );
@@ -135,24 +135,6 @@ function tripal_featuremap_menu() {
     'type' => MENU_CALLBACK
     'type' => MENU_CALLBACK
   );
   );
 
 
-  // AJAX calls for adding/removing properties to a featuremap
-  $items['tripal_featuremap/properties/add'] = array(
-    'page callback' => 'tripal_featuremap_property_add',
-    'access arguments' => array('edit chado_featuremap content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_featuremap/properties/description'] = array(
-    'page callback' => 'tripal_featuremap_property_get_description',
-    'access arguments' => array('edit chado_featuremap content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_featuremap/properties/minus/%/%'] = array(
-    'page callback' => 'tripal_featuremap_property_delete',
-    'page arguments' => array(3, 4),
-    'access arguments' => array('edit chado_featuremap content'),
-    'type ' => MENU_CALLBACK,
-  );
-
   $items['admin/tripal/chado/tripal_featuremap/views/featuremaps/enable'] = array(
   $items['admin/tripal/chado/tripal_featuremap/views/featuremaps/enable'] = array(
     'title' => 'Enable featuremap Administrative View',
     'title' => 'Enable featuremap Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',

+ 14 - 0
tripal_genetic/tripal_genetic.module

@@ -13,6 +13,20 @@ require('theme/tripal_genetic.theme.inc');
 require('includes/tripal_genetic.schema.inc');
 require('includes/tripal_genetic.schema.inc');
 require('includes/tripal_genetic.admin.inc');
 require('includes/tripal_genetic.admin.inc');
 
 
+/**
+ *  Set the permission types that the chado module uses.  Essentially we
+ *  want permissionis 
+ *
+ * @ingroup tripal_genetic
+ */
+function tripal_genetic_permission() {
+  return array(
+    'adminster tripal genetic' => array(
+      'title' => t('Administer Genetic Module'),
+      'description' => t('Allow users to administer the genetic module.'),
+    ),
+  );
+}
 /**
 /**
  *  Menu items are automatically added for the new node types created
  *  Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  by this module to the 'Create Content' Navigation menu item.  This function

+ 12 - 4
tripal_library/includes/tripal_library.chado_node.inc

@@ -436,9 +436,17 @@ function tripal_library_node_view($node, $view_mode, $langcode) {
  * @param $node
  * @param $node
  */
  */
 function tripal_library_node_presave($node) {
 function tripal_library_node_presave($node) {
-  // if this is a chado_library and the $node->library object is set then we
-  // are syncing and we want to set the node title to be the same as the node name
-  if ($node->type == 'chado_library' and property_exists($node, 'library')) {
-    $node->title = $node->library->name;
+  switch ($node->type) {
+    case 'chado_library':
+      // for a form submission the fields part of the node object
+      // but for a sync the feilds are in an object of the node
+      if(property_exists($node, 'library')) {
+        // set the title
+        $node->title = $node->name;
+      } 
+      else {
+        // the title field is already in the form
+      }
+      break;
   }
   }
 }
 }

+ 8 - 2
tripal_library/tripal_library.install

@@ -154,8 +154,14 @@ function tripal_library_add_mview_library_feature_count(){
  * Adds new CV's used by this module
  * Adds new CV's used by this module
  */
  */
 function tripal_library_add_cvs(){
 function tripal_library_add_cvs(){
-  tripal_cv_add_cv('library_property', 'Contains properties for libraries');
-  tripal_cv_add_cv('library_type', 'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).');
+  tripal_cv_add_cv(
+    'library_property', 
+    'Contains properties for libraries'
+  );
+  tripal_cv_add_cv(
+    'library_type', 
+    'Contains terms for types of libraries (e.g. BAC, cDNA, FOSMID, etc).'
+  );
 }
 }
 /**
 /**
  * @ingroup tripal_library
  * @ingroup tripal_library

+ 4 - 4
tripal_library/tripal_library.module

@@ -62,7 +62,7 @@ function tripal_library_menu() {
     'title' => 'Libraries',
     'title' => 'Libraries',
     'description' => 'Any biological library. Examples of genomic libraries include BAC, cDNA, FOSMID, etc.',
     'description' => 'Any biological library. Examples of genomic libraries include BAC, cDNA, FOSMID, etc.',
     'page callback' => 'tripal_library_admin_libraries_listing',
     'page callback' => 'tripal_library_admin_libraries_listing',
-    'access arguments' => array('administer tripal libraries'),
+    'access arguments' => array('administer tripal library'),
     'type' => MENU_NORMAL_ITEM,
     'type' => MENU_NORMAL_ITEM,
   );
   );
 
 
@@ -71,7 +71,7 @@ function tripal_library_menu() {
     'description' => 'Basic Description of Tripal Library Module Functionality',
     'description' => 'Basic Description of Tripal Library Module Functionality',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_library_help'),
     'page arguments' => array('tripal_library_help'),
-    'access arguments' => array('administer tripal libraries'),
+    'access arguments' => array('administer tripal library'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -81,7 +81,7 @@ function tripal_library_menu() {
     'description' => 'Configure the Tripal Library module',
     'description' => 'Configure the Tripal Library module',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_library_admin'),
     'page arguments' => array('tripal_library_admin'),
-    'access arguments' => array('administer tripal libraries'),
+    'access arguments' => array('administer tripal library'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 5
     'weight' => 5
   );
   );
@@ -99,7 +99,7 @@ function tripal_library_menu() {
     'title' => 'Enable Library Administrative View',
     'title' => 'Enable Library Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_library_admin_libraries', 'admin/tripal/chado/tripal_library'),
     'page arguments' => array('tripal_library_admin_libraries', 'admin/tripal/chado/tripal_library'),
-    'access arguments' => array('administer tripal libraries'),
+    'access arguments' => array('administer tripal library'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 

+ 17 - 3
tripal_natural_diversity/tripal_natural_diversity.module

@@ -12,6 +12,20 @@ require_once('includes/tripal_natural_diversity.admin.inc');
  * @}
  * @}
  */
  */
 
 
+/**
+ *  Set the permission types that the chado module uses.  Essentially we
+ *  want permissionis
+ *
+ * @ingroup tripal_natural_diversity
+ */
+function tripal_natural_diversity_permission() {
+  return array(
+    'adminster tripal nd' => array(
+      'title' => t('Administer Natural Diversity Module'),
+      'description' => t('Allow users to administer the natural diversity module.'),
+    ),
+  );
+}
 /**
 /**
  *  Menu items are automatically added for the new node types created
  *  Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  by this module to the 'Create Content' Navigation menu item.  This function
@@ -27,7 +41,7 @@ function tripal_natural_diversity_menu() {
    'title' => 'Natural Diversity Experiments',
    'title' => 'Natural Diversity Experiments',
    'description' => 'Experiments relating to natural diversity such as genotype and phenotype experiments.',
    'description' => 'Experiments relating to natural diversity such as genotype and phenotype experiments.',
    'page callback' => 'tripal_natural_diversity_admin_natdiv_view',
    'page callback' => 'tripal_natural_diversity_admin_natdiv_view',
-   'access arguments' => array('adminster tripal natural_diversity'),
+   'access arguments' => array('adminster tripal nd'),
    'type' => MENU_NORMAL_ITEM,
    'type' => MENU_NORMAL_ITEM,
   );
   );
 
 
@@ -36,7 +50,7 @@ function tripal_natural_diversity_menu() {
     'description' => ('Help for the Tripal natural diversity module.'),
     'description' => ('Help for the Tripal natural diversity module.'),
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_natural_diversity_help'),
     'page arguments' => array('tripal_natural_diversity_help'),
-    'access arguments' => array('administer tripal natual_diversity'),
+    'access arguments' => array('administer tripal nd'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -45,7 +59,7 @@ function tripal_natural_diversity_menu() {
     'title' => 'Enable Natural Diversity Administrative View',
     'title' => 'Enable Natural Diversity Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_natural_diversity_admin_natdiv_exp', 'admin/tripal/chado/tripal_natdiv'),
     'page arguments' => array('tripal_natural_diversity_admin_natdiv_exp', 'admin/tripal/chado/tripal_natdiv'),
-    'access arguments' => array('administer tripal natural_diversity'),
+    'access arguments' => array('administer tripal nd'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 

+ 1 - 1
tripal_organism/api/tripal_organism.api.inc

@@ -1,7 +1,7 @@
 <?php
 <?php
 
 
 /**
 /**
- * @defgroup tripal_library_api Organism API
+ * @defgroup tripal_organism_api Organism API
  * @ingroup tripal_api
  * @ingroup tripal_api
  * @{
  * @{
  * Provides an application programming interface (API) to manage organisms
  * Provides an application programming interface (API) to manage organisms

+ 15 - 6
tripal_organism/includes/tripal_organism.chado_node.inc

@@ -260,13 +260,14 @@ function chado_organism_delete($node) {
   $check_feature = chado_query($sql, array(':organism_id' => $organism_id))->fetchObject();
   $check_feature = chado_query($sql, array(':organism_id' => $organism_id))->fetchObject();
   $sql = "SELECT library_id FROM {library} WHERE organism_id = :organism_id";
   $sql = "SELECT library_id FROM {library} WHERE organism_id = :organism_id";
   $check_lib = chado_query($sql, array(':organism_id' => $organism_id))->fetchObject();
   $check_lib = chado_query($sql, array(':organism_id' => $organism_id))->fetchObject();
-
-  if (!$check_lib && !$check_feature) {
+  $sql = "SELECT stock_id FROM {stock} WHERE organism_id = :organism_id";
+  $check_stock = chado_query($sql, array(':organism_id' => $organism_id))->fetchObject();
+  
+  if (!$check_lib && !$check_feature && !$check_stock) {
     tripal_core_chado_delete('organism', array('organism_id' => $organism_id));
     tripal_core_chado_delete('organism', array('organism_id' => $organism_id));
   }
   }
   else {
   else {
-    drupal_set_message(t("Organism deleted from drupal. Warning: at least one " .
-        "library or feature depends on this organism. It was not removed from chado."));
+    drupal_set_message(t("Warning: other data depends on this organism. The organism page was removed from this site but the organism was removed from Chado."), 'warning');
   }
   }
 }
 }
 
 
@@ -412,8 +413,16 @@ function chado_organism_load($nodes) {
 function tripal_organism_node_presave($node) {
 function tripal_organism_node_presave($node) {
   switch ($node->type) {
   switch ($node->type) {
     case 'chado_organism':
     case 'chado_organism':
-      // set the title for the node
-      $node->title = "$node->genus $node->species";
+      // for a form submission the fields part of the node object
+      // but for a sync the feilds are in an object of the node
+      if(property_exists($node, 'organism')) {
+        // set the title
+        $node->title = $node->organism->genus . " " . $node->organism->species;
+      } 
+      else {
+        // set the title
+        $node->title = $node->genus  . " " . $node->species;
+      }
       break;
       break;
   }
   }
 }
 }

+ 1 - 1
tripal_organism/theme/tripal_organism/tripal_organism_description.tpl.php

@@ -6,6 +6,6 @@ $organism = $variables['node']->organism;
    <table id="tripal_organism-table-description" class="tripal_organism-table tripal-table tripal-table-horz">
    <table id="tripal_organism-table-description" class="tripal_organism-table tripal-table tripal-table-horz">
       <tr class="tripal_organism-table-odd-row tripal-table-even-row">
       <tr class="tripal_organism-table-odd-row tripal-table-even-row">
         <td><?php print $organism->comment; ?></td>
         <td><?php print $organism->comment; ?></td>
-      </tr>        	                                
+      </tr>                                          
    </table>
    </table>
 </div>
 </div>

+ 15 - 0
tripal_phenotype/tripal_phenotype.module

@@ -8,6 +8,21 @@
  * @}
  * @}
  */
  */
 
 
+/**
+ *  Set the permission types that the chado module uses.  Essentially we
+ *  want permissionis
+ *
+ * @ingroup tripal_phenotype
+ */
+function tripal_phenotype_permission() {
+  return array(
+    'adminster tripal phenotype' => array(
+      'title' => t('Administer Phenotype Module'),
+      'description' => t('Allow users to administer the phenotype module.'),
+    ),
+  );
+}
+
 /**
 /**
  *  Menu items are automatically added for the new node types created
  *  Menu items are automatically added for the new node types created
  *  by this module to the 'Create Content' Navigation menu item.  This function
  *  by this module to the 'Create Content' Navigation menu item.  This function

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

@@ -408,30 +408,30 @@ function chado_project_node_access($node, $op, $account) {
  */
  */
 function tripal_project_node_view($node, $view_mode, $langcode) {
 function tripal_project_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
   switch ($node->type) {
-  	case 'chado_project':
-  	  // Show feature browser and counts
-  	  if ($view_mode == 'full') {
-  	    $node->content['tripal_project_base'] = array(
-  	      '#value' => theme('tripal_project_base', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_project_contact'] = array(
-  	      '#value' => theme('tripal_project_contact', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_project_properties'] = array(
-  	      '#value' => theme('tripal_project_properties', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_project_publications'] = array(
-  	      '#value' => theme('tripal_project_publications', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_project_relationships'] = array(
-  	      '#value' => theme('tripal_project_relationships', array('node' => $node)),
-  	    );
-  	  }
-  	  if ($view_mode == 'teaser') {
-  	    $node->content['tripal_project_teaser'] = array(
-  	      '#value' => theme('tripal_project_teaser', array('node' => $node)),
-  	    );
-  	  }
-  	  break;
+    case 'chado_project':
+      // Show feature browser and counts
+      if ($view_mode == 'full') {
+        $node->content['tripal_project_base'] = array(
+          '#value' => theme('tripal_project_base', array('node' => $node)),
+        );
+        $node->content['tripal_project_contact'] = array(
+          '#value' => theme('tripal_project_contact', array('node' => $node)),
+        );
+        $node->content['tripal_project_properties'] = array(
+          '#value' => theme('tripal_project_properties', array('node' => $node)),
+        );
+        $node->content['tripal_project_publications'] = array(
+          '#value' => theme('tripal_project_publications', array('node' => $node)),
+        );
+        $node->content['tripal_project_relationships'] = array(
+          '#value' => theme('tripal_project_relationships', array('node' => $node)),
+        );
+      }
+      if ($view_mode == 'teaser') {
+        $node->content['tripal_project_teaser'] = array(
+          '#value' => theme('tripal_project_teaser', array('node' => $node)),
+        );
+      }
+      break;
   }
   }
 }
 }

+ 5 - 5
tripal_project/tripal_project.module

@@ -38,7 +38,7 @@ function tripal_project_menu() {
     'title' => 'Projects',
     'title' => 'Projects',
     'description' => ('A project. Can be used for grouping data such as with the natural diversity module data.'),
     'description' => ('A project. Can be used for grouping data such as with the natural diversity module data.'),
     'page callback' => 'tripal_project_admin_project_view',
     'page callback' => 'tripal_project_admin_project_view',
-    'access arguments' => array('adminster tripal projects'),
+    'access arguments' => array('adminster tripal project'),
     'type' => MENU_NORMAL_ITEM
     'type' => MENU_NORMAL_ITEM
   );
   );
 
 
@@ -47,7 +47,7 @@ function tripal_project_menu() {
     'description' => ("Basic Description of Tripal Project Module Functionality."),
     'description' => ("Basic Description of Tripal Project Module Functionality."),
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_project_help'),
     'page arguments' => array('tripal_project_help'),
-    'access arguments' => array('adminster tripal projects'),
+    'access arguments' => array('adminster tripal project'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 6
     'weight' => 6
   );
   );
@@ -56,7 +56,7 @@ function tripal_project_menu() {
     'title' => 'Settings',
     'title' => 'Settings',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_project_admin'),
     'page arguments' => array('tripal_project_admin'),
-    'access arguments' => array('adminster tripal projects'),
+    'access arguments' => array('adminster tripal project'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 4
     'weight' => 4
   );
   );
@@ -66,7 +66,7 @@ function tripal_project_menu() {
     'description' => 'Create pages on this site for projects stored in Chado',
     'description' => 'Create pages on this site for projects stored in Chado',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_project', 'chado_project'),
     'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_project', 'chado_project'),
-    'access arguments' => array('administer tripal projects'),
+    'access arguments' => array('administer tripal project'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 0
     'weight' => 0
   );
   );
@@ -75,7 +75,7 @@ function tripal_project_menu() {
     'title' => 'Enable Project Administrative View',
     'title' => 'Enable Project Administrative View',
     'page callback' => 'tripal_views_admin_enable_view',
     'page callback' => 'tripal_views_admin_enable_view',
     'page arguments' => array('tripal_project_admin_projects', 'admin/tripal/chado/tripal_project'),
     'page arguments' => array('tripal_project_admin_projects', 'admin/tripal/chado/tripal_project'),
-    'access arguments' => array('administer tripal projects'),
+    'access arguments' => array('administer tripal project'),
     'type' => MENU_CALLBACK,
     'type' => MENU_CALLBACK,
   );
   );
 
 

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

@@ -940,46 +940,46 @@ function chado_pub_delete(&$node) {
  */
  */
 function tripal_pub_node_view($node, $view_mode, $langcode) {
 function tripal_pub_node_view($node, $view_mode, $langcode) {
   switch ($node->type) {
   switch ($node->type) {
-  	case 'chado_pub':
-  	  // Show feature browser and counts
-  	  if ($view_mode == 'full') {
-  	    $node->content['tripal_pub_authors'] = array(
-  	      '#value' => theme('tripal_pub_authors', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_base'] = array(
-  	      '#value' => theme('tripal_pub_base', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_featuremaps'] = array(
-  	      '#value' => theme('tripal_pub_featuremaps', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_features'] = array(
-  	      '#value' => theme('tripal_pub_features', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_libraries'] = array(
-  	      '#value' => theme('tripal_pub_libraries', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_projects'] = array(
-  	      '#value' => theme('tripal_pub_projects', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_properties'] = array(
-  	      '#value' => theme('tripal_pub_properties', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_references'] = array(
-  	      '#value' => theme('tripal_pub_references', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_relationships'] = array(
-  	      '#value' => theme('tripal_pub_relationships', array('node' => $node)),
-  	    );
-  	    $node->content['tripal_pub_stocks'] = array(
-  	      '#value' => theme('tripal_pub_stocks', array('node' => $node)),
-  	    );
-  	  }
-  	  if ($view_mode == 'teaser') {
-  	    $node->content['tripal_pub_teaser'] = array(
-  	      '#value' => theme('tripal_pub_teaser', array('node' => $node)),
-  	    );
-  	  }
-  	  break;
+    case 'chado_pub':
+      // Show feature browser and counts
+      if ($view_mode == 'full') {
+        $node->content['tripal_pub_authors'] = array(
+          '#value' => theme('tripal_pub_authors', array('node' => $node)),
+        );
+        $node->content['tripal_pub_base'] = array(
+          '#value' => theme('tripal_pub_base', array('node' => $node)),
+        );
+        $node->content['tripal_pub_featuremaps'] = array(
+          '#value' => theme('tripal_pub_featuremaps', array('node' => $node)),
+        );
+        $node->content['tripal_pub_features'] = array(
+          '#value' => theme('tripal_pub_features', array('node' => $node)),
+        );
+        $node->content['tripal_pub_libraries'] = array(
+          '#value' => theme('tripal_pub_libraries', array('node' => $node)),
+        );
+        $node->content['tripal_pub_projects'] = array(
+          '#value' => theme('tripal_pub_projects', array('node' => $node)),
+        );
+        $node->content['tripal_pub_properties'] = array(
+          '#value' => theme('tripal_pub_properties', array('node' => $node)),
+        );
+        $node->content['tripal_pub_references'] = array(
+          '#value' => theme('tripal_pub_references', array('node' => $node)),
+        );
+        $node->content['tripal_pub_relationships'] = array(
+          '#value' => theme('tripal_pub_relationships', array('node' => $node)),
+        );
+        $node->content['tripal_pub_stocks'] = array(
+          '#value' => theme('tripal_pub_stocks', array('node' => $node)),
+        );
+      }
+      if ($view_mode == 'teaser') {
+        $node->content['tripal_pub_teaser'] = array(
+          '#value' => theme('tripal_pub_teaser', array('node' => $node)),
+        );
+      }
+      break;
   }
   }
 }
 }
 /**
 /**

+ 7 - 10
tripal_pub/includes/tripal_pub.pub_search.inc

@@ -159,16 +159,13 @@ function tripal_pub_search_form($form, &$form_state) {
     '#default_value' => $num_criteria,
     '#default_value' => $num_criteria,
   );
   );
   
   
-  if (user_access('access administration pages')) {
-    $form['admin-instructions'] = array(
-      '#prefix' => '<div class="tripal-no-results">',
-      '#markup'  =>  t('Administrators, you can select the fields with which a user can use to search,
-          by checking the desired fields on the ' .
-          l('Publication Module Settings Page', 'admin/tripal/chado/tripal_pub/configuration'). ' in
-         the section titled "Search Options".  The selected fields will appear in the dropdowns below.'),
-      '#suffix' => '</div>'
-    );
-  }
+  $form['admin-instructions'] = array(
+    '#markup'  =>  theme('tripal_admin_message', array('message' => 
+      t('Administrators, you can select the fields with which a user can use to search,
+         by checking the desired fields on the ' .
+         l('Publication Module Settings Page', 'admin/tripal/chado/tripal_pub/configuration'). ' in
+        the section titled "Search Options".  The selected fields will appear in the dropdowns below.'))),
+  ); 
   $form['instructions'] = array(
   $form['instructions'] = array(
     '#markup'  =>  t('To search for publications enter keywords in the text boxes below.  
     '#markup'  =>  t('To search for publications enter keywords in the text boxes below.  
         You can limit your search by selecting the field in the dropdown box. Click the 
         You can limit your search by selecting the field in the dropdown box. Click the 

+ 94 - 94
tripal_pub/theme/tripal_pub_help.tpl.php

@@ -6,106 +6,106 @@ module additionally provides a search tool for finding publications that
 have been added to Chado database.</p>
 have been added to Chado database.</p>
 <h3>Setup Instructions:</h3>
 <h3>Setup Instructions:</h3>
 <ol>
 <ol>
-	<li>
-	<p><b>Set Permissions</b>: The publication module supports the Drupal
-	user permissions interface for controlling access to publication
-	content and functions. These permissions include viewing, creating,
-	editing or administering of publications. The default is that only the
-	original site administrator has these permissions. You can <a
-		href="<?php print url('admin/user/roles') ?>">add roles</a> for
-	classifying users, <a href="<?php print url('admin/user/user') ?>">assign
-	users to roles</a> and <a
-		href="<?php print url('admin/user/permissions') ?>">assign permissions</a>
-	for the publication content to those roles. For a simple setup, allow
-	anonymous users access to view publication content and allow the site
-	administrator all other permissions.</p>
-	</li>
-	<li>
-	<p><b>Sync Publications</b>: If you already have publications in your
-	Chado database, or you loaded them through a means other than Tripal,
-	and you want those publications to appear on your site then you will
-	need to "sync" them with Drupal. Use the <?php print l('sync publications', 'admin/tripal/tripal_pub/sync') ?>
-	page to sync all publications.</p>
-	</li>
-	<li>
-	<p><b>Configure the Search Behavior</b>: Before allowing site visitors
-	to search for publications visit the <?php print l('configuration page', 'admin/tripal/tripal_pub/configuration') ?>
-	to disable or enable fields for searching. Tripal uses its own ontology
-	for storing publication information in Chado, and all child terms of
-	the "Publication Details" are made available for searching. However,
-	some of these may not be desired for searching and can be disabled.</p>
-	</li>
-	<li>
-	<p><b>AGL Importer</b>: Initially, the Tripal publication module
-	supports creating publication importers using PubMed and the USDA
-	National Agricultural Library (AGL). The AGL database uses a Z39.50
-	protocol for querying and therefore Tripal requires the 'YAZ' library
-	to connect. Before you can query AGL you must install the YAZ library
-	and the PHP YAZ library. The following steps can be used on an Ubuntu
-	12.04 server to intall the necessary pre-requisites:</p>
-	<ol>
-		<li>Install the YAZ libraries: sudo apt-get install yaz libyaz4-dev</li>
-		<li>Install the PHP YAZ extension: sudo pecl install yaz</li>
-		<li>Add the text 'extension=yaz.so' to the appropriate php.ini file
-		(e.g. /etc/php5/apache2filter/php.ini). On Ubuntu you may need to
-		add it to the php.ini file specfic for the Apache webserver and 
-		also to the php.ini specific for the command-line.</li>
-		<li>Restart the webserver</li>
-	</ol>
-	</li>
-	<li>
-	<p><b>Automate Importers:</b> Site administrators can <?php print l('create publication importers', 'admin/tripal/tripal_pub/import/new') ?>
-	that can be used to query remote databases (e.g. PubMed) and import
-	publications into this database. After creation of importers you can
-	automate import of publications into the site by creating a cron job
-	with a <?php print l('Drush', "http://drupal.org/project/drush")?>
-	command. The cron job can be setup to run the importers periodically.
-	The following is an example entry, added to the 'root' crontab, that
-	would run importers on a weekly bases (Friday at 9am): <br>
-	</p>
-	<pre>0 9 * * 5  su - [web user] -c 'cd [drupal install path]; drush -l http://[site url] tpubs-import --report=[email]'</pre>
-	Where:<br>
-	<p>[web user] is the name of the user on the system under which the web
-	server runs<br>
-	[drupal install path] is the location where drupal is installed<br>
-	[site url] is the URL path for the site <br>
-	[email] is the email address of the person who should receive an HTML
-	report of the publications added. Separate multiple emails with a comma
-	(no spaces).<br>
-	The --report=Y option indicates that an HTML style report should be
-	generated listing the publications that were added. If this options is
-	not used then no report is generated.</p>
-	</li>
+  <li>
+  <p><b>Set Permissions</b>: The publication module supports the Drupal
+  user permissions interface for controlling access to publication
+  content and functions. These permissions include viewing, creating,
+  editing or administering of publications. The default is that only the
+  original site administrator has these permissions. You can <a
+    href="<?php print url('admin/user/roles') ?>">add roles</a> for
+  classifying users, <a href="<?php print url('admin/user/user') ?>">assign
+  users to roles</a> and <a
+    href="<?php print url('admin/user/permissions') ?>">assign permissions</a>
+  for the publication content to those roles. For a simple setup, allow
+  anonymous users access to view publication content and allow the site
+  administrator all other permissions.</p>
+  </li>
+  <li>
+  <p><b>Sync Publications</b>: If you already have publications in your
+  Chado database, or you loaded them through a means other than Tripal,
+  and you want those publications to appear on your site then you will
+  need to "sync" them with Drupal. Use the <?php print l('sync publications', 'admin/tripal/tripal_pub/sync') ?>
+  page to sync all publications.</p>
+  </li>
+  <li>
+  <p><b>Configure the Search Behavior</b>: Before allowing site visitors
+  to search for publications visit the <?php print l('configuration page', 'admin/tripal/tripal_pub/configuration') ?>
+  to disable or enable fields for searching. Tripal uses its own ontology
+  for storing publication information in Chado, and all child terms of
+  the "Publication Details" are made available for searching. However,
+  some of these may not be desired for searching and can be disabled.</p>
+  </li>
+  <li>
+  <p><b>AGL Importer</b>: Initially, the Tripal publication module
+  supports creating publication importers using PubMed and the USDA
+  National Agricultural Library (AGL). The AGL database uses a Z39.50
+  protocol for querying and therefore Tripal requires the 'YAZ' library
+  to connect. Before you can query AGL you must install the YAZ library
+  and the PHP YAZ library. The following steps can be used on an Ubuntu
+  12.04 server to intall the necessary pre-requisites:</p>
+  <ol>
+    <li>Install the YAZ libraries: sudo apt-get install yaz libyaz4-dev</li>
+    <li>Install the PHP YAZ extension: sudo pecl install yaz</li>
+    <li>Add the text 'extension=yaz.so' to the appropriate php.ini file
+    (e.g. /etc/php5/apache2filter/php.ini). On Ubuntu you may need to
+    add it to the php.ini file specfic for the Apache webserver and 
+    also to the php.ini specific for the command-line.</li>
+    <li>Restart the webserver</li>
+  </ol>
+  </li>
+  <li>
+  <p><b>Automate Importers:</b> Site administrators can <?php print l('create publication importers', 'admin/tripal/tripal_pub/import/new') ?>
+  that can be used to query remote databases (e.g. PubMed) and import
+  publications into this database. After creation of importers you can
+  automate import of publications into the site by creating a cron job
+  with a <?php print l('Drush', "http://drupal.org/project/drush")?>
+  command. The cron job can be setup to run the importers periodically.
+  The following is an example entry, added to the 'root' crontab, that
+  would run importers on a weekly bases (Friday at 9am): <br>
+  </p>
+  <pre>0 9 * * 5  su - [web user] -c 'cd [drupal install path]; drush -l http://[site url] tpubs-import --report=[email]'</pre>
+  Where:<br>
+  <p>[web user] is the name of the user on the system under which the web
+  server runs<br>
+  [drupal install path] is the location where drupal is installed<br>
+  [site url] is the URL path for the site <br>
+  [email] is the email address of the person who should receive an HTML
+  report of the publications added. Separate multiple emails with a comma
+  (no spaces).<br>
+  The --report=Y option indicates that an HTML style report should be
+  generated listing the publications that were added. If this options is
+  not used then no report is generated.</p>
+  </li>
 </ol>
 </ol>
 <h3>Features of this Module:</h3>
 <h3>Features of this Module:</h3>
 <ul>
 <ul>
 
 
-	<li>
-	<p><b>Add/Edit/Delete Publications</b>: Publications can be maually
-	added <?php  l('here', 'node/add/chado-pub') ?>. Once added,
-	publications can be modified or deleted by clicking the Edit tab at the
-	top of a publication page.</p>
-	</li>
+  <li>
+  <p><b>Add/Edit/Delete Publications</b>: Publications can be maually
+  added <?php  l('here', 'node/add/chado-pub') ?>. Once added,
+  publications can be modified or deleted by clicking the Edit tab at the
+  top of a publication page.</p>
+  </li>
 
 
-	<li>
-	<p><b>Publication Search Tool</b>: A <?php print l('search tool','find/publications') ?>
-	is provided for finding publications. Unlike most default search tools
-	for Tripal, this tool does not rely on Drupal Views</p>
-	</li>
+  <li>
+  <p><b>Publication Search Tool</b>: A <?php print l('search tool','find/publications') ?>
+  is provided for finding publications. Unlike most default search tools
+  for Tripal, this tool does not rely on Drupal Views</p>
+  </li>
 
 
-	<li>
-	<p><b>Bulk Import of Publications</b>: Site administrators can <?php print l('add a new publication importer', 'admin/tripal/tripal_pub/import/new') ?>
-	which provides a set of search terms for querying a remote publication
-	database (e.g. PubMed). Publications that matche the search terms can
-	be imported when the publication import cron command is executed. The
-	cron command can be executed using the Drush command: drush
-	tpubs-import. This drush command can be added as a system-wide cron (in
-	the same way the Tripal jobs cron is implemented) to be executed on a
-	periodic basis. This will allow the site to import publications which
-	have been newly added to remote databases and which are relative to the
-	site. Site administrators can <?php print l('see the list of importers', 'admin/tripal/tripal_pub/import_list') ?>
-	and edit, disable or delete the importers.</p>
-	</li>
+  <li>
+  <p><b>Bulk Import of Publications</b>: Site administrators can <?php print l('add a new publication importer', 'admin/tripal/tripal_pub/import/new') ?>
+  which provides a set of search terms for querying a remote publication
+  database (e.g. PubMed). Publications that matche the search terms can
+  be imported when the publication import cron command is executed. The
+  cron command can be executed using the Drush command: drush
+  tpubs-import. This drush command can be added as a system-wide cron (in
+  the same way the Tripal jobs cron is implemented) to be executed on a
+  periodic basis. This will allow the site to import publications which
+  have been newly added to remote databases and which are relative to the
+  site. Site administrators can <?php print l('see the list of importers', 'admin/tripal/tripal_pub/import_list') ?>
+  and edit, disable or delete the importers.</p>
+  </li>
 
 
 
 
 
 

+ 12 - 29
tripal_pub/tripal_pub.module

@@ -64,7 +64,7 @@ function tripal_pub_menu() {
     'title' => 'Publications',
     'title' => 'Publications',
     'description' => ('A documented provenance artefact - publications, documents, personal communication.'),
     'description' => ('A documented provenance artefact - publications, documents, personal communication.'),
     'page callback' => 'tripal_pub_admin_pub_view',
     'page callback' => 'tripal_pub_admin_pub_view',
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type' => MENU_NORMAL_ITEM
     'type' => MENU_NORMAL_ITEM
   );
   );
 
 
@@ -73,7 +73,7 @@ function tripal_pub_menu() {
     'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of publications'),
     'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of publications'),
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_pub_help'),
     'page arguments' => array('tripal_pub_help'),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
@@ -83,7 +83,7 @@ function tripal_pub_menu() {
     'description' => 'Configure the Tripal publication module.',
     'description' => 'Configure the Tripal publication module.',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_pub_admin'),
     'page arguments' => array('tripal_pub_admin'),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 5
     'weight' => 5
   );
   );
@@ -104,7 +104,7 @@ function tripal_pub_menu() {
     'description' => 'Update publication citations',
     'description' => 'Update publication citations',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_pub_citation_form'),
     'page arguments' => array('tripal_pub_citation_form'),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 1
     'weight' => 1
   );
   );
@@ -113,7 +113,7 @@ function tripal_pub_menu() {
     'title' => t('Importers'),
     'title' => t('Importers'),
     'description' => t('List all publication importers'),
     'description' => t('List all publication importers'),
     'page callback' => 'tripal_pub_importers_list',
     'page callback' => 'tripal_pub_importers_list',
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 0
     'weight' => 0
   );
   );
@@ -131,65 +131,48 @@ function tripal_pub_menu() {
     'title' => t('Add an Importer'),
     'title' => t('Add an Importer'),
     'description' => t('Add a new publication importer.'),
     'description' => t('Add a new publication importer.'),
     'page callback' => 'tripal_pub_importer_setup_page',
     'page callback' => 'tripal_pub_importer_setup_page',
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/chado/tripal_pub/import/raw/%'] = array(
   $items['admin/tripal/chado/tripal_pub/import/raw/%'] = array(
     'page callback' => 'tripal_pub_get_raw_data',
     'page callback' => 'tripal_pub_get_raw_data',
     'page arguments' => array(6),
     'page arguments' => array(6),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/chado/tripal_pub/import/edit/%'] = array(
   $items['admin/tripal/chado/tripal_pub/import/edit/%'] = array(
     'page callback' => 'tripal_pub_importer_setup_page',
     'page callback' => 'tripal_pub_importer_setup_page',
     'page arguments' => array(5, 6),
     'page arguments' => array(5, 6),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/chado/tripal_pub/import/submit/%'] = array(
   $items['admin/tripal/chado/tripal_pub/import/submit/%'] = array(
     'page callback' => 'tripal_pub_importer_submit_job',
     'page callback' => 'tripal_pub_importer_submit_job',
     'page arguments' => array(6),
     'page arguments' => array(6),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/chado/tripal_pub/import/delete/%'] = array(
   $items['admin/tripal/chado/tripal_pub/import/delete/%'] = array(
     'page callback' => 'tripal_pub_importer_delete',
     'page callback' => 'tripal_pub_importer_delete',
     'page arguments' => array(5),
     'page arguments' => array(5),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
   $items['admin/tripal/chado/tripal_pub/import/changedb'] = array(
   $items['admin/tripal/chado/tripal_pub/import/changedb'] = array(
     'page callback' => 'tripal_pub_importer_setup_page_update_remotedb',
     'page callback' => 'tripal_pub_importer_setup_page_update_remotedb',
     'page arguments' => array(),
     'page arguments' => array(),
-    'access arguments' => array('administer tripal pubs'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
 
 
   $items['admin/tripal/chado/tripal_pub/import/criteria/%/%'] = array(
   $items['admin/tripal/chado/tripal_pub/import/criteria/%/%'] = array(
     'page callback' => 'tripal_pub_importer_setup_page_update_criteria',
     'page callback' => 'tripal_pub_importer_setup_page_update_criteria',
     'page arguments' => array(5, 6),
     'page arguments' => array(5, 6),
-    'access arguments' => array('administer tripal pubs'),
-    'type ' => MENU_CALLBACK,
-  );
-
-  $items['tripal_pub/chado/properties/add'] = array(
-    'page callback' => 'tripal_pub_property_add',
-    'access arguments' => array('edit chado_pub content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_pub/chado/properties/description'] = array(
-    'page callback' => 'tripal_pub_property_get_description',
-    'access arguments' => array('edit chado_pub content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_pub/chado/properties/minus/%/%'] = array(
-    'page callback' => 'tripal_pub_property_delete',
-    'page arguments' => array(3, 4),
-    'access arguments' => array('edit chado_pub content'),
+    'access arguments' => array('administer tripal pub'),
     'type ' => MENU_CALLBACK,
     'type ' => MENU_CALLBACK,
   );
   );
 
 

+ 11 - 2
tripal_stock/includes/tripal_stock.chado_node.inc

@@ -783,7 +783,16 @@ function tripal_stock_node_presave($node) {
 
 
   switch ($node->type) {
   switch ($node->type) {
     case 'chado_stock':
     case 'chado_stock':
-      $values = array('organism_id' => $node->organism_id);
+      // for a form submission the fields part of the node object
+      // but for a sync the feilds are in an object of the node
+      $organism_id = null;
+      if(property_exists($node, 'stock')) {
+        $organism_id = $node->stock->organism_id;
+      }
+      else {
+        $organism_id = $node->organism_id;
+      }
+      $values = array('organism_id' => $organism_id);
       $organism = tripal_core_chado_select('organism', array('genus','species'), $values);
       $organism = tripal_core_chado_select('organism', array('genus','species'), $values);
       $values = array('cvterm_id' => $node->type_id);
       $values = array('cvterm_id' => $node->type_id);
       $cvterm = tripal_core_chado_select('cvterm', array('name'), $values);
       $cvterm = tripal_core_chado_select('cvterm', array('name'), $values);
@@ -873,7 +882,7 @@ function tripal_stock_node_view($node, $view_mode, $langcode) {
     case 'chado_organism':
     case 'chado_organism':
       if ($view_mode == 'full') {
       if ($view_mode == 'full') {
         $node->content['tripal_organism_stocks'] = array(
         $node->content['tripal_organism_stocks'] = array(
-          '#value' => theme('tripal_organism_stocks', $node),
+          '#value' => theme('tripal_organism_stocks', array('node' => $node)),
         );
         );
       }
       }
       break;
       break;

+ 1 - 1
tripal_stock/theme/tripal_organism/tripal_organism_stocks.tpl.php

@@ -44,7 +44,7 @@ if (count($stocks) > 0) { ?>
           <td><?php
           <td><?php
             $name = $stock->name;
             $name = $stock->name;
             if (!$stock->name) {
             if (!$stock->name) {
-            	$name = $stock->uniquename;
+              $name = $stock->uniquename;
             }
             }
             if ($stock->nid) {    
             if ($stock->nid) {    
               print l($name, "node/$stock->nid", array('attributes' => array('target' => '_blank')));        
               print l($name, "node/$stock->nid", array('attributes' => array('target' => '_blank')));        

+ 13 - 11
tripal_stock/tripal_stock.module

@@ -39,12 +39,20 @@ require_once("api/tripal_stock.api.inc");
 function tripal_stock_menu() {
 function tripal_stock_menu() {
   $items = array();
   $items = array();
 
 
+  // the menu link for addressing any stock (by name, uniquename, synonym)
+  $items['stock/%'] = array(
+    'page callback' => 'tripal_stock_match_stocks_page',
+    'page arguments' => array(1),
+    'access arguments' => array('access chado_stock content'),
+    'type' => MENU_LOCAL_TASK,
+  );
+  
   //Administrative settings menu-----------------
   //Administrative settings menu-----------------
   $items['admin/tripal/chado/tripal_stock'] = array(
   $items['admin/tripal/chado/tripal_stock'] = array(
     'title' => 'Stocks',
     'title' => 'Stocks',
     'description' => 'A stock is the physical entities of an organism, either living or preserved.',
     'description' => 'A stock is the physical entities of an organism, either living or preserved.',
     'page callback' => 'tripal_stock_admin_stock_view',
     'page callback' => 'tripal_stock_admin_stock_view',
-    'access arguments' => array('administer tripal stocks'),
+    'access arguments' => array('administer tripal stock'),
     'type' => MENU_NORMAL_ITEM
     'type' => MENU_NORMAL_ITEM
   );
   );
 
 
@@ -53,7 +61,7 @@ function tripal_stock_menu() {
     'description' => 'Settings for Chado Stocks',
     'description' => 'Settings for Chado Stocks',
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('tripal_stock_admin'),
     'page arguments' => array('tripal_stock_admin'),
-    'access arguments' => array('administer tripal stocks'),
+    'access arguments' => array('administer tripal stock'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 5
     'weight' => 5
   );
   );
@@ -64,7 +72,7 @@ function tripal_stock_menu() {
     'page callback' => 'drupal_get_form',
     'page callback' => 'drupal_get_form',
     //'page arguments' => array('tripal_stock_sync_form'),
     //'page arguments' => array('tripal_stock_sync_form'),
     'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_stock', 'chado_stock'),
     'page arguments' => array('tripal_core_chado_node_sync_form', 'tripal_stock', 'chado_stock'),
-    'access arguments' => array('administer tripal stocks'),
+    'access arguments' => array('administer tripal stock'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 0
     'weight' => 0
   );
   );
@@ -74,18 +82,12 @@ function tripal_stock_menu() {
     'description' => 'Basic Description of Tripal Stock Module Functionality',
     'description' => 'Basic Description of Tripal Stock Module Functionality',
     'page callback' => 'theme',
     'page callback' => 'theme',
     'page arguments' => array('tripal_stock_help'),
     'page arguments' => array('tripal_stock_help'),
-    'access arguments' => array('administer tripal stocks'),
+    'access arguments' => array('administer tripal stock'),
     'type' => MENU_LOCAL_TASK,
     'type' => MENU_LOCAL_TASK,
     'weight' => 10
     'weight' => 10
   );
   );
 
 
-  // the menu link for addressing any stock (by name, uniquename, synonym)
-  $items['stock/%'] = array(
-    'page callback' => 'tripal_stock_match_stocks_page',
-    'page arguments' => array(1),
-    'access arguments' => array('access chado_stock content'),
-    'type' => MENU_LOCAL_TASK,
-  );
+
   return $items;
   return $items;
 }
 }
 
 

+ 24 - 24
tripal_views/tripal_views.views.inc

@@ -569,35 +569,35 @@ function tripal_views_views_data_alter(&$data) {
           //      without 1st needing to add relationship to organism table
           //      without 1st needing to add relationship to organism table
           $base_field = $base_table . '_id';
           $base_field = $base_table . '_id';
           $data[$linker_table][$base_field] = array(
           $data[$linker_table][$base_field] = array(
-			      'group' => $base_title,
-			      'title' => $base_title . 'Node',
-			      'help' => "Links $base_title to it's node.",
-			      'relationship' => array(
-			        'handler' => 'views_handler_relationship',
-			        'title' => t("$base_title => Node"),
-			        'label' => t("$base_title => Node"),
-			        'real field' => 'nid',
-			        'base' => 'node',
-			        'base field' => 'nid'
-			      ),
-			    );
+            'group' => $base_title,
+            'title' => $base_title . 'Node',
+            'help' => "Links $base_title to it's node.",
+            'relationship' => array(
+              'handler' => 'views_handler_relationship',
+              'title' => t("$base_title => Node"),
+              'label' => t("$base_title => Node"),
+              'real field' => 'nid',
+              'base' => 'node',
+              'base field' => 'nid'
+            ),
+          );
 
 
           // Add Chado fields to a node-based view
           // Add Chado fields to a node-based view
           // This will only be done with relationships
           // This will only be done with relationships
           $base_field = $base_table . '_id';
           $base_field = $base_table . '_id';
           $data['node'][$base_field] = array(
           $data['node'][$base_field] = array(
-			      'group' => $base_title,
-			      'title' => $base_title,
-			      'help' => "Links node to chado $base_title.",
-			      'relationship' => array(
-			        'handler' => 'views_handler_relationship',
-			        'title' => t("Node => $base_title"),
-			        'label' => t("Node => $base_title"),
-			        'real field' => 'nid',
-			        'base' => $linker_table,
-			        'base field' => 'nid'
-			      ),
-			    );
+            'group' => $base_title,
+            'title' => $base_title,
+            'help' => "Links node to chado $base_title.",
+            'relationship' => array(
+              'handler' => 'views_handler_relationship',
+              'title' => t("Node => $base_title"),
+              'label' => t("Node => $base_title"),
+              'real field' => 'nid',
+              'base' => $linker_table,
+              'base field' => 'nid'
+            ),
+          );
 
 
         }
         }
       }
       }