You are here

function cf_settings_unregister in Common Functionality 7.2

Remove a registered variable from the variables registry.

For variable types that can be deleted, this will remove/delete the variable from the database. This delete operation will only happen if no other modules are registered with the variable.

Parameters

string $variable_name: A string representing the variable name.

string $variable_type: A string representing the variable type.

string $module_name: A string representing the module name.

Return value

bool TRUE if unregistration was successfull, FALSE otherwise.

See also

variable_del()

Related topics

1 call to cf_settings_unregister()
cf_settings_modules_uninstalled in modules/cf_settings/cf_settings.module
Implements hook_modules_uninstalled().

File

modules/cf_settings/cf_settings.module, line 251
Common Functionality - PHP INI module.

Code

function cf_settings_unregister($variable_name, $variable_type, $module_name) {
  if (!is_string($variable_name) || empty($variable_name)) {
    return FALSE;
  }
  if (!is_string($variable_type) || empty($variable_type)) {
    return FALSE;
  }
  if (!is_string($module_name) || empty($module_name)) {
    return FALSE;
  }
  $options_table = cf_db_options_get_options_name('cf_settings', 'variable_type');
  if ($options_table === FALSE) {
    return FALSE;
  }
  $subquery = db_select($options_table, 'csot');
  $subquery
    ->fields('csot', array(
    'id',
  ));
  $subquery
    ->condition('machine_name', $variable_type);
  $query = db_delete('cf_settings_register');
  $query
    ->condition('variable_name', $variable_name);
  $query
    ->condition('module_name', $module_name);
  $query
    ->condition('variable_type', $subquery, 'IN');
  $query
    ->execute();
  if ($variable_type == 'drupal_variables') {
    if (!cf_settings_is_registered($variable_name, $variable_type)) {
      variable_del($variable_name);
    }
  }
  watchdog('unregister', "The module %module_name has unregistered the %variable_type: %variable_name.", array(
    '%variable_name' => $variable_name,
    '%variable_type' => $variable_type,
    '%module_name' => $module_name,
  ));
  return TRUE;
}