123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- <?php
- function tripal_contact_admin() {
- $form = array();
-
-
-
- $active_jobs = FALSE;
- if (tripal_get_module_active_jobs('tripal_contact')) {
- $active_jobs = TRUE;
- }
-
- if (!$active_jobs) {
- get_tripal_contact_admin_form_cleanup_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);
- }
- 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,
- );
- }
- function get_tripal_contact_admin_form_reindex_set(&$form) {
-
- $form['reindex'] = array(
- '#type' => 'fieldset',
- '#title' => t('Reindex Map Features')
- );
-
- $sql = "SELECT * FROM {contact} ORDER BY name";
- $lib_rset = chado_query($sql);
-
- $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,
- );
- }
- function tripal_contact_admin_validate($form, &$form_state) {
- global $user;
- $job_args = array();
-
-
- 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)) {
-
- $sql = "SELECT * FROM {contact} WHERE contact_id = :contact_id";
- $contact = db_fetch_object(chado_query($sql, array(':contact_id' => $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);
- }
- }
- }
-
-
-
- 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);
- }
- }
- function tripal_contact_cleanup($dummy = NULL, $job_id = NULL) {
- return tripal_core_clean_orphaned_nodes('contact', $job_id);
-
- }
- function tripal_contact_add_taxonomy($node, $contact_id) {
- }
|