*/
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;
-
- /**
- * Store "to" contact details.
- * @var array
- */
- public $_toContactDetails = [];
-
- /**
- * Store all selected contact id's, that includes to, cc and bcc contacts
- * @var array
- */
- public $_allContactIds = [];
-
- /**
- * Store only "to" contact ids.
- * @var array
- */
- public $_toContactIds = [];
-
- /**
- * Store only "cc" contact ids.
- * @var array
- */
- public $_ccContactIds = [];
-
- /**
- * Store only "bcc" contact ids.
- * @var array
- */
- public $_bccContactIds = [];
+ use CRM_Contact_Form_Task_EmailTrait;
/**
* Build all the data structures needed to build the form.
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
public function preProcess() {
+ // @todo - more of the handling in this function should be move to the trait. Notably the title part is
+ // not set on other forms that share the trait.
// store case id if present
$this->_caseId = CRM_Utils_Request::retrieve('caseid', 'String', $this, FALSE);
$this->_context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this);
else {
CRM_Utils_System::setTitle(ts('New Email'));
}
- CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($this);
-
- if (!$cid && $this->_context != 'standalone') {
- parent::preProcess();
+ if ($this->_context === 'search') {
+ $this->_single = TRUE;
}
-
- $this->assign('single', $this->_single);
- if (CRM_Core_Permission::check('administer CiviCRM')) {
- $this->assign('isAdmin', 1);
+ if ($cid || $this->_context === 'standalone') {
+ // When search context is false the parent pre-process is not set. That avoids it changing the
+ // redirect url & attempting to set the search params of the form. It may have only
+ // historical significance.
+ $this->setIsSearchContext(FALSE);
}
+ $this->traitPreProcess();
}
/**
- * Build the form object.
- */
- public function buildQuickForm() {
- //enable form element
- $this->assign('suppressForm', FALSE);
- $this->assign('emailTask', TRUE);
-
- CRM_Contact_Form_Task_EmailCommon::buildQuickForm($this);
- }
-
- /**
- * Process the form after the input has been submitted and validated.
+ * Stub function as EmailTrait calls this.
+ *
+ * @todo move some code from preProcess into here.
*/
- public function postProcess() {
- CRM_Contact_Form_Task_EmailCommon::postProcess($this);
- }
+ public function setContactIDs() {}
/**
* List available tokens for this form.
*
* @return array
+ * @throws \CRM_Core_Exception
*/
public function listTokens() {
$tokens = CRM_Core_SelectValues::contactTokens();