You are here

function simplenews_validate_taxonomy in Simplenews 5

Same name and namespace in other branches
  1. 6.2 simplenews.module \simplenews_validate_taxonomy()
  2. 6 simplenews.module \simplenews_validate_taxonomy()
3 calls to simplenews_validate_taxonomy()
simplenews_insert in ./simplenews.module
Implementation of hook_insert(). Saves extra node content to module database table.
simplenews_update in ./simplenews.module
Implementation of hook_update().
simplenews_validate in ./simplenews.module
Implementation of hook_validate().

File

./simplenews.module, line 384

Code

function simplenews_validate_taxonomy($taxonomy) {
  $vid = variable_get('simplenews_vid', '');
  $result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid);
  while ($tid = db_fetch_object($result)) {
    $tids[] = $tid->tid;
  }
  if (isset($tids) && !empty($taxonomy)) {
    $taxes = array();
    foreach ($taxonomy as $tax) {
      $taxes[] = $tax;
    }
    $selected_terms = array_intersect($tids, $taxes);
    return empty($selected_terms) ? FALSE : $selected_terms;
  }
  return FALSE;
}