Commit | Line | Data |
---|---|---|
060b6f10 AH |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
6 | | This work is published under the GNU AGPLv3 license with some | | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
9 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | ||
12 | /** | |
13 | * | |
14 | * @package CRM | |
88bd6b02 | 15 | * @author Andie Hunt, AGH Strategies |
060b6f10 AH |
16 | * |
17 | */ | |
18 | ||
19 | /** | |
20 | * Display a banned icon to flag privacy preferences | |
21 | * | |
22 | * @param $params | |
23 | * - field: the applicable privacy field | |
24 | * (one of CRM_Core_SelectValues::privacy() or `on_hold`) | |
560641fb | 25 | * - condition: if present and falsey, return empty |
060b6f10 AH |
26 | * |
27 | * @param $smarty | |
28 | * | |
29 | * @return string | |
30 | */ | |
31 | function smarty_function_privacyFlag($params, &$smarty) { | |
560641fb AH |
32 | if (array_key_exists('condition', $params) && !$params['condition']) { |
33 | return ''; | |
34 | } | |
060b6f10 AH |
35 | $icons = [ |
36 | 'do_not_phone' => 'fa-phone', | |
37 | 'do_not_email' => 'fa-paper-plane', | |
38 | 'do_not_mail' => 'fa-envelope', | |
22b9e1d6 | 39 | 'do_not_sms' => 'fa-comments-o', |
060b6f10 AH |
40 | 'do_not_trade' => 'fa-exchange', |
41 | 'is_opt_out' => 'fa-paper-plane-o', | |
42 | ]; | |
43 | $titles = CRM_Core_SelectValues::privacy(); | |
44 | $field = $params['field'] ?? 'do_not_mail'; | |
45 | if ($field == 'on_hold') { | |
46 | $text = ts('Email on hold - generally due to bouncing.'); | |
47 | return <<<HEREDOC | |
adc7472f | 48 | <span class="privacy-flag email-hold" title="$text"><i class="crm-i fa-exclamation-triangle fa-lg font-red" aria-hidden="true"></i></span><span class="sr-only">$text</span> |
060b6f10 AH |
49 | HEREDOC; |
50 | } | |
51 | $class = str_replace('_', '-', $field); | |
52 | $text = ts('Privacy flag: %1', [1 => $titles[$field]]); | |
53 | return <<<HEREDOC | |
adc7472f | 54 | <span class="fa-stack privacy-flag $class" title="$text" aria-hidden="true"><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> |
060b6f10 AH |
55 | HEREDOC; |
56 | } |