From 6dbe2c23d4631893816cd7e59121276d553c97c1 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 13 Jul 2015 12:16:02 -0400 Subject: [PATCH] CRM-16354 - Improve wysiwyg upgrade & add message to user --- CRM/Upgrade/Incremental/php/FourSeven.php | 43 ++++++++++++++----- .../Incremental/sql/4.7.alpha1.mysql.tpl | 4 +- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 599be257c6..9d044aad43 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -68,6 +68,30 @@ class CRM_Upgrade_Incremental_php_FourSeven { * @return void */ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { + if ($rev == '4.7.alpha1') { + $config = CRM_Core_Config::singleton(); + $editor_id = self::updateWysiwyg(); + $msg = NULL; + $ext_href = 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1') . '"'; + $dsp_href = 'href="' . CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1') . '"'; + $blog_href = 'href="https://civicrm.org/blogs/colemanw/big-changes-wysiwyg-editing-47"'; + switch ($editor_id) { + // TinyMCE + case 1: + $msg = ts('Your configured editor "TinyMCE" is no longer part of the main CiviCRM download. To continue using it, visit the Manage Extensions page to download and install the TinyMCE extension.', array(1 => $ext_href)); + break; + + // Drupal/Joomla editor + case 3: + case 4: + $msg = ts('CiviCRM no longer integrates with the "%1 Default Editor." Your wysiwyg setting has been reset to the built-in CKEditor. Learn more...', array(1 => $config->userFramework, 2 => $blog_href)); + break; + } + if ($msg) { + $postUpgradeMessage .= '

' . $msg . '

'; + } + $postUpgradeMessage .= '

' . ts('CiviCRM now includes the easy-to-use CKEditor Configurator. To customize the features and display of your wysiwyg editor, visit the Display Preferences page. Learn more...', array(1 => $dsp_href, 2 => $blog_href)) . '

'; + } } @@ -111,25 +135,22 @@ class CRM_Upgrade_Incremental_php_FourSeven { * @param string $rev */ public function upgrade_4_7_alpha1($rev) { - // Task to process sql. - $this->addTask(ts('Update wysiwyg editor settings.'), 'updateWysiwyg'); + $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'task_4_7_x_runSql', $rev); } /** * CRM-16354 * - * @param \CRM_Queue_TaskContext $ctx - * - * @return bool + * @return int */ - public static function updateWysiwyg(CRM_Queue_TaskContext $ctx) { + public static function updateWysiwyg() { $editorID = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id'); - // Previously any value indicated one of 4 wysiwyg editors shipped in core, and no value indicated 'Textfield' - // Now Textfield is 1, CKEditor is 2, and the rest have been dropped from core. - $editorID = $editorID ? 2 : 1; - CRM_Core_BAO_Setting::setItem($editorID, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id'); + // Previously a numeric value indicated one of 4 wysiwyg editors shipped in core, and no value indicated 'Textarea' + // Now the options are "Textarea", "CKEditor", and the rest have been dropped from core. + $newEditor = $editorID ? "CKEditor" : "Textarea"; + CRM_Core_BAO_Setting::setItem($newEditor, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id'); - return TRUE; + return $editorID; } } diff --git a/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl index 3650787a60..3856d6a831 100644 --- a/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl @@ -3,13 +3,13 @@ -- CRM-16354 SELECT @option_group_id_wysiwyg := max(id) from civicrm_option_group where name = 'wysiwyg_editor'; -UPDATE civicrm_option_group SET name = 'Textarea', {localize field='label'}label = 'Textarea'{/localize} +UPDATE civicrm_option_value SET name = 'Textarea', {localize field='label'}label = 'Textarea'{/localize} WHERE value = 1 AND option_group_id = @option_group_id_wysiwyg; DELETE FROM civicrm_option_value WHERE name IN ('Joomla Default Editor', 'Drupal Default Editor') AND option_group_id = @option_group_id_wysiwyg; -UPDATE civicrm_option_group SET is_active = 1, is_reserved = 1 WHERE option_group_id = @option_group_id_wysiwyg; +UPDATE civicrm_option_value SET is_active = 1, is_reserved = 1 WHERE option_group_id = @option_group_id_wysiwyg; --CRM-16719 SELECT @option_group_id_report := max(id) from civicrm_option_group where name = 'report_template'; -- 2.25.1