public $_toContactEmails = [];
- /**
- * @return array $domainEmails;
- * @deprecated Generate an array of Domain email addresses.
- */
- public static function domainEmails() {
- CRM_Core_Error::deprecatedFunctionWarning('CRM_Core_BAO_Email::domainEmails()');
- return CRM_Core_BAO_Email::domainEmails();
- }
-
/**
* Pre Process Form Addresses to be used in Quickform
*
* @throws \CiviCRM_API3_Exception
*/
public static function preProcessFromAddress(&$form, $bounce = TRUE) {
- $form->_single = FALSE;
- $className = CRM_Utils_System::getClassName($form);
- if (property_exists($form, '_context') &&
- $form->_context != 'search' &&
- $className == 'CRM_Contact_Form_Task_Email'
- ) {
- $form->_single = TRUE;
+ if (!isset($form->_single)) {
+ // @todo ensure this is already set.
+ $form->_single = FALSE;
}
$form->_emails = [];
* @throws \CRM_Core_Exception
*/
public static function buildQuickForm(&$form) {
+ CRM_Core_Error::deprecatedFunctionWarning('This code is no longer used in core and will be removed');
$toArray = $ccArray = $bccArray = [];
$suppressedEmails = 0;
//here we are getting logged in user id as array but we need target contact id. CRM-5988
$cc = $form->add('text', 'cc_id', ts('CC'), $emailAttributes);
$bcc = $form->add('text', 'bcc_id', ts('BCC'), $emailAttributes);
+ if ($to->getValue()) {
+ $form->_toContactIds = $form->_contactIds = [];
+ }
$setDefaults = TRUE;
if (property_exists($form, '_context') && $form->_context == 'standalone') {
$setDefaults = FALSE;
$form->_allContactIds = $form->_toContactIds = $form->_contactIds;
foreach ($elements as $element) {
if ($$element->getValue()) {
- $allEmails = explode(',', $$element->getValue());
- if ($element == 'to') {
- $form->_toContactIds = $form->_contactIds = [];
- }
- foreach ($allEmails as $value) {
- list($contactId, $email) = explode('::', $value);
+ foreach (self::getEmails($$element) as $value) {
+ $contactId = $value['contact_id'];
+ $email = $value['email'];
if ($contactId) {
switch ($element) {
case 'to':
* @throws \Civi\API\Exception\UnauthorizedException
*/
public static function postProcess(&$form) {
+ CRM_Core_Error::deprecatedFunctionWarning('This code is no longer used in core and will be removed');
+
self::bounceIfSimpleMailLimitExceeded(count($form->_contactIds));
// check and ensure that
* @throws \Civi\API\Exception\UnauthorizedException
*/
public static function submit(&$form, $formValues) {
+ CRM_Core_Error::deprecatedFunctionWarning('This code is no longer used in core and will be removed');
+
self::saveMessageTemplate($formValues);
$from = $formValues['from_email_address'] ?? NULL;
* @throws \Civi\API\Exception\UnauthorizedException
*/
protected static function saveMessageTemplate($formValues) {
+ CRM_Core_Error::deprecatedFunctionWarning('This code is no longer used in core and will be removed');
+
if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) {
$messageTemplate = [
'msg_text' => $formValues['text_message'],
* The number of emails the user is attempting to send
*/
public static function bounceIfSimpleMailLimitExceeded($count) {
+ CRM_Core_Error::deprecatedFunctionWarning('This code is no longer used in core and will be removed');
+
$limit = Civi::settings()->get('simple_mail_limit');
if ($count > $limit) {
CRM_Core_Error::statusBounce(ts('Please do not use this task to send a lot of emails (greater than %1). Many countries have legal requirements when sending bulk emails and the CiviMail framework has opt out functionality and domain tokens to help meet these.',
}
}
+ /**
+ * Get the emails from the added element.
+ *
+ * @param HTML_QuickForm_Element $element
+ *
+ * @return array
+ */
+ protected static function getEmails($element): array {
+ CRM_Core_Error::deprecatedFunctionWarning('This code is no longer used in core and will be removed');
+
+ $allEmails = explode(',', $element->getValue());
+ $return = [];
+ foreach ($allEmails as $value) {
+ $values = explode('::', $value);
+ $return[] = ['contact_id' => $values[0], 'email' => $values[1]];
+ }
+ return $return;
+ }
+
}