Switch from statusBounce to Exception in CRM_Mailing_BAO_Mailing::checkPermission as not on form layer
}
if (!in_array($id, $mailingIDs)) {
- CRM_Core_Error::fatal(ts('You do not have permission to access this mailing report'));
+ throw new CRM_Core_Exception(ts('You do not have permission to access this mailing report'));
}
}
*/
public static function del($id) {
if (empty($id)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception(ts('No id passed to mailing del function'));
}
CRM_Utils_Hook::pre('delete', 'Mailing', $id, CRM_Core_DAO::$_nullArray);
*/
public static function delJob($id) {
if (empty($id)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception(ts('No id passed to mailing delJob function'));
}
\Civi::log('This function is deprecated, use CRM_Mailing_BAO_MailingJob::del instead', ['civi.tag' => 'deprecated']);
*/
public static function del($id) {
if (empty($id)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception(ts('No id passed to MailingAB del function'));
}
CRM_Core_Transaction::create()->run(function () use ($id) {
CRM_Utils_Hook::pre('delete', 'MailingAB', $id, CRM_Core_DAO::$_nullArray);
static $smtpConnectionErrors = 0;
if (!is_object($mailer) || empty($fields)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Either mailer is not an object or we don\'t have recipients to send to in this group');
}
// get the return properties
$activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Bulk Email');
}
if (!$activityTypeID) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Execption(ts('No relevant activity type found when recording Mailing Event delivered Activity'));
}
}
$dao = CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
- CRM_Core_Error::fatal('Please file an issue with the backtrace');
+ throw new CRM_Core_Exception('Please file an issue with the backtrace');
return $success;
}
}
if (!$ids['mailing_id']) {
- CRM_Core_Error::fatal();
+ CRM_Core_Error::statusBounce(ts('No mailing id has been able to be determined'));
}
$params['approver_id'] = $this->_contactID;
// 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.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
$mailing = new CRM_Mailing_BAO_Mailing();
if ($q == NULL) {
// ERROR.
- CRM_Core_Error::fatal(ts('Invalid form parameters.'));
+ throw new CRM_Core_Exception(ts('Invalid form parameters.'));
CRM_Core_Error::statusBounce(ts('Invalid form parameters.'));
}
$mailing = &$q->getMailing();
!$queue_id ||
!$hash
) {
- CRM_Core_Error::fatal(ts("Missing input parameters"));
+ throw new CRM_Core_Exception(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"));
+ throw new CRM_Core_Exception(ts("There was an error in your request"));
}
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
$rows[] = $row;
}
if (empty($rows)) {
- CRM_Core_Error::fatal(ts('There are no public mailing list groups to display.'));
+ throw new CRM_Core_Exception(ts('There are no public mailing list groups to display.'));
}
$this->assign('rows', $rows);
$this->addFormRule(['CRM_Mailing_Form_Subscribe', 'formRule']);
!$queue_id ||
!$hash
) {
- CRM_Core_Error::fatal(ts("Missing Parameters"));
+ throw new CRM_Core_Exception(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"));
+ throw new CRM_Core_Exception(ts("There was an error in your request"));
}
list($displayName, $email) = CRM_Mailing_Event_BAO_Queue::getContactInfo($queue_id);
if ($this->_sms) {
// if this is an SMS page, check that the user has permission to browse SMS
if (!CRM_Core_Permission::check('send SMS')) {
- CRM_Core_Error::fatal(ts('You do not have permission to send SMS'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to send SMS'));
}
}
else {
// permission (specific permissions have been copied from
// CRM/Mailing/xml/Menu/Mailing.xml)
if (!CRM_Core_Permission::check([['access CiviMail', 'approve mailings', 'create mailings', 'schedule mailings']])) {
- CRM_Core_Error::fatal(ts('You do not have permission to view this page.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to view this page.'));
}
}
}
elseif ($this->_action & CRM_Core_Action::CLOSE) {
if (!CRM_Core_Permission::checkActionPermission('CiviMail', CRM_Core_Action::CLOSE)) {
- CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
CRM_Mailing_BAO_MailingJob::pause($this->_mailingId);
CRM_Core_Session::setStatus(ts('The mailing has been paused. Active message deliveries may continue for a few minutes, but CiviMail will not begin delivery of any more batches.'), ts('Paused'), 'success');
}
elseif ($this->_action & CRM_Core_Action::REOPEN) {
if (!CRM_Core_Permission::checkActionPermission('CiviMail', CRM_Core_Action::CLOSE)) {
- CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
CRM_Mailing_BAO_MailingJob::resume($this->_mailingId);
CRM_Core_Session::setStatus(ts('The mailing has been resumed.'), ts('Resumed'), 'success');
// 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.'));
+ CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.'));
}
CRM_Mailing_BAO_Mailing::del($this->_mailingId);
!$queue_id ||
!$hash
) {
- CRM_Core_Error::fatal(ts("Missing input parameters"));
+ throw new CRM_Core_Exception(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"));
+ throw new CRM_Core_Exception(ts("There was an error in your request"));
}
$cancel = CRM_Utils_Request::retrieve("_qf_{$this->_type}_cancel", 'String', CRM_Core_DAO::$_nullObject,
!$subscribe_id ||
!$hash
) {
- CRM_Core_Error::fatal(ts("Missing input parameters"));
+ throw new CRM_Core_Exception(ts("Missing input parameters"));
}
$result = CRM_Mailing_Event_BAO_Confirm::confirm($contact_id, $subscribe_id, $hash);
elseif ($context == 'angPage') {
$angPage = CRM_Utils_Request::retrieve('angPage', 'String', $this);
if (!preg_match(':^[a-zA-Z0-9\-_/]+$:', $angPage)) {
- CRM_Core_Error::fatal('Malformed return URL');
+ throw new CRM_Core_Exception('Malformed return URL');
}
$backUrl = CRM_Utils_System::url('civicrm/a/#/' . $angPage);
$backUrlTitle = ts('Back to Report');