Replace stop-icon.png with fa-ban over a relevant icon for privacy
authorAndrew Hunt <andrew@aghstrategies.com>
Thu, 7 May 2020 19:27:32 +0000 (15:27 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Sun, 10 May 2020 19:12:01 +0000 (15:12 -0400)
CRM/Contact/Selector.php
CRM/Core/Smarty/plugins/function.privacyFlag.php [new file with mode: 0644]
css/civicrm.css
i/stop-icon.png [deleted file]
templates/CRM/Contact/Form/Selector.tpl
templates/CRM/Contact/Page/Inline/Address.tpl
templates/CRM/Contact/Page/Inline/Email.tpl
templates/CRM/Contact/Page/Inline/Phone.tpl

index 0e1c82f78c5a059cfe078383ce78e4102e032df0..2296ddd2e43c8d7c262ea4055119131fbe5b206f 100644 (file)
@@ -61,6 +61,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
     'status',
     'do_not_email',
     'do_not_phone',
+    'do_not_sms',
     'do_not_mail',
   ];
 
diff --git a/CRM/Core/Smarty/plugins/function.privacyFlag.php b/CRM/Core/Smarty/plugins/function.privacyFlag.php
new file mode 100644 (file)
index 0000000..e4e3593
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @author Andrew Hunt, AGH Strategies
+ * $Id$
+ *
+ */
+
+/**
+ * Display a banned icon to flag privacy preferences
+ *
+ * @param $params
+ *   - field: the applicable privacy field
+ *     (one of CRM_Core_SelectValues::privacy() or `on_hold`)
+ *
+ * @param $smarty
+ *
+ * @return string
+ */
+function smarty_function_privacyFlag($params, &$smarty) {
+  $icons = [
+    'do_not_phone' => 'fa-phone',
+    'do_not_email' => 'fa-paper-plane',
+    'do_not_mail' => 'fa-envelope',
+    'do_not_sms' => 'fa-mobile',
+    'do_not_trade' => 'fa-exchange',
+    'is_opt_out' => 'fa-paper-plane-o',
+  ];
+  $titles = CRM_Core_SelectValues::privacy();
+  $field = $params['field'] ?? 'do_not_mail';
+  if ($field == 'on_hold') {
+    $text = ts('Email on hold - generally due to bouncing.');
+    return <<<HEREDOC
+<span class="privacy-flag email-hold" title="$text"><i class="crm-i fa-exclamation-triangle fa-lg font-red"></i></span><span class="sr-only">$text</span>
+HEREDOC;
+  }
+  $class = str_replace('_', '-', $field);
+  $text = ts('Privacy flag: %1', [1 => $titles[$field]]);
+  return <<<HEREDOC
+<span class="fa-stack privacy-flag $class" title="$text"><i class="crm-i {$icons[$field]} fa-stack-1x"></i><i class="crm-i fa-ban fa-stack-2x font-red"></i></span><span class="sr-only">$text</span>
+HEREDOC;
+}
index c85cc871735027aeb2c9a66f12e7b5b7693b594c..be8af43c421b65f5e7f705b9424a517774fa99c9 100644 (file)
@@ -2470,9 +2470,8 @@ div.crm-master-accordion-header a.helpicon {
 
 /* privacy icons */
 #crm-container div span.privacy-flag {
-  background-repeat: no-repeat;
-  background-image: url("../i/stop-icon.png");
   float: right;
+  font-size: 80%;
 }
 
 /* specific, targeted fixes */
diff --git a/i/stop-icon.png b/i/stop-icon.png
deleted file mode 100644 (file)
index e00eea4..0000000
Binary files a/i/stop-icon.png and /dev/null differ
index 338c6e0883b901557294975c9242a43ac1d2be58..36cf635081419cd708b6871ea8f1cad81d917d9c 100644 (file)
@@ -81,7 +81,7 @@
             <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`&context=`$context`"}">{if $row.is_deleted}<del>{/if}{$row.sort_name}{if $row.is_deleted}</del>{/if}</a></td>
             {if $action eq 512 or $action eq 256}
               {if !empty($columnHeaders.street_address)}
-          <td><span title="{$row.street_address|escape}">{$row.street_address|mb_truncate:22:"...":true}{if $row.do_not_mail} <span class="icon privacy-flag do-not-mail"></span>{/if}</span></td>
+          <td><span title="{$row.street_address|escape}">{$row.street_address|mb_truncate:22:"...":true}{if $row.do_not_mail} {privacyFlag field=do_not_mail}{/if}</span></td>
         {/if}
         {if !empty($columnHeaders.city)}
                 <td>{$row.city}</td>
                     <span title="{$row.email|escape}">
                         {$row.email|mb_truncate:17:"...":true}
                         {if $row.on_hold}
-                          (On Hold)<span class="status-hold" title="{ts}This email is on hold (probably due to bouncing).{/ts}"></span>
+                          {privacyFlag field=on_hold}
                         {elseif $row.do_not_email}
-                          <span class="icon privacy-flag do-not-email" title="{ts}Do Not Email{/ts}"></span>
+                          {privacyFlag field=do_not_email}
                         {/if}
                     </span>
                 {/if}
                 {if $row.phone}
                   {$row.phone}
                   {if $row.do_not_phone}
-                    <span class="icon privacy-flag do-not-phone" title="{ts}Do Not Phone{/ts}" ></span>
+                    {privacyFlag field=do_not_phone}
+                  {/if}
+                  {if $row.do_not_sms}
+                    {privacyFlag field=do_not_sms}
                   {/if}
                 {/if}
               </td>
index d507e76d3f9777142106d361473e9fcc8d213196..e2c70343d9b5fbc6bab598889aa434adf6daa852 100644 (file)
@@ -24,7 +24,7 @@
       <div class="crm-summary-row {if $add.is_primary eq 1} primary{/if}">
         <div class="crm-label">
           {ts 1=$add.location_type}%1 Address{/ts}
-          {if $privacy.do_not_mail}<span class="icon privacy-flag do-not-mail" title="{ts}Privacy flag: Do Not Mail{/ts}"></span>{/if}
+          {if $privacy.do_not_mail}{privacyFlag field=do_not_mail}{/if}
           {if $config->mapProvider AND
               !empty($add.geo_code_1) AND
               is_numeric($add.geo_code_1) AND
index 48aa7263cfd711c0ccfe69518e2e6a1a88de390a..afc29d4bebae6db774b168c4477131d5715d5eed 100644 (file)
@@ -19,7 +19,7 @@
     <div class="crm-summary-row">
       <div class="crm-label">
         {ts}Email{/ts}
-        {if $privacy.do_not_email}<span class="icon privacy-flag do-not-email" title="{ts}Privacy flag: Do Not Email{/ts}"></span>{/if}
+        {if $privacy.do_not_email}{privacyFlag field=do_not_email}{/if}
       </div>
       <div class="crm-content"></div>
     </div>
@@ -29,7 +29,7 @@
     <div class="crm-summary-row {if $item.is_primary eq 1}primary{/if}">
       <div class="crm-label">
         {$item.location_type} {ts}Email{/ts}
-        {if $privacy.do_not_email}<span class="icon privacy-flag do-not-email" title="{ts}Privacy flag: Do Not Email{/ts}"></span>{elseif $item.on_hold}<span class="icon privacy-flag email-hold" title="{ts}Email on hold - generally due to bouncing.{/ts}"></span>{/if}
+        {if $privacy.do_not_email}{privacyFlag field=do_not_email}{elseif $item.on_hold}{privacyFlag field=on_hold}{/if}
       </div>
       <div class="crm-content crm-contact_email">
         {if !$item.on_hold and !$privacy.do_not_email}
index 2b788cb1772160b9dcf988a4d1a7d5b452e083dd..3ab90ab126e663ed999943284514b8aa34c106ed 100644 (file)
@@ -19,7 +19,8 @@
       <div class="crm-summary-row">
         <div class="crm-label">
           {ts}Phone{/ts}
-          {if $privacy.do_not_phone}<span class="icon privacy-flag do-not-phone" title="{ts}Privacy flag: Do Not Phone{/ts}"></span>{/if}
+          {if $privacy.do_not_sms}{privacyFlag field=do_not_sms}{/if}
+          {if $privacy.do_not_phone}{privacyFlag field=do_not_phone}{/if}
         </div>
         <div class="crm-content"></div>
       </div>
@@ -28,7 +29,8 @@
       {if $item.phone || $item.phone_ext}
         <div class="crm-summary-row {if $item.is_primary eq 1}primary{/if}">
           <div class="crm-label">
-            {if $privacy.do_not_phone}<span class="icon privacy-flag do-not-phone" title="{ts}Privacy flag: Do Not Phone{/ts}"></span>{/if}
+            {if $privacy.do_not_sms}{privacyFlag field=do_not_sms}{/if}
+            {if $privacy.do_not_phone}{privacyFlag field=do_not_phone}{/if}
             {$item.location_type} {$item.phone_type}
           </div>
           <div class="crm-content crm-contact_phone">