From acfdaee46bf2a4b16383b311a12f255a900ce7fa Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Thu, 12 Aug 2021 09:29:11 -0400 Subject: [PATCH] dev/user-interface#38 Contact Edit: Only display email signatures for contacts that have a user/CMS account --- CRM/Contact/Form/Edit/Email.php | 21 +++++++++++++-------- templates/CRM/Contact/Form/Edit/Email.tpl | 4 ++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CRM/Contact/Form/Edit/Email.php b/CRM/Contact/Form/Edit/Email.php index a0716dfe4967..c75865bd8294 100644 --- a/CRM/Contact/Form/Edit/Email.php +++ b/CRM/Contact/Form/Edit/Email.php @@ -81,14 +81,19 @@ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = F $form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { - - $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] - ); + // 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 + if (!empty($form->_contactId)) { + $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] + ); + } + } } } } diff --git a/templates/CRM/Contact/Form/Edit/Email.tpl b/templates/CRM/Contact/Form/Edit/Email.tpl index 97780b9880a6..4c4988f17eff 100644 --- a/templates/CRM/Contact/Form/Edit/Email.tpl +++ b/templates/CRM/Contact/Form/Edit/Email.tpl @@ -26,8 +26,8 @@ {$form.email.$blockId.email.html|crmAddClass:email} {$form.email.$blockId.location_type_id.html} -
- {if $className eq 'CRM_Contact_Form_Contact'} + {if $className eq 'CRM_Contact_Form_Contact' and !empty($form.email.$blockId.signature_html.html)} +