Browse Source

Tripal analysis adheres to Drupal coding standards

Pubudu Basnayaka 12 years ago
parent
commit
fb8bf61008

+ 285 - 284
tripal_analysis/tripal_analysis.admin.inc

@@ -6,7 +6,7 @@
 /**
  * Purpose: Provide Guidance to new Tripal Admin
  *
- * @return 
+ * @return
  *   HTML Formatted text
  *
  * @ingroup tripal_analysis
@@ -15,9 +15,9 @@ function tripal_analysis_module_description_page() {
 
   $text .= '<h3>Tripal Analysis Administrative Tools Quick Links:</h3>';
   $text .= "<ul>
-             <li><a href=\"".url("admin/tripal/tripal_analysis/configuration") . "\">Analysis Configuration</a></li>
+             <li><a href=\"" . url("admin/tripal/tripal_analysis/configuration") . "\">Analysis Configuration</a></li>
            </ul>";
- 
+
 
   $text .= '<h3>Module Description:</h3>';
   $text .= '<p>The Tripal Analysis module provides a generic analysis content type that is intended to be
@@ -30,66 +30,66 @@ function tripal_analysis_module_description_page() {
   $text .= '<h3>Setup Instructions:</h3>';
   $text .= '<p>After installation of the analysis module or any specialized analysis module.  The following tasks should be performed
             <ol>
-              <li><p><b>Set Permissions</b>: Each analysis module supports the Drupal user permissions interface for 
-               controlling access to the content and functions. These permissions include viewing, 
+              <li><p><b>Set Permissions</b>: Each analysis module supports the Drupal user permissions interface for
+               controlling access to the content and functions. These permissions include viewing,
                creating, editing or administering of
-               analysis content. The default is that only the original site administrator has these 
-               permissions.  You can <a href="'.url('admin/user/roles').'">add roles</a> for classifying users, 
-               <a href="'.url('admin/user/user').'">assign users to roles</a> and
-               <a href="'.url('admin/user/permissions').'">assign permissions</a> for the analysis content to 
-               those roles.  For a simple setup, allow anonymous users access to view organism content and 
+               analysis content. The default is that only the original site administrator has these
+               permissions.  You can <a href="' . url('admin/user/roles') .  '">add roles</a> for classifying users,
+               <a href="' . url('admin/user/user') . '">assign users to roles</a> and
+               <a href="' . url('admin/user/permissions') . '">assign permissions</a> for the analysis content to
+               those roles.  For a simple setup, allow anonymous users access to view organism content and
                allow the site administrator all other permissions.</p></li>
 
 
-               <li><p><b>Create Analysis</b>:  An analysis should be <a href="'.url('node/add').'">created</a> before data is imported into
+               <li><p><b>Create Analysis</b>:  An analysis should be <a href="' . url('node/add') . '">created</a> before data is imported into
                chado.  The generic analysis type should only be used when a more specialized analysis module
-               (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into 
-               Chado should be associated with an analysis.    
+               (e.g. Tripal Analysis Blast module) does not already exists.  All data imported into
+               Chado should be associated with an analysis.
 
                <li><p><b>Sync Analyses</b>:  If Chado has preloaded analyses then you can sync those.  This process is what
-               creates the pages for viewing an analysis on the site.  Analyses can be synced using the 
-               <a href="'.url('admin/tripal/tripal_analysis/configuration').'">Analysis Configuration page</a>. 
+               creates the pages for viewing an analysis on the site.  Analyses can be synced using the
+               <a href="' . url('admin/tripal/tripal_analysis/configuration') . '">Analysis Configuration page</a>.
                However, syncing an analyses will always create a generic analysis content type.  If you would like
                to use a specialized analysis module for visualization of data then do not sync the analysis but recreate it
                using the appropriate specialized analysis content type.</p></li>
- 
+
             </ol>
             </p>';
-  
-  
+
+
   $text .= '<h3>Features of this Module:</h3>';
   $text .= '<p>Aside from providing a generic content type the Tripal Analysis module also provides the following functionality
             <ul>
-            
-              <li><p><b>Basic Analysis Lookup View</b>: This module provides a basic <a href="'.url('analyses').'">analysis search 
+
+              <li><p><b>Basic Analysis Lookup View</b>: This module provides a basic <a href="' . url('analyses') . '">analysis search
               tool</a> for finding or listing analyses in Chado. It does not require indexing for Drupal searching but relies
-              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>              
+              on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a> must be installed. </p></li>
 
             </ul>
             </p>';
 
    $text .= '<h3>Page Customizations</h3>';
-   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal. 
+   $text .= '<p>There are several ways to customize the look-and-feel for the way Chado data is presented through Tripal.
              Below is a description of several methods.  These methods may be used in conjunction with one another to
-             provide fine-grained control. 
+             provide fine-grained control.
              <ul>
 
-             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a> 
-              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.  
-              Tripal comes with pre-set layouts for analysis pages.  However, 
+             <li><p><b>Integration with Drupal Panels</b>:  <a href="http://drupal.org/project/views">Drupal Panels</a>
+              allows for customization of a page layout if you don\'t want to do PHP/Javascript/CSS programming.
+              Tripal comes with pre-set layouts for analysis pages.  However,
               Panels become useful if you prefer a layout that is different from the pre-set layouts.  Chado content
-              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the 
+              is provided to Panels in the form of Drupal "blocks" which you can then place anywhere on a page using the
               Panel\'s GUI.</p></li>
 
-             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the 
+             <li><p><b>Drupal\'s Content Construction Kit (CCK)</b>: the
              <a href="http://drupal.org/project/cck">Content Construction Kit (CCK) </a> is a powerful way to add non-Chado content
              to any page without need to edit template files or knowing PHP.  You must first download and install CCK.
              With CCK, the site administartor can create a new field to appear on the page.  For example, currently,
-             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text 
+             the Chado publication module is not yet supported by Tripal.  Therefore, the site administrator can add a text
              field to the analysis pages.  This content is not stored in Chado, but will appear on the analysis page.  A field
              added by CCK will also appear in the form when editing a analysis to allow users to manually enter the appropriate
              text.  If the default pre-set layout and themeing for Tripal is used, it is better to create the CCK element,
-             indicate that it is not to be shown (using the CCK interface), then manually add the new content type 
+             indicate that it is not to be shown (using the CCK interface), then manually add the new content type
              where desired by editing the templates (as described below).  If using Panels, the CCK field can be added to the
              location desired using the Panels interface.</p></li>
 
@@ -97,18 +97,18 @@ function tripal_analysis_module_description_page() {
              themeing for Chado content.    The analysis module has a template file for analysis "nodes" (Tripal analysis pages).  This file
              is named "node-chado_analysis.tpl.php", and provides javascript, HTML and PHP code for display of the analysis
              pages.  Specialized analysis modules will have their own template files as well, such as "node-chado_analysis-blast.tpl.php" for the
-             Tripal Analysis Blast module.  You can edit the template file to control which types of information (or which analysis "blocks") are displayed 
-             for analysis. Be sure to 
+             Tripal Analysis Blast module.  You can edit the template file to control which types of information (or which analysis "blocks") are displayed
+             for analysis. Be sure to
              copy these template to your primary theme directory for editing. Do not edit them in the "theme_tripal" directory as
              future Tripal updates may overwrite your customizations. See the <a href="http://tripal.sourceforge.net/">Tripal website </a>
              for instructions on how to access variables and other Chado content within the template file.</p></li>
 
              <li><p><b>Analysis "Block" Templates</b>:  In the "theme_tripal" directory are subdirectories named after each tripal module (e.g. "tripal_feature", "tripal_library", etc.).
              Inside each directory is a set of templates that control distinct types of information for each content type.  For example,
-             there is a "base" template for displaying of data directly from the Chado feature table, and a "references" 
-             template for showing external site references for a feature (data from the feature_dbxref table). 
+             there is a "base" template for displaying of data directly from the Chado feature table, and a "references"
+             template for showing external site references for a feature (data from the feature_dbxref table).
               These templates are used both by Drupal blocks
-             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template 
+             for use in Drupal Panels (as described above) or for use in the default pre-set layout that the node template
              provides (also desribed above).  Analyses block templates can exist in any of these directories.  For example, the Tripal Analysis Unigene
              module uses templates in the tripal_analysis_unigene, tripal_organism, and tripal_feature directories.  Content for a unigene is then
              cusotmizable within each of these contexts.
@@ -120,9 +120,9 @@ function tripal_analysis_module_description_page() {
 
              <li><p><b>Adding Links to the "Resources" Sidebar</b>: If you use the pre-set default Tripal layout for theming, you
              will see a "Resources" sidebar on each page.  The links that appear on the sidebar are automatically generated
-             using Javascript for all of the analysis "Blocks" that appear on the page. If you want to add additional links 
-             (e.g. a dynamic link to GBrowse for the analysis) and you want that link to appear in the 
-             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the 
+             using Javascript for all of the analysis "Blocks" that appear on the page. If you want to add additional links
+             (e.g. a dynamic link to GBrowse for the analysis) and you want that link to appear in the
+             "Resources" sidebar, simply edit the Drupal Node Template (as described above) and add the link to the
              section at the bottom of the template file where the resources section is found.</p></li>
 
              </ul>
@@ -140,66 +140,67 @@ function tripal_analysis_module_description_page() {
  * @ingroup tripal_analysis
  */
 function tripal_analysis_admin() {
-	// Create a new administrative form. We'll add main functions to the form
-	// first (Sync, Reindex, Clean, Taxonify). Thereafter, any sub-module that
-	// has a setting will be added.
-	$form = array();
-
-	// before proceeding check to see if we have any
-	// currently processing jobs. If so, we don't want
-	// to give the opportunity to sync libraries
-	$active_jobs = FALSE;
-	if(tripal_get_module_active_jobs('tripal_organism')){
-		$active_jobs = TRUE;
-	}
-
-	// add the field set for syncing libraries
-	if(!$active_jobs){
-		// add the field set for syncing analyses
-		get_tripal_analysis_admin_form_sync_set($form);
-//		get_tripal_analysis_admin_form_reindex_set($form);
-//		get_tripal_analysis_admin_form_taxonomy_set($form);
-		get_tripal_analysis_admin_form_cleanup_set($form);
-	} else {
-		$form['notice'] = array(
-		   '#type' => 'fieldset',
-		   '#title' => t('Analysis Management Temporarily Unavailable')
-		);
-		$form['notice']['message'] = array(
+  // Create a new administrative form. We'll add main functions to the form
+  // first (Sync, Reindex, Clean, Taxonify). Thereafter, any sub-module that
+  // has a setting will be added.
+  $form = array();
+
+  // before proceeding check to see if we have any
+  // currently processing jobs. If so, we don't want
+  // to give the opportunity to sync libraries
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_organism')) {
+    $active_jobs = TRUE;
+  }
+
+  // add the field set for syncing libraries
+  if (!$active_jobs) {
+    // add the field set for syncing analyses
+    get_tripal_analysis_admin_form_sync_set($form);
+//    get_tripal_analysis_admin_form_reindex_set($form);
+//    get_tripal_analysis_admin_form_taxonomy_set($form);
+    get_tripal_analysis_admin_form_cleanup_set($form);
+  }
+  else {
+    $form['notice'] = array(
+       '#type' => 'fieldset',
+       '#title' => t('Analysis Management Temporarily Unavailable')
+    );
+    $form['notice']['message'] = array(
           '#value' => t('Currently, analysis management jobs are waiting or are running. . Managemment features have been hidden until these jobs complete.  Please check back later once these jobs have finished.  You can view the status of pending jobs in the Tripal jobs page.'),
-		);
-	}
-
-	// Add sub-module settings. Pull all sub-module information from
-	// {tripal_analysis} table
-	$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)) {
-
-		// Check if the hook_get_settings() function is already defined.
-		$func = $data->modulename."_get_settings";
-		$functions = get_defined_functions();
-		$settings;
-		foreach($functions['user'] as $function) {
-			if ($function == $func) {
-				$settings = $func();
-			}
-		}
-		
-		// Add sub-module's specific settings to the administrative view
-		if ($settings) {
-			// Define a fieldset for the sub-module
-			$form["field$counter"] = array(
+    );
+  }
+
+  // Add sub-module settings. Pull all sub-module information from
+  // {tripal_analysis} table
+  $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)) {
+
+    // Check if the hook_get_settings() function is already defined.
+    $func = $data->modulename . "_get_settings";
+    $functions = get_defined_functions();
+    $settings;
+    foreach ($functions['user'] as $function) {
+      if ($function == $func) {
+        $settings = $func();
+      }
+    }
+
+    // Add sub-module's specific settings to the administrative view
+    if ($settings) {
+      // Define a fieldset for the sub-module
+      $form["field$counter"] = array(
             '#type' => 'fieldset',
             '#title' => "$settings->title",
             '#collapsible' => TRUE
-			);
-			$form["field$counter"]["$settings->title"] = $settings->form;
-		}
-		$counter ++;
-	}
-	return system_settings_form($form);
+      );
+      $form["field$counter"]["$settings->title"] = $settings->form;
+    }
+    $counter ++;
+  }
+  return system_settings_form($form);
 }
 
 /**
@@ -207,32 +208,32 @@ function tripal_analysis_admin() {
  * @ingroup tripal_analysis
  */
 function get_tripal_analysis_admin_form_taxonomy_set(&$form) {
-	$form['taxonify'] = array(
+  $form['taxonify'] = array(
       '#type' => 'fieldset',
       '#title' => t('Assign Drupal Taxonomy to Analysis Features')
-	);
+  );
 
-	// get the list of analyses
-	$sql = "SELECT * FROM {Analysis} ORDER BY name";
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	$lib_rset = db_query($sql);
-	tripal_db_set_active($previous_db);  // now use drupal database
+  // get the list of analyses
+  $sql = "SELECT * FROM {Analysis} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $lib_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
 
-	// iterate through all of the libraries
-	$lib_boxes = array();
-	while($analysis = db_fetch_object($lib_rset)){
-		$lib_boxes[$analysis->analysis_id] = "$analysis->name";
-	}
+  // iterate through all of the libraries
+  $lib_boxes = array();
+  while ($analysis = db_fetch_object($lib_rset)) {
+    $lib_boxes[$analysis->analysis_id] = "$analysis->name";
+  }
 
-	$form['taxonify']['description'] = array(
+  $form['taxonify']['description'] = array(
        '#type' => 'item',
        '#value' => t("Drupal allows for assignment of \"taxonomy\" or catagorical terms to " .
           "nodes. These terms allow for advanced filtering during searching. This option allows ".
           "for setting taxonomy only for features that belong to the selected analyses below.  All other features will be unaffected.  To set taxonomy for all features in the site see the Feature Administration page."),
-		 '#weight' => 1,
-	);
+     '#weight' => 1,
+  );
 
-	$form['taxonify']['tx-analyses'] = array (
+  $form['taxonify']['tx-analyses'] = array(
      '#title'       => t('Analyses'),
      '#type'        => t('checkboxes'),
      '#description' => t("Check the analyses whose features you want to reset taxonomy.  Note: this list contains all analyses, even those that may not be synced."),
@@ -241,42 +242,42 @@ function get_tripal_analysis_admin_form_taxonomy_set(&$form) {
      '#suffix'      => '</div>',
      '#options'     => $lib_boxes,
      '#weight'      => 2
-	);
-	$form['taxonify']['tx-button'] = array(
+  );
+  $form['taxonify']['tx-button'] = array(
       '#type' => 'submit',
       '#value' => t('Set Feature Taxonomy'),
       '#weight'      => 3
-	);
+  );
 }
-/** 
+/**
  *
  * @ingroup tripal_analysis
  */
 function get_tripal_analysis_admin_form_reindex_set(&$form) {
-	// define the fieldsets
-	$form['reindex'] = array(
+  // define the fieldsets
+  $form['reindex'] = array(
       '#type' => 'fieldset',
       '#title' => t('Reindex Analysis Features')
-	);
-
-	// get the list of libraries
-	$sql = "SELECT * FROM {Analysis} ORDER BY name";
-	$previous_db = tripal_db_set_active('chado');  // use chado database
-	$lib_rset = db_query($sql);
-	tripal_db_set_active($previous_db);  // now use drupal database
-
-	// iterate through all of the libraries
-	$lib_boxes = array();
-	while($analysis = db_fetch_object($lib_rset)){
-		$lib_boxes[$analysis->analysis_id] = "$analysis->name";
-	}
-	$form['reindex']['description'] = array(
+  );
+
+  // get the list of libraries
+  $sql = "SELECT * FROM {Analysis} ORDER BY name";
+  $previous_db = tripal_db_set_active('chado');  // use chado database
+  $lib_rset = db_query($sql);
+  tripal_db_set_active($previous_db);  // now use drupal database
+
+  // iterate through all of the libraries
+  $lib_boxes = array();
+  while ($analysis = db_fetch_object($lib_rset)) {
+    $lib_boxes[$analysis->analysis_id] = "$analysis->name";
+  }
+  $form['reindex']['description'] = array(
        '#type' => 'item',
        '#value' => t("This option allows for reindexing of only those features that belong to the selected analyses below. All other features will be unaffected.  To reindex all features in the site see the Feature Administration page."),
-		 '#weight' => 1,
-	);
+     '#weight' => 1,
+  );
 
-	$form['reindex']['re-analyses'] = array (
+  $form['reindex']['re-analyses'] = array(
      '#title'       => t('Libraries'),
      '#type'        => t('checkboxes'),
      '#description' => t("Check the analyses whoee features you want to reindex. Note: this list contains all analyses, even those that may not be synced."),
@@ -285,23 +286,23 @@ function get_tripal_analysis_admin_form_reindex_set(&$form) {
      '#suffix'      => '</div>',
      '#options'     => $lib_boxes,
      '#weight' => 2,
-	);
-	$form['reindex']['re-button'] = array(
+  );
+  $form['reindex']['re-button'] = array(
       '#type' => 'submit',
       '#value' => t('Reindex Features'),
       '#weight' => 3,
-	);
+  );
 }
-/** 
+/**
  *
  * @ingroup tripal_analysis
  */
 function get_tripal_analysis_admin_form_cleanup_set(&$form) {
-	$form['cleanup'] = array(
+  $form['cleanup'] = array(
       '#type' => 'fieldset',
       '#title' => t('Clean Up')
-	);
-	$form['cleanup']['description'] = array(
+  );
+  $form['cleanup']['description'] = array(
        '#type' => 'item',
        '#value' => t("With Drupal and chado residing in different databases ".
           "it is possible that nodes in Drupal and analyses in Chado become ".
@@ -309,62 +310,62 @@ function get_tripal_analysis_admin_form_cleanup_set(&$form) {
           "deleted but the corresponding chado analysis is not and/or vice ".
           "versa. Click the button below to resolve these discrepancies."),
        '#weight' => 1,
-	);
-	$form['cleanup']['button'] = array(
+  );
+  $form['cleanup']['button'] = array(
       '#type' => 'submit',
       '#value' => t('Clean up orphaned analyses'),
       '#weight' => 2,
-	);
+  );
 }
-/** 
+/**
  *
  * @ingroup tripal_analysis
  */
-function get_tripal_analysis_admin_form_sync_set (&$form) {
-	// define the fieldsets
-	$form['sync'] = array(
+function get_tripal_analysis_admin_form_sync_set(&$form) {
+  // define the fieldsets
+  $form['sync'] = array(
       '#type' => 'fieldset',
       '#title' => t('Sync Analyses')
-	);
-
-	// before proceeding check to see if we have any
-	// currently processing jobs. If so, we don't want
-	// to give the opportunity to sync analyses
-	$active_jobs = FALSE;
-	if(tripal_get_module_active_jobs('tripal_analysis')){
-		$active_jobs = TRUE;
-	}
-
-	if(!$active_jobs){
-			
-		// get the list of analyses
-		$sql = "SELECT * FROM {analysis} ORDER BY name";
-		$previous_db = tripal_db_set_active('chado');  // use chado database
-		$ana_rset = db_query($sql);
-		tripal_db_set_active($previous_db);  // now use drupal database
-			
-		// if we've added any analyses to the list that can be synced
-		// then we want to build the form components to allow the user
-		// to select one or all of them.  Otherwise, just present
-		// a message stating that all analyses are currently synced.
-		$ana_boxes = array();
-		$added = 0;
-		while($analysis = db_fetch_object($ana_rset)){
-			// 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))){
-				$ana_boxes[$analysis->analysis_id] = "$analysis->name";
-				$added++;
-			}
-		}
-
-		// if we have analyses we need to add to the checkbox then
-		// build that form element
-		if($added > 0){
-			$ana_boxes['all'] = "All analyses";
-
-			$form['sync']['analyses'] = array (
+  );
+
+  // before proceeding check to see if we have any
+  // currently processing jobs. If so, we don't want
+  // to give the opportunity to sync analyses
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_analysis')) {
+    $active_jobs = TRUE;
+  }
+
+  if (!$active_jobs) {
+
+    // get the list of analyses
+    $sql = "SELECT * FROM {analysis} ORDER BY name";
+    $previous_db = tripal_db_set_active('chado');  // use chado database
+    $ana_rset = db_query($sql);
+    tripal_db_set_active($previous_db);  // now use drupal database
+
+    // if we've added any analyses to the list that can be synced
+    // then we want to build the form components to allow the user
+    // to select one or all of them.  Otherwise, just present
+    // a message stating that all analyses are currently synced.
+    $ana_boxes = array();
+    $added = 0;
+    while ($analysis = db_fetch_object($ana_rset)) {
+      // 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))) {
+        $ana_boxes[$analysis->analysis_id] = "$analysis->name";
+        $added++;
+      }
+    }
+
+    // if we have analyses we need to add to the checkbox then
+    // build that form element
+    if ($added > 0) {
+      $ana_boxes['all'] = "All analyses";
+
+      $form['sync']['analyses'] = array(
            '#title'       => t('Available analyses'),
            '#type'        => t('checkboxes'),
            '#description' => t("Check the analyses you want to sync.  Drupal ".
@@ -374,112 +375,112 @@ function get_tripal_analysis_admin_form_sync_set (&$form) {
            '#prefix'      => '<div id="ana_boxes">',
            '#suffix'      => '</div>',
            '#options'     => $ana_boxes,
-			);
-			$form['sync']['button'] = array(
+      );
+      $form['sync']['button'] = array(
             '#type' => 'submit',
             '#value' => t('Submit Sync Job')
-			);
-		}
-		// we don't have any analyses to select from
-		else {
-			$form['sync']['value'] = array(
+      );
+    }
+    // we don't have any analyses to select from
+    else {
+      $form['sync']['value'] = array(
             '#value' => t('All analyses in Chado are currently synced with Drupal.')
-			);
-		}
-	}
-	// we don't want to present a form since we have an active job running
-	else {
-		$form['sync']['value'] = array(
+      );
+    }
+  }
+  // we don't want to present a form since we have an active job running
+  else {
+    $form['sync']['value'] = array(
           '#value' => t('Currently, jobs exist related to chado analyses. Please check back later for analyses that can by synced once these jobs have finished.  You can view the status of pending jobs in the Tripal jobs page.')
-		);
-	}
+    );
+  }
 }
 /**
  *
  * @ingroup tripal_analysis
  */
 function tripal_analysis_admin_validate($form, &$form_state) {
-	global $user;  // we need access to the user info
-	$job_args = array();
-
-	if ($form_state['values']['op'] == t('Submit Sync Job')) {
-
-		// check to see if the user wants to sync chado and drupal.  If
-		// so then we need to register a job to do so with tripal
-		$analyses = $form_state['values']['analyses'];
-		$do_all = FALSE;
-		$to_sync = array();
-
-		foreach ($analyses as $analysis_id){
-			if(preg_match("/^all$/i",$analysis_id)){
-				$do_all = TRUE;
-			}
-			if($analysis_id and preg_match("/^\d+$/i",$analysis_id)){
-				// get the list of analyses
-				$sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
-				$previous_db = tripal_db_set_active('chado');  // use chado database
-				$analysis = db_fetch_object(db_query($sql,$analysis_id));
-				tripal_db_set_active($previous_db);  // now use drupal database
-				$to_sync[$analysis_id] = $analysis->name;
-			}
-		}
-
-		// submit the job the tripal job manager
-		if($do_all){
-			tripal_add_job('Sync all analyses','tripal_analysis','tripal_analysis_sync_analyses',$job_args,$user->uid);
-		}
-		else{
-			foreach($to_sync as $analysis_id => $name){
-				$job_args[0] = $analysis_id;
-				tripal_add_job("Sync analysis: $name",'tripal_analysis','tripal_analysis_sync_analyses',$job_args,$user->uid);
-			}
-		}
-	}
-	// -------------------------------------
-	// Submit the Reindex Job if selected
-	if ($form_state['values']['op'] == t('Reindex Features')) {
-		global $user;  // we need access to the user info
-		$job_args = array();
-		$analyses = $form_state['values']['re-analyses'];
-		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";
-				$previous_db = tripal_db_set_active('chado');  // use chado database
-				$analysis = db_fetch_object(db_query($sql,$analysis_id));
-				tripal_db_set_active($previous_db);  // now use drupal database
-				$job_args[0] = $analysis_id;
-				tripal_add_job("Reindex features for analysis: $analysis->name",'tripal_analysis',
-             'tripal_analysis_reindex_features',$job_args,$user->uid);
-			}
-		}
-	}
-
-	// -------------------------------------
-	// Submit the Taxonomy Job if selected
-	if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
-		global $user;  // we need access to the user info
-		$job_args = array();
-		$analyses = $form_state['values']['tx-analyses'];
-		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";
-				$previous_db = tripal_db_set_active('chado');  // use chado database
-				$analysis = db_fetch_object(db_query($sql,$analysis_id));
-				tripal_db_set_active($previous_db);  // now use drupal database
-				$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);
-			}
-		}
-	}
-
-	// -------------------------------------
-	// Submit the Cleanup Job if selected
-	if ($form_state['values']['op'] == t('Clean up orphaned analyses')) {
-		tripal_add_job('Cleanup orphaned analyses','tripal_analysis',
-         'tripal_analyses_cleanup',$job_args,$user->uid);
-	}
+  global $user;  // we need access to the user info
+  $job_args = array();
+
+  if ($form_state['values']['op'] == t('Submit Sync Job')) {
+
+    // check to see if the user wants to sync chado and drupal.  If
+    // so then we need to register a job to do so with tripal
+    $analyses = $form_state['values']['analyses'];
+    $do_all = FALSE;
+    $to_sync = array();
+
+    foreach ($analyses as $analysis_id) {
+      if (preg_match("/^all$/i", $analysis_id)) {
+        $do_all = TRUE;
+      }
+      if ($analysis_id and preg_match("/^\d+$/i", $analysis_id)) {
+        // get the list of analyses
+        $sql = "SELECT * FROM {analysis} WHERE analysis_id = %d";
+        $previous_db = tripal_db_set_active('chado');  // use chado database
+        $analysis = db_fetch_object(db_query($sql, $analysis_id));
+        tripal_db_set_active($previous_db);  // now use drupal database
+        $to_sync[$analysis_id] = $analysis->name;
+      }
+    }
+
+    // submit the job the tripal job manager
+    if ($do_all) {
+      tripal_add_job('Sync all analyses', 'tripal_analysis', 'tripal_analysis_sync_analyses', $job_args, $user->uid);
+    }
+    else{
+      foreach ($to_sync as $analysis_id => $name) {
+        $job_args[0] = $analysis_id;
+        tripal_add_job("Sync analysis: $name", 'tripal_analysis', 'tripal_analysis_sync_analyses', $job_args, $user->uid);
+      }
+    }
+  }
+  // -------------------------------------
+  // Submit the Reindex Job if selected
+  if ($form_state['values']['op'] == t('Reindex Features')) {
+    global $user;  // we need access to the user info
+    $job_args = array();
+    $analyses = $form_state['values']['re-analyses'];
+    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";
+        $previous_db = tripal_db_set_active('chado');  // use chado database
+        $analysis = db_fetch_object(db_query($sql, $analysis_id));
+        tripal_db_set_active($previous_db);  // now use drupal database
+        $job_args[0] = $analysis_id;
+        tripal_add_job("Reindex features for analysis: $analysis->name", 'tripal_analysis',
+             'tripal_analysis_reindex_features', $job_args, $user->uid);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the Taxonomy Job if selected
+  if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
+    global $user;  // we need access to the user info
+    $job_args = array();
+    $analyses = $form_state['values']['tx-analyses'];
+    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";
+        $previous_db = tripal_db_set_active('chado');  // use chado database
+        $analysis = db_fetch_object(db_query($sql, $analysis_id));
+        tripal_db_set_active($previous_db);  // now use drupal database
+        $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);
+      }
+    }
+  }
+
+  // -------------------------------------
+  // Submit the Cleanup Job if selected
+  if ($form_state['values']['op'] == t('Clean up orphaned analyses')) {
+    tripal_add_job('Cleanup orphaned analyses', 'tripal_analysis',
+         'tripal_analyses_cleanup', $job_args, $user->uid);
+  }
 }
 

+ 18 - 18
tripal_analysis/tripal_analysis.api.inc

@@ -20,9 +20,9 @@
  */
 function tripal_analysis_chado_analysis_schema() {
   $description = array();
-  
+
   // Default table description in tripal_core.schema.api.inc: tripal_core_chado_analysis_schema()
-  
+
   $referring_tables = array(
       'analysisfeature',
       'analysisprop',
@@ -30,7 +30,7 @@ function tripal_analysis_chado_analysis_schema() {
       'quantification'
   );
   $description['referring_tables'] = $referring_tables;
-  
+
   return $description;
 }
 
@@ -60,7 +60,7 @@ function tripal_analysis_chado_analysisfeature_schema() {
           'analysis_id' => 'analysis_id',
         ),
   );
-  
+
   return $description;
 }
 
@@ -137,8 +137,8 @@ function tripal_analysis_chado_analysisprop_schema() {
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_get_property($analysis_id,$property){
-   return tripal_core_get_property('analysis',$analysis_id,$property,'tripal');
+function tripal_analysis_get_property($analysis_id, $property) {
+   return tripal_core_get_property('analysis', $analysis_id, $property, 'tripal');
 }
 
 /**
@@ -158,8 +158,8 @@ function tripal_analysis_get_property($analysis_id,$property){
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_insert_property($analysis_id,$property,$value,$update_if_present = 0){
-    return tripal_core_insert_property('analysis',$analysis_id,$property,'tripal',$value,$update_if_present);
+function tripal_analysis_insert_property($analysis_id, $property, $value, $update_if_present = 0) {
+    return tripal_core_insert_property('analysis', $analysis_id, $property, 'tripal', $value, $update_if_present);
 }
 
 /**
@@ -171,7 +171,7 @@ function tripal_analysis_insert_property($analysis_id,$property,$value,$update_i
  *   The cvterm name of the property to update
  * @param $value
  *   The value of the property to update
- * @param $insert_if_missing 
+ * @param $insert_if_missing
  *   A boolean indicated whether to insert the record if it's absent
  *
  * Note: The property will be identified using the unique combination of the $analysis_id and $property
@@ -182,8 +182,8 @@ function tripal_analysis_insert_property($analysis_id,$property,$value,$update_i
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_update_property($analysis_id,$property,$value,$insert_if_missing = 0){
-   return tripal_core_update_property('analysis',$analysis_id,$property,'tripal',$value, $insert_if_missing);
+function tripal_analysis_update_property($analysis_id, $property, $value, $insert_if_missing = 0) {
+   return tripal_core_update_property('analysis', $analysis_id, $property, 'tripal', $value, $insert_if_missing);
 }
 
 /**
@@ -198,12 +198,12 @@ function tripal_analysis_update_property($analysis_id,$property,$value,$insert_i
  * and then it will be deleted
  *
  * @return
- *   True of success, False otherwise 
+ *   True of success, False otherwise
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_delete_property($analysis_id,$property){
-   return tripal_core_delete_property('analysis',$analysis_id,$property,'tripal');
+function tripal_analysis_delete_property($analysis_id, $property) {
+   return tripal_core_delete_property('analysis', $analysis_id, $property, 'tripal');
 }
 /**
  * Retreives the node of a sync'ed analysis
@@ -212,15 +212,15 @@ function tripal_analysis_delete_property($analysis_id,$property){
  *   The analysis_id of the property to delete
  *
  * @return
- *   node of analysis on success, null otherwise 
+ *   node of analysis on success, null otherwise
  *
  * @ingroup tripal_analysis_api
  */
-function tripal_analysis_get_node($analysis_id){
-   $sql = "SELECT * 
+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));
+   $node = db_fetch_object(db_query($sql, $analysis_id));
    return $node;
 }

+ 54 - 54
tripal_analysis/tripal_analysis.install

@@ -6,49 +6,49 @@
  */
 function tripal_analysis_install() {
 
-	// create the module's data directory
-	tripal_create_moddir('tripal_analysis');
+  // create the module's data directory
+  tripal_create_moddir('tripal_analysis');
 
-	// Use schema API to create database table.
-	drupal_install_schema('tripal_analysis');
-	
-	// Create analysisfeatureprop table in chado. This cannot be accomplished
-	// by calling drupal_install_schema because it's not in the drupal db. This
-	// table is used to store Blast xml and Interpro html/goterms
-	$previous_db = tripal_db_set_active('chado');
-	if (!db_table_exists('analysisfeatureprop')) {
-	   $sql = "CREATE TABLE {analysisfeatureprop} (".
-	          "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
-	          "  analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
-	          "  type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
-	          "  value TEXT, ".
-	          "  rank INTEGER NOT NULL, ".
-	          "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
-	          ")";
-	   db_query($sql);
-	}
-	tripal_db_set_active($previous_db);
+  // Use schema API to create database table.
+  drupal_install_schema('tripal_analysis');
 
-   tripal_cv_add_cvterm(array('name' => 'analysis_type','def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'),'tripal',0,1,'tripal');
-	tripal_cv_add_cvterm(array('name' => 'analysis_date','def' => 'The date that an analysis was performed.'),'tripal',0,1,'tripal');
-	tripal_cv_add_cvterm(array('name' => 'analysis_short_name','def' => 'A computer legible (no spaces '.
-      'or special characters) abbreviation for the analysis.'),'tripal',0,1,'tripal');
+  // Create analysisfeatureprop table in chado. This cannot be accomplished
+  // by calling drupal_install_schema because it's not in the drupal db. This
+  // table is used to store Blast xml and Interpro html/goterms
+  $previous_db = tripal_db_set_active('chado');
+  if (!db_table_exists('analysisfeatureprop')) {
+     $sql = "CREATE TABLE {analysisfeatureprop} (".
+            "  analysisfeatureprop_id SERIAL PRIMARY KEY, ".
+            "  analysisfeature_id INTEGER NOT NULL REFERENCES analysisfeature(analysisfeature_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
+            "  type_id INTEGER NOT NULL REFERENCES cvterm(cvterm_id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, ".
+            "  value TEXT, ".
+            "  rank INTEGER NOT NULL, ".
+            "  CONSTRAINT analysisfeature_id_type_id_rank UNIQUE(analysisfeature_id, type_id, rank)".
+            ")";
+     db_query($sql);
+  }
+  tripal_db_set_active($previous_db);
+
+   tripal_cv_add_cvterm(array('name' => 'analysis_type', 'def' => 'The type of analysis was performed. This value is automatically set by each Tripal Analysis module and should be equal to the module name (e.g. tripal_analysis_blast, tripal_analysis_go).'), 'tripal', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'analysis_date', 'def' => 'The date that an analysis was performed.'), 'tripal', 0, 1, 'tripal');
+  tripal_cv_add_cvterm(array('name' => 'analysis_short_name', 'def' => 'A computer legible (no spaces ' .
+      'or special characters) abbreviation for the analysis.'), 'tripal', 0, 1 , 'tripal');
 }
 
 /*******************************************************************************
  * 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 ".
+  // 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%'";
-	$result = db_query($sql_ana_id);
-	while ($ana = db_fetch_object($result)) {
-		node_delete($ana->nid);
-	}
+  $result = db_query($sql_ana_id);
+  while ($ana = db_fetch_object($result)) {
+    node_delete($ana->nid);
+  }
 }
 
 /*******************************************************************************
@@ -58,39 +58,39 @@ function tripal_analysis_uninstall() {
  * tripal_analysis_blast, that are registered with this module.
  */
 function tripal_analysis_schema() {
-	// chado_analysis table
-	$schema['chado_analysis'] = array(
+  // chado_analysis table
+  $schema['chado_analysis'] = array(
       'fields' => array(
          'vid' => array(
             'type' => 'int',
             'unsigned' => TRUE,
             'not null' => TRUE,
             'default' => 0
-	),
+  ),
          'nid' => array(
             'type' => 'int',
             'unsigned' => TRUE,
             'not null' => TRUE,
             'default' => 0
-	),
+  ),
          'analysis_id' => array(
             'type' => 'int',
             'not null' => TRUE,
             'default' => 0
-	)
-	),
+  )
+  ),
       'indexes' => array(
          'analysis_id' => array('analysis_id')
-	),
+  ),
       'unique keys' => array(
-         'nid_vid' => array('nid','vid'),
+         'nid_vid' => array('nid', ß'vid'),
          'vid' => array('vid')
-	),
+  ),
       'primary key' => array('nid'),
-	);
+  );
 
-	// tripal_analysis table
-	$schema['tripal_analysis'] = array(
+  // tripal_analysis table
+  $schema['tripal_analysis'] = array(
       'description' => t('Table to store analysis sub-modules'),
       'fields' => array(
          'modulename' => array(
@@ -99,13 +99,13 @@ function tripal_analysis_schema() {
             'not null' => TRUE,
             'description' => t('The module name. Tripal Analysis will use the '.
                                'module name to call module_setting_form()')
-	)
-	),
+  )
+  ),
       'unique keys' => array(
          'modulename' => array('modulename')
-	)
-	);
-	return $schema;
+  )
+  );
+  return $schema;
 }
 
 /*******************************************************************************
@@ -129,12 +129,12 @@ function tripal_analysis_requirements($phase) {
 /*******************************************************************************
  * Provide update script for adding new cvterms
  */
-function tripal_analysis_update_6001(){
+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');
+   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;
 }

File diff suppressed because it is too large
+ 343 - 331
tripal_analysis/tripal_analysis.module


+ 9 - 9
tripal_analysis/tripal_analysis.views.inc

@@ -6,7 +6,7 @@
  *  chado/tripal analysis tables. Supplementary functions can be found in
  *  ./views/
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
@@ -18,7 +18,7 @@
 
 require('views/analysis.views.inc');
 require('views/chado_analysis.views.inc');
-require('views/misc_tables.views.inc'); 
+require('views/misc_tables.views.inc');
 /**
  * Implements hook_views_data()
  *
@@ -26,7 +26,7 @@ require('views/misc_tables.views.inc');
  *
  * @return: a data array which follows the structure outlined in the
  *   views2 documentation for this hook. Essentially, it's an array of table
- *   definitions keyed by chado/tripal table name. Each table definition 
+ *   definitions keyed by chado/tripal table name. Each table definition
  *   includes basic details about the table, fields in that table and
  *   relationships between that table and others (joins)
  *
@@ -46,7 +46,7 @@ function tripal_analysis_views_data()  {
  * Implements hook_views_handlers()
  *
  * Purpose: Register all custom handlers with views
- *   where a handler describes either "the type of field", 
+ *   where a handler describes either "the type of field",
  *   "how a field should be filtered", "how a field should be sorted"
  *
  * @return
@@ -75,7 +75,7 @@ function tripal_analysis_views_views_handlers() {
  */
 function tripal_analysis_views_data_alter(&$data) {
 
-  if( !(is_array($db_url) and array_key_exists('chado',$db_url)) ){
+  if (!(is_array($db_url) and array_key_exists('chado', $db_url)) ) {
 
     // Add featuer relationship to node
     $data['node']['analysis_chado_nid'] = array(
@@ -93,7 +93,7 @@ function tripal_analysis_views_data_alter(&$data) {
       ),
     );
   }
-  
+
 }
 
 /**
@@ -101,9 +101,9 @@ function tripal_analysis_views_data_alter(&$data) {
  *
  * @ingroup tripal_analysis_views
  */
-function tripal_analysis_views_default_views () {
+function tripal_analysis_views_default_views() {
   $views = array();
-  
+
   // Main default view
   // List all cvterms based on cv
   $view = new view;
@@ -541,6 +541,6 @@ function tripal_analysis_views_default_views () {
     'name' => 'navigation',
   ));
   $views[$view->name] = $view;
-  
+
   return $views;
 }

+ 71 - 69
tripal_analysis/tripal_analysis_privacy.inc

@@ -3,80 +3,82 @@
 /*
  *  Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
  */
-function tripal_analysis_check_permission ($analysis_id) {
-	if (module_exists('node_privacy_byrole')) {
-		global $user;
-		$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));
-			if ($access == 1) {
-				$node_access = 1;
-				break;
-			}
-		}
-		if ($node_access == 1 || $user->uid == 1) {
-			return TRUE;
-		} else {
-			return FALSE;
-		}
-	
-	// If 'node_privacy_byrole' module is not enabled, return TRUE;
-	} else {
-		return TRUE;
-	}
+function tripal_analysis_check_permission($analysis_id) {
+  if (module_exists('node_privacy_byrole')) {
+    global $user;
+    $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));
+      if ($access == 1) {
+        $node_access = 1;
+        break;
+      }
+    }
+    if ($node_access == 1 || $user->uid == 1) {
+      return TRUE;
+    }
+    else {
+      return FALSE;
+    }
+
+  // If 'node_privacy_byrole' module is not enabled, return TRUE;
+  }
+  else {
+    return TRUE;
+  }
 }
 
 /*
  * Set permissions for features associated with an analysis
  */
-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";
-	$previous_db = db_set_active('chado');
-	$features = db_query($sql, $analysis_id);
-	db_set_active($previous_db);
-	
-	// 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));
-		$counter ++;
-	}
-	
-	//Convert analysis_id into node_id
-	$ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = $analysis_id"));
-	// Get available roles
-	$roles = array_keys(user_roles());
-	
-	$interval = intval(($counter + 1) * 0.01);
-	$idx_iterations = 1;
-	
-	// Update permission node by node
-	foreach ($feature_nids AS $fnid) {
-		if ($idx_iterations % $interval == 0) {
-			$percentage = (int) ($idx_iterations / ($counter + 1) * 100);
-			tripal_job_set_progress($job_id, $percentage);
-			print $percentage."% ";
-		}
+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";
+  $previous_db = db_set_active('chado');
+  $features = db_query($sql, $analysis_id);
+  db_set_active($previous_db);
+
+  // 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));
+    $counter ++;
+  }
 
-		db_query("DELETE FROM {node_privacy_byrole} WHERE nid = %d AND realm = 'node_privacy_byrole_role'", $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));
-			db_query("INSERT INTO {node_privacy_byrole} (nid, gid, realm, grant_view, grant_update, grant_delete)
+  //Convert analysis_id into node_id
+  $ana_nid = db_result(db_query("SELECT nid FROM {chado_analysis} WHERE analysis_id = $analysis_id"));
+  // Get available roles
+  $roles = array_keys(user_roles());
+
+  $interval = intval(($counter + 1) * 0.01);
+  $idx_iterations = 1;
+
+  // Update permission node by node
+  foreach ($feature_nids AS $fnid) {
+    if ($idx_iterations % $interval == 0) {
+      $percentage = (int) ($idx_iterations / ($counter + 1) * 100);
+      tripal_job_set_progress($job_id, $percentage);
+      print $percentage . "% ";
+    }
+
+    db_query("DELETE FROM {node_privacy_byrole} WHERE nid = %d AND realm = 'node_privacy_byrole_role'", $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));
+      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);
-		}
-		$node = node_load($fnid);
-		node_save($node);
-		$idx_iterations ++;
-	}	
-}
+    }
+    $node = node_load($fnid);
+    node_save($node);
+    $idx_iterations ++;
+  }
+}

+ 69 - 67
tripal_analysis/views/analysis.views.inc

@@ -1,6 +1,7 @@
 <?php
-	/**
- * Purpose: this function returns the portion of the data array 
+  /**
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the analysis table, it's fields and any joins between it and other tables
  * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  *
@@ -29,24 +30,24 @@
  * @ingroup tripal_analysis_views
  */
 function retrieve_analysis_views_data() {
-	global $db_url;
-	$data = array();
+  global $db_url;
+  $data = array();
 
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
      $database = 'chado';
   }
-	
+
   // Basic table definition
   $data['analysis']['table']['group'] = 'Chado Analysis';
- 	$data['analysis']['table']['base'] = array(
- 		'field' => 'analysis_id',
- 		'title' => t('Chado Analysis'),
- 		'help' => t("An analysis is a particular type of a computational analysis; it may be a blast of one sequence against another, or an all by all blast, or a different kind of analysis altogether. It is a single unit of computation."),
- 	);
-  if($database){
+   $data['analysis']['table']['base'] = array(
+     'field' => 'analysis_id',
+     'title' => t('Chado Analysis'),
+     'help' => t("An analysis is a particular type of a computational analysis; it may be a blast of one sequence against another, or an all by all blast, or a different kind of analysis altogether. It is a single unit of computation."),
+   );
+  if ($database) {
      $data['analysis']['table']['base']['database'] = $database;
   }
 
@@ -63,20 +64,20 @@ function retrieve_analysis_views_data() {
   );
 
   // Analysis properties?
- 	$data['analysisprop']['table'] = array(
+   $data['analysisprop']['table'] = array(
 'group' => 'Chado analysis Properties',
- 		'field' => 'analysisprop_id',
- 		'title' => t('Chado analysis Properties'),
- 		'help' => '  ',
- 	);
- 	
- 	$data['analysisprop']['table']['join']['analysis'] = array(
+     'field' => 'analysisprop_id',
+     'title' => t('Chado analysis Properties'),
+     'help' => '  ',
+   );
+
+   $data['analysisprop']['table']['join']['analysis'] = array(
     'left_field' => 'analysis_id',
     'field' => 'analysis_id',
     'handler' => 'views_handler_join_chado_aggregator'
- 	);
- 	
- 	$data['analysisprop']['value'] = array(
+   );
+
+   $data['analysisprop']['value'] = array(
     'title' => t('Value'),
     'help' => t(' '),
     'field' => array(
@@ -92,9 +93,9 @@ function retrieve_analysis_views_data() {
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
- 	);
- 	
- 	$data['analysisprop']['all'] = array(
+   );
+
+   $data['analysisprop']['all'] = array(
     'title' => t('All'),
     'help' => t('An aggregate field that contains all fields for a row.'),
     'field' => array(
@@ -110,37 +111,38 @@ function retrieve_analysis_views_data() {
     'argument' => array(
       'handler' => 'views_handler_argument_string',
     ),
- 	);
- 	
-	// Table Field Definitions----------------------
-	// Field: analysis_id (primary key)
-	$data['analysis']['analysis_id'] = array(
-	  'title' => 'analysis ID',
-	  'help' => 'The primary key of the analysis table.',
-	  'field' => array(
-	    'handler' => 'views_handler_field_numeric',
-	    'click sortable' => TRUE,
-	  ),
-	  'filter' => array(
-	    'handler' => 'views_handler_filter_numeric',
-	  ),
-	  'sort' => array(
-	    'handler' => 'chado_views_handler_sort',
-	  ),
-	);
-	
+   );
+
+  // Table Field Definitions----------------------
+  // Field: analysis_id (primary key)
+  $data['analysis']['analysis_id'] = array(
+    'title' => 'analysis ID',
+    'help' => 'The primary key of the analysis table.',
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'chado_views_handler_sort',
+    ),
+  );
+
   // Calculated Field: Node ID
   //  use custom field handler to query drupal for the node ID
   //  this is only needed if chado is in a separate database from drupal
-  if($database){
-		$data['analysis']['analysis_nid'] = array(
-	  	'title' => 'Node ID',
-	  	'help' => 'The node ID for the current analysis',
-	  	'field' => array(
-	    	'handler' => 'views_handler_field_computed_analysis_nid',
-	  	),
-		);
-  } else {
+  if ($database) {
+    $data['analysis']['analysis_nid'] = array(
+      'title' => 'Node ID',
+      'help' => 'The node ID for the current analysis',
+      'field' => array(
+        'handler' => 'views_handler_field_computed_analysis_nid',
+      ),
+    );
+  }
+  else {
     // Add relationship between chado_analysis and analysis
     $data['analysis']['analysis_nid'] = array(
       'group' => 'Analysis',
@@ -158,9 +160,9 @@ function retrieve_analysis_views_data() {
     );
 
   }
-	
-	// Field: name (varchar 255)
- 	$data['analysis']['name'] = array(
+
+  // Field: name (varchar 255)
+   $data['analysis']['name'] = array(
     'title' => t('Name'),
     'help' => t(''),
     'field' => array(
@@ -177,13 +179,13 @@ function retrieve_analysis_views_data() {
       'handler' => 'views_handler_argument_string',
     ),
   );
-  // if joined to the node table add a "Link to Node" option for the field  
+  // if joined to the node table add a "Link to Node" option for the field
   if (!$database) {
     $data['analysis']['name']['field']['handler'] = 'views_handler_field_node_optional';
   }
 
   // Field: description (text)
- 	$data['analysis']['description'] = array(
+   $data['analysis']['description'] = array(
     'title' => t('Description'),
     'help' => t(''),
     'field' => array(
@@ -202,7 +204,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: program (varchar 255)
- 	$data['analysis']['program'] = array(
+   $data['analysis']['program'] = array(
     'title' => t('Program'),
     'help' => t('Program name, e.g. blastx, blastp, sim4, genscan.'),
     'field' => array(
@@ -221,7 +223,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: program version (varchar 255)
- 	$data['analysis']['programversion'] = array(
+   $data['analysis']['programversion'] = array(
     'title' => t('Program Version'),
     'help' => t('Version description, e.g. TBLASTX 2.0MP-WashU [09-Nov-2000].'),
     'field' => array(
@@ -240,7 +242,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: algorithm (varchar 255)
- 	$data['analysis']['algorithm'] = array(
+   $data['analysis']['algorithm'] = array(
     'title' => t('Algorithm'),
     'help' => t('Algorithm name, e.g. blast.'),
     'field' => array(
@@ -258,7 +260,7 @@ function retrieve_analysis_views_data() {
     ),
   );
 
- 	$data['analysis']['sourcename'] = array(
+   $data['analysis']['sourcename'] = array(
     'title' => t('Source Name'),
     'help' => t('Source name, e.g. cDNA, SwissProt.'),
     'field' => array(
@@ -277,7 +279,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: source version (varchar 255)
- 	$data['analysis']['sourceversion'] = array(
+   $data['analysis']['sourceversion'] = array(
     'title' => t('Source Version'),
     'help' => t('The version of the source.'),
     'field' => array(
@@ -296,7 +298,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: source URI/URL (text)
- 	$data['analysis']['sourceuri'] = array(
+   $data['analysis']['sourceuri'] = array(
     'title' => t('Source URL'),
     'help' => t('This is an optional, permanent URL or URI for the source of the analysis.'),
     'field' => array(
@@ -315,7 +317,7 @@ function retrieve_analysis_views_data() {
   );
 
   // Field: time executed (datetime)
- 	$data['analysis']['timeexecuted'] = array(
+   $data['analysis']['timeexecuted'] = array(
     'title' => 'Time Executed',
     'help' => 'The date & time when this analysis was executed.',
     'field' => array(
@@ -327,5 +329,5 @@ function retrieve_analysis_views_data() {
     ),
   );
 
- 	return $data;
-}
+   return $data;
+}

+ 24 - 23
tripal_analysis/views/chado_analysis.views.inc

@@ -1,7 +1,8 @@
 <?php
 
 /**
- * Purpose: this function returns the portion of the data array 
+ * @file
+ * Purpose: this function returns the portion of the data array
  *   which describes the chado_analysis drupal table, it's fields and any joins between it and other tables
  * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  *
@@ -10,14 +11,14 @@
  *
  * @ingroup tripal_analysis_views
  */
-function retrieve_chado_analysis_views_data () {
-	global $db_url;
+function retrieve_chado_analysis_views_data() {
+  global $db_url;
   $data = array();
-  
+
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
      // return empty data array b/c if chado is external then no join to the nodetable can be made
      return $data;
   }
@@ -32,37 +33,37 @@ function retrieve_chado_analysis_views_data () {
     'title' => t('Analysis Node ID'),
     'help' => t('The node ID for this analysis'),
     'field' => array(
-     	'handler' => 'views_handler_field_numeric',
- 		  'click sortable' => TRUE,
+       'handler' => 'views_handler_field_numeric',
+       'click sortable' => TRUE,
     ),
     'filter' => array(
-     	'handler' => 'views_handler_filter_numeric',
+       'handler' => 'views_handler_filter_numeric',
     ),
     'sort' => array(
-     	'handler' => 'views_handler_sort',
+       'handler' => 'views_handler_sort',
     ),
   );
-  
+
   // Note: No joins need to be made from $data['analysis']['table']
-  
+
   // Join the chado analysis table to analysis
   $data['chado_analysis']['table']['join']['analysis'] = array(
-  	'left_field' => 'analysis_id',
-  	'field' => 'analysis_id',
+    'left_field' => 'analysis_id',
+    'field' => 'analysis_id',
   );
-  
+
   // Join the node table to chado analysis
   $data['node']['table']['join']['chado_analysis'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Join the node table to analysis
   $data['node']['table']['join']['analysis'] = array(
-  	'left_table' => 'chado_analysis',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
+    'left_table' => 'chado_analysis',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
   // Add relationship between chado_analysis and analysis
   $data['chado_analysis']['analysis_nid'] = array(
@@ -95,6 +96,6 @@ function retrieve_chado_analysis_views_data () {
       'base field' => 'nid'
     ),
   );
-  
-	return $data;
+
+  return $data;
 }

+ 13 - 14
tripal_analysis/views/handlers/views_handler_field_computed_analysis_nid.inc

@@ -6,18 +6,17 @@
  * @ingroup tripal_analysis
  */
 class views_handler_field_computed_analysis_nid extends views_handler_field_numeric {
-	function construct() {
-		parent::construct();
-		drupal_set_message('Computed Analysis NID Handler loaded');
-		$this->additional_fields['analysis_id'] = array('table' => 'analysis', 'field' => 'analysis_id');
-	}
+  function construct() {
+    parent::construct();
+    drupal_set_message('Computed Analysis NID Handler loaded');
+    $this->additional_fields['analysis_id'] = array('table' => 'analysis', 'field' => 'analysis_id');
+  }
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
 
-	function query() { 
-		$this->ensure_my_table();
-		$this->add_additional_fields(); 
-	}
-
-	function render($values) { 
-		return $values->analysis_nid;
-	}
-} 
+  function render($values) {
+    return $values->analysis_nid;
+  }
+}

+ 6 - 5
tripal_analysis/views/misc_tables.views.inc

@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @file
  * Purpose: Allows the analysis module to add fields to other module views
  *
  *   For example, a field counting the number of analysis' associted with a given feature would be
@@ -13,14 +14,14 @@
           'handler' => 'views_handler_field_chado_count',
           'table_to_query' => 'analysis_feature',
         ),
-      ); 
+      );
  *   @endcode
  *
  * @ingroup tripal_analysis_views
  */
 function retrieve_analysis_misc_tables_views_data() {
   $data = array();
- 
+
   // Table: Feature---------------------------------------------------------------------------------
   // Calculated Field: Number of analysis' (Count -Int)
   // Provides the number of analysis' for a given feature
@@ -31,7 +32,7 @@ function retrieve_analysis_misc_tables_views_data() {
       'handler' => 'views_handler_field_chado_count',
       'table_to_query' => 'analysisfeature',
     ),
-  );  
-  
+  );
+
   return $data;
-}
+}

+ 29 - 29
tripal_analysis/views/template.node_join.views.inc

@@ -5,18 +5,18 @@
  *
  *  - simply replace all XXX with the original chado table you want to join to it's drupal nodes.
  *    (ie: If you want to join features to their drupal nodes then XXX=feature)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
- *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
+ *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in
  *        tripal_analysis_views_data() by adding the following line:
  *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
+ *        to the function and including the file directly above the function (blow the function
  *        header by adding:
  *           require_once('views/XXX.views.inc');
  *
  *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
+ */
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -24,31 +24,31 @@
  *  with this module in:
  *  @see tripal_analysis.views.inc --in tripal_analysis_views_data()
  *
- *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table. 
+ *  Note: All chado tables are joined to their drupal nodes through the chado_XXX linking table.
  *        This file simply defines this linking table and joins the three tables together.
  *        No modification of XXX.views.inc is needed.
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
- 
+
 /**
- * Purpose: this function returns the portion of the data array 
- *   which describes the chado_XXX drupal table, it's fields and any joins between it 
+ * Purpose: this function returns the portion of the data array
+ *   which describes the chado_XXX drupal table, it's fields and any joins between it
  *   and other tables
  * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  *
  * The main need for description of this table to views is to join chado data with drupal nodes
  *
  */
-function retrieve_chado_XXX_views_data () {
-	global $db_url;
+function retrieve_chado_XXX_views_data() {
+  global $db_url;
   $data = array();
-  
+
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
      // return empty data array b/c if chado is external then no join to the nodetable can be made
      return $data;
   }
@@ -57,28 +57,28 @@ function retrieve_chado_XXX_views_data () {
   $data['chado_XXX']['table'] = array(
     'field' => 'nid',
   );
-  
+
   //Relationship Definitions---------------------------------
   // Note: No joins need to be made from $data['XXX']['table']
-  
+
   // Join the chado_XXX table to XXX
   $data['chado_XXX']['table']['join']['XXX'] = array(
-  	'left_field' => 'XXX_id',
-  	'field' => 'XXX_id',
+    'left_field' => 'XXX_id',
+    'field' => 'XXX_id',
   );
-  
+
   // Join the node table to chado_XXX
   $data['node']['table']['join']['chado_XXX'] = array(
-  	'left_field' => 'nid',
-  	'field' => 'nid',
+    'left_field' => 'nid',
+    'field' => 'nid',
   );
-  
+
   // Join the node table to XXX
   $data['node']['table']['join']['XXX'] = array(
-  	'left_table' => 'chado_XXX',
-  	'left_field' => 'nid',
-  	'field' => 'nid',
-  );  
+    'left_table' => 'chado_XXX',
+    'left_field' => 'nid',
+    'field' => 'nid',
+  );
 
-	return $data;
-}
+  return $data;
+}

+ 28 - 28
tripal_analysis/views/template.table_defn.views.inc

@@ -5,7 +5,7 @@
  *
  *   - Every instance of XXX should be replaced with the name of your table
  *   - If this is a base table (you want a view where every row is a row from this table)
- *     then change $data['XXX']['table'] to $data['XXX']['table']['base'] 
+ *     then change $data['XXX']['table'] to $data['XXX']['table']['base']
  *     and $data['XXX']['table']['database'] to $data['XXX']['table']['base']['database']
  *   - Relationships between this table and others: YYY is the table you are trying to join to this
  *     one. You want to join a table to this one if this table contains a foreign key to the other
@@ -15,18 +15,18 @@
  *   - Create a field definition for each field in this table using the example fields already
  *     listed. Match the type of the database field to the field definition listed below.
  *     (ie: for a text/varchar field from the database use plain_text_field below)
- * 
- *  NOTE: Creating the table definition file is not enough. You also need to call the 
- *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in 
+ *
+ *  NOTE: Creating the table definition file is not enough. You also need to call the
+ *        retrieve_XXX_views_data() function from ../tripal_analysis.views.inc in
  *        tripal_analysis_views_data() by adding the following line:
  *           $data = array_merge($data, retrieve_XXX_views_data());
- *        to the function and including the file directly above the function (blow the function 
+ *        to the function and including the file directly above the function (blow the function
  *        header by adding:
  *           require_once('views/XXX.views.inc');
  *
  *  REMOVE THIS COMMENT IN THE COPY!
- */ 
- 
+ */
+
 /**
  *  @file
  *  This file defines the data array for a given chado table. This array
@@ -34,12 +34,12 @@
  *  with this module in:
  *  @see tripal_analysis.views.inc --in tripal_analysis_views_data()
  *
- *  Documentation on views integration can be found at 
+ *  Documentation on views integration can be found at
  *  http://views2.logrus.com/doc/html/index.html.
  */
 
 /*************************************************************************
- * Purpose: this function returns the portion of the data array 
+ * Purpose: this function returns the portion of the data array
  *   which describes the XXX table, it's fields and any joins between it and other tables
  * @see tripal_analysis_views_data() --in tripal_analysis.views.inc
  *
@@ -55,23 +55,23 @@
   // if the chado database is not local to the drupal database
   // then we need to set the database name.  This should always
   // be 'chado'.
-  if(is_array($db_url) and array_key_exists('chado',$db_url)){
+  if (is_array($db_url) and array_key_exists('chado', $db_url)) {
     $database = 'chado';
   }
-   
+
   //Basic table definition-----------------------------------
   $data['XXX']['table']['group'] = t('Chado XXX');
-  
+
   $data['XXX']['table'] = array(
     'field' => 'primary_id',
     'title' => t('Chado XXX'),
     'help' => t('Enter some user-friendly description of this tables purpose to the user.'),
   );
-  if($database){
+  if ($database) {
      $data['XXX']['table']['database'] = $database;
   }
 
-  
+
   //Relationship Definitions---------------------------------
   //Join: YYY => XXX
   // Notice that this relationship tells the primary table to show it's fields to the
@@ -80,16 +80,16 @@
   $data['XXX']['table']['join']['YYY'] = array(
     'left_field' => 'foreign key in YYY table',
     'field' => 'primary key in XXX table',
-  );  
-  
+  );
+
   //Join: XXX => XY => YYY
   // This relationship should be described in both directions
-  // in the appropriate files (ie: for feature => library 
+  // in the appropriate files (ie: for feature => library
   // describe in both feature.views.inc and library.views.inc)
   $data['XXX']['table']['join']['XY'] = array(
     'left_field' => 'matching XXX key in the XY table',
     'field' => 'primary key in XXX table',
-  );  
+  );
   $data['XXX']['table']['join']['YYY'] = array(
     'left_table' => 'XY',
     'left_field' => 'matching XXX key in the XY table',
@@ -99,9 +99,9 @@
     'left_field' => 'primary key in YYY table',
     'field' => 'matching YYY key in the XY table',
   );
-   
+
   //Table Field Definitions----------------------------------
-      
+
   //Field: XXX_id (primary key)
   $data['XXX']['field_name'] = array(
     'title' => t('XXX Primary Key'),
@@ -123,7 +123,7 @@
    * Remove this section when done
    */
 
-  //Field: plain_text_field (chado datatype)   
+  //Field: plain_text_field (chado datatype)
   $data['XXX']['plain_text_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -142,7 +142,7 @@
     ),
   );
 
-  //Field: numeric_field (chado datatype)   
+  //Field: numeric_field (chado datatype)
   $data['XXX']['numeric_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -158,7 +158,7 @@
     ),
   );
 
-  //Field: boolean_field (chado datatype)   
+  //Field: boolean_field (chado datatype)
   $data['XXX']['boolean_field'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -174,7 +174,7 @@
     ),
   );
 
-  //Field: unix_timestamp (chado datatype)   
+  //Field: unix_timestamp (chado datatype)
   $data['XXX']['unix_timestamp'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -190,7 +190,7 @@
     ),
   );
 
-  //Field: human_readable_date (chado datatype)   
+  //Field: human_readable_date (chado datatype)
   $data['XXX']['human_readable_date'] = array(
     'title' => t('Human-Readable Name'),
     'help' => t('Description of this field.'),
@@ -202,10 +202,10 @@
       'handler' => 'views_handler_sort_date',
     ),
   );
-   
+
    /*
     * End of Example Field definitions
     */
-    
+
   return $data;
-}
+}

Some files were not shown because too many files changed in this diff