Pass menubar preference as a param. Simplify cache mechanics. (#8)
authorTim Otten <totten@civicrm.org>
Mon, 8 Apr 2019 23:20:36 +0000 (16:20 -0700)
committercolemanw <coleman@civicrm.org>
Mon, 8 Apr 2019 23:20:36 +0000 (19:20 -0400)
Ex: If an admin uses an API call (CLI/REST) to change the menubar color,
then they don't need to follow-up with a cache-clear.  The new setting just
goes live.

Ex: If a customization (via `civicrm.settings.php` or via extension) decides
on the color scheme programmatically (e.g.  per-domain or per-role or
per-user-preference), then they don't need to clear cache.  Multiple color
schemes can coexist.

CRM/Admin/Form/Preferences/Display.php
CRM/Core/Resources.php

index 5f84883e956bfa8b0e006656d4683c282db098fa..9ba36825cdf95a5b513ca380b16a64049c03cd68 100644 (file)
@@ -106,8 +106,6 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
 
     $this->postProcessCommon();
 
-    \Civi::service('asset_builder')->clear();
-
     // If "Configure CKEditor" button was clicked
     if (!empty($this->_params['ckeditor_config'])) {
       // Suppress the "Saved" status message and redirect to the CKEditor Config page
index 98b3ba8ae5bd965e6c4a97a3aee5111c93981950..55d8461d8fd4e2c1d5a59588c60dbe1117928b6b 100644 (file)
@@ -765,7 +765,9 @@ class CRM_Core_Resources {
       $items[] = 'bower_components/smartmenus/dist/jquery.smartmenus.min.js';
       $items[] = 'bower_components/smartmenus/dist/addons/keyboard/jquery.smartmenus.keyboard.min.js';
       $items[] = 'js/crm.menubar.js';
-      $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css');
+      $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css', [
+        'color' => Civi::settings()->get('menubar_color'),
+      ]);
       $items[] = [
         'menubar' => [
           'position' => $position,
@@ -844,7 +846,7 @@ class CRM_Core_Resources {
     foreach ($items as $item) {
       $e->content .= file_get_contents(self::singleton()->getPath('civicrm', $item));
     }
-    $color = Civi::settings()->get('menubar_color');
+    $color = $e->params['color'];
     if (!CRM_Utils_Rule::color($color)) {
       $color = Civi::settings()->getDefault('menubar_color');
     }