Skip to content
Snippets Groups Projects
Commit 7e8f799b authored by Nicholas Thompson's avatar Nicholas Thompson
Browse files

Some code for variable tidy-up on uninstall and setting submission

parent 0f5190ab
No related branches found
No related tags found
No related merge requests found
......@@ -73,9 +73,27 @@ function page_title_update_6200() {
*/
function page_title_uninstall() {
drupal_uninstall_schema('page_title');
// Clear variables
variable_del('page_title_default');
variable_del('page_title_individual');
variable_del('page_title_front');
foreach (node_get_types('names') AS $type => $name) {
variable_del("page_title_display_$type");
variable_del('page_title_blog');
variable_del('page_title_user');
variable_del('page_title_user_showfield');
variable_del('page_title_pager_pattern');
// Clear the node specific variables
$types = node_get_types('names');
foreach ($types as $type => $name) {
variable_del("page_title_type_{$type}");
variable_del("page_title_type_{$type}_showfield");
}
// Clear the vocab specific variables
$vocabs = taxonomy_get_vocabularies();
foreach ($vocabs as $vid => $vocab) {
variable_del("page_title_vocab_{$vid}");
variable_del("page_title_vocab_{$vid}_showfield");
}
}
......@@ -89,7 +89,8 @@ function page_title_theme() {
* Updates settings after a node type change.
*/
function page_title_node_type($op, $info) {
if ($op == 'update' && !empty($info->old_type) and $info->type != $info->old_type) {
// Handle a content type rename
if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) {
// Load the old node type settings.
$temp = variable_get('page_title_type_'. $info->old_type, '');
......@@ -99,15 +100,21 @@ function page_title_node_type($op, $info) {
}
// Delete the old setting
variable_del('page_title_type_'. $info-old_type);
variable_del('page_title_type_'. $info->old_type);
// Essentially, do the same as above but with the _showfield suffix for the node type
$temp = variable_get('page_title_type_'. $info->old_type .'_showfield', 0);
if ($temp) {
variable_set('page_title_type_'. $info->type .'_showfield', $temp);
}
variable_del('page_title_type_'. $info-old_type .'_showfield');
variable_del('page_title_type_'. $info->old_type .'_showfield');
}
// If deleted, remove the variables
if ($op == 'delete') {
variable_del('page_title_type_'. $info->type);
variable_del('page_title_type_'. $info->type .'_showfield');
}
}
......@@ -201,6 +208,9 @@ function page_title_node_type_form_submit($form, &$form_state) {
$show_field = $form_state['values']['page_title']['show_field']['show_field'] ? 1 : 0;
variable_set('page_title_type_'. $form_state['values']['type'] .'_showfield', $show_field);
variable_set('page_title_type_'. $form_state['values']['type'], $form_state['values']['page_title']['pattern']);
// For some reason the node module adds the fieldset as a separate entry in the variables table... we dont want this!
variable_del('page_title_'. $form_state['values']['type']);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment