(NFC) (dev/core#878) Simplify copyright header (CRM/*)
[civicrm-core.git] / CRM / Contact / Form / Edit / Email.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
c037736a 19 * Form helper class for an Email object.
6a488035
TO
20 */
21class CRM_Contact_Form_Edit_Email {
22
23 /**
fe482240 24 * Build the form object elements for an email object.
6a488035 25 *
77c5b619
TO
26 * @param CRM_Core_Form $form
27 * Reference to the form object.
28 * @param int $blockCount
29 * Block number to build.
30 * @param bool $blockEdit
31 * Is it block edit.
6a488035 32 */
00be9182 33 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
6a488035
TO
34 // passing this via the session is AWFUL. we need to fix this
35 if (!$blockCount) {
36 $blockId = ($form->get('Email_Block_Count')) ? $form->get('Email_Block_Count') : 1;
37 }
38 else {
39 $blockId = $blockCount;
40 }
41
42 $form->applyFilter('__ALL__', 'trim');
43
44 //Email box
be2fb01f 45 $form->addField("email[$blockId][email]", ['entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId])]);
6a488035
TO
46 $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email');
47 if (isset($form->_contactType) || $blockEdit) {
48 //Block type
be2fb01f 49 $form->addField("email[$blockId][location_type_id]", ['entity' => 'email', 'placeholder' => NULL, 'class' => 'eight', 'option_url' => NULL]);
6a488035 50
031f9ac8 51 //TODO: Refactor on_hold field to select.
6a488035
TO
52 $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
53
54 //On-hold select
55 if ($multipleBulk) {
be2fb01f 56 $holdOptions = [
6ea503d4 57 0 => ts('- select -'),
6a488035
TO
58 1 => ts('On Hold Bounce'),
59 2 => ts('On Hold Opt Out'),
be2fb01f 60 ];
6a488035
TO
61 $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions);
62 }
63 else {
be2fb01f 64 $form->addField("email[$blockId][on_hold]", ['entity' => 'email', 'type' => 'advcheckbox', 'aria-label' => ts('On Hold for Email %1?', [1 => $blockId])]);
6a488035
TO
65 }
66
67 //Bulkmail checkbox
68 $form->assign('multipleBulk', $multipleBulk);
be2fb01f 69 $js = ['id' => "Email_" . $blockId . "_IsBulkmail" , 'aria-label' => ts('Bulk Mailing for Email %1?', [1 => $blockId])];
c13191a7
SL
70 if (!$blockEdit) {
71 $js['onClick'] = 'singleSelect( this.id );';
6a488035 72 }
c13191a7 73 $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js);
6a488035
TO
74
75 //is_Primary radio
be2fb01f 76 $js = ['id' => "Email_" . $blockId . "_IsPrimary", 'aria-label' => ts('Email %1 is primary?', [1 => $blockId])];
6a488035
TO
77 if (!$blockEdit) {
78 $js['onClick'] = 'singleSelect( this.id );';
79 }
80
81 $form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js);
82
83 if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
84
85 $form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'),
be2fb01f 86 ['rows' => 2, 'cols' => 40]
6a488035
TO
87 );
88
5d51a2f9 89 $form->add('wysiwyg', "email[$blockId][signature_html]", ts('Signature (HTML)'),
be2fb01f 90 ['rows' => 2, 'cols' => 40]
6a488035
TO
91 );
92 }
93 }
94 }
96025800 95
6a488035 96}