function taxonomy_tools_publisher_unpublish in Taxonomy Tools 7
Same name and namespace in other branches
- 8 taxonomy_tools_publisher/taxonomy_tools_publisher.module \taxonomy_tools_publisher_unpublish()
Unpublishes scheduled taxonomy terms.
1 call to taxonomy_tools_publisher_unpublish()
- taxonomy_tools_publisher_cron in taxonomy_tools_publisher/
taxonomy_tools_publisher.module - Implements hook_cron().
File
- taxonomy_tools_publisher/
taxonomy_tools_publisher.module, line 208 - Drupal hooks and functions to manipulate taxonomy terms.
Code
function taxonomy_tools_publisher_unpublish() {
// Collect term ID's of terms which publish on value is before now.
$config = array_filter(variable_get('taxonomy_tools_publisher_config', array()));
$query = db_select('field_data_field_taxonomy_term_unpublish_on', 'foo');
$query
->addField('foo', 'entity_id', 'tid');
$query
->addField('foo', 'field_taxonomy_term_unpublish_on_value', 'unpublish_on');
$query
->leftJoin('taxonomy_term_data', 'bar', 'foo.entity_id = bar.tid');
$query
->join('taxonomy_vocabulary', 'baz', 'baz.vid = bar.vid');
$query
->condition('baz.machine_name', $config, 'IN');
$result = $query
->execute()
->fetchAll();
$tids = array();
foreach ($result as $data) {
if ($data->unpublish_on < REQUEST_TIME) {
$tids[] = $data->tid;
}
}
foreach ($tids as $tid) {
// Unpublish the term.
taxonomy_tools_publisher_unpublish_term($tid);
}
}