Browse Source

Fixed bug in views integration that kept the mview column of the tripal_views table from being set

spficklin 13 years ago
parent
commit
da2c611ed2

+ 11 - 5
base/tripal_views/tripal_views.module

@@ -4,7 +4,9 @@ require_once "tripal_views_integration.inc";
 require_once "tripal_views.views.inc";
 
 /**
+ * Implements hook_menu()
  *
+ * Purpose: this hook provides details about new menu items added by this module
  *
  * @ingroup tripal_views
  */
@@ -20,8 +22,8 @@ function tripal_views_menu() {
    );
 
  	$items['admin/tripal/views/integration'] = array(
-     'title' => t('Views Integration'),
-     'description' => t('Allows you to select existing materialized views and provide details for integration with Drupal Views.'),
+     'title' => t('Integrated Tables'),
+     'description' => t('Provide a list of all integrated tables and allows for adding new tables or editing already integrated tables.'),
      'page callback' => 'tripal_views_integration_setup_list',
      'access arguments' => array('manage tripal_views_integration'),
      'type' => MENU_NORMAL_ITEM,
@@ -55,9 +57,9 @@ function tripal_views_menu() {
    return $items;
 }
 /**
- *  Set the permission types that the chado module uses.  Essentially we
- *  want permissionis that protect creation, editing and deleting of chado
- *  data objects
+ * Implements hook_views_api()
+ * 
+ * Purpose: Set the permission types that the chado module uses.  
  *
  * @ingroup tripal_views
  */
@@ -81,6 +83,10 @@ function tripal_views_views_api() {
    );
 }
 /**
+ * Implements hook_theme()
+ *
+ * Purpose: this hook provides details about themable objects added by 
+ *   this module
  *
  * @ingroup tripal_views
  */

+ 8 - 0
base/tripal_views/tripal_views.views.inc

@@ -376,6 +376,14 @@ function tripal_views_add_node_ids_to_view (&$view) {
 	return $view;
 }
 /**
+ * Generates a dynamic data array for Views
+ *
+ * Purpose: This function is a hook used by the Views module. It populates and
+ *   returns a data array that specifies for the Views module the base table,
+ *   the tables it joins with and handlers.  The data array is populated
+ *   using the data stored in the tripal_views tables.
+ *
+ * @return a data array formatted for the Views module
  *
  * @ingroup tripal_views
  */

+ 56 - 9
base/tripal_views/tripal_views_integration.inc

@@ -54,6 +54,12 @@ function tripal_views_description_page() {
   return $text;
 }
 /**
+ * Purpose: Generates a themable table containing the list of integrated tables
+ *   The look-and-feel of the table can be altered by overriding the theme for
+ *   tables.
+ *
+ * @return
+ *    a themed HTML table   
  *
  * @ingroup tripal_views_integration
  */
@@ -86,6 +92,12 @@ function tripal_views_integration_setup_list(){
 }
 
 /**
+ * Purpose: Deletes integration of a table with the Views module.  This 
+ *   function is meant to be called from a menu item. After completion it
+ *   redirects the user to the views intergation page.
+ *
+ * @param $setup_id
+ *    the unique setup id for the integrated table   
  *
  * @ingroup tripal_views_integration
  */
@@ -96,6 +108,19 @@ function tripal_views_integration_delete($setup_id){
 }
 
 /**
+ * Purpose: defines the web form used for specifing the base table, joins and
+ *   handlers when integrating a table with views.  This form is used for both
+ *   creating a new record and editing an existing record.
+ *
+ * @param &$form_state
+ *    The form state which is passed automatically by drupal  
+ *
+ * @param $setup_id
+ *    The unique setup for an integrated table.  This value is only set when
+ *    the form is used for updating an existing record.  
+ *
+ * @return
+ *    A proper Drupal form associative array.
  *
  * @ingroup tripal_views_integration
  */
@@ -678,6 +703,13 @@ function tripal_views_integration_form(&$form_state, $setup_id = NULL){
 
 
 /**
+ * Purpose: validates the tripal_views_integration_form after submission
+ *
+ * @param $form
+ *    The form object which is passed automatically by drupal  
+ *
+ * @param &$form_state
+ *    The form state pbject which is passed automatically by drupal  
  *
  * @ingroup tripal_views_integration
  */
@@ -697,7 +729,17 @@ function tripal_views_integration_form_validate($form, &$form_state){
   }
   // TODO: do we need to require that a handler be set for each field and each type of handler?
 }
+
+
 /**
+ * Purpose: inserts or updates the record in the tripal views integration
+ *   tables.  This function is only called if validation is passed. 
+ *
+ * @param $form
+ *    The form object which is passed automatically by drupal  
+ *
+ * @param &$form_state
+ *    The form state pbject which is passed automatically by drupal  
  *
  * @ingroup tripal_views_integration
  */
@@ -706,6 +748,8 @@ function tripal_views_integration_form_submit($form, &$form_state){
    $mview_id = $form_state['values']['mview_id'];
    $table_name = $form_state['values']['table_name'];
    $setup_id = $form_state['values']['setup_id'];
+   $priority = $form_state['values']['row_priority'];
+   $comment = $form_state['values']['row_description'];
 
    // get details about this mview
    if ($mview_id) {
@@ -731,19 +775,18 @@ function tripal_views_integration_form_submit($form, &$form_state){
        'mview_id' => $mview_id,
        'table_name' => $mview->mv_table,
        'name' => $name,
-       'priority' => $form_state['values']['row_priority'],
-       'comment' => $form_state['values']['row_description'],
-       
+       'priority' => $priority,
+       'comment' => $comment,       
       );
    } 
    // if a chado table then...
-   if($table_name){
-            // build the record for insert/update
+   else {
+      // build the record for insert/update
       $tripal_views_record = array(
        'table_name' => $table_name,
        'name' => $name,
-       'priority' => $form_state['values']['row_priority'],
-       'comment' => $form_state['values']['row_description'],
+       'priority' => $priority,
+       'comment' => $comment,
       );
    }
 
@@ -761,8 +804,6 @@ function tripal_views_integration_form_submit($form, &$form_state){
       }
    }
    
-
-   
    // if this is an update then clean out the existing joins and handlers so we can add new ones
    if($setup_id){  
       db_query("DELETE FROM {tripal_views_field} WHERE setup_id = %d",$setup_id);
@@ -830,6 +871,12 @@ function tripal_views_integration_form_submit($form, &$form_state){
 }
 
 /**
+ * Purpose: this function queries all modules currently enabled on the site
+ *   looking for custom handlers and returns a list of all available handerls.
+ *   The base View handlers are also included.
+ *
+ * @return
+ *   Returns an array of handler names
  *
  * @ingroup tripal_views_integration
  */