fetchField();
variable_set('termstatus_enable', empty($any_tid));
}
/**
* Implements hook_uninstall().
*/
function termstatus_uninstall() {
variable_del('termstatus_enable');
}
/**
* Implements hook_requirements().
*/
function termstatus_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time.
$t = get_t();
if ($phase != 'install') {
// Check if term status is enabled.
if (!variable_get('termstatus_enable', FALSE)) {
$requirements['taxonomy_term_status'] = array(
'title' => $t('Taxonomy Term Status'),
'value' => $t('Term status is not configured yet. First visit the configuration page in order to build the status records and then enable it.', array('@config_link' => url('admin/config/system/termstatus'))),
'severity' => REQUIREMENT_WARNING,
);
}
else {
$requirements['taxonomy_term_status'] = array(
'title' => $t('Taxonomy Term Status'),
'value' => $t('Term status is configured and active. If the site is experiencing problems with visibility of taxonomy terms, you may have to rebuild the term status records using the configuration page.', array('@config_link' => url('admin/config/system/termstatus'))),
'severity' => REQUIREMENT_OK,
);
}
}
return $requirements;
}
/**
* Implements hook_schema().
*/
function termstatus_schema() {
$schema['termstatus'] = array(
'description' => 'The base table for termstatus.',
'fields' => array(
'tid' => array(
'description' => 'Primary Key: The {taxonomy_term_data}.tid of the term.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'status' => array(
'description' => 'Boolean indicating whether the term is published (visible to non-administrators).',
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
),
'primary key' => array('tid'),
'term_status' => array('tid', 'status'),
'foreign keys' => array(
'taxonomy_term_data' => array(
'table' => 'taxonomy_term_data',
'columns' => array('tid' => 'tid'),
),
),
);
return $schema;
}
/**
* Remove taxonomy_ prefix from variable names.
*/
function termstatus_update_7000() {
if (variable_get('taxonomy_term_status_enable', FALSE)) {
variable_set('termstatus_enable', TRUE);
}
variable_del('taxonomy_term_status_enable');
$termstatus_vars = db_query("SELECT name FROM {variable} WHERE name LIKE 'taxonomy_termstatus_%'")->fetchCol();
foreach ($termstatus_vars as $old_name) {
$new_name = substr($old_name, 9);
variable_set($new_name, variable_get($old_name));
variable_del($old_name);
}
}