Browse Source

Continued coversion of analysis, organism, project and feature modules

spficklin 11 years ago
parent
commit
4dfd3d859b

+ 8 - 8
tripal_analysis/api/tripal_analysis.api.inc

@@ -16,10 +16,10 @@
  * @ingroup tripal_analysis
  */
 function tripal_analysis_register_child($modulename) {
-  $sql = "SELECT * FROM {tripal_analysis} WHERE modulename = '%s'";
-  if (!db_result($sql, $modulename)) {
-    $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES ('%s')";
-    db_query($sql, $modulename);
+  $sql = "SELECT * FROM {tripal_analysis} WHERE modulename = :modname";
+  if (!db_query($sql, array(':modname' => $modulename))->fetchField()) {
+    $sql = "INSERT INTO {tripal_analysis} (modulename) VALUES (:modname)";
+    db_query($sql, array(':modname' => $modulename));
   }
 }
 
@@ -33,8 +33,8 @@ function tripal_analysis_register_child($modulename) {
  */
 function tripal_analysis_unregister_child($modulename) {
   if (db_table_exists('tripal_analysis')) {
-      $sql = "DELETE FROM {tripal_analysis} WHERE modulename = '%s'";
-      db_query($sql, $modulename);
+      $sql = "DELETE FROM {tripal_analysis} WHERE modulename = :modname";
+      db_query($sql, array(':modname' => $modulename));
   }
 }
 /**
@@ -142,7 +142,7 @@ function tripal_analysis_get_node($analysis_id) {
   $sql = "SELECT *
            FROM {chado_analysis} CA
               INNER JOIN {node} N on CA.nid = N.nid
-           WHERE analysis_id = %d";
-  $node = db_fetch_object(db_query($sql, $analysis_id));
+           WHERE analysis_id = :analysis_id";
+  $node = db_query($sql, array(':analysis_id' => $analysis_id))->fetchObject();
   return $node;
 }

+ 22 - 22
tripal_analysis/includes/tripal_analysis.admin.inc

@@ -55,7 +55,7 @@ function tripal_analysis_admin() {
   $sql = "SELECT modulename FROM {tripal_analysis}";
   $result = db_query($sql);
   $counter = 0;  //keep track of the number of sub-modules
-  while ($data = db_fetch_object($result)) {
+  while ($data = $result->fetchObject()) {
 
     // Check if the hook_get_settings() function is already defined.
     $func = $data->modulename . "_get_settings";
@@ -105,7 +105,7 @@ function get_tripal_analysis_admin_form_taxonomy_set(&$form) {
 
   // iterate through all of the libraries
   $lib_boxes = array();
-  while ($analysis = db_fetch_object($lib_rset)) {
+  while ($analysis = $lib_rset->fetchObject()) {
     $lib_boxes[$analysis->analysis_id] = "$analysis->name";
   }
 
@@ -158,7 +158,7 @@ function get_tripal_analysis_admin_form_reindex_set(&$form) {
 
   // iterate through all of the libraries
   $lib_boxes = array();
-  while ($analysis = db_fetch_object($lib_rset)) {
+  while ($analysis = $lib_rset->fetchObject()) {
     $lib_boxes[$analysis->analysis_id] = "$analysis->name";
   }
   $form['reindex']['description'] = array(
@@ -254,11 +254,11 @@ function get_tripal_analysis_admin_form_sync_set(&$form) {
     // a message stating that all analyses are currently synced.
     $ana_boxes = array();
     $added = 0;
-    while ($analysis = db_fetch_object($ana_rset)) {
+    while ($analysis = $ana_rset->fetchObject()) {
       // check to see if the analysis is already present as a node in drupal.
       // if so, then skip it.
-      $sql = "SELECT * FROM {chado_analysis} WHERE analysis_id = %d";
-      if (!db_fetch_object(db_query($sql, $analysis->analysis_id))) {
+      $sql = "SELECT * FROM {chado_analysis} WHERE analysis_id = :analysis_id";
+      if (!db_query($sql, array(':analysis_id' => $analysis->analysis_id))->fetchObject()) {
         $ana_boxes[$analysis->analysis_id] = "$analysis->name";
         $added++;
       }
@@ -329,8 +329,8 @@ function tripal_analysis_admin_validate($form, &$form_state) {
       }
       if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
         // get the list of analyses
-        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-        $analysis = db_fetch_object(chado_query($sql, $analysis_id));
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = :analysis_id";
+        $analysis = chado_query($sql, array(':analysis_id' => $analysis_id))->fetchObject();
         $to_sync[$analysis_id] = $analysis->name;
       }
     }
@@ -355,8 +355,8 @@ function tripal_analysis_admin_validate($form, &$form_state) {
     foreach ($analyses as $analysis_id) {
       if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
         // get the analysis info
-        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-        $analysis = db_fetch_object(chado_query($sql, $analysis_id));
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = :analysis_id";
+        $analysis = chado_query($sql, array(':analysis_id' => $analysis_id))->fetchObject();
         $job_args[0] = $analysis_id;
         tripal_add_job("Reindex features for analysis: $analysis->name", 'tripal_analysis',
              'tripal_analysis_reindex_features', $job_args, $user->uid);
@@ -373,8 +373,8 @@ function tripal_analysis_admin_validate($form, &$form_state) {
     foreach ($analyses as $analysis_id) {
       if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
         // get the analysis info
-        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-        $analysis = db_fetch_object(chado_query($sql, $analysis_id));
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = :analysis_id";
+        $analysis = chado_query($sql, array(':analysis_id' => $analysis_id))->fetchObject();
         $job_args[0] = $analysis_id;
         tripal_add_job("Set taxonomy for features in analysis: $analysis->name", 'tripal_analysis',
              'tripal_analysis_taxonify_features', $job_args, $user->uid);
@@ -403,25 +403,25 @@ function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
     $sql = "SELECT Analysis_id, name, description, program, " .
         "  programversion, algorithm, sourcename, sourceversion, sourceuri, " .
           "  timeexecuted " .
-          "FROM {Analysis} ";
+          "FROM {analysis} ";
     $results = chado_query($sql);
   }
   else {
     $sql = "SELECT Analysis_id, name, description, program, " .
          "  programversion, algorithm, sourcename, sourceversion, sourceuri, " .
           "  timeexecuted " .
-          "FROM {Analysis} " .
-          "WHERE analysis_id = %d";
-    $results = chado_query($sql, $analysis_id);
+          "FROM {analysis} " .
+          "WHERE analysis_id = :analysis_id";
+    $results = chado_query($sql, array(':analysis_id' => $analysis_id));
   }
 
 
   // We'll use the following SQL statement for checking if the analysis
   // already exists as a drupal node.
   $sql = "SELECT * FROM {chado_analysis} " .
-          "WHERE analysis_id = %d";
+          "WHERE analysis_id = :analysis_id";
 
-  while ($analysis = db_fetch_object($results)) {
+  while ($analysis = $results->fetchObject()) {
         print "syncing analysis ";
         print $analysis->name;
         print ", ";
@@ -430,17 +430,17 @@ function tripal_analysis_sync_analyses($analysis_id = NULL, $job_id = NULL) {
 
     // check if this analysis already exists in the drupal database. if it
     // does then skip this analysis and go to the next one.
-    if (!db_fetch_object(db_query($sql, $analysis->analysis_id))) {
+    if (!db_query($sql, array(':analysis_id' => $analysis->analysis_id))->fetchObject()) {
 
       $new_node = new stdClass();
 
       // try to access analysis type for this analysis
       $sql = "SELECT * FROM {analysisprop}
-                    WHERE analysis_id = %d
+                    WHERE analysis_id = :analysis_id
                     AND type_id =
-                        (SELECT cvterm_id from {cvterm} where name = '%s')
+                        (SELECT cvterm_id from {cvterm} where name = :name)
             ";
-      $analysis_type = db_fetch_object(chado_query($sql, $analysis->analysis_id, "analysis_type"));
+      $analysis_type = chado_query($sql, array(':analysis_id' => $analysis->analysis_id, ':name' => "analysis_type"))->fetchObject();
 
       // Get the type of analysis using cvterm_id
             // Current possibilities: kegg, unigene, interpro, blast

+ 25 - 22
tripal_analysis/includes/tripal_analysis.form.inc

@@ -137,10 +137,10 @@ function chado_analysis_form(&$node, $form_state = NULL) {
   $day = preg_replace("/^\d+-\d+-0?(\d+) .*/", "$1", $default_time);
   // If the time is not set, use current time
   if (!$default_time) {
-    $default_time = time();
-    $year = format_date($default_time, 'custom', 'Y');
+    $default_time = REQUEST_TIME;
+    $year  = format_date($default_time, 'custom', 'Y');
     $month = format_date($default_time, 'custom', 'n');
-    $day = format_date($default_time, 'custom', 'j');
+    $day   = format_date($default_time, 'custom', 'j');
   }
   $form['timeexecuted']= array(
       '#type' => 'date',
@@ -177,7 +177,7 @@ function chado_analysis_form(&$node, $form_state = NULL) {
     ORDER BY CVT.name ASC
   ";
   $prop_types = chado_query($sql);
-  while ($prop = db_fetch_object($prop_types)) {
+  while ($prop = $prop_types->fetchObject()) {
     $properties_select[$prop->cvterm_id] = $prop->name;
     $properties_list[$prop->cvterm_id] = $prop;
   }
@@ -322,11 +322,12 @@ function chado_analysis_node_form_add_new_empty_props(&$form, $properties_select
   $form['properties']['table']['new']["new_id"] = array(
     '#type'          => 'select',
     '#options'       => $properties_select,
-    '#ahah' => array(
-      'path'    => "tripal_analysis/properties/description",
-      'wrapper' => 'tripal-analysis-new_value-desc',
-      'event'   => 'change',
-      'method'  => 'replace',          
+    '#ajax' => array(
+      'callback' => "tripal_analysis_property_get_description",
+      'wrapper'  => 'tripal-analysis-new_value-desc',
+      'effect'   => 'fade',
+      'event'    => 'change',
+      'method'   => 'replace',          
   ),
   );
   $form['properties']['table']['new']["new_value"] = array(
@@ -340,11 +341,12 @@ function chado_analysis_node_form_add_new_empty_props(&$form, $properties_select
     '#type'         => 'image_button',      
     '#value'        => t('Add'),
     '#src'          => drupal_get_path('theme', 'tripal') . '/images/add.png',
-    '#ahah' => array(
-      'path'    => "tripal_analysis/properties/add",
-      'wrapper' => 'tripal-analysis-edit-properties-table',
-      'event'   => 'click',
-      'method'  => 'replace',          
+    '#ajax' => array(
+      'callback' => "tripal_analysis_property_add",
+      'wrapper'  => 'tripal-analysis-edit-properties-table',
+      'effect'   => 'fade',
+      'event'    => 'click',
+      'method'   => 'replace',          
     ),
     '#attributes' => array('onClick' => 'return false;'),
     );
@@ -406,11 +408,12 @@ function chado_analysis_node_form_add_new_props(&$form, $form_state, &$d_propert
           '#type'         => 'image_button',
           '#value'        => t('Remove'),
           '#src'          => drupal_get_path('theme', 'tripal') . '/images/minus.png',
-          '#ahah' => array(
-            'path'    => "tripal_analysis/properties/minus/$new_id/$rank",
-            'wrapper' => 'tripal-analysis-edit-properties-table',
-            'event'   => 'click',
-            'method'  => 'replace',
+          '#ajax' => array(
+            'callback' => "tripal_analysis/properties/minus/$new_id/$rank",
+            'wrapper'  => 'tripal-analysis-edit-properties-table',
+            'effect'   => 'fade',
+            'event'    => 'click',
+            'method'   => 'replace',
         ),
           '#attributes' => array('onClick' => 'return false;'),
         );
@@ -487,11 +490,11 @@ function chado_analysis_node_form_add_analysisprop_table_props(&$form, $form_sta
     FROM {analysisprop} PP
       INNER JOIN {cvterm} CVT on CVT.cvterm_id = PP.type_id
       INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
-    WHERE PP.analysis_id = %d and CV.name = 'analysis_property'
+    WHERE PP.analysis_id = :analysis_id and CV.name = 'analysis_property'
     ORDER BY CVT.name, PP.rank
   ";
-  $analysis_props = chado_query($sql, $analysis_id);
-  while ($prop = db_fetch_object($analysis_props)) {
+  $analysis_props = chado_query($sql, array(':analysis_id' => $analysis_id));
+  while ($prop = $analysis_props->fetchObject()) {
 
     $type_id = $prop->cvterm_id;
     $rank = count($d_properties[$type_id]);

+ 20 - 13
tripal_analysis/includes/tripal_analysis_privacy.inc

@@ -16,8 +16,12 @@ function tripal_analysis_check_permission($analysis_id) {
     $roles = $user->roles;
     $node_access = 0;
     foreach ($roles AS $rid => $role) {
-      $p_sql = "SELECT grant_view FROM {node_access} NA INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid WHERE analysis_id=%d AND gid = %d";
-      $access = db_result(db_query($p_sql, $analysis_id, $rid));
+      $p_sql = "
+        SELECT grant_view 
+        FROM {node_access} NA 
+          INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid 
+        WHERE analysis_id = :analysis_id AND gid = :gid";
+      $access = db_query($p_sql, array(':analysis_id' => $analysis_id, ':gid' => $rid))->fetchField();
       if ($access == 1) {
         $node_access = 1;
         break;
@@ -51,20 +55,20 @@ function tripal_analysis_set_feature_permission($analysis_id, $nid) {
   print "Updating feature permissions:\n";
 
   // Get features associated with the analysis
-  $sql = "SELECT feature_id FROM {analysisfeature} WHERE analysis_id = %d";
-  $features = chado_query($sql, $analysis_id);
+  $sql = "SELECT feature_id FROM {analysisfeature} WHERE analysis_id = :analysis_id";
+  $features = chado_query($sql, array(':analysis_id' => $analysis_id));
 
   // Convert feature_id into node_id
   $feature_nids = array();
   $counter = 0;
-  $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = %d";
-  while ($feature = db_fetch_object($features)) {
-    $feature_nids [$counter] = db_result(db_query($sql, $feature->feature_id));
+  $sql = "SELECT nid FROM {chado_feature} WHERE feature_id = :feature_id";
+  while ($feature = $features->fetchObject()) {
+    $feature_nids[$counter] = db_query($sql, array(':feature_id' => $feature->feature_id))->fetchField();
     $counter ++;
   }
 
   //Convert analysis_id into node_id
-  $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = %analysis_id", $analysis_id));
+  $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = :analysis_id", array(':analysis_id' => $analysis_id)));
   // Get available roles
   $roles = array_keys(user_roles());
 
@@ -79,14 +83,17 @@ function tripal_analysis_set_feature_permission($analysis_id, $nid) {
       print $percentage . "% ";
     }
 
-    db_query("DELETE FROM {node_privacy_byrole} WHERE nid = %d AND realm = 'node_privacy_byrole_role'", $fnid);
+    db_query("DELETE FROM {node_privacy_byrole} WHERE nid = :nid AND realm = 'node_privacy_byrole_role'", array(':nid' => $fnid));
     foreach ($roles AS $rid) {
       // Get permissions of this analysis for this role
-      $rsql = "SELECT * FROM {node_privacy_byrole} WHERE gid = %d AND nid = %d AND realm = 'node_privacy_byrole_role'";
-      $ana_perm = db_fetch_object(db_query($rsql, $rid, $ana_nid));
+      $rsql = "SELECT * FROM {node_privacy_byrole} WHERE gid = :gid AND nid = :nid AND realm = 'node_privacy_byrole_role'";
+      $ana_perm = db_query($rsql, array(':gid' => $rid, ':nid' => $ana_nid))->fetchObject();
       db_query("INSERT INTO {node_privacy_byrole} (nid, gid, realm, grant_view, grant_update, grant_delete)
-                  VALUES (%d, %d, '%s', %d, %d, %d)", $fnid, $rid, 'node_privacy_byrole_role', $ana_perm->grant_view,
-                  $ana_perm->grant_update, $ana_perm->grant_delete);
+                VALUES (:nid, :gid, :realm, :grant_view, :grant_update, :grant_delete)", 
+                array(':nid' => $fnid, ':gid' => $rid, ':realm' => 'node_privacy_byrole_role', 
+                      ':grant_view' => $ana_perm->grant_view, 
+                      ':grant_update' => $ana_perm->grant_update, 
+                      ':grant_delete' => $ana_perm->grant_delete));
     }
     $node = node_load($fnid);
     node_save($node);

+ 9 - 70
tripal_analysis/tripal_analysis.install

@@ -12,9 +12,6 @@ function tripal_analysis_install() {
   // create the module's data directory
   tripal_create_moddir('tripal_analysis');
 
-  // Use schema API to create database table.
-  drupal_install_schema('tripal_analysis');
-
   // we may need the analysisfeatureprop table if it doesn't already exist
   tripal_analysis_create_analysisfeatureprop();
   
@@ -91,14 +88,15 @@ function tripal_analysis_add_cvterms() {
  * Implementation of hook_uninstall().
  */
 function tripal_analysis_uninstall() {
-  // Use schema API to delete database table.
-  drupal_uninstall_schema('tripal_analysis');
+
   // Remove analysis nodes from drupal.
-  $sql_ana_id = "SELECT nid, vid " .
-                 "FROM {node} " .
-                 "WHERE type like 'chado_analysi%'";
+  $sql_ana_id = "
+    SELECT nid, vid 
+    FROM {node} 
+    WHERE type like 'chado_analysi%'
+  ";
   $result = db_query($sql_ana_id);
-  while ($ana = db_fetch_object($result)) {
+  while ($ana = $result->fetchObject()) {
     node_delete($ana->nid);
   }
 }
@@ -146,14 +144,13 @@ function tripal_analysis_schema() {
 
   // tripal_analysis table
   $schema['tripal_analysis'] = array(
-    'description' => t('Table to store analysis sub-modules'),
+    'description' => 'Table to store analysis sub-modules',
     'fields' => array(
       'modulename' => array(
         'type' => 'text',
         'size' => 'small',
         'not null' => TRUE,
-        'description' => t('The module name. Tripal Analysis will use the ' .
-                            'module name to call module_setting_form()')
+        'description' => 'The module name. Tripal Analysis will use the module name to call module_setting_form()'
       )
     ),
     'unique keys' => array(
@@ -164,64 +161,6 @@ function tripal_analysis_schema() {
   return $schema;
 }
 
-/**
- *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
- *  This update adds a new analysis_organism materialized view
- *
- */
-function tripal_analysis_update_6100() {
-  // add the new materialized view
-  tripal_analysis_add_mview_analysis_organism();
-  
-  // move the analysis_type property into a new CV so that user's can change this property if
-  // they want too  
-  tripal_cv_add_cv('tripal_analysis', 'Terms used for managing analyses in Tripal');
-  
-  $sql = "
-    UPDATE {cvterm} SET cv_id = 
-      (SELECT cv_id FROM {cv} WHERE name = 'tripal_analysis')
-    WHERE cv_id = (SELECT cv_id FROM {cv} WHERE name = 'tripal') AND
-      name = 'analysis_type'
-  ";
-  chado_query($sql);
-  
-  $ret = array(
-    '#finished' => 1,
-  );
-
-  return $ret;
-}
-
-/**
- * Provide update script for adding new cvterms
- */
-function tripal_analysis_update_6001() {
-   // we have some new cvterms to add
-  tripal_cv_add_cvterm(array('name' => 'based_on_analysis', 'def' => 'The analysis that this analysis was based on. For example, blast/kegg/interpro analyses are based on a unigene analysis. The unigene analysis_id should be stored in analysisprop as the rank using this cvterm. The name of said unigene analysis can be inserted as the value in analysisprop.'), 'tripal', 0, 1, 'tripal');
-  tripal_cv_add_cvterm(array('name' => 'additional_files', 'def' => 'Additional files for this analysis. Each file should be separated by a semi-colon and have this format: <file description>, <file path>;'), 'tripal', 0, 1, 'tripal');
-  $ret = array(
-      '#finished' => 1,
-  );
-  return $ret;
-}
-
-/**
- *  Update for Drupal 6.x, Tripal 1.1, Analysis Module 1.1
- *  This update adds a new analysis_property cv and 'Analysis Type' cvterm
- */
-function tripal_analysis_update_6101() {
-  // the 'analysis_property' vocabulary is for user definable properties.  Even though we already have
-  // an analysis_type term in the 'tripal_analysis' vocabular we duplicate it here because the 
-  // tripal_analysis vocabulary is intended for use by the extension modules.  user's should not be able
-  // to directly modify properties set by extension modules for an analysis.
-   tripal_cv_add_cvterm(array('name' => 'Analysis Type', 'def' => 'The type of analysis was performed.'), 
-     'analysis_property', 0, 1, 'tripal');
-
-  $ret = array(
-      '#finished' => 1,
-  );
-  return $ret;
-}
 /**
  * Implementation of hook_requirements(). 
  */

+ 46 - 53
tripal_analysis/tripal_analysis.module

@@ -82,19 +82,8 @@ function tripal_analysis_menu() {
       'type' => MENU_NORMAL_ITEM,
       'file' => 'includes/tripal_analysis.admin.inc',
   );
- 
-    
-  // AJAX calls for adding/removing properties to a contact
-  $items['tripal_analysis/properties/add'] = array(
-    'page callback' => 'tripal_analysis_property_add',
-    'access arguments' => array('edit chado_analysis content'),
-    'type ' => MENU_CALLBACK,
-  );
-  $items['tripal_analysis/properties/description'] = array(
-    'page callback' => 'tripal_analysis_property_get_description',
-    'access arguments' => array('edit chado_analysis content'),
-    'type ' => MENU_CALLBACK,
-  );
+     
+
   $items['tripal_analysis/properties/minus/%/%'] = array(
     'page callback' => 'tripal_analysis_property_delete',
     'page arguments' => array(3, 4),
@@ -200,7 +189,7 @@ function chado_analysis_insert($node) {
       ORDER BY CVT.name ASC
   ";
   $prop_types = chado_query($sql);
-  while ($prop = db_fetch_object($prop_types)) {
+  while ($prop = $prop_types->fetchObject()) {
     $properties_list[$prop->cvterm_id] = $prop->name;
   }
     
@@ -262,7 +251,7 @@ function chado_analysis_delete($node) {
               "WHERE nid = :nid " .
               "AND vid = :vid";
   db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
-  $sql_del = "DELETE FROM {node_revisions} " .
+  $sql_del = "DELETE FROM {node_revision} " .
               "WHERE nid = :nid " .
               "AND vid = :vid";
   db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
@@ -359,7 +348,7 @@ function chado_analysis_update($node) {
       ORDER BY CVT.name ASC
       ";
   $prop_types = chado_query($sql);
-  while ($prop = db_fetch_object($prop_types)) {
+  while ($prop = $prop_types->fetchObject()) {
     $properties_list[$prop->cvterm_id] = $prop->name;
   }
 
@@ -392,13 +381,13 @@ function chado_analysis_update($node) {
   // now add in the properties by first removing any the analysis
   // already has and adding the ones we have
   $sql = "
-    DELETE FROM {analysisprop} WHERE analysis_id = %d AND type_id IN (
+    DELETE FROM {analysisprop} WHERE analysis_id = :analysis_id AND type_id IN (
       SELECT CVT.cvterm_id
       FROM  {cvterm} CVT
         INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
       WHERE CV.name = 'analysis_property')
   ";
-  $success = chado_query($sql, $analysis_id);
+  $success = chado_query($sql, array(':analysis_id' => $analysis_id));
   if (!$success) {
     drupal_set_message("Cannot update analysis properties", "error");
     watchdog('t_analysis', "Cannot update analysis properties.", array(), WATCHDOG_ERROR);
@@ -489,12 +478,12 @@ function tripal_analysis_help($path, $arg) {
  *
  * This hook allows node modules to limit access to the node types they define.
  *
- *  @param $op
- *  The operation to be performed
- *
  *  @param $node
  *  The node on which the operation is to be performed, or, if it does not yet exist, the
  *  type of node to be created
+ *  
+ *  @param $op
+ *  The operation to be performed
  *
  *  @param $account
  *  A user object representing the user for whom the operation is to be performed
@@ -507,7 +496,7 @@ function tripal_analysis_help($path, $arg) {
  *
  * @ingroup tripal_analysis
  */
-function chado_analysis_access($op, $node, $account) {
+function chado_analysis_node_access($node, $op, $account) {
 
   if ($op == 'create') {
     if (!user_access('create chado_analysis content', $account)) {
@@ -540,7 +529,7 @@ function chado_analysis_access($op, $node, $account) {
  *
  * @ingroup tripal_analysis
  */
-function tripal_analysis_perm() {
+function tripal_analysis_permission() {
   return array(
     'access chado_analysis content' => array(
       'title' => t('View Analyses'),
@@ -601,38 +590,42 @@ function tripal_analysis_theme() {
 /**
  *
  *
- * @ingroup tripal_feature
+ * @ingroup tripal_analysis
  */
-function tripal_analysis_block($op = 'list', $delta = 0, $edit=array()) {
-  switch ($op) {
-    case 'list':
-      $blocks['base']['info'] = t('Tripal Analysis Details');
-      $blocks['base']['cache'] = BLOCK_NO_CACHE;
-      
-      $blocks['featureblast']['info'] = t('Tripal Feature Analyses');
-      $blocks['featureblast']['cache'] = BLOCK_NO_CACHE;
-      
-      return $blocks;
-
-  case 'view':
-    if (user_access('access chado_analysis content') and arg(0) == 'node' and is_numeric(arg(1))) {
-      $nid = arg(1);
-      $node = node_load($nid);
-
-      $block = array();
-      switch ($delta) {       
-        case 'base':
-          $block['subject'] = t('Analysis Details');
-          $block['content'] = theme('tripal_analysis_base', $node);
-          break;
-        case 'tripal_feature_analyses':
-          $block['subject'] = t('Feature Analyses');
-          $block['content'] = theme('tripal_feature_analyses', $node);
-          break;
-        default :
-      }
-      return $block;
+function tripal_analysis_block_info() {
+  $blocks['base']['info'] = t('Tripal Analysis Details');
+  $blocks['base']['cache'] = BLOCK_NO_CACHE;
+  
+  $blocks['featureblast']['info'] = t('Tripal Feature Analyses');
+  $blocks['featureblast']['cache'] = BLOCK_NO_CACHE;
+  
+  return $blocks;
+}
+
+/**
+ *
+ *
+ * @ingroup tripal_analysis
+ */
+function tripal_analysis_block_view($delta = '') {
+
+  if (user_access('access chado_analysis content') and arg(0) == 'node' and is_numeric(arg(1))) {
+    $nid = arg(1);
+    $node = node_load($nid);
+
+    $block = array();
+    switch ($delta) {       
+      case 'base':
+        $block['subject'] = t('Analysis Details');
+        $block['content'] = theme('tripal_analysis_base', $node);
+        break;
+      case 'tripal_feature_analyses':
+        $block['subject'] = t('Feature Analyses');
+        $block['content'] = theme('tripal_feature_analyses', $node);
+        break;
+      default :
     }
+    return $block;
   }
 }
 

+ 2 - 2
tripal_feature/tripal_feature.info

@@ -1,9 +1,9 @@
 name = Tripal Feature
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing, inserting and editing of chado features.
-core = 6.x
+core = 7.x
 project = tripal_feature
 package = Tripal
-version = 6.x-1.1
+version = 7.x-2.0
 dependencies[] = search
 dependencies[] = path
 dependencies[] = tripal_core

+ 48 - 47
tripal_organism/tripal_organism.module

@@ -39,50 +39,50 @@ function tripal_organism_node_info() {
 }
 
 /**
- * Display block with organisms
- * @param op    - parameter to define the phase being called for the block
- * @param delta - id of the block to return (ignored when op is list)
- * @param edit  - when op is save, contains the submitted form data
  *
  * @ingroup tripal_organism
  */
-function tripal_organism_block($op = 'list', $delta = '0', $edit = array()) {
-  switch ($op) {
-    case 'list':
-      $blocks['base']['info'] = t('Tripal Organism Details');
-      $blocks['base']['cache'] = BLOCK_NO_CACHE;
-
-      $blocks['description']['info'] = t('Tripal Organism Description');
-      $blocks['description']['cache'] = BLOCK_NO_CACHE;
-
-      $blocks['image']['info'] = t('Tripal Organism Image');
-      $blocks['image']['cache'] = BLOCK_NO_CACHE;
-
-      return $blocks;
-
-    case 'view':
-      if (user_access('access chado_feature content') and arg(0) == 'node' and is_numeric(arg(1))) {
-        $nid = arg(1);
-        $node = node_load($nid);
-
-        $block = array();
-        switch ($delta) {
-          case 'base':
-            $block['subject'] = t('Organism Details');
-            $block['content'] = theme('tripal_organism_base', $node);
-            break;
-          case 'description':
-            $block['subject'] = t('Organism Description');
-            $block['content'] = theme('tripal_organism_description', $node);
-            break;
-          case 'image':
-            $block['subject'] = t('Organism Image');
-            $block['content'] = theme('tripal_organism_image', $node);
-            break;
-          default:
-        }
-        return $block;
-      }
+function tripal_organism_block_info() {
+
+  $blocks['base']['info'] = t('Tripal Organism Details');
+  $blocks['base']['cache'] = BLOCK_NO_CACHE;
+
+  $blocks['description']['info'] = t('Tripal Organism Description');
+  $blocks['description']['cache'] = BLOCK_NO_CACHE;
+
+  $blocks['image']['info'] = t('Tripal Organism Image');
+  $blocks['image']['cache'] = BLOCK_NO_CACHE;
+
+  return $blocks;
+   
+}
+/**
+ *
+ * @ingroup tripal_organism
+ */
+function tripal_organism_block_view($delta = '') {
+
+  if (user_access('access chado_feature content') and arg(0) == 'node' and is_numeric(arg(1))) {
+    $nid = arg(1);
+    $node = node_load($nid);
+  
+    $block = array();
+    switch ($delta) {
+      case 'base':
+        $block['subject'] = t('Organism Details');
+        $block['content'] = theme('tripal_organism_base', $node);
+        break;
+      case 'description':
+        $block['subject'] = t('Organism Description');
+        $block['content'] = theme('tripal_organism_description', $node);
+        break;
+      case 'image':
+        $block['subject'] = t('Organism Image');
+        $block['content'] = theme('tripal_organism_image', $node);
+        break;
+      default:
+    }
+    return $block;
   }
 }
 /**
@@ -153,13 +153,14 @@ function tripal_organism_theme() {
  * Implement hook_access().
  *
  * This hook allows node modules to limit access to the node types they define.
- *
- *  @param $op
- *  The operation to be performed
- *
+ * 
  *  @param $node
  *  The node on which the operation is to be performed, or, if it does not yet exist, the
  *  type of node to be created
+ *  
+ *  @param $op
+ *  The operation to be performed
+ *
  *
  *  @param $account
  *  A user object representing the user for whom the operation is to be performed
@@ -172,7 +173,7 @@ function tripal_organism_theme() {
  *
  * @ingroup tripal_organism
  */
-function chado_organism_access($op, $node, $account) {
+function chado_organism_node_access($node, $op, $account) {
   if ($op == 'create') {
     if (!user_access('create chado_organism content', $account)) {
       return FALSE;
@@ -388,7 +389,7 @@ function chado_organism_delete($node) {
              "WHERE nid = :nid " .
              "AND vid = :vid";
   db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
-  $sql_del = "DELETE FROM {node_revisions} " .
+  $sql_del = "DELETE FROM {node_revision} " .
              "WHERE nid = ':nid' " .
              "AND vid = ':vid'";
   db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));

+ 10 - 10
tripal_project/includes/tripal_project.admin.inc

@@ -90,11 +90,11 @@ function get_tripal_project_admin_form_sync_set(&$form) {
     // a message stating that all projects are currently synced.
     $proj_boxes = array();
     $added = 0;
-    while ($project = db_fetch_object($org_rset)) {
+    while ($project = $org_rset->fetchObject()) {
       // check to see if the project is already present as a node in drupal.
       // if so, then skip it.
-      $sql = "SELECT * FROM {chado_project} WHERE project_id = %d";
-      if (!db_fetch_object(db_query($sql, $project->project_id))) {
+      $sql = "SELECT * FROM {chado_project} WHERE project_id = :project_id";
+      if (!db_query($sql, array(':project_id' => $project->project_id))->fetchObject()) { 
         $proj_boxes[$project->project_id] = $project->name;
         $added++;
       }
@@ -156,7 +156,7 @@ function tripal_project_admin_validate($form, &$form_state) {
       if ($project_id and preg_match("/^\d+$/i" , $project_id)) {
         // get the list of projects
         $sql = "SELECT * FROM {Project} WHERE project_id = %d";
-        $project = db_fetch_object(chado_query($sql, $project_id));
+        $project = chado_query($sql, $project_id)->fetchObject();
         $to_sync[$project_id] = "$project->genus $project->species";
       }
     }
@@ -183,7 +183,7 @@ function tripal_project_admin_validate($form, &$form_state) {
       if ($project_id and preg_match("/^\d+$/i" , $project_id)) {
         // get the project info
         $sql = "SELECT * FROM {project} WHERE project_id = %d";
-        $project = db_fetch_object(chado_query($sql , $project_id));
+        $project = chado_query($sql , $project_id)->fetchObject();
         $job_args[0] = $project_id;
         tripal_add_job("Reindex features for project: $project->genus ".
          "$project->species", 'tripal_project' ,
@@ -200,7 +200,7 @@ function tripal_project_admin_validate($form, &$form_state) {
       if ($project_id and preg_match("/^\d+$/i", $project_id)) {
         // get the project info
         $sql = "SELECT * FROM {project} WHERE project_id = %d";
-        $project = db_fetch_object(chado_query($sql , $project_id));
+        $project = chado_query($sql , $project_id)->fetchObject();
         $job_args[0] = $project_id;
         tripal_add_job("Set taxonomy for features in project: ".
           "$project->genus $project->species" , 'tripal_project',
@@ -239,11 +239,11 @@ function tripal_project_sync_projects($project_id = NULL, $job_id = NULL) {
   $sql = "SELECT * FROM {chado_project} ".
          "WHERE project_id = %d";
 
-  while ($project = db_fetch_object($results)) {
+  while ($project = $results->fetchObject()) {
 
     // check if this project already exists in the drupal database. if it
     // does then skip this project and go to the next one.
-    if (!db_fetch_object(db_query($sql, $project->project_id))) {
+    if (!db_query($sql, $project->project_id)->fetchObject()) {
 
       $new_node = new stdClass();
       $new_node->type = 'chado_project';
@@ -290,14 +290,14 @@ function tripal_project_sync_all_projects() {
   //retrieve all projects in drupal
   $resource = db_query('SELECT project_id FROM {chado_project}');
   $drupal_projects = array();
-  while ($r = db_fetch_object($resource)) {
+  while ($r = $resource->fetchObject()) {
     $drupal_projects[$r->project_id] = $r->project_id;
   }
 
   // retrieve all projects in chado
   $chado_projects = array();
   $resource = chado_query('SELECT project_id FROM {project}');
-  while ($r = db_fetch_object($resource)) {
+  while ($r = $resource->fetchObject()) {
     // if not already in drupal add to list to be sync'd
     if (!isset($drupal_projects[$r->project_id])) {
       $chado_projects[$r->project_id] = $r->project_id;

+ 2 - 2
tripal_project/tripal_project.info

@@ -1,8 +1,8 @@
 name = Tripal Project
 description = A module for interfacing the GMOD chado database with Drupal, providing viewing of projects
-core = 6.x
+core = 7.x
 project = tripal_project
 package = Tripal
-version = 6.x-1.1
+version = 7.x-2.0
 dependencies[] = tripal_core
 dependencies[] = tripal_cv

+ 5 - 14
tripal_project/tripal_project.install

@@ -14,7 +14,10 @@
  * Implementation of hook_install().
  */
 function tripal_project_install() {
-  drupal_install_schema('tripal_project');
+  
+  // create the module's data directory
+  tripal_create_moddir('tripal_project');
+  
   tripal_project_add_cvterms();
 }
 
@@ -22,7 +25,7 @@ function tripal_project_install() {
  * Implementation of hook_uninstall().
  */
 function tripal_project_uninstall() {
-  drupal_uninstall_schema('tripal_project');
+
 }
 
 /**
@@ -79,16 +82,4 @@ function tripal_project_add_cvterms() {
   // description in the libraryprop table.
   tripal_cv_add_cvterm(array('name' => 'project_description', 'def' => 'Description of a project'), 
     'tripal', 0, 1, 'tripal'); 
-}
-/**
- *  Update for Drupal 6.x, Tripal 1.0
- *  This update
- *   - adds the library types
- *
- * @ingroup tripal_library
- */
-function tripal_project_update_6000() {
-  // add in the missing library typ cv terms
-  tripal_project_add_cvterms();
-  return $ret;
 }

+ 105 - 91
tripal_project/tripal_project.module

@@ -66,13 +66,28 @@ function tripal_project_menu() {
  *
  * @ingroup tripal_project
  */
-function tripal_project_perm() {
+function tripal_project_permission() {
   return array(
-    'access chado_projects content',
-    'create chado_projects content',
-    'delete chado_projects content',
-    'edit chado_projects content',
-    'adminster tripal projects',
+    'access chado_project content' => array(
+      'title' => t('View Projects'),
+      'description' => t('Allow users to view project pages.'),
+    ),
+    'create chado_project content' => array(
+      'title' => t('Create Projects'),
+      'description' => t('Allow users to create new project pages.'),
+    ),
+    'delete chado_project content' => array(
+      'title' => t('Delete Projects'),
+      'description' => t('Allow users to delete project pages.'),
+    ),
+    'edit chado_project content' => array(
+      'title' => t('Edit Projects'),
+      'description' => t('Allow users to edit project pages.'),
+    ),
+    'adminster tripal project' => array(
+      'title' => t('Administer Projects'),
+      'description' => t('Allow users to administer all projects.'),
+    ),
   );
 }
 
@@ -81,12 +96,13 @@ function tripal_project_perm() {
  *
  * This hook allows node modules to limit access to the node types they define.
  *
- *  @param $op
- *  The operation to be performed
- *
  *  @param $node
  *  The node on which the operation is to be performed, or, if it does not yet exist, the
  *  type of node to be created
+ *  
+ *  @param $op
+ *  The operation to be performed
+ *
  *
  *  @param $account
  *  A user object representing the user for whom the operation is to be performed
@@ -99,7 +115,7 @@ function tripal_project_perm() {
  *  
  * @ingroup tripal_project
  */
-function chado_project_access($op, $node, $account) {
+function chado_project_node_access($node, $op, $account) {
 
   if ($op == 'create') {
     if (!user_access('create chado_projects content', $account)) {
@@ -139,7 +155,7 @@ function tripal_project_node_info() {
   return array(
     'chado_project' => array(
       'name' => t('Project'),
-      'module' => 'chado_project',
+      'base' => 'chado_project',
       'description' => t('A module for interfacing the GMOD chado database with Drupal, providing viewing of projects'),
       'has_title' => TRUE,
       'title_label' => t('Project Name'),
@@ -266,12 +282,12 @@ function chado_project_validate($node) {
   // check to make sure the name on the project is unique
   // before we try to insert into chado.
   if ($node->project_id) {
-    $sql = "SELECT * FROM {project} WHERE name = '%s' AND NOT project_id = %d";
-    $project = db_fetch_object(chado_query($sql, $node->title, $node->project_id));
+    $sql = "SELECT * FROM {project} WHERE name = :name AND NOT project_id = :project_id";
+    $project = chado_query($sql, array(':name' => $node->title, ':project_id' => $node->project_id))->fetchObject();
   }
   else {
-    $sql = "SELECT * FROM {project} WHERE name = '%s'";
-    $project = db_fetch_object(chado_query($sql, $node->title));
+    $sql = "SELECT * FROM {project} WHERE name = :name";
+    $project = chado_query($sql, array(':name' => $node->title))->fetchObject();
   }
   if ($project) {
     form_set_error('title', t('The unique project name already exists. Please choose another'));
@@ -310,8 +326,8 @@ function chado_project_insert($node) {
     if (!$project_id) {
        // next add the item to the drupal table
       $sql = "INSERT INTO {chado_project} (nid, vid, project_id) ".
-             "VALUES (%d, %d, %d)";
-      db_query($sql, $node->nid, $node->vid, $project['project_id']);
+             "VALUES (:nid, :vid, :project_id)";
+      db_query($sql, array(':nid' => $node->nid, ':vid' => $node->vid, ':project_id' => $project['project_id']));
     }
   }
   else {
@@ -345,22 +361,22 @@ function chado_project_delete($node) {
   // Remove data from {chado_project}, {node} and {node_revisions} tables of
   // drupal database
   $sql_del = "DELETE FROM {chado_project} ".
-             "WHERE nid = %d ".
-             "AND vid = %d";
-  db_query($sql_del, $node->nid, $node->vid);
-  $sql_del = "DELETE FROM {node_revisions} ".
-             "WHERE nid = %d ".
-             "AND vid = %d";
-  db_query($sql_del, $node->nid, $node->vid);
+             "WHERE nid = :nid ".
+             "AND vid = :vid";
+  db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
+  $sql_del = "DELETE FROM {node_revision} ".
+             "WHERE nid = :nid ".
+             "AND vid = :vod";
+  db_query($sql_del,  array(':nid' => $node->nid, ':vid' => $node->vid));
   $sql_del = "DELETE FROM {node} ".
-             "WHERE nid = %d ".
-             "AND vid = %d";
-  db_query($sql_del, $node->nid, $node->vid);
+             "WHERE nid = :nid ".
+             "AND vid = :vid";
+  db_query($sql_del,  array(':nid' => $node->nid, ':vid' => $node->vid));
 
 
   // Remove data from project and projectprop tables of chado database as well
-  chado_query("DELETE FROM {projectprop} WHERE project_id = %d", $project_id);
-  chado_query("DELETE FROM {project} WHERE project_id = %d", $project_id);
+  chado_query("DELETE FROM {projectprop} WHERE project_id = :project_id", array(':project_id' => $project_id));
+  chado_query("DELETE FROM {project} WHERE project_id = :project_id", array(':project_id' => $project_id));
 }
 
 /**
@@ -421,65 +437,63 @@ function chado_project_load($node) {
 }
 
 /**
- * Display block with projects
- * @param op    - parameter to define the phase being called for the block
- * @param delta - id of the block to return (ignored when op is list)
- * @param edit  - when op is save, contains the submitted form data
  *
  * @ingroup tripal_project
  */
-function tripal_project_block($op = 'list', $delta = '0', $edit = array()) {
-  switch ($op) {
-    case 'list':
-
-    $blocks['projectbase']['info'] = t('Tripal Project Details');
-    $blocks['projectbase']['cache'] = BLOCK_NO_CACHE;
-
-    $blocks['projectprops']['info'] = t('Tripal Project Properties');
-    $blocks['projectprops']['cache'] = BLOCK_NO_CACHE;
-
-    $blocks['projectpubs']['info'] = t('Tripal Project Publications');
-    $blocks['projectpubs']['cache'] = BLOCK_NO_CACHE;
-
-    $blocks['projectcont']['info'] = t('Tripal Project Contact');
-    $blocks['projectcont']['cache'] = BLOCK_NO_CACHE;
-
-    $blocks['projectrels']['info'] = t('Tripal Project Relationships');
-    $blocks['projectrels']['cache'] = BLOCK_NO_CACHE;
-
-    return $blocks;
-
-    case 'view':
-      if (user_access('access chado_project content') and arg(0) == 'node' and is_numeric(arg(1))) {
-        $nid = arg(1);
-        $node = node_load($nid);
-
-        $block = array();
-        switch ($delta) {
-          case 'projectbase':
-            $block['subject'] = t('Project Details');
-            $block['content'] = theme('tripal_project_base', $node);
-            break;
-          case 'projectprops':
-            $block['subject'] = t('Properties');
-            $block['content'] = theme('tripal_project_properties', $node);
-            break;
-          case 'projectpubs':
-            $block['subject'] = t('Publications');
-            $block['content'] = theme('tripal_project_publications', $node);
-            break;
-          case 'projectcont':
-            $block['subject'] = t('Contact');
-            $block['content'] = theme('tripal_project_contact', $node);
-            break;
-          case 'projectrels':
-            $block['subject'] = t('Relationships');
-            $block['content'] = theme('tripal_project_relationships', $node);
-            break;
-          default :
-        }
-        return $block;
-      }
+function tripal_project_block_info() {
+
+  $blocks['projectbase']['info'] = t('Tripal Project Details');
+  $blocks['projectbase']['cache'] = BLOCK_NO_CACHE;
+  
+  $blocks['projectprops']['info'] = t('Tripal Project Properties');
+  $blocks['projectprops']['cache'] = BLOCK_NO_CACHE;
+  
+  $blocks['projectpubs']['info'] = t('Tripal Project Publications');
+  $blocks['projectpubs']['cache'] = BLOCK_NO_CACHE;
+  
+  $blocks['projectcont']['info'] = t('Tripal Project Contact');
+  $blocks['projectcont']['cache'] = BLOCK_NO_CACHE;
+  
+  $blocks['projectrels']['info'] = t('Tripal Project Relationships');
+  $blocks['projectrels']['cache'] = BLOCK_NO_CACHE;
+  
+  return $blocks;
+}
+/**
+ *
+ * @ingroup tripal_project
+ */
+function tripal_project_block_view($delta = '') {
+ 
+  if (user_access('access chado_project content') and arg(0) == 'node' and is_numeric(arg(1))) {
+    $nid = arg(1);
+    $node = node_load($nid);
+  
+    $block = array();
+    switch ($delta) {
+      case 'projectbase':
+        $block['subject'] = t('Project Details');
+        $block['content'] = theme('tripal_project_base', $node);
+        break;
+      case 'projectprops':
+        $block['subject'] = t('Properties');
+        $block['content'] = theme('tripal_project_properties', $node);
+        break;
+      case 'projectpubs':
+        $block['subject'] = t('Publications');
+        $block['content'] = theme('tripal_project_publications', $node);
+        break;
+      case 'projectcont':
+        $block['subject'] = t('Contact');
+        $block['content'] = theme('tripal_project_contact', $node);
+        break;
+      case 'projectrels':
+        $block['subject'] = t('Relationships');
+        $block['content'] = theme('tripal_project_relationships', $node);
+        break;
+      default :
+    }
+    return $block;
   }
 }
 /**
@@ -501,18 +515,18 @@ function tripal_project_preprocess_tripal_project_relationships(&$variables) {
       INNER JOIN {project} P            ON PR.object_project_id = P.project_id
       INNER JOIN {cvterm} CVT           ON PR.type_id           = CVT.cvterm_id
       LEFT JOIN public.chado_project CP ON P.project_id         = CP.project_id
-    WHERE PR.subject_project_id = %d
+    WHERE PR.subject_project_id = :project_id
   ";
-  $as_subject = chado_query($sql, $project->project_id);
+  $as_subject = chado_query($sql, array(':project_id' => $project->project_id));
   $sql = "
     SELECT P.name, P.project_id, CP.nid, CVT.name as rel_type
     FROM project_relationship PR
       INNER JOIN {project} P            ON PR.subject_project_id = P.project_id
       INNER JOIN {cvterm} CVT           ON PR.type_id            = CVT.cvterm_id
       LEFT JOIN public.chado_project CP ON P.project_id          = CP.project_id
-    WHERE PR.object_project_id = %d
+    WHERE PR.object_project_id = :project_id
   ";
-  $as_object = chado_query($sql, $project->project_id);
+  $as_object = chado_query($sql, array(':project_id' => $project->project_id));
 
   // combine both object and subject relationshisp into a single array
   $relationships = array();
@@ -520,7 +534,7 @@ function tripal_project_preprocess_tripal_project_relationships(&$variables) {
   $relationships['subject'] = array();
 
   // iterate through the object relationships
-  while ($relationship = db_fetch_object($as_object)) {
+  while ($relationship = $as_object->fetchObject()) {
 
      // get the relationship and child types
      $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));
@@ -536,7 +550,7 @@ function tripal_project_preprocess_tripal_project_relationships(&$variables) {
   }
 
   // now add in the subject relationships
-  while ($relationship = db_fetch_object($as_subject)) {
+  while ($relationship = $as_subject->fetchObject()) {
 
      // get the relationship and child types
      $rel_type = t(preg_replace('/_/', " ", $relationship->rel_type));