}
}
- if ($row['status'] == 'Complete' && !$row['archived']) {
+ if (in_array($row['status'], array('Complete', 'Canceled')) &&
+ !$row['archived']) {
if ($allAccess || $showCreateLinks) {
$actionMask |= CRM_Core_Action::RENEW;
}
function whereClause(&$params, $sortBy = TRUE) {
$values = $clauses = array();
+ $isFormSubmitted = $this->_parent->get('hidden_find_mailings');
$title = $this->_parent->get('mailing_name');
-
if ($title) {
$clauses[] = 'name LIKE %1';
if (strpos($title, '%') !== FALSE) {
}
}
+ $dateClause1 = $dateClause2 = array();
$from = $this->_parent->get('mailing_from');
if (!CRM_Utils_System::isNull($from)) {
if ($this->_parent->get('unscheduled')) {
$params[3] = array($to, 'String');
}
- $addtlStatuses = $this->_parent->get('archived') ? ", 'Canceled'" : '';
+ $dateClauses = array();
if (!empty($dateClause1)) {
- if (!$this->_parent->get('unscheduled')) {
- $dateClause1[] = "civicrm_mailing_job.status IN ('Complete', 'Running' $addtlStatuses)";
- $dateClause2[] = "civicrm_mailing_job.status IN ('Scheduled' $addtlStatuses)";
- }
-
- if (!empty($dateClause1)) {
- $dateClause1 = implode(' AND ', $dateClause1);
- }
- if (!empty($dateClause2)) {
- $dateClause2 = implode(' AND ', $dateClause2);
- }
-
- $dateC = NULL;
- if (!empty($dateClause1)) {
- $dateC = " ({$dateClause1}) ";
- }
- if (!empty($dateClause2)) {
- if ($dateC) {
- $dateC .= " OR ({$dateClause2}) ";
- }
- else {
- $dateC = " ({$dateClause2}) ";
- }
- }
- $clauses[] = " ({$dateC}) ";
+ $dateClauses[] = implode(' AND ', $dateClause1);
}
-
- if ($this->_parent->get('unscheduled')) {
- $clauses[] = "civicrm_mailing_job.status is null";
- $clauses[] = "civicrm_mailing.scheduled_id IS NULL";
+ if (!empty($dateClause2)) {
+ $dateClauses[] = implode(' AND ', $dateClause2);
+ }
+ $dateClauses = implode(' OR ', $dateClauses);
+ if (!empty($dateClauses)) {
+ $clauses[] = "({$dateClauses})";
}
if ($this->_parent->get('sms')) {
- $clauses[] = "(civicrm_mailing.sms_provider_id IS NOT NULL)";
+ $clauses[] = "civicrm_mailing.sms_provider_id IS NOT NULL";
}
else {
- $clauses[] = "(civicrm_mailing.sms_provider_id IS NULL)";
+ $clauses[] = "civicrm_mailing.sms_provider_id IS NULL";
}
- // CRM-4290, do not show archived or unscheduled mails
- // on 'Scheduled and Sent Mailing' page selector
- if ($this->_parent->get('scheduled')) {
- $clauses[] = "civicrm_mailing.scheduled_id IS NOT NULL";
- $clauses[] = "( civicrm_mailing.is_archived IS NULL OR civicrm_mailing.is_archived = 0 )";
+ // get values submitted by form
+ $isDraft = $this->_parent->get('status_unscheduled');
+ $isArchived = $this->_parent->get('is_archived');
+ $mailingStatus = $this->_parent->get('mailing_status');
+
+ if (!$isFormSubmitted && $this->_parent->get('scheduled')) {
+ // mimic default behavior for scheduled screen
+ $isArchived = 0;
+ $mailingStatus = array('Scheduled' => 1, 'Complete' => 1, 'Running' => 1, 'Canceled' => 1);
+ }
+ if (!$isFormSubmitted && $this->_parent->get('archived')) {
+ // mimic default behavior for archived screen
+ $isArchived = 1;
+ }
+ if (!$isFormSubmitted && $this->_parent->get('unscheduled')) {
+ // mimic default behavior for draft screen
+ $isDraft = 1;
}
- if (!$this->_parent->get('unscheduled')) {
- // all status filter implementation
- if ($status = $this->_parent->get('mailing_status')) {
- $status = array_keys($status);
- }
- if ($this->_parent->get('all_status')) {
- $status = $this->_parent->get('allStatuses');
- }
- if ($this->_parent->get('all_status') && $this->_parent->get('scheduled')) {
- $status = array('Scheduled', 'Complete', 'Running');
- }
+ $statusClauses = array();
+ if ($isDraft) {
+ $statusClauses[] = "civicrm_mailing.scheduled_id IS NULL";
+ }
+ if (!empty($mailingStatus)) {
+ $statusClauses[] = "civicrm_mailing_job.status IN ('" . implode("', '", array_keys($mailingStatus)) . "')";
+ }
+ if (!empty($statusClauses)) {
+ $clauses[] = "(" . implode(' OR ', $statusClauses) . ")";
+ }
- if (!empty($status)) {
- $status = implode("','", $status);
- $clauses[] = "civicrm_mailing_job.status IN ('$status')";
+ if (isset($isArchived)) {
+ if ($isArchived) {
+ $clauses[] = "civicrm_mailing.is_archived = 1";
+ } else {
+ $clauses[] = "(civicrm_mailing.is_archived IS NULL OR civicrm_mailing.is_archived = 0)";
}
- elseif ($this->_parent->get('scheduled')) {
- $clauses[] = "civicrm_mailing_job.status IN ('Scheduled', 'Complete', 'Running')";
- }
- }
- if ($this->_parent->get('archived')) {
- // CRM-6446: archived view should also show cancelled mailings
- $clauses[] = "(civicrm_mailing.is_archived = 1 OR civicrm_mailing_job.status = 'Canceled')";
}
if ($sortBy &&