Add configuration UI for Communication Style options
authorOlaf Buddenhagen <antrik@digitalcourage.de>
Tue, 13 Aug 2013 22:30:42 +0000 (00:30 +0200)
committerOlaf Buddenhagen <antrik@digitalcourage.de>
Wed, 9 Oct 2013 10:17:28 +0000 (12:17 +0200)
Add a page in the Communication Preferences, using the generic Option
handler.

The menu entry is added above the entries for Email Greeting Formats,
Postal Greeting Formats, and Addressee Formats, just like in the actual
contact forms and views.

CRM/Admin/Form/Options.php
CRM/Admin/Page/Options.php
CRM/Core/xml/Menu/Admin.xml
CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl
xml/templates/civicrm_navigation.tpl

index 66dae58245b92b2e1adfd7ac568eb2d66a155f60..50f413e46fdce800dc52205a47272107b1408744 100644 (file)
@@ -271,7 +271,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
 
     //fix for CRM-3552, CRM-4575
     if (in_array($this->_gName, array(
-      'email_greeting', 'postal_greeting', 'addressee', 'from_email_address', 'case_status', 'encounter_medium', 'case_type'))) {
+      'communication_style', 'email_greeting', 'postal_greeting', 'addressee', 'from_email_address', 'case_status', 'encounter_medium', 'case_type'))) {
       $this->assign('showDefault', TRUE);
       $this->add('checkbox', 'is_default', ts('Default Option?'));
     }
index 14407a72076b24d97f5009eede208ce1790cc175..74395c8d5082dac08d6b81732383196b325edb91 100644 (file)
@@ -116,6 +116,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic {
         array(
           'from_email_address', 'email_greeting',
           'postal_greeting', 'addressee',
+          'communication_style',
           'case_status', 'encounter_medium',
           'case_type',
         )
index ecbafb53a8dc430383ee51e49c9d36910920f643..f56b9d8302f48bd8bc0632942e55c8b58a9e16fa 100644 (file)
      <icon>admin/small/template.png</icon>
      <weight>70</weight>
   </item>
+  <item>
+     <path>civicrm/admin/options/communication_style</path>
+     <title>Communication Style Options</title>
+     <desc>Options for Communication Style selection.</desc>
+     <path_arguments>group=communication_style</path_arguments>
+     <page_callback>CRM_Admin_Page_Options</page_callback>
+     <adminGroup>Communications</adminGroup>
+     <icon>admin/small/01.png</icon>
+     <weight>75</weight>
+  </item>
   <item>
      <path>civicrm/admin/options/email_greeting</path>
      <title>Email Greeting Formats</title>
index 3a0a94bf45f894f704433e2469406c92fe8ec918..1d2b2a27983365258c9a5ff2b1bbe2853b853dab 100644 (file)
@@ -19,3 +19,18 @@ INSERT INTO
 VALUES
   (@option_group_id_communication_style, {localize}'{ts escape="sql"}Formal{/ts}'{/localize}  , 1, 'formal'  , NULL, 0, 1, 1, NULL, 0, 0, 1, NULL, NULL),
   (@option_group_id_communication_style, {localize}'{ts escape="sql"}Familiar{/ts}'{/localize}, 2, 'familiar', NULL, 0, 0, 2, NULL, 0, 0, 1, NULL, NULL);
+
+-- Insert menu item at Administer > Communications, above the various Greeting Formats
+
+SELECT @parent_id := `id` FROM `civicrm_navigation` WHERE `name` = 'Communications' AND `domain_id` = {$domainID};
+SELECT @add_weight := MIN(`weight`) FROM `civicrm_navigation` WHERE `name` IN('Email Greeting Formats', 'Postal Greeting Formats', 'Addressee Formats') AND `parent_id` = @parent_id;
+
+UPDATE `civicrm_navigation`
+SET `weight` = `weight`+1
+WHERE `parent_id` = @parent_id
+AND `weight` >= @add_weight;
+
+INSERT INTO `civicrm_navigation`
+  ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
+VALUES
+  ( {$domainID}, 'civicrm/admin/options/communication_style&group=communication_style&reset=1', '{ts escape="sql" skip="true"}Communication Style Options{/ts}', 'Communication Style Options', 'administer CiviCRM', '', @parent_id, '1', NULL, @add_weight );
index c77bd53fe98667cdd949dc72ea58367123e610da..8c9424a9f030f15444f1f63a9f90731c80390228 100644 (file)
@@ -406,9 +406,10 @@ VALUES
     ( @domainID, 'civicrm/admin/options/preferred_communication_method&group=preferred_communication_method&reset=1',  '{ts escape="sql" skip="true"}Preferred Communication Methods{/ts}', 'Preferred Communication Methods',  'administer CiviCRM', '', @communicationslastID, '1', NULL, 5 ),
     ( @domainID, 'civicrm/admin/labelFormats&reset=1',                                  '{ts escape="sql" skip="true"}Label Formats{/ts}',                 'Label Formats',                                                     'administer CiviCRM', '', @communicationslastID, '1', NULL, 6 ),
     ( @domainID, 'civicrm/admin/pdfFormats&reset=1',                                    '{ts escape="sql" skip="true"}Print Page (PDF) Formats{/ts}',      'Print Page (PDF) Formats',                                          'administer CiviCRM', '', @communicationslastID, '1', NULL, 7 ),
-    ( @domainID, 'civicrm/admin/options/email_greeting&group=email_greeting&reset=1',   '{ts escape="sql" skip="true"}Email Greeting Formats{/ts}',        'Email Greeting Formats',                                            'administer CiviCRM', '', @communicationslastID, '1', NULL, 8 ),
-    ( @domainID, 'civicrm/admin/options/postal_greeting&group=postal_greeting&reset=1', '{ts escape="sql" skip="true"}Postal Greeting Formats{/ts}',       'Postal Greeting Formats',                                           'administer CiviCRM', '', @communicationslastID, '1', NULL, 9 ),
-    ( @domainID, 'civicrm/admin/options/addressee&group=addressee&reset=1',             '{ts escape="sql" skip="true"}Addressee Formats{/ts}',             'Addressee Formats',                                                 'administer CiviCRM', '', @communicationslastID, '1', NULL, 10 );
+    ( @domainID, 'civicrm/admin/options/communication_style&group=communication_style&reset=1',   '{ts escape="sql" skip="true"}Communication Style Options{/ts}', 'Communication Style Options',                               'administer CiviCRM', '', @communicationslastID, '1', NULL, 8 ),
+    ( @domainID, 'civicrm/admin/options/email_greeting&group=email_greeting&reset=1',   '{ts escape="sql" skip="true"}Email Greeting Formats{/ts}',        'Email Greeting Formats',                                            'administer CiviCRM', '', @communicationslastID, '1', NULL, 9 ),
+    ( @domainID, 'civicrm/admin/options/postal_greeting&group=postal_greeting&reset=1', '{ts escape="sql" skip="true"}Postal Greeting Formats{/ts}',       'Postal Greeting Formats',                                           'administer CiviCRM', '', @communicationslastID, '1', NULL, 10 ),
+    ( @domainID, 'civicrm/admin/options/addressee&group=addressee&reset=1',             '{ts escape="sql" skip="true"}Addressee Formats{/ts}',             'Addressee Formats',                                                 'administer CiviCRM', '', @communicationslastID, '1', NULL, 11 );
 
 INSERT INTO civicrm_navigation
     ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )