diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-09 11:51:54 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2008-01-09 11:51:54 +0000 |
commit | 6ab877faf12c9760be3cefa79c2075c9dbdfcf49 (patch) | |
tree | c79e2408d2f1a8ca746f6dd3fdcb5650ed885a4a /modules/locale | |
parent | 8ec14386b896b5bc8614ad7b0950578e41b66342 (diff) | |
download | brdo-6ab877faf12c9760be3cefa79c2075c9dbdfcf49.tar.gz brdo-6ab877faf12c9760be3cefa79c2075c9dbdfcf49.tar.bz2 |
#206021 by dropcube and myself: language content type settings were not properly namespaced
Diffstat (limited to 'modules/locale')
-rw-r--r-- | modules/locale/locale.install | 38 | ||||
-rw-r--r-- | modules/locale/locale.module | 6 |
2 files changed, 41 insertions, 3 deletions
diff --git a/modules/locale/locale.install b/modules/locale/locale.install index fe1d6b135..2208a2f70 100644 --- a/modules/locale/locale.install +++ b/modules/locale/locale.install @@ -163,6 +163,44 @@ function locale_update_6004() { } /** + * Change language setting variable of content types. + * + * Use language_content_type_<content_type> instead of language_<content_type> + * so content types such as 'default', 'count' or 'negotiation' will not + * interfer with language variables. + */ +function locale_update_6005() { + foreach (node_get_types() as $type => $content_type) { + // Default to NULL, so we can skip dealing with non-existent settings. + $setting = variable_get('language_'. $type, NULL); + if ($type == 'default' && is_numeric($setting)) { + // language_default was overwritten with the content type setting, + // so reset the default language and save the content type setting. + variable_set('language_content_type_default', $setting); + variable_del('language_default'); + drupal_set_message('The default language setting has been reset to its default value. Check the '. l('language configuration page', 'admin/settings/language') .' to configure it correctly.'); + } + elseif ($type == 'negotiation') { + // Either it is the negotiation setting or the content type setting, it + // is an integer. The language_negotiation setting is not reset, but + // the user is alerted that this setting possibly was overwritten + variable_set('language_content_type_negotiation', $setting); + drupal_set_message('The language negotiation setting was possibly overwritten by a content type of the same name. Check the '. l('language configuration page', 'admin/settings/language/configure') .' and the '. l('<em>'. $content_type->name ."</em> content type's multilingual support settings", 'admin/content/types/negotiation', array('html' => TRUE)) .' to configure them correctly.'); + } + elseif (!is_null($setting)) { + // Change the language setting variable for any other content type. + // Do not worry about language_count, it will be updated below. + variable_set('language_content_type_'. $type, $setting); + variable_del('language_'. $type); + } + } + // Update language count variable that might be overwritten. + $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1')); + variable_set('language_count', $count); + return array(); +} + +/** * @} End of "defgroup updates-5.x-to-6.x" */ diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 78bbbdaea..eaf914176 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -259,10 +259,10 @@ function locale_form_alter(&$form, $form_state, $form_id) { // Language setting for content types case 'node_type_form': if (isset($form['identity']['type'])) { - $form['workflow']['language'] = array( + $form['workflow']['language_content_type'] = array( '#type' => 'radios', '#title' => t('Multilingual support'), - '#default_value' => variable_get('language_'. $form['#node_type']->type, 0), + '#default_value' => variable_get('language_content_type_'. $form['#node_type']->type, 0), '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the <a href="!languages">enabled languages</a>. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/settings/language'))), ); @@ -272,7 +272,7 @@ function locale_form_alter(&$form, $form_state, $form_id) { // Language field for nodes default: if (isset($form['#id']) && $form['#id'] == 'node-form') { - if (isset($form['#node']->type) && variable_get('language_'. $form['#node']->type, 0)) { + if (isset($form['#node']->type) && variable_get('language_content_type_'. $form['#node']->type, 0)) { $form['language'] = array( '#type' => 'select', '#title' => t('Language'), |