CRM-16354 - Migrate forms to new wysiwyg code
[civicrm-core.git] / CRM / Contact / Form / Edit / Email.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035
TO
32 * $Id$
33 *
34 */
35
36/**
37 * form helper class for an Email object
38 */
39class CRM_Contact_Form_Edit_Email {
40
41 /**
fe482240 42 * Build the form object elements for an email object.
6a488035 43 *
77c5b619
TO
44 * @param CRM_Core_Form $form
45 * Reference to the form object.
46 * @param int $blockCount
47 * Block number to build.
48 * @param bool $blockEdit
49 * Is it block edit.
6a488035
TO
50 *
51 * @return void
6a488035 52 */
00be9182 53 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
6a488035
TO
54 // passing this via the session is AWFUL. we need to fix this
55 if (!$blockCount) {
56 $blockId = ($form->get('Email_Block_Count')) ? $form->get('Email_Block_Count') : 1;
57 }
58 else {
59 $blockId = $blockCount;
60 }
61
62 $form->applyFilter('__ALL__', 'trim');
63
64 //Email box
65 $form->addElement('text', "email[$blockId][email]", ts('Email'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email', 'email'));
66 $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email');
67 if (isset($form->_contactType) || $blockEdit) {
68 //Block type
353ffa53
TO
69 $form->addSelect("email[$blockId][location_type_id]", array(
70 'entity' => 'email',
71 'class' => 'eight',
d5cc0fc2 72 'placeholder' => NULL,
353ffa53 73 ));
6a488035
TO
74
75 $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
76
77 //On-hold select
78 if ($multipleBulk) {
6ea503d4
TO
79 $holdOptions = array(
80 0 => ts('- select -'),
6a488035
TO
81 1 => ts('On Hold Bounce'),
82 2 => ts('On Hold Opt Out'),
83 );
84 $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions);
85 }
86 else {
87 $form->addElement('advcheckbox', "email[$blockId][on_hold]", NULL);
88 }
89
90 //Bulkmail checkbox
91 $form->assign('multipleBulk', $multipleBulk);
92 if ($multipleBulk) {
93 $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
94 $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js);
95 }
96 else {
97 $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
98 if (!$blockEdit) {
99 $js['onClick'] = 'singleSelect( this.id );';
100 }
101 $form->addElement('radio', "email[$blockId][is_bulkmail]", '', '', '1', $js);
102 }
103
104 //is_Primary radio
105 $js = array('id' => "Email_" . $blockId . "_IsPrimary");
106 if (!$blockEdit) {
107 $js['onClick'] = 'singleSelect( this.id );';
108 }
109
110 $form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js);
111
112 if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
113
114 $form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'),
115 array('rows' => 2, 'cols' => 40)
116 );
117
5d51a2f9 118 $form->add('wysiwyg', "email[$blockId][signature_html]", ts('Signature (HTML)'),
6a488035
TO
119 array('rows' => 2, 'cols' => 40)
120 );
121 }
122 }
123 }
96025800 124
6a488035 125}