function key_delete_key in Key 7.3
Delete a key configuration.
Parameters
string $id: The ID of the configuration to delete.
bool $messages: TRUE if messages should be displayed.
Return value
bool TRUE if successful, FALSE if not.
2 calls to key_delete_key()
- key_config_delete_confirm_submit in includes/
key.admin.inc - Submit handler for key_config_delete_confirm().
- _drush_key_delete in drush/
key_delete.inc - Delete a key.
File
- ./
key.module, line 614 - Main Key functionality and hook implementations.
Code
function key_delete_key($id, $messages = TRUE) {
// Load the configuration.
$config = key_get_key($id);
// If the configuration could not be loaded.
if (!$config) {
// Display message and log to watchdog.
if ($messages) {
drupal_set_message(t('The key was not deleted because it could not be found.'));
watchdog('key', 'The key was not deleted because it could not be found.', array(), WATCHDOG_NOTICE, l(t('view'), KEY_MENU_PATH . '/list'));
}
return FALSE;
}
// Load the key provider plugin.
$key_provider = key_get_plugin('key_provider', $config['key_provider']);
if ($delete_callback = ctools_plugin_get_function($key_provider, 'delete key value')) {
call_user_func($delete_callback, $config);
}
db_delete('key_config')
->condition('id', $id)
->execute();
if ($messages) {
$t_args = array(
'%label' => $config['label'],
);
drupal_set_message(t('The key %label has been deleted.', $t_args));
watchdog('key', 'Deleted key %label.', $t_args, WATCHDOG_NOTICE);
}
// Try to load the configuration again.
$config = key_get_key($id);
return $config ? FALSE : TRUE;
}