123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <?php
- function tripal_get_default_cv($table, $field) {
- $sql = "
- SELECT cv_id
- FROM {tripal_cv_defaults}
- WHERE table_name = :table and field_name = :field
- ";
- $cv_id = db_query($sql, array(':table' => $table, ':field' => $field))->fetchField();
- return tripal_get_cv(array('cv_id' => $cv_id));
- }
- function tripal_get_default_cv_table($cv_id) {
- $default = db_select('tripal_cv_defaults', 't')
- ->fields('t', array('table_name', 'field_name'))
- ->condition('cv_id', $cv_id)
- ->execute()
- ->fetchObject();
- return $default;
- }
- function tripal_get_cvterm_default_select_options($table, $field, $field_desc) {
- $default_cv = tripal_get_default_cv($table, $field);
- $options = array();
- if ($default_cv) {
- $options = tripal_get_cvterm_select_options($default_cv->cv_id);
- if (count($options) == 0) {
- tripal_set_message('There are no ' . $field_desc . '. Please ' .
- l('add terms',
- 'admin/tripal/vocab/cv/' .$default_cv->cv_id. '/cvterm/add',
- array('attributes' => array('target' => '_blank'))) . ' to the ' .
- $default_cv->name .' vocabulary.',
- TRIPAL_WARNING);
- }
- }
- else {
- tripal_set_message('There is not a default vocabulary set for ' . $field_desc . '. '.
- 'Please set one using the ' .
- l('vocabulary defaults configuration page',
- 'admin/tripal/vocab/defaults',
- array('attributes' => array('target' => '_blank'))) . '.',
- TRIPAL_WARNING);
- }
- return $options;
- }
|