First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
238
sites/all/modules/civicrm/CRM/Mailing/Form/Approve.php
Normal file
238
sites/all/modules/civicrm/CRM/Mailing/Form/Approve.php
Normal file
|
@ -0,0 +1,238 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Form_Approve extends CRM_Core_Form {
|
||||
|
||||
public function redirectToListing() {
|
||||
$url = CRM_Utils_System::url('civicrm/mailing/browse/scheduled', 'reset=1&scheduled=true');
|
||||
CRM_Utils_System::redirect($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set variables up before form is built.
|
||||
*/
|
||||
public function preProcess() {
|
||||
if (CRM_Mailing_Info::workflowEnabled()) {
|
||||
if (!CRM_Core_Permission::check('approve mailings') && !CRM_Core_Permission::check('access CiviMail')) {
|
||||
$this->redirectToListing();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->redirectToListing();
|
||||
}
|
||||
|
||||
// when user come from search context.
|
||||
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
|
||||
|
||||
//retrieve mid from different wizard and url contexts
|
||||
$this->_mailingID = $this->get('mailing_id');
|
||||
$this->_approveFormOnly = FALSE;
|
||||
if (!$this->_mailingID) {
|
||||
$this->_mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, TRUE);
|
||||
$this->_approveFormOnly = TRUE;
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$this->_contactID = $session->get('userID');
|
||||
|
||||
$this->_mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$this->_mailing->id = $this->_mailingID;
|
||||
if (!$this->_mailing->find(TRUE)) {
|
||||
$this->redirectToListing();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
if ($this->_mailingID) {
|
||||
$defaults['approval_status_id'] = $this->_mailing->approval_status_id;
|
||||
$defaults['approval_note'] = $this->_mailing->approval_note;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object for the approval/rejection mailing.
|
||||
*/
|
||||
public function buildQuickform() {
|
||||
$title = ts('Approve/Reject Mailing') . " - {$this->_mailing->name}";
|
||||
CRM_Utils_System::setTitle($title);
|
||||
|
||||
$this->addElement('textarea', 'approval_note', ts('Approve/Reject Note'));
|
||||
|
||||
$mailApprovalStatus = CRM_Core_OptionGroup::values('mail_approval_status');
|
||||
|
||||
// eliminate the none option
|
||||
$noneOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status',
|
||||
'None',
|
||||
'name'
|
||||
);
|
||||
if ($noneOptionID) {
|
||||
unset($mailApprovalStatus[$noneOptionID]);
|
||||
}
|
||||
|
||||
$this->addRadio('approval_status_id', ts('Approval Status'), $mailApprovalStatus, array(), NULL, TRUE);
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'spacing' => ' ',
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
|
||||
// add the preview elements
|
||||
$preview = array();
|
||||
|
||||
$preview['subject'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing',
|
||||
$this->_mailingID,
|
||||
'subject'
|
||||
);
|
||||
|
||||
$mailingKey = $this->_mailingID;
|
||||
if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) {
|
||||
$mailingKey = $hash;
|
||||
}
|
||||
|
||||
$preview['viewURL'] = CRM_Utils_System::url('civicrm/mailing/view', "reset=1&id={$mailingKey}");
|
||||
$preview['type'] = $this->_mailing->body_html ? 'html' : 'text';
|
||||
$preview['attachment'] = CRM_Core_BAO_File::attachmentInfo('civicrm_mailing', $this->_mailingID);
|
||||
|
||||
$this->assign_by_ref('preview', $preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the posted form values. Approve /reject a mailing.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// get the submitted form values.
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$ids = array();
|
||||
if (isset($this->_mailingID)) {
|
||||
$ids['mailing_id'] = $this->_mailingID;
|
||||
}
|
||||
else {
|
||||
$ids['mailing_id'] = $this->get('mailing_id');
|
||||
}
|
||||
|
||||
if (!$ids['mailing_id']) {
|
||||
CRM_Core_Error::fatal();
|
||||
}
|
||||
|
||||
$params['approver_id'] = $this->_contactID;
|
||||
$params['approval_date'] = date('YmdHis');
|
||||
|
||||
// if rejected, then we need to reset the scheduled date and scheduled id
|
||||
$rejectOptionID = CRM_Core_OptionGroup::getValue('mail_approval_status',
|
||||
'Rejected',
|
||||
'name'
|
||||
);
|
||||
if ($rejectOptionID &&
|
||||
$params['approval_status_id'] == $rejectOptionID
|
||||
) {
|
||||
$params['scheduled_id'] = 'null';
|
||||
$params['scheduled_date'] = 'null';
|
||||
|
||||
// also delete any jobs associated with this mailing
|
||||
$job = new CRM_Mailing_BAO_MailingJob();
|
||||
$job->mailing_id = $ids['mailing_id'];
|
||||
$job->delete();
|
||||
}
|
||||
else {
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing->id = $ids['mailing_id'];
|
||||
$mailing->find(TRUE);
|
||||
|
||||
$params['scheduled_date'] = CRM_Utils_Date::processDate($mailing->scheduled_date);
|
||||
}
|
||||
|
||||
CRM_Mailing_BAO_Mailing::create($params, $ids);
|
||||
|
||||
//when user perform mailing from search context
|
||||
//redirect it to search result CRM-3711
|
||||
$ssID = $this->get('ssID');
|
||||
if ($ssID && $this->_searchBasedMailing) {
|
||||
if ($this->_action == CRM_Core_Action::BASIC) {
|
||||
$fragment = 'search';
|
||||
}
|
||||
elseif ($this->_action == CRM_Core_Action::PROFILE) {
|
||||
$fragment = 'search/builder';
|
||||
}
|
||||
elseif ($this->_action == CRM_Core_Action::ADVANCED) {
|
||||
$fragment = 'search/advanced';
|
||||
}
|
||||
else {
|
||||
$fragment = 'search/custom';
|
||||
}
|
||||
$context = $this->get('context');
|
||||
if (!CRM_Contact_Form_Search::isSearchContext($context)) {
|
||||
$context = 'search';
|
||||
}
|
||||
$urlParams = "force=1&reset=1&ssID={$ssID}&context={$context}";
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
|
||||
return $this->controller->setDestination($url);
|
||||
}
|
||||
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext(CRM_Utils_System::url('civicrm/mailing/browse/scheduled',
|
||||
'reset=1&scheduled=true'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Name of the form.
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle() {
|
||||
return ts('Approve/Reject Mailing');
|
||||
}
|
||||
|
||||
}
|
92
sites/all/modules/civicrm/CRM/Mailing/Form/Browse.php
Normal file
92
sites/all/modules/civicrm/CRM/Mailing/Form/Browse.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build the form object for disable mail feature
|
||||
*/
|
||||
class CRM_Mailing_Form_Browse extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* Heart of the viewing process. The runner gets all the meta data for
|
||||
* the contact and calls the appropriate type of page to view.
|
||||
*/
|
||||
public function preProcess() {
|
||||
$this->_mailingId = CRM_Utils_Request::retrieve('mid', 'Positive', $this);
|
||||
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this);
|
||||
|
||||
// check for action permissions.
|
||||
if (!CRM_Core_Permission::checkActionPermission('CiviMail', $this->_action)) {
|
||||
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
|
||||
}
|
||||
|
||||
$mailing = new CRM_Mailing_BAO_Mailing();
|
||||
$mailing->id = $this->_mailingId;
|
||||
$subject = '';
|
||||
if ($mailing->find(TRUE)) {
|
||||
$subject = $mailing->subject;
|
||||
}
|
||||
$this->assign('subject', $subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Confirm'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
if ($this->_action & CRM_Core_Action::DELETE) {
|
||||
CRM_Mailing_BAO_Mailing::del($this->_mailingId);
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::DISABLE) {
|
||||
CRM_Mailing_BAO_MailingJob::cancel($this->_mailingId);
|
||||
}
|
||||
elseif ($this->_action & CRM_Core_Action::RENEW) {
|
||||
//set is_archived to 1
|
||||
CRM_Core_DAO::setFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingId, 'is_archived', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
207
sites/all/modules/civicrm/CRM/Mailing/Form/Component.php
Normal file
207
sites/all/modules/civicrm/CRM/Mailing/Form/Component.php
Normal file
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for Location Type.
|
||||
*/
|
||||
class CRM_Mailing_Form_Component extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The id of the object being edited / created
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* The name of the BAO object for this form.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_BAOName;
|
||||
|
||||
public function preProcess() {
|
||||
$this->_id = $this->get('id');
|
||||
$this->_BAOName = $this->get('BAOName');
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
$this->applyFilter(array('name', 'subject', 'body_html'), 'trim');
|
||||
|
||||
$this->add('text', 'name', ts('Name'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'name'), TRUE
|
||||
);
|
||||
$this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array(
|
||||
'CRM_Mailing_DAO_Component',
|
||||
$this->_id,
|
||||
));
|
||||
|
||||
$this->add('select', 'component_type', ts('Component Type'), CRM_Core_SelectValues::mailingComponents());
|
||||
|
||||
$this->add('text', 'subject', ts('Subject'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'subject'),
|
||||
TRUE
|
||||
);
|
||||
$this->add('textarea', 'body_text', ts('Body - TEXT Format'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_text')
|
||||
);
|
||||
$this->add('textarea', 'body_html', ts('Body - HTML Format'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Component', 'body_html')
|
||||
);
|
||||
|
||||
$this->addYesNo('is_default', ts('Default?'));
|
||||
$this->addYesNo('is_active', ts('Enabled?'));
|
||||
|
||||
$this->addFormRule(array('CRM_Mailing_Form_Component', 'formRule'));
|
||||
$this->addFormRule(array('CRM_Mailing_Form_Component', 'dataRule'));
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Save'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default values for the form.
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = array();
|
||||
$params = array();
|
||||
|
||||
if (isset($this->_id)) {
|
||||
$params = array('id' => $this->_id);
|
||||
$baoName = $this->_BAOName;
|
||||
$baoName::retrieve($params, $defaults);
|
||||
}
|
||||
else {
|
||||
$defaults['is_active'] = 1;
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form submission.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// store the submitted values in an array
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
if ($this->_action & CRM_Core_Action::UPDATE) {
|
||||
$params['id'] = $this->_id;
|
||||
}
|
||||
|
||||
$component = CRM_Mailing_BAO_Component::add($params);
|
||||
CRM_Core_Session::setStatus(ts('The mailing component \'%1\' has been saved.', array(
|
||||
1 => $component->name,
|
||||
)
|
||||
), ts('Saved'), 'success');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation.
|
||||
*
|
||||
* @param array $params
|
||||
* (ref.) an assoc array of name/value pairs.
|
||||
*
|
||||
* @param $files
|
||||
* @param $options
|
||||
*
|
||||
* @return bool|array
|
||||
* mixed true or array of errors
|
||||
*/
|
||||
public static function dataRule($params, $files, $options) {
|
||||
if ($params['component_type'] == 'Header' || $params['component_type'] == 'Footer') {
|
||||
$InvalidTokens = array();
|
||||
}
|
||||
else {
|
||||
$InvalidTokens = array('action.forward' => ts("This token can only be used in send mailing context (body, header, footer).."));
|
||||
}
|
||||
$errors = array();
|
||||
foreach (array(
|
||||
'text',
|
||||
'html',
|
||||
) as $type) {
|
||||
$dataErrors = array();
|
||||
foreach ($InvalidTokens as $token => $desc) {
|
||||
if ($params['body_' . $type]) {
|
||||
if (preg_match('/' . preg_quote('{' . $token . '}') . '/', $params['body_' . $type])) {
|
||||
$dataErrors[] = '<li>' . ts('This message is having a invalid token - %1: %2', array(
|
||||
1 => $token,
|
||||
2 => $desc,
|
||||
)) . '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($dataErrors)) {
|
||||
$errors['body_' . $type] = ts('The following errors were detected in %1 message:', array(
|
||||
1 => $type,
|
||||
)) . '<ul>' . implode('', $dataErrors) . '</ul><br /><a href="' . CRM_Utils_System::docURL2('Tokens', TRUE, NULL, NULL, NULL, "wiki") . '">' . ts('More information on tokens...') . '</a>';
|
||||
}
|
||||
}
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that either body text or body html is required.
|
||||
* @param array $params
|
||||
* (ref.) an assoc array of name/value pairs.
|
||||
*
|
||||
* @param $files
|
||||
* @param $options
|
||||
*
|
||||
* @return bool|array
|
||||
* mixed true or array of errors
|
||||
*/
|
||||
public static function formRule($params, $files, $options) {
|
||||
$errors = array();
|
||||
if (empty($params['body_text']) && empty($params['body_html'])) {
|
||||
$errors['body_text'] = ts("Please provide either HTML or TEXT format for the Body.");
|
||||
$errors['body_html'] = ts("Please provide either HTML or TEXT format for the Body.");
|
||||
}
|
||||
return empty($errors) ? TRUE : $errors;
|
||||
}
|
||||
|
||||
}
|
160
sites/all/modules/civicrm/CRM/Mailing/Form/ForwardMailing.php
Normal file
160
sites/all/modules/civicrm/CRM/Mailing/Form/ForwardMailing.php
Normal file
|
@ -0,0 +1,160 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form {
|
||||
public function preProcess() {
|
||||
$job_id = CRM_Utils_Request::retrieve('jid', 'Positive',
|
||||
$this, NULL
|
||||
);
|
||||
$queue_id = CRM_Utils_Request::retrieve('qid', 'Positive',
|
||||
$this, NULL
|
||||
);
|
||||
$hash = CRM_Utils_Request::retrieve('h', 'String',
|
||||
$this, NULL
|
||||
);
|
||||
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
|
||||
if ($q == NULL) {
|
||||
|
||||
// ERROR.
|
||||
CRM_Core_Error::fatal(ts('Invalid form parameters.'));
|
||||
CRM_Core_Error::statusBounce(ts('Invalid form parameters.'));
|
||||
}
|
||||
$mailing = &$q->getMailing();
|
||||
|
||||
if ($hash) {
|
||||
$emailId = CRM_Core_DAO::getfieldValue('CRM_Mailing_Event_DAO_Queue', $hash, 'email_id', 'hash');
|
||||
$this->_fromEmail = $fromEmail = CRM_Core_DAO::getfieldValue('CRM_Core_DAO_Email', $emailId, 'email');
|
||||
$this->assign('fromEmail', $fromEmail);
|
||||
}
|
||||
|
||||
// Show the subject instead of the name here, since it's being
|
||||
// displayed to external contacts/users.
|
||||
|
||||
CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject)));
|
||||
|
||||
$this->set('queue_id', $queue_id);
|
||||
$this->set('job_id', $job_id);
|
||||
$this->set('hash', $hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$this->add('text', "email_$i", ts('Email %1', array(1 => $i + 1)));
|
||||
$this->addRule("email_$i", ts('Email is not valid.'), 'email');
|
||||
}
|
||||
|
||||
//insert message Text by selecting "Select Template option"
|
||||
$this->add('textarea', 'forward_comment', ts('Comment'), array('cols' => '80', 'rows' => '8'));
|
||||
$this->add('wysiwyg', 'html_comment',
|
||||
ts('HTML Message'),
|
||||
array('cols' => '80', 'rows' => '8')
|
||||
);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Forward'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission of new/edit contact is processed.
|
||||
*/
|
||||
public function postProcess() {
|
||||
$queue_id = $this->get('queue_id');
|
||||
$job_id = $this->get('job_id');
|
||||
$hash = $this->get('hash');
|
||||
$timeStamp = date('YmdHis');
|
||||
|
||||
$formValues = $this->controller->exportValues($this->_name);
|
||||
$params = array();
|
||||
$params['body_text'] = $formValues['forward_comment'];
|
||||
$html_comment = $formValues['html_comment'];
|
||||
$params['body_html'] = str_replace('%7B', '{', str_replace('%7D', '}', $html_comment));
|
||||
|
||||
$emails = array();
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$email = $this->controller->exportValue($this->_name, "email_$i");
|
||||
if (!empty($email)) {
|
||||
$emails[] = $email;
|
||||
}
|
||||
}
|
||||
|
||||
$forwarded = NULL;
|
||||
foreach ($emails as $email) {
|
||||
$params = array(
|
||||
'version' => 3,
|
||||
'job_id' => $job_id,
|
||||
'event_queue_id' => $queue_id,
|
||||
'hash' => $hash,
|
||||
'email' => $email,
|
||||
'time_stamp' => $timeStamp,
|
||||
'fromEmail' => $this->_fromEmail,
|
||||
'params' => $params,
|
||||
);
|
||||
$result = civicrm_api('Mailing', 'event_forward', $params);
|
||||
if (!civicrm_error($result)) {
|
||||
$forwarded++;
|
||||
}
|
||||
}
|
||||
|
||||
$status = ts('Mailing is not forwarded to the given email address.', array(
|
||||
'count' => count($emails),
|
||||
'plural' => 'Mailing is not forwarded to the given email addresses.',
|
||||
));
|
||||
if ($forwarded) {
|
||||
$status = ts('Mailing is forwarded successfully to %count email address.', array(
|
||||
'count' => $forwarded,
|
||||
'plural' => 'Mailing is forwarded successfully to %count email addresses.',
|
||||
));
|
||||
}
|
||||
|
||||
CRM_Utils_System::setUFMessage($status);
|
||||
|
||||
// always redirect to front page of url
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$session->pushUserContext($config->userFrameworkBaseURL);
|
||||
}
|
||||
|
||||
}
|
126
sites/all/modules/civicrm/CRM/Mailing/Form/Optout.php
Normal file
126
sites/all/modules/civicrm/CRM/Mailing/Form/Optout.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Form_Optout extends CRM_Core_Form {
|
||||
|
||||
public function preProcess() {
|
||||
|
||||
$this->_type = 'optout';
|
||||
|
||||
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
|
||||
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
|
||||
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
|
||||
|
||||
if (!$job_id ||
|
||||
!$queue_id ||
|
||||
!$hash
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts("Missing input parameters"));
|
||||
}
|
||||
|
||||
// verify that the three numbers above match
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
if (!$q) {
|
||||
CRM_Core_Error::fatal(ts("There was an error in your request"));
|
||||
}
|
||||
|
||||
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
|
||||
$this->assign('display_name', $displayName);
|
||||
$emailMasked = CRM_Utils_String::maskEmail($email);
|
||||
$this->assign('email_masked', $emailMasked);
|
||||
$this->assign('email', $email);
|
||||
$this->_email = $email;
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
|
||||
CRM_Utils_System::setTitle(ts('Please Confirm Your Opt Out'));
|
||||
|
||||
$this->add('text', 'email_confirm', ts('Verify email address to opt out:'));
|
||||
$this->addRule('email_confirm', ts('Email address is required to opt out.'), 'required');
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Opt Out'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
|
||||
$values = $this->exportValues();
|
||||
|
||||
// check if EmailTyped matches Email address
|
||||
$result = CRM_Utils_String::compareStr($this->_email, $values['email_confirm'], TRUE);
|
||||
|
||||
$job_id = $this->_job_id;
|
||||
$queue_id = $this->_queue_id;
|
||||
$hash = $this->_hash;
|
||||
|
||||
$confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}", "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1");
|
||||
$this->assign('confirmURL', $confirmURL);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($confirmURL);
|
||||
|
||||
if ($result == TRUE) {
|
||||
// Email address verified
|
||||
if (CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_domain($job_id, $queue_id, $hash)) {
|
||||
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, NULL, TRUE, $job_id);
|
||||
}
|
||||
|
||||
$statusMsg = ts('Email: %1 has been successfully opted out',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'success');
|
||||
}
|
||||
elseif ($result == FALSE) {
|
||||
// Email address not verified
|
||||
|
||||
$statusMsg = ts('The email address: %1 you have entered does not match the email associated with this opt out request.',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
154
sites/all/modules/civicrm/CRM/Mailing/Form/Search.php
Normal file
154
sites/all/modules/civicrm/CRM/Mailing/Form/Search.php
Normal file
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Form_Search extends CRM_Core_Form {
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
$parent = $this->controller->getParent();
|
||||
$nameTextLabel = ($parent->_sms) ? ts('SMS Name') : ts('Mailing Name');
|
||||
|
||||
$this->add('text', 'mailing_name', $nameTextLabel,
|
||||
CRM_Core_DAO::getAttribute('CRM_Mailing_DAO_Mailing', 'title')
|
||||
);
|
||||
|
||||
CRM_Core_Form_Date::buildDateRange($this, 'mailing', 1, '_from', '_to', ts('From'), FALSE);
|
||||
|
||||
$this->add('text', 'sort_name', ts('Created or Sent by'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')
|
||||
);
|
||||
|
||||
CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this);
|
||||
|
||||
// CRM-15434 - Fix mailing search by status in non-English languages
|
||||
$statusVals = CRM_Core_SelectValues::getMailingJobStatus();
|
||||
foreach ($statusVals as $statusId => $statusName) {
|
||||
$this->addElement('checkbox', "mailing_status[$statusId]", NULL, $statusName);
|
||||
}
|
||||
$this->addElement('checkbox', 'status_unscheduled', NULL, ts('Draft / Unscheduled'));
|
||||
$this->addYesNo('is_archived', ts('Mailing is Archived'), TRUE);
|
||||
|
||||
// Search by language, if multi-lingual
|
||||
$enabledLanguages = CRM_Core_I18n::languages(TRUE);
|
||||
|
||||
if (count($enabledLanguages) > 1) {
|
||||
$this->addElement('select', 'language', ts('Language'), array('' => ts('- all languages -')) + $enabledLanguages, array('class' => 'crm-select2'));
|
||||
}
|
||||
|
||||
if ($parent->_sms) {
|
||||
$this->addElement('hidden', 'sms', $parent->_sms);
|
||||
}
|
||||
$this->add('hidden', 'hidden_find_mailings', 1);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'refresh',
|
||||
'name' => ts('Search'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function setDefaultValues() {
|
||||
$defaults = $statusVals = array();
|
||||
$parent = $this->controller->getParent();
|
||||
|
||||
if ($parent->get('unscheduled')) {
|
||||
$defaults['status_unscheduled'] = 1;
|
||||
}
|
||||
if ($parent->get('scheduled')) {
|
||||
$statusVals = array('Scheduled', 'Complete', 'Running', 'Canceled');
|
||||
$defaults['is_archived'] = 0;
|
||||
}
|
||||
if ($parent->get('archived')) {
|
||||
$defaults['is_archived'] = 1;
|
||||
}
|
||||
foreach ($statusVals as $status) {
|
||||
$defaults['mailing_status'][$status] = 1;
|
||||
}
|
||||
|
||||
if ($parent->_sms) {
|
||||
$defaults['sms'] = 1;
|
||||
}
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
CRM_Contact_BAO_Query::fixDateValues($params["mailing_relative"], $params['mailing_from'], $params['mailing_to']);
|
||||
|
||||
$parent = $this->controller->getParent();
|
||||
if (!empty($params)) {
|
||||
$fields = array(
|
||||
'mailing_name',
|
||||
'mailing_from',
|
||||
'mailing_to',
|
||||
'sort_name',
|
||||
'campaign_id',
|
||||
'mailing_status',
|
||||
'sms',
|
||||
'status_unscheduled',
|
||||
'is_archived',
|
||||
'language',
|
||||
'hidden_find_mailings',
|
||||
);
|
||||
foreach ($fields as $field) {
|
||||
if (isset($params[$field]) &&
|
||||
!CRM_Utils_System::isNull($params[$field])
|
||||
) {
|
||||
if (in_array($field, array(
|
||||
'mailing_from',
|
||||
'mailing_to',
|
||||
)) && !$params["mailing_relative"]
|
||||
) {
|
||||
$time = ($field == 'mailing_to') ? '235959' : NULL;
|
||||
$parent->set($field, CRM_Utils_Date::processDate($params[$field], $time));
|
||||
}
|
||||
else {
|
||||
$parent->set($field, $params[$field]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$parent->set($field, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
202
sites/all/modules/civicrm/CRM/Mailing/Form/Subscribe.php
Normal file
202
sites/all/modules/civicrm/CRM/Mailing/Form/Subscribe.php
Normal file
|
@ -0,0 +1,202 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Form_Subscribe extends CRM_Core_Form {
|
||||
protected $_groupID = NULL;
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$this->_groupID = CRM_Utils_Request::retrieve('gid', 'Integer', $this,
|
||||
FALSE, NULL, 'REQUEST'
|
||||
);
|
||||
|
||||
// ensure that there is a destination, if not set the destination to the
|
||||
// referrer string
|
||||
if (!$this->controller->getDestination()) {
|
||||
$this->controller->setDestination(NULL, TRUE);
|
||||
}
|
||||
|
||||
if ($this->_groupID) {
|
||||
$groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
|
||||
|
||||
// make sure requested qroup is accessible and exists
|
||||
$query = "
|
||||
SELECT title, description
|
||||
FROM civicrm_group
|
||||
WHERE id={$this->_groupID}
|
||||
AND visibility != 'User and User Admin Only'
|
||||
AND $groupTypeCondition";
|
||||
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
if ($dao->fetch()) {
|
||||
$this->assign('groupName', $dao->title);
|
||||
CRM_Utils_System::setTitle(ts('Subscribe to Mailing List - %1', array(1 => $dao->title)));
|
||||
}
|
||||
else {
|
||||
CRM_Core_Error::statusBounce("The specified group is not configured for this action OR The group doesn't exist.");
|
||||
}
|
||||
|
||||
$this->assign('single', TRUE);
|
||||
}
|
||||
else {
|
||||
$this->assign('single', FALSE);
|
||||
CRM_Utils_System::setTitle(ts('Mailing List Subscription'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
// add the email address
|
||||
$this->add('text',
|
||||
'email',
|
||||
ts('Email'),
|
||||
CRM_Core_DAO::getAttribute('CRM_Core_DAO_Email',
|
||||
'email'
|
||||
),
|
||||
TRUE
|
||||
);
|
||||
$this->addRule('email', ts("Please enter a valid email address."), 'email');
|
||||
|
||||
if (!$this->_groupID) {
|
||||
// create a selector box of all public groups
|
||||
$groupTypeCondition = CRM_Contact_BAO_Group::groupTypeCondition('Mailing');
|
||||
|
||||
$query = "
|
||||
SELECT id, title, description
|
||||
FROM civicrm_group
|
||||
WHERE ( saved_search_id = 0
|
||||
OR saved_search_id IS NULL )
|
||||
AND visibility != 'User and User Admin Only'
|
||||
AND $groupTypeCondition
|
||||
ORDER BY title";
|
||||
$dao = CRM_Core_DAO::executeQuery($query);
|
||||
$rows = array();
|
||||
while ($dao->fetch()) {
|
||||
$row = array();
|
||||
$row['id'] = $dao->id;
|
||||
$row['title'] = $dao->title;
|
||||
$row['description'] = $dao->description;
|
||||
$row['checkbox'] = CRM_Core_Form::CB_PREFIX . $row['id'];
|
||||
$this->addElement('checkbox',
|
||||
$row['checkbox'],
|
||||
NULL, NULL
|
||||
);
|
||||
$rows[] = $row;
|
||||
}
|
||||
if (empty($rows)) {
|
||||
CRM_Core_Error::fatal(ts('There are no public mailing list groups to display.'));
|
||||
}
|
||||
$this->assign('rows', $rows);
|
||||
$this->addFormRule(array('CRM_Mailing_Form_Subscribe', 'formRule'));
|
||||
}
|
||||
|
||||
$addCaptcha = TRUE;
|
||||
|
||||
// if recaptcha is not configured, then dont add it
|
||||
// CRM-11316 Only enable ReCAPTCHA for anonymous visitors
|
||||
$config = CRM_Core_Config::singleton();
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$contactID = $session->get('userID');
|
||||
|
||||
if (empty($config->recaptchaPublicKey) ||
|
||||
empty($config->recaptchaPrivateKey) ||
|
||||
$contactID
|
||||
) {
|
||||
$addCaptcha = FALSE;
|
||||
}
|
||||
else {
|
||||
// If this is POST request and came from a block,
|
||||
// lets add recaptcha only if already present.
|
||||
// Gross hack for now.
|
||||
if (!empty($_POST) &&
|
||||
!array_key_exists('recaptcha_challenge_field', $_POST)
|
||||
) {
|
||||
$addCaptcha = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($addCaptcha) {
|
||||
// add captcha
|
||||
$captcha = CRM_Utils_ReCAPTCHA::singleton();
|
||||
$captcha->add($this);
|
||||
$this->assign('isCaptcha', TRUE);
|
||||
}
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Subscribe'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fields
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public static function formRule($fields) {
|
||||
foreach ($fields as $name => $dontCare) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return array('_qf_default' => 'Please select one or more mailing lists.');
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$params = $this->controller->exportValues($this->_name);
|
||||
|
||||
$groups = array();
|
||||
if ($this->_groupID) {
|
||||
$groups[] = $this->_groupID;
|
||||
}
|
||||
else {
|
||||
foreach ($params as $name => $dontCare) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$groups[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($groups, $params);
|
||||
}
|
||||
|
||||
}
|
153
sites/all/modules/civicrm/CRM/Mailing/Form/Task.php
Normal file
153
sites/all/modules/civicrm/CRM/Mailing/Form/Task.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates form components for relationship
|
||||
*/
|
||||
class CRM_Mailing_Form_Task extends CRM_Core_Form {
|
||||
|
||||
/**
|
||||
* The task being performed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_task;
|
||||
|
||||
/**
|
||||
* The additional clause that we restrict the search with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_componentClause = NULL;
|
||||
|
||||
/**
|
||||
* The array that holds all the component ids.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_componentIds;
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
self::preProcessCommon($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CRM_Core_Form $form
|
||||
* @param bool $useTable
|
||||
*/
|
||||
public static function preProcessCommon(&$form, $useTable = FALSE) {
|
||||
$values = $form->controller->exportValues($form->get('searchFormName'));
|
||||
|
||||
$form->_task = CRM_Utils_Array::value('task', $values);
|
||||
$mailingTasks = CRM_Mailing_Task::tasks();
|
||||
$form->assign('taskName', CRM_Utils_Array::value('task', $values));
|
||||
|
||||
// ids are mailing event queue ids
|
||||
$ids = array();
|
||||
if ($values['radio_ts'] == 'ts_sel') {
|
||||
foreach ($values as $name => $value) {
|
||||
if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) {
|
||||
$ids[] = substr($name, CRM_Core_Form::CB_PREFIX_LEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$queryParams = $form->get('queryParams');
|
||||
$sortOrder = NULL;
|
||||
if ($form->get(CRM_Utils_Sort::SORT_ORDER)) {
|
||||
$sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER);
|
||||
}
|
||||
|
||||
$query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
|
||||
CRM_Contact_BAO_Query::MODE_MAILING
|
||||
);
|
||||
|
||||
$result = $query->searchQuery(0, 0, $sortOrder);
|
||||
while ($result->fetch()) {
|
||||
$ids[] = $result->mailing_recipients_id;
|
||||
}
|
||||
$form->assign('totalSelectedMailingRecipients', $form->get('rowCount'));
|
||||
}
|
||||
|
||||
if (!empty($ids)) {
|
||||
$form->_componentClause = ' civicrm_mailing_recipients.id IN ( ' . implode(',', $ids) . ' ) ';
|
||||
}
|
||||
|
||||
// set the context for redirection for any task actions
|
||||
$session = CRM_Core_Session::singleton();
|
||||
|
||||
$fragment = 'search';
|
||||
if ($form->_action == CRM_Core_Action::ADVANCED) {
|
||||
$fragment .= '/advanced';
|
||||
}
|
||||
|
||||
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form);
|
||||
$urlParams = 'force=1';
|
||||
if (CRM_Utils_Rule::qfKey($qfKey)) {
|
||||
$urlParams .= "&qfKey=$qfKey";
|
||||
}
|
||||
|
||||
$url = CRM_Utils_System::url('civicrm/contact/' . $fragment, $urlParams);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->replaceUserContext($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple shell that derived classes can call to add buttons to
|
||||
* the form with a customized title for the main Submit
|
||||
*
|
||||
* @param string $title
|
||||
* Title of the main button.
|
||||
* @param string $nextType
|
||||
* @param string $backType
|
||||
* @param bool $submitOnce
|
||||
*/
|
||||
public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => $nextType,
|
||||
'name' => $title,
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => $backType,
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* Given the selected contacts, prepare a mailing with a hidden group.
|
||||
*/
|
||||
class CRM_Mailing_Form_Task_AdhocMailing extends CRM_Contact_Form_Task {
|
||||
|
||||
public function preProcess() {
|
||||
parent::preProcess();
|
||||
$templateTypes = CRM_Mailing_BAO_Mailing::getTemplateTypes();
|
||||
list ($groupId, $ssId) = $this->createHiddenGroup();
|
||||
$mailing = civicrm_api3('Mailing', 'create', array(
|
||||
'name' => "",
|
||||
'campaign_id' => NULL,
|
||||
'replyto_email' => "",
|
||||
'template_type' => $templateTypes[0]['name'],
|
||||
'template_options' => array('nonce' => 1),
|
||||
'subject' => "",
|
||||
'body_html' => "",
|
||||
'body_text' => "",
|
||||
'groups' => array(
|
||||
'include' => array($groupId),
|
||||
'exclude' => array(),
|
||||
'base' => array(),
|
||||
),
|
||||
'mailings' => array(
|
||||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
),
|
||||
));
|
||||
|
||||
CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mailing['id']));
|
||||
}
|
||||
|
||||
}
|
95
sites/all/modules/civicrm/CRM/Mailing/Form/Task/Print.php
Normal file
95
sites/all/modules/civicrm/CRM/Mailing/Form/Task/Print.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class provides the functionality to print mailing recipient records
|
||||
*/
|
||||
class CRM_Mailing_Form_Task_Print extends CRM_Mailing_Form_Task {
|
||||
|
||||
/**
|
||||
* Build all the data structures needed to build the form.
|
||||
*/
|
||||
public function preProcess() {
|
||||
parent::preprocess();
|
||||
|
||||
// set print view, so that print templates are called
|
||||
$this->controller->setPrint(1);
|
||||
|
||||
// get the formatted params
|
||||
$queryParams = $this->get('queryParams');
|
||||
|
||||
$sortID = NULL;
|
||||
if ($this->get(CRM_Utils_Sort::SORT_ID)) {
|
||||
$sortID = CRM_Utils_Sort::sortIDValue($this->get(CRM_Utils_Sort::SORT_ID),
|
||||
$this->get(CRM_Utils_Sort::SORT_DIRECTION)
|
||||
);
|
||||
}
|
||||
|
||||
$selector = new CRM_Mailing_Selector_Search($queryParams, $this->_action, $this->_componentClause);
|
||||
$controller = new CRM_Core_Selector_Controller($selector, NULL, $sortID, CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::SCREEN);
|
||||
$controller->setEmbedded(TRUE);
|
||||
$controller->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form object - it consists of
|
||||
* - displaying the QILL (query in local language)
|
||||
* - displaying elements for saving the search.
|
||||
*/
|
||||
public function buildQuickForm() {
|
||||
//
|
||||
// just need to add a javacript to popup the window for printing
|
||||
//
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Print Mailing Recipients'),
|
||||
'js' => array('onclick' => 'window.print()'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'back',
|
||||
'name' => ts('Done'),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form after the input has been submitted and validated.
|
||||
*/
|
||||
public function postProcess() {
|
||||
// redirect to the main search page after printing is over
|
||||
}
|
||||
|
||||
}
|
144
sites/all/modules/civicrm/CRM/Mailing/Form/Unsubscribe.php
Normal file
144
sites/all/modules/civicrm/CRM/Mailing/Form/Unsubscribe.php
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
/*
|
||||
+--------------------------------------------------------------------+
|
||||
| CiviCRM version 4.7 |
|
||||
+--------------------------------------------------------------------+
|
||||
| Copyright CiviCRM LLC (c) 2004-2017 |
|
||||
+--------------------------------------------------------------------+
|
||||
| This file is a part of CiviCRM. |
|
||||
| |
|
||||
| CiviCRM is free software; you can copy, modify, and distribute it |
|
||||
| under the terms of the GNU Affero General Public License |
|
||||
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
|
||||
| |
|
||||
| CiviCRM is distributed in the hope that it will be useful, but |
|
||||
| WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| See the GNU Affero General Public License for more details. |
|
||||
| |
|
||||
| You should have received a copy of the GNU Affero General Public |
|
||||
| License and the CiviCRM Licensing Exception along |
|
||||
| with this program; if not, contact CiviCRM LLC |
|
||||
| at info[AT]civicrm[DOT]org. If you have questions about the |
|
||||
| GNU Affero General Public License or the licensing of CiviCRM, |
|
||||
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
|
||||
+--------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package CRM
|
||||
* @copyright CiviCRM LLC (c) 2004-2017
|
||||
*/
|
||||
class CRM_Mailing_Form_Unsubscribe extends CRM_Core_Form {
|
||||
|
||||
public function preProcess() {
|
||||
|
||||
$this->_type = 'unsubscribe';
|
||||
|
||||
$this->_job_id = $job_id = CRM_Utils_Request::retrieve('jid', 'Integer', $this);
|
||||
$this->_queue_id = $queue_id = CRM_Utils_Request::retrieve('qid', 'Integer', $this);
|
||||
$this->_hash = $hash = CRM_Utils_Request::retrieve('h', 'String', $this);
|
||||
|
||||
if (!$job_id ||
|
||||
!$queue_id ||
|
||||
!$hash
|
||||
) {
|
||||
CRM_Core_Error::fatal(ts("Missing Parameters"));
|
||||
}
|
||||
|
||||
// verify that the three numbers above match
|
||||
$q = CRM_Mailing_Event_BAO_Queue::verify($job_id, $queue_id, $hash);
|
||||
if (!$q) {
|
||||
CRM_Core_Error::fatal(ts("There was an error in your request"));
|
||||
}
|
||||
|
||||
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
|
||||
$this->assign('display_name', $displayName);
|
||||
$emailMasked = CRM_Utils_String::maskEmail($email);
|
||||
$this->assign('email_masked', $emailMasked);
|
||||
$this->assign('email', $email);
|
||||
$this->_email = $email;
|
||||
|
||||
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash, TRUE);
|
||||
$this->assign('groups', $groups);
|
||||
$groupExist = NULL;
|
||||
foreach ($groups as $key => $value) {
|
||||
if ($value) {
|
||||
$groupExist = TRUE;
|
||||
}
|
||||
}
|
||||
if (!$groupExist) {
|
||||
$statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.',
|
||||
array(1 => $email)
|
||||
);
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
|
||||
}
|
||||
$this->assign('groupExist', $groupExist);
|
||||
|
||||
}
|
||||
|
||||
public function buildQuickForm() {
|
||||
CRM_Utils_System::addHTMLHead('<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">');
|
||||
CRM_Utils_System::setTitle(ts('Please Confirm Your Unsubscribe from this Mailing/Group'));
|
||||
|
||||
$this->add('text', 'email_confirm', ts('Verify email address to unsubscribe:'));
|
||||
$this->addRule('email_confirm', ts('Email address is required to unsubscribe.'), 'required');
|
||||
|
||||
$buttons = array(
|
||||
array(
|
||||
'type' => 'next',
|
||||
'name' => ts('Unsubscribe'),
|
||||
'isDefault' => TRUE,
|
||||
),
|
||||
array(
|
||||
'type' => 'cancel',
|
||||
'name' => ts('Cancel'),
|
||||
),
|
||||
);
|
||||
|
||||
$this->addButtons($buttons);
|
||||
}
|
||||
|
||||
public function postProcess() {
|
||||
$values = $this->exportValues();
|
||||
|
||||
// check if EmailTyped matches Email address
|
||||
$result = CRM_Utils_String::compareStr($this->_email, $values['email_confirm'], TRUE);
|
||||
$job_id = $this->_job_id;
|
||||
$queue_id = $this->_queue_id;
|
||||
$hash = $this->_hash;
|
||||
|
||||
$confirmURL = CRM_Utils_System::url("civicrm/mailing/{$this->_type}", "reset=1&jid={$job_id}&qid={$queue_id}&h={$hash}&confirm=1");
|
||||
$this->assign('confirmURL', $confirmURL);
|
||||
$session = CRM_Core_Session::singleton();
|
||||
$session->pushUserContext($confirmURL);
|
||||
|
||||
if ($result == TRUE) {
|
||||
// Email address verified
|
||||
|
||||
$groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash);
|
||||
if (count($groups)) {
|
||||
CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, $groups, FALSE, $job_id);
|
||||
}
|
||||
|
||||
$statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'success');
|
||||
}
|
||||
elseif ($result == FALSE) {
|
||||
// Email address not verified
|
||||
|
||||
$statusMsg = ts('The email address: %1 you have entered does not match the email associated with this unsubscribe request.',
|
||||
array(1 => $values['email_confirm'])
|
||||
);
|
||||
|
||||
CRM_Core_Session::setStatus($statusMsg, '', 'fail');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue