function get_tripal_featuremap_admin_form_sync_set

1.x tripal_featuremap.admin.inc get_tripal_featuremap_admin_form_sync_set(&$form)

Related topics

1 call to get_tripal_featuremap_admin_form_sync_set()
tripal_featuremap_admin in tripal_featuremap/includes/tripal_featuremap.admin.inc
Administrative settings form

File

tripal_featuremap/includes/tripal_featuremap.admin.inc, line 155

Code

function get_tripal_featuremap_admin_form_sync_set(&$form) {
  // define the fieldsets
  $form['sync'] = array(
    '#type' => 'fieldset',
    '#title' => t('Sync Maps')
  );


  // get the list of maps
  $sql = "SELECT * FROM {featuremap} ORDER BY name";
  $lib_rset = chado_query($sql);

  // if we've added any maps 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 maps are currently synced.
  $lib_boxes = array();
  $added = 0;
  while ($featuremap = db_fetch_object($lib_rset)) {
    // check to see if the map is already present as a node in drupal.
    // if so, then skip it.
    $sql = "SELECT * FROM {chado_featuremap} WHERE featuremap_id = %d";
    if (!db_fetch_object(db_query($sql, $featuremap->featuremap_id))) {
      $lib_boxes[$featuremap->featuremap_id] = "$featuremap->name";
      $added++;
    }
  }

  // if we have maps we need to add to the checkbox then
  // build that form element
  if ($added > 0) {
    $lib_boxes['all'] = "All Maps";

    $form['reindex']['description'] = array(
      '#type' => 'item',
      '#value' => t("This option allows for the creation of Drupal content for maps in chado. Only the selected maps will be synced."),
      '#weight' => 1,
    );


    $form['sync']['featuremaps'] = array(
      '#title' => t('Available Maps'),
      '#type' => t('checkboxes'),
      '#description' => t("Check the maps you want to sync.  Drupal content will be created for each of the maps listed above.  Select 'All Maps' to sync all of them."),
      '#required' => FALSE,
      '#prefix' => '<div id="lib_boxes">',
      '#suffix' => '</div>',
      '#options' => $lib_boxes,
      '#weight' => 2,
    );
    $form['sync']['button'] = array(
      '#type' => 'submit',
      '#value' => t('Sync Maps'),
      '#weight' => 3,
    );
  }
  // we don't have any maps to select from
  else {
    $form['sync']['value'] = array(
      '#value' => t('All maps in Chado are currently synced with Drupal.')
    );
  }
}