CRM-16354 - Improve wysiwyg upgrade & add message to user
authorColeman Watts <coleman@civicrm.org>
Mon, 13 Jul 2015 16:16:02 +0000 (12:16 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 14 Jul 2015 15:38:17 +0000 (11:38 -0400)
CRM/Upgrade/Incremental/php/FourSeven.php
CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl

index 599be257c601178a415cc590521d9ea4985ef148..9d044aad43c66029ba3f3b69d2e67ccf1031bd6c 100644 (file)
@@ -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 <a %1>Manage Extensions</a> 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. <a %2>Learn more...</a>', array(1 => $config->userFramework, 2 => $blog_href));
+          break;
+      }
+      if ($msg) {
+        $postUpgradeMessage .= '<p>' . $msg . '</p>';
+      }
+      $postUpgradeMessage .= '<p>' . ts('CiviCRM now includes the easy-to-use CKEditor Configurator. To customize the features and display of your wysiwyg editor, visit the <a %1>Display Preferences</a> page. <a %2>Learn more...</a>', array(1 => $dsp_href, 2 => $blog_href)) . '</p>';
+    }
   }
 
 
@@ -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;
   }
 
 }
index 3650787a6030a6221a4abbf5c970e4face66d3d6..3856d6a831efb4dc2a4fdb45ecdf1658ca485479 100644 (file)
@@ -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';