Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Start transitioning EmailCommon class to a trait #16935

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 5 additions & 24 deletions CRM/Activity/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,12 @@
* 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);
Expand All @@ -49,20 +35,15 @@ public function preProcess() {

/**
* Build the form object.
*
* @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
// Enable form element.
$this->assign('emailTask', TRUE);
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.
*
Expand Down
31 changes: 1 addition & 30 deletions CRM/Contact/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,7 @@
*/
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.
Expand Down Expand Up @@ -139,13 +117,6 @@ public function buildQuickForm() {
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.
*
Expand Down
51 changes: 51 additions & 0 deletions CRM/Contact/Form/Task/EmailTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?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);
}

}
25 changes: 1 addition & 24 deletions CRM/Contribute/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,7 @@
* 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.
Expand All @@ -60,13 +44,6 @@ public function buildQuickForm() {
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.
*
Expand Down
32 changes: 1 addition & 31 deletions CRM/Event/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,14 @@
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $
*/

/**
* This class provides the functionality to email a group of
* 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.
Expand All @@ -68,13 +45,6 @@ public function buildQuickForm() {
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.
*
Expand Down
41 changes: 5 additions & 36 deletions CRM/Member/Form/Task/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,22 @@
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id: Email.php 45499 2013-02-08 12:31:05Z kurund $
*
*/

/**
* This class provides the functionality to email a group of
* 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);
Expand All @@ -64,8 +43,8 @@ public function preProcess() {
/**
* Build the form object.
*
*
* @return void
* @throws \CRM_Core_Exception
*/
public function buildQuickForm() {
//enable form element
Expand All @@ -74,16 +53,6 @@ public function buildQuickForm() {
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.
*
Expand Down