if ($parent->_sms) {
$this->addElement('hidden', 'sms', $parent->_sms);
}
+ $this->add('hidden', 'hidden_find_mailings', 1);
$this->addButtons(array(
array(
$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');
+ 'campaign_id', 'mailing_status', 'sms', 'status_unscheduled', 'is_archived', 'hidden_find_mailings');
foreach ($fields as $field) {
if (isset($params[$field]) &&
!CRM_Utils_System::isNull($params[$field])
function whereClause(&$params, $sortBy = TRUE) {
$values = $clauses = array();
- $title = $this->_parent->get('mailing_name');
+ $isFormSubmitted = $this->_parent->get('hidden_find_mailings');
+ $title = $this->_parent->get('mailing_name');
if ($title) {
$clauses[] = 'name LIKE %1';
if (strpos($title, '%') !== FALSE) {
$clauses[] = "({$dateClauses})";
}
- if ($this->_parent->get('status_unscheduled')) {
- $clauses[] = "civicrm_mailing_job.status IS NULL";
- $clauses[] = "civicrm_mailing.scheduled_id IS NULL";
- }
-
if ($this->_parent->get('sms')) {
$clauses[] = "civicrm_mailing.sms_provider_id IS NOT NULL";
}
$clauses[] = "civicrm_mailing.sms_provider_id IS NULL";
}
+ // 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 ($isDraft) {
+ $clauses[] = "civicrm_mailing_job.status IS NULL";
+ $clauses[] = "civicrm_mailing.scheduled_id IS NULL";
+ }
+
// CRM-4290, do not show archived or unscheduled mails
// on 'Scheduled and Sent Mailing' page selector
if (!empty($mailingStatus)) {
$clauses[] = "civicrm_mailing.scheduled_id IS NOT NULL";
- $clauses[] = "civicrm_mailing.scheduled_id IN ('" . implode("', '", array_keys($mailingStatus)) . "')";
+ $clauses[] = "civicrm_mailing_job.status IN ('" . implode("', '", array_keys($mailingStatus)) . "')";
}
- $isArchived = $this->_parent->get('is_archived');
if (isset($isArchived)) {
if ($isArchived) {
// CRM-6446: archived view should also show cancelled mailings