You are here

function cctags_cron in cctags 6

Implementation of hook_cron

File

./cctags.module, line 471

Code

function cctags_cron() {
  $delcount = 0;
  $vocs = variable_get('cctags_cron_clear', array());
  foreach ($vocs as $voc => $value) {
    if ($value != 0) {
      $tids = taxonomy_get_tree($value);
      foreach ($tids as $term) {
        cctags_invoke_term_count($term);
        if ($term->count == 0) {
          $delcount++;
          taxonomy_del_term($term->tid);
        }
      }
      if ($delcount) {
        watchdog('cctags', 'Remove unused terms in the cron from vocabulary %name %count terms.', array(
          '%name' => $vocabulary->name,
          '%count' => $delcount,
        ), WATCHDOG_NOTICE);
      }
    }
  }
  if ($delcount) {
    _cctags_clear_cache(NULL, 'all', TRUE);
  }
}