dev/user-interface#38 Contact Edit: Only display email signatures for contacts that...
authorMathieu Lutfy <mathieu@symbiotic.coop>
Thu, 12 Aug 2021 13:29:11 +0000 (09:29 -0400)
committerMathieu Lutfy <mathieu@bidon.ca>
Thu, 12 Aug 2021 18:25:50 +0000 (14:25 -0400)
CRM/Contact/Form/Edit/Email.php
templates/CRM/Contact/Form/Edit/Email.tpl

index a0716dfe4967c503a5f87f73d0e68d53cd792caa..c75865bd8294c2457bc0cb2d76a8d46a0145d947 100644 (file)
@@ -81,14 +81,19 @@ class CRM_Contact_Form_Edit_Email {
       $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]
+            );
+          }
+        }
       }
     }
   }
index 97780b9880a66fd2152c1a7db326a919e1e287ef..4c4988f17effb22d9c6da9723670ae603104f743 100644 (file)
@@ -26,8 +26,8 @@
 
 <tr id="Email_Block_{$blockId}">
   <td>{$form.email.$blockId.email.html|crmAddClass:email}&nbsp;{$form.email.$blockId.location_type_id.html}
-    <div class="clear"></div>
-    {if $className eq 'CRM_Contact_Form_Contact'}
+    {if $className eq 'CRM_Contact_Form_Contact' and !empty($form.email.$blockId.signature_html.html)}
+      <div class="clear"></div>
       <div class="email-signature crm-collapsible collapsed">
         <div class="collapsible-title">
           {ts}Signature{/ts}