function tripal_library_admin_validate
1.x tripal_library.admin.inc | tripal_library_admin_validate($form, &$form_state) |
Related topics
File
- tripal_library/
includes/ tripal_library.admin.inc, line 225
Code
function tripal_library_admin_validate($form, &$form_state) {
global $user; // we need access to the user info
$job_args = array();
// Submit the Sync Job if selected
if ($form_state['values']['op'] == t('Sync Libraries')) {
// check to see if the user wants to sync chado and drupal. If
// so then we need to register a job to do so with tripal
$libraries = $form_state['values']['libraries'];
$do_all = FALSE;
$to_sync = array();
foreach ($libraries as $library_id) {
if (preg_match("/^all$/i", $library_id)) {
$do_all = TRUE;
}
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
// get the library info
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
$library = db_fetch_object(chado_query($sql, $library_id));
$to_sync[$library_id] = $library->name;
}
}
// submit the job to the tripal job manager
if ($do_all) {
tripal_add_job('Sync all libraries', 'tripal_library', 'tripal_library_sync_libraries', $job_args, $user->uid);
}
else {
foreach ($to_sync as $library_id => $name) {
$job_args[0] = $library_id;
tripal_add_job("Sync library: $name", 'tripal_library', 'tripal_library_sync_libraries', $job_args, $user->uid);
}
}
}
// -------------------------------------
// Submit the Reindex Job if selected
if ($form_state['values']['op'] == t('Reindex Features')) {
$libraries = $form_state['values']['re-libraries'];
foreach ($libraries as $library_id) {
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
// get the library info
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
$library = db_fetch_object(chado_query($sql, $library_id));
$job_args[0] = $library_id;
tripal_add_job("Reindex features for library: $library->name", 'tripal_library',
'tripal_library_reindex_features', $job_args, $user->uid);
}
}
}
// -------------------------------------
// Submit the Taxonomy Job if selected
if ($form_state['values']['op'] == t('Set Feature Taxonomy')) {
$libraries = $form_state['values']['tx-libraries'];
foreach ($libraries as $library_id) {
if ($library_id and preg_match("/^\d+$/i", $library_id)) {
// get the library info
$sql = "SELECT * FROM {Library} WHERE library_id = %d";
$library = db_fetch_object(chado_query($sql, $library_id));
$job_args[0] = $library_id;
tripal_add_job("Set taxonomy for features in library: $library->name", 'tripal_library',
'tripal_library_taxonify_features', $job_args, $user->uid);
}
}
}
// -------------------------------------
// Submit the Cleanup Job if selected
if ($form_state['values']['op'] == t('Clean up orphaned libraries')) {
tripal_add_job('Cleanup orphaned libraries', 'tripal_library',
'tripal_library_cleanup', $job_args, $user->uid);
}
}