function get_tripal_analysis_admin_form_sync_set
1.x tripal_analysis.admin.inc | get_tripal_analysis_admin_form_sync_set(&$form) |
The "sync Analysis in chado with drupal" form
Parameters
$form: The administrative form as it is currently
Return value
A form API array describing an administrative form
Related topics
1 call to get_tripal_analysis_admin_form_sync_set()
- tripal_analysis_admin in tripal_analysis/
includes/ tripal_analysis.admin.inc - Administration page callbacks for the Tripal Analysis module
File
- tripal_analysis/
includes/ tripal_analysis.admin.inc, line 230 - Contains functions displaying administrative pages and forms
Code
function get_tripal_analysis_admin_form_sync_set(&$form) {
// define the fieldsets
$form['sync'] = array(
'#type' => 'fieldset',
'#title' => t('Sync Analyses')
);
// before proceeding check to see if we have any
// currently processing jobs. If so, we don't want
// to give the opportunity to sync analyses
$active_jobs = FALSE;
if (tripal_get_module_active_jobs('tripal_analysis')) {
$active_jobs = TRUE;
}
if (!$active_jobs) {
// get the list of analyses
$sql = "SELECT * FROM {analysis} ORDER BY name";
$ana_rset = chado_query($sql);
// if we've added any analyses 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 analyses are currently synced.
$ana_boxes = array();
$added = 0;
while ($analysis = db_fetch_object($ana_rset)) {
// check to see if the analysis is already present as a node in drupal.
// if so, then skip it.
$sql = "SELECT * FROM {chado_analysis} WHERE analysis_id = %d";
if (!db_fetch_object(db_query($sql, $analysis->analysis_id))) {
$ana_boxes[$analysis->analysis_id] = "$analysis->name";
$added++;
}
}
// if we have analyses we need to add to the checkbox then
// build that form element
if ($added > 0) {
$ana_boxes['all'] = "All analyses";
$form['sync']['analyses'] = array(
'#title' => t('Available analyses'),
'#type' => t('checkboxes'),
'#description' => t("Check the analyses you want to sync. Drupal " .
"content will be created for each of the analyses listed above. " .
"Select 'All analyses' to sync all of them."),
'#required' => FALSE,
'#prefix' => '<div id="ana_boxes">',
'#suffix' => '</div>',
'#options' => $ana_boxes,
);
$form['sync']['button'] = array(
'#type' => 'submit',
'#value' => t('Submit Sync Job')
);
}
// we don't have any analyses to select from
else {
$form['sync']['value'] = array(
'#value' => t('All analyses in Chado are currently synced with Drupal.')
);
}
}
// we don't want to present a form since we have an active job running
else {
$form['sync']['value'] = array(
'#value' => t('Currently, jobs exist related to chado analyses. Please check back later for analyses that can by synced once these jobs have finished. You can view the status of pending jobs in the Tripal jobs page.')
);
}
}