Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
f299f7db | 31 | * @copyright CiviCRM LLC (c) 2004-2020 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
c037736a | 35 | * Form helper class for an Email object. |
6a488035 TO |
36 | */ |
37 | class CRM_Contact_Form_Edit_Email { | |
38 | ||
39 | /** | |
fe482240 | 40 | * Build the form object elements for an email object. |
6a488035 | 41 | * |
77c5b619 TO |
42 | * @param CRM_Core_Form $form |
43 | * Reference to the form object. | |
44 | * @param int $blockCount | |
45 | * Block number to build. | |
46 | * @param bool $blockEdit | |
47 | * Is it block edit. | |
6a488035 | 48 | */ |
00be9182 | 49 | public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) { |
6a488035 TO |
50 | // passing this via the session is AWFUL. we need to fix this |
51 | if (!$blockCount) { | |
52 | $blockId = ($form->get('Email_Block_Count')) ? $form->get('Email_Block_Count') : 1; | |
53 | } | |
54 | else { | |
55 | $blockId = $blockCount; | |
56 | } | |
57 | ||
58 | $form->applyFilter('__ALL__', 'trim'); | |
59 | ||
60 | //Email box | |
be2fb01f | 61 | $form->addField("email[$blockId][email]", ['entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId])]); |
6a488035 TO |
62 | $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email'); |
63 | if (isset($form->_contactType) || $blockEdit) { | |
64 | //Block type | |
be2fb01f | 65 | $form->addField("email[$blockId][location_type_id]", ['entity' => 'email', 'placeholder' => NULL, 'class' => 'eight', 'option_url' => NULL]); |
6a488035 | 66 | |
031f9ac8 | 67 | //TODO: Refactor on_hold field to select. |
6a488035 TO |
68 | $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail(); |
69 | ||
70 | //On-hold select | |
71 | if ($multipleBulk) { | |
be2fb01f | 72 | $holdOptions = [ |
6ea503d4 | 73 | 0 => ts('- select -'), |
6a488035 TO |
74 | 1 => ts('On Hold Bounce'), |
75 | 2 => ts('On Hold Opt Out'), | |
be2fb01f | 76 | ]; |
6a488035 TO |
77 | $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions); |
78 | } | |
79 | else { | |
be2fb01f | 80 | $form->addField("email[$blockId][on_hold]", ['entity' => 'email', 'type' => 'advcheckbox', 'aria-label' => ts('On Hold for Email %1?', [1 => $blockId])]); |
6a488035 TO |
81 | } |
82 | ||
83 | //Bulkmail checkbox | |
84 | $form->assign('multipleBulk', $multipleBulk); | |
be2fb01f | 85 | $js = ['id' => "Email_" . $blockId . "_IsBulkmail" , 'aria-label' => ts('Bulk Mailing for Email %1?', [1 => $blockId])]; |
c13191a7 SL |
86 | if (!$blockEdit) { |
87 | $js['onClick'] = 'singleSelect( this.id );'; | |
6a488035 | 88 | } |
c13191a7 | 89 | $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js); |
6a488035 TO |
90 | |
91 | //is_Primary radio | |
be2fb01f | 92 | $js = ['id' => "Email_" . $blockId . "_IsPrimary", 'aria-label' => ts('Email %1 is primary?', [1 => $blockId])]; |
6a488035 TO |
93 | if (!$blockEdit) { |
94 | $js['onClick'] = 'singleSelect( this.id );'; | |
95 | } | |
96 | ||
97 | $form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js); | |
98 | ||
99 | if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { | |
100 | ||
101 | $form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'), | |
be2fb01f | 102 | ['rows' => 2, 'cols' => 40] |
6a488035 TO |
103 | ); |
104 | ||
5d51a2f9 | 105 | $form->add('wysiwyg', "email[$blockId][signature_html]", ts('Signature (HTML)'), |
be2fb01f | 106 | ['rows' => 2, 'cols' => 40] |
6a488035 TO |
107 | ); |
108 | } | |
109 | } | |
110 | } | |
96025800 | 111 | |
6a488035 | 112 | } |