You are here

function twit_submit_block_taxonomy_check in Heartbeat 8

Check to see if hashtag is already in taxonomy before adding

1 call to twit_submit_block_taxonomy_check()
twit_submit_block_submit_callback in modules/statusmessage/includes/twit.php

File

modules/statusmessage/includes/twit.php, line 32

Code

function twit_submit_block_taxonomy_check($term) {
  $query = db_select('taxonomy_term_data', 'ttd')
    ->fields('ttd', array(
    'tid',
    'name',
  ))
    ->condition('ttd.name', $term->text);
  $query = db_query('SELECT tid FROM taxonomy_term_data WHERE name = :name', array(
    ':name' => $term->text,
  ));
  if ($query
    ->rowCount() >= 2) {
    dpm($query
      ->rowCount());
    $result = $query
      ->fetchObject();
    dpm($result);
    $tid = $result->tid;
  }
  else {
    $tid = twit_submit_block_taxonomy_add($term->text);
  }
  return $tid;
}