Skip to content

Commit

Permalink
Fix email notices on email edit block
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Aug 24, 2022
1 parent 3b85809 commit 7a673a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
16 changes: 1 addition & 15 deletions CRM/Contact/Form/Edit/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class CRM_Contact_Form_Edit_Email {
public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
// passing this via the session is AWFUL. we need to fix this
if (!$blockCount) {
CRM_Core_Error::deprecatedWarning('pass in blockCount');
$blockId = ($form->get('Email_Block_Count')) ? $form->get('Email_Block_Count') : 1;
}
else {
Expand Down Expand Up @@ -83,21 +84,6 @@ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = F
}

$form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js);
// Only display the signature fields if this contact has a CMS account
// because they can only send email if they have access to the CRM
$isAddSignatureFields = $form instanceof \CRM_Contact_Form_Contact && !empty($form->_contactId);
$form->assign('isAddSignatureFields', $isAddSignatureFields);
if ($isAddSignatureFields) {
$ufID = CRM_Core_BAO_UFMatch::getUFId($form->_contactId);
if ($ufID) {
$form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'),
['rows' => 2, 'cols' => 40]
);
$form->add('wysiwyg', "email[$blockId][signature_html]", ts('Signature (HTML)'),
['rows' => 2, 'cols' => 40]
);
}
}
}
}

Expand Down
27 changes: 24 additions & 3 deletions CRM/Contact/Form/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,31 @@ public static function buildQuickForm(&$form) {
$generateAjaxRequest++;
$ajaxRequestBlocks[$blockName][$instance] = TRUE;
}
switch ($blockName) {
case 'Email':
CRM_Contact_Form_Edit_Email::buildQuickForm($form, $instance);
// Only display the signature fields if this contact has a CMS account
// because they can only send email if they have access to the CRM
$ufID = $form->_contactId && CRM_Core_BAO_UFMatch::getUFId($form->_contactId);
$form->assign('isAddSignatureFields', (bool) $ufID);
if ($ufID) {
$form->add('textarea', "email[$instance][signature_text]", ts('Signature (Text)'),
['rows' => 2, 'cols' => 40]
);
$form->add('wysiwyg', "email[$instance][signature_html]", ts('Signature (HTML)'),
['rows' => 2, 'cols' => 40]
);
}
break;

default:
// @todo This pattern actually adds complexity compared to filling out a switch statement
// for the limited number of blocks - as we also have to receive the block count
$form->set($blockName . '_Block_Count', $instance);
$formName = 'CRM_Contact_Form_Edit_' . $blockName;
$formName::buildQuickForm($form);
}

$form->set($blockName . '_Block_Count', $instance);
$formName = 'CRM_Contact_Form_Edit_' . $blockName;
$formName::buildQuickForm($form);
}
}

Expand Down

0 comments on commit 7a673a8

Please sign in to comment.