This is a really awful class - I've added a trait & moved the calls from the various forms to that trait
so the code on EmailCommon for buildForm is now only called once. I will follow up with more the same
* This class provides the functionality to email a group of contacts.
*/
class CRM_Activity_Form_Task_Email extends CRM_Activity_Form_Task {
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_single = FALSE;
-
- public $_noEmails = FALSE;
-
- /**
- * All the existing templates in the system.
- *
- * @var array
- */
- public $_templates;
+ use CRM_Contact_Form_Task_EmailTrait;
/**
* Build all the data structures needed to build the form.
+ *
+ * @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
/**
* Build the form object.
+ *
+ * @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
// Enable form element.
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
}
- /**
- * Process the form after the input has been submitted and validated.
- */
- public function postProcess() {
- CRM_Contact_Form_Task_EmailCommon::postProcess($this);
- }
-
/**
* List available tokens for this form.
*
*/
class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task {
- /**
- * Are we operating in "single mode".
- *
- * Single mode means sending email to one specific contact.
- *
- * @var bool
- */
- public $_single = FALSE;
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_noEmails = FALSE;
-
- /**
- * All the existing templates in the system.
- *
- * @var array
- */
- public $_templates = NULL;
+ use CRM_Contact_Form_Task_EmailTrait;
/**
* Store "to" contact details.
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
}
- /**
- * Process the form after the input has been submitted and validated.
- */
- public function postProcess() {
- CRM_Contact_Form_Task_EmailCommon::postProcess($this);
- }
-
/**
* List available tokens for this form.
*
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+/**
+ * This class provides the common functionality for tasks that send emails.
+ */
+trait CRM_Contact_Form_Task_EmailTrait {
+
+ /**
+ * Are we operating in "single mode", i.e. sending email to one
+ * specific contact?
+ *
+ * @var bool
+ */
+ public $_single = FALSE;
+
+ public $_noEmails = FALSE;
+
+ /**
+ * All the existing templates in the system.
+ *
+ * @var array
+ */
+ public $_templates;
+
+ /**
+ * Process the form after the input has been submitted and validated.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ * @throws \Civi\API\Exception\UnauthorizedException
+ */
+ public function postProcess() {
+ CRM_Contact_Form_Task_EmailCommon::postProcess($this);
+ }
+
+}
* This class provides the functionality to email a group of contacts.
*/
class CRM_Contribute_Form_Task_Email extends CRM_Contribute_Form_Task {
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_single = FALSE;
-
- public $_noEmails = FALSE;
-
- /**
- * All the existing templates in the system.
- *
- * @var array
- */
- public $_templates = NULL;
+ use CRM_Contact_Form_Task_EmailTrait;
/**
* Build all the data structures needed to build the form.
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
}
- /**
- * Process the form after the input has been submitted and validated.
- */
- public function postProcess() {
- CRM_Contact_Form_Task_EmailCommon::postProcess($this);
- }
-
/**
* List available tokens for this form.
*
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $
*/
/**
* contacts.
*/
class CRM_Event_Form_Task_Email extends CRM_Event_Form_Task {
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_single = FALSE;
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_noEmails = FALSE;
-
- /**
- * All the existing templates in the system.
- *
- * @var array
- */
- public $_templates = NULL;
+ use CRM_Contact_Form_Task_EmailTrait;
/**
* Build all the data structures needed to build the form.
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
}
- /**
- * Process the form after the input has been submitted and validated.
- */
- public function postProcess() {
- CRM_Contact_Form_Task_EmailCommon::postProcess($this);
- }
-
/**
* List available tokens for this form.
*
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
- * $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $
- *
*/
/**
* contacts.
*/
class CRM_Member_Form_Task_Email extends CRM_Member_Form_Task {
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_single = FALSE;
-
- /**
- * Are we operating in "single mode", i.e. sending email to one
- * specific contact?
- *
- * @var bool
- */
- public $_noEmails = FALSE;
-
- /**
- * All the existing templates in the system.
- *
- * @var array
- */
- public $_templates = NULL;
+ use CRM_Contact_Form_Task_EmailTrait;
/**
* Build all the data structures needed to build the form.
*
* @return void
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function preProcess() {
CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
/**
* Build the form object.
*
- *
* @return void
+ * @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
//enable form element
CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
}
- /**
- * Process the form after the input has been submitted and validated.
- *
- *
- * @return void
- */
- public function postProcess() {
- CRM_Contact_Form_Task_EmailCommon::postProcess($this);
- }
-
/**
* List available tokens for this form.
*