ソースを参照

Added contact configuration page and admin theme page. Also added template for contact publications

spficklin 11 年 前
コミット
4c8824efcd

+ 159 - 0
tripal_contact/includes/tripal_contact.admin.inc

@@ -1 +1,160 @@
 <?php
+/**
+ * Administrative settings form
+ *
+ * @ingroup tripal_contact
+ */
+function tripal_contact_admin() {
+  $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 maps
+  $active_jobs = FALSE;
+  if (tripal_get_module_active_jobs('tripal_contact')) {
+    $active_jobs = TRUE;
+  }
+
+  // add the field set for syncing maps
+  if (!$active_jobs) {
+    get_tripal_contact_admin_form_cleanup_set($form);
+// TODO: complete coding of indexing and taxonomy assignment to features.    
+//    get_tripal_contact_admin_form_reindex_set($form);
+//    get_tripal_contact_admin_form_taxonomy_set($form);
+  }
+  else {
+    $form['notice'] = array(
+     '#type' => 'fieldset',
+     '#title' => t('Feature Map Management Temporarily Unavailable')
+    );
+    $form['notice']['message'] = array(
+        '#value' => t('Currently, feature map 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.'),
+    );
+  }
+
+  return system_settings_form($form);
+}
+/**
+ *
+ *
+ * @ingroup tripal_contact
+ */
+function get_tripal_contact_admin_form_cleanup_set(&$form) {
+  $form['cleanup'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Clean Up')
+  );
+  $form['cleanup']['description'] = array(
+     '#type' => 'item',
+     '#value' => t("With Drupal and chado residing in different databases ".
+        "it is possible that nodes in Drupal and maps in Chado become ".
+        "\"orphaned\".  This can occur if an map node in Drupal is ".
+        "deleted but the corresponding chado map is not and/or vice ".
+        "versa. Click the button below to resolve these discrepancies."),
+     '#weight' => 1,
+  );
+  $form['cleanup']['button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Clean up orphaned maps'),
+    '#weight' => 2,
+  );
+}
+
+/**
+ *
+ * @ingroup tripal_contact
+ */
+function get_tripal_contact_admin_form_reindex_set(&$form) {
+   // define the fieldsets
+  $form['reindex'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Reindex Map Features')
+  );
+
+  // get the list of maps
+  $sql = "SELECT * FROM {contact} ORDER BY name";
+  $lib_rset = chado_query($sql);
+
+  // iterate through all of the maps
+  $lib_boxes = array();
+  while ($contact = db_fetch_object($lib_rset)) {
+    $lib_boxes[$contact->contact_id] = "$contact->name";
+  }
+  $form['reindex']['description'] = array(
+     '#type' => 'item',
+     '#value' => t("This option allows for reindexing of only those features that belong to the selected maps below. All other features will be unaffected.  To reindex all features in the site see the Feature Administration page."),
+   '#weight' => 1,
+  );
+
+  $form['reindex']['re-maps'] = array(
+   '#title'       => t('Contacts'),
+   '#type'        => t('checkboxes'),
+   '#description' => t("Check the maps whoee features you want to reindex. Note: this list contains all maps, even those that may not be synced."),
+   '#required'    => FALSE,
+   '#prefix'      => '<div id="lib_boxes">',
+   '#suffix'      => '</div>',
+   '#options'     => $lib_boxes,
+   '#weight' => 2,
+  );
+  $form['reindex']['re-button'] = array(
+    '#type' => 'submit',
+    '#value' => t('Reindex Features'),
+    '#weight' => 3,
+  );
+}
+/**
+ *
+ * @ingroup tripal_contact
+ */
+function tripal_contact_admin_validate($form, &$form_state) {
+  global $user;  // we need access to the user info
+  $job_args = array();
+
+  // -------------------------------------
+  // Submit the Reindex Job if selected
+  if ($form_state['values']['op'] == t('Reindex Features')) {
+    $contacts = $form_state['values']['re-maps'];
+    foreach ($contacts as $contact_id) {
+      if ($contact_id and preg_match("/^\d+$/i", $contact_id)) {
+        // get the map info
+        $sql = "SELECT * FROM {contact} WHERE contact_id = %d";
+        $contact = db_fetch_object(chado_query($sql, $contact_id));
+        $job_args[0] = $contact_id;
+        tripal_add_job("Reindex features for map: $contact->name", 'tripal_contact',
+         'tripal_contact_reindex_features', $job_args, $user->uid);
+      }
+    }
+  }
+  
+  // -------------------------------------
+  // Submit the Cleanup Job if selected
+  if ($form_state['values']['op'] == t('Clean up orphaned maps')) {
+    tripal_add_job('Cleanup orphaned maps', 'tripal_contact',
+       'tripal_contact_cleanup', $job_args, $user->uid);
+  }
+}
+
+
+/**
+ * Remove orphaned drupal nodes
+ *
+ * @param $dummy
+ *   Not Used -kept for backwards compatibility
+ * @param $job_id
+ *   The id of the tripal job executing this function
+ *
+ * @ingroup tripal_contact
+ */
+function tripal_contact_cleanup($dummy = NULL, $job_id = NULL) {
+
+  return tripal_core_clean_orphaned_nodes('contact', $job_id);
+  
+}
+/**
+ * Add the map as a taxonomy term for associating with map_features
+ *
+ * @ingroup tripal_contact
+ */
+function tripal_contact_add_taxonomy($node, $contact_id) {
+
+}

+ 36 - 0
tripal_contact/theme/tripal_contact_admin.tpl.php

@@ -0,0 +1,36 @@
+<h3>Tripal Contact Quick Links:</h3>
+<ul>
+  <li><a href="<?php print url('admin/tripal/tripal_contact/configuration') ?>">Contact Configuration</a></li>
+  <li><a href="<?php print url('admin/tripal/tripal_contact/sync') ?>">Sync Contacts</a></li>
+</ul>
+
+<h3>Module Description:</h3>
+<p>The Tripal Contact module is an interface for the Chado Contact module which provides information about
+   people or organizations.  This module provides support for visualization of "contact" pages, editing and updating.
+</p>
+
+<h3>Setup Instructions:</h3>
+<ol>
+   <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
+   or administer contacts. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
+   permissions under the 'tripal_contact' section as appropriate for your site. For a simple setup, allow anonymous 
+   users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
+ 
+ <li><p><b>Create a Contact</b>:  An contact can be <?php print l('created', 'node/add/chado-contact')?> 
+ manually in the same way any other data type.  Contacts may also be created automatically by using the 
+ publication module publication importers. Alternatively, the Tripal bulk loader may also be used to load contacts.</p></li>
+ 
+ <li><p><b>Sync any Existing Contacts</b>: Before Contacts can be viewed on the website, they must first be <?php print l('created manually', 'node/add/chado-contact')  ?> 
+          or if they already exist in the Chado database they <?php print l('must be synced', 'admin/tripal/tripal_contact/sync') ?> with Drupal.
+          Once synced, contact pages will appear on the site.</p></li> 
+</ol>
+
+
+<h3>Features of this Module:</h3>
+<ul>
+  <li><p><b>Edit or Delete Contacts</b>: Contacts can be manually edited or deleted by navigating to the map page and clicking the "Edit" button.</p></li>  
+    <li><p><b>Simple Search Tool</b>: A <?php print l('simple search tool','chado/contacts') ?> is provided for 
+    finding contacts. This tool relies on Drupal Views.  <a href="http://drupal.org/project/views">Drupal Views</a>
+    which must be installed to see the search tool.  Look for it in the navigation menu under the item 
+    "Search Biological Data". </p></li>
+</ul>

+ 13 - 0
tripal_contact/tripal_contact.module

@@ -94,6 +94,16 @@ function tripal_contact_menu() {
     'type' => MENU_NORMAL_ITEM
   );
   
+  $items['admin/tripal/tripal_contact/configuration'] = array(
+    'title' => 'Configuration',
+    'description' => 'Integration of Chado contacts.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('tripal_contact_admin'),
+    'access arguments' => array('administer tripal contact'),
+    'type' => MENU_NORMAL_ITEM,
+  );
+  
+  
   $items['admin/tripal/tripal_contact/sync'] = array(
     'title' => ' Sync Contacts',
     'description' => 'Sync contacts in Chado with Drupal',
@@ -144,6 +154,9 @@ function tripal_contact_theme() {
     'tripal_contact_relationships' => array(
       'arguments' => array('node' => NULL)
     ),
+    'tripal_contact_publications' => array(
+      'arguments' => array('node' => NULL)
+    ),
     'tripal_contact_admin' => array(
       'template' => 'tripal_contact_admin',  
       'arguments' =>  array(NULL),  

+ 3 - 3
tripal_featuremap/theme/tripal_featuremap_admin.tpl.php

@@ -1,4 +1,4 @@
-<h3>Tripal Feature Map Administrative Tools Quick Links:</h3>
+<h3>Tripal Feature Map Quick Links:</h3>
 <ul>
   <li><a href="<?php print url('admin/tripal/tripal_featuremap/configuration') ?>">Map Configuration</a></li>
 </ul>
@@ -12,8 +12,8 @@
 <h3>Setup Instructions:</h3>
 <ol>
    <li><p><b>Set Permissions</b>: By default only the site administrator account has access to create, edit, delete
-   or administer features. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
-   permissions under the 'tripal_library' section as appropriate for your site. For a simple setup, allow anonymous 
+   or administer maps. Navigate to the <?php print l('permissions page', 'admin/user/permissions')?> and set the
+   permissions under the 'tripal_featuremap' section as appropriate for your site. For a simple setup, allow anonymous 
    users access to view content and create a special role for creating, editing and other administrative tasks.</p></li>
  
  <li><p><b>Create a Map</b>:  An map (called a feature map in Chado) can be <?php print l('created', 'node/add/chado-featuremap')?>