tripal_cv.cvtermpath_form.inc

Provides a form for updating controlled vocabularies path

File

tripal_cv/includes/tripal_cv.cvtermpath_form.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provides a form for updating controlled vocabularies path
  5. */
  6. /**
  7. * Form for re-doing the cvterm path
  8. *
  9. * @ingroup tripal_cv
  10. */
  11. function tripal_cv_cvtermpath_form() {
  12. // get a list of db from chado for user to choose
  13. $sql = "SELECT * FROM {cv} WHERE NOT name = 'tripal' ORDER BY name ";
  14. $results = chado_query($sql);
  15. $cvs = array();
  16. $cvs[] = '';
  17. foreach ($results as $cv) {
  18. $cvs[$cv->cv_id] = $cv->name;
  19. }
  20. $form['cvid'] = array(
  21. '#title' => t('Controlled Vocabulary/Ontology Name'),
  22. '#type' => 'select',
  23. '#options' => $cvs,
  24. '#description' => t('The Chado cvtermpath is a database table that provides lineage for ontology terms
  25. and is useful for quickly finding any ancestor parent of a term. This table must be populated for each
  26. ontology. Select a controlled vocabulary for which you would like to upate the cvtermpath.'),
  27. );
  28. $form['description'] = array(
  29. '#type' => 'item',
  30. '#value' => t("Submit a job to update chado cvtermpath table."),
  31. '#weight' => 1,
  32. );
  33. $form['button'] = array(
  34. '#type' => 'submit',
  35. '#value' => t('Update cvtermpath'),
  36. '#weight' => 2,
  37. );
  38. return $form;
  39. }
  40. /**
  41. * Cvterm path form submit
  42. *
  43. * @ingroup tripal_cv
  44. */
  45. function tripal_cv_cvtermpath_form_submit($form, &$form_state) {
  46. global $user;
  47. $cvid = $form_state['values']['cvid'];
  48. // first get the controlled vocabulary name:
  49. $sql = "SELECT * FROM {cv} WHERE cv_id = :cv_id";
  50. $cv = chado_query($sql, array(':cv_id' => $cvid))->fetchObject();
  51. // Submit a job to update cvtermpath
  52. $job_args = array($cvid);
  53. if ($form_state['values']['op'] == t('Update cvtermpath')) {
  54. tripal_add_job("Update cvtermpath: $cv->name", 'tripal_cv',
  55. 'tripal_cv_update_cvtermpath', $job_args, $user->uid);
  56. }
  57. }