commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / CRM / Contact / Form / Edit / Email.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2015
32 * $Id$
33 *
34 */
35
36 /**
37 * form helper class for an Email object
38 */
39 class CRM_Contact_Form_Edit_Email {
40
41 /**
42 * Build the form object elements for an email object.
43 *
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.
50 *
51 * @return void
52 */
53 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
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
69 $form->addSelect("email[$blockId][location_type_id]", array(
70 'entity' => 'email',
71 'class' => 'eight',
72 'placeholder' => NULL,
73 'option_url' => NULL,
74 ));
75
76 $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail();
77
78 //On-hold select
79 if ($multipleBulk) {
80 $holdOptions = array(
81 0 => ts('- select -'),
82 1 => ts('On Hold Bounce'),
83 2 => ts('On Hold Opt Out'),
84 );
85 $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions);
86 }
87 else {
88 $form->addElement('advcheckbox', "email[$blockId][on_hold]", NULL);
89 }
90
91 //Bulkmail checkbox
92 $form->assign('multipleBulk', $multipleBulk);
93 if ($multipleBulk) {
94 $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
95 $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js);
96 }
97 else {
98 $js = array('id' => "Email_" . $blockId . "_IsBulkmail");
99 if (!$blockEdit) {
100 $js['onClick'] = 'singleSelect( this.id );';
101 }
102 $form->addElement('radio', "email[$blockId][is_bulkmail]", '', '', '1', $js);
103 }
104
105 //is_Primary radio
106 $js = array('id' => "Email_" . $blockId . "_IsPrimary");
107 if (!$blockEdit) {
108 $js['onClick'] = 'singleSelect( this.id );';
109 }
110
111 $form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js);
112
113 if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') {
114
115 $form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'),
116 array('rows' => 2, 'cols' => 40)
117 );
118
119 $form->addWysiwyg("email[$blockId][signature_html]", ts('Signature (HTML)'),
120 array('rows' => 2, 'cols' => 40)
121 );
122 }
123 }
124 }
125
126 }