function get_tripal_library_admin_form_sync_set

1.x tripal_library.admin.inc get_tripal_library_admin_form_sync_set(&$form)

Related topics

1 call to get_tripal_library_admin_form_sync_set()
tripal_library_admin in tripal_library/includes/tripal_library.admin.inc
Administrative settings form

File

tripal_library/includes/tripal_library.admin.inc, line 158

Code

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


  // get the list of libraries
  $sql = "SELECT * FROM {Library} ORDER BY uniquename";
  $lib_rset = chado_query($sql);

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

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

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


    $form['sync']['libraries'] = array(
      '#title' => t('Available Libraries'),
      '#type' => t('checkboxes'),
      '#description' => t("Check the libraries you want to sync.  Drupal content will be created for each of the libraries listed above.  Select 'All Libraries' 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 Libraries'),
      '#weight' => 3,
    );
  }
  // we don't have any libraries to select from
  else {
    $form['sync']['value'] = array(
      '#value' => t('All libraries in Chado are currently synced with Drupal.')
    );
  }
}