cvtermpath_form.inc 1.7 KB

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