Skip to content

Commit

Permalink
[Ref] Move rule to email trait
Browse files Browse the repository at this point in the history
This is part of dis-establishing EmailCommon - the function is not called from elsewhere
  • Loading branch information
eileenmcnaughton committed Aug 8, 2021
1 parent 80bc869 commit 19f0858
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CRM/Contact/Form/Task/EmailCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static function preProcessFromAddress(&$form, $bounce = TRUE) {
* true if no errors, else array of errors
*/
public static function formRule(array $fields) {
CRM_Core_Error::deprecatedFunctionWarning('no replacement');
$errors = [];
//Added for CRM-1393
if (!empty($fields['saveTemplate']) && empty($fields['saveTemplateName'])) {
Expand Down
20 changes: 19 additions & 1 deletion CRM/Contact/Form/Task/EmailTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function buildQuickForm() {
//Added for CRM-15984: Add campaign field
CRM_Campaign_BAO_Campaign::addCampaign($this);

$this->addFormRule(['CRM_Contact_Form_Task_EmailCommon', 'formRule'], $this);
$this->addFormRule([__CLASS__, 'saveTemplateFormRule'], $this);
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Task/EmailCommon.js', 0, 'html-header');
}

Expand Down Expand Up @@ -644,4 +644,22 @@ protected function createFollowUpActivities($formValues, $activityId): string {
return $followupStatus;
}

/**
* Form rule.
*
* @param array $fields
* The input form values.
*
* @return bool|array
* true if no errors, else array of errors
*/
public static function saveTemplateFormRule(array $fields) {
$errors = [];
//Added for CRM-1393
if (!empty($fields['saveTemplate']) && empty($fields['saveTemplateName'])) {
$errors['saveTemplateName'] = ts('Enter name to save message template');
}
return empty($errors) ? TRUE : $errors;
}

}

0 comments on commit 19f0858

Please sign in to comment.