示例#1
0
 function whereClause(&$params, $sortBy = true, $force)
 {
     $values = array();
     $clauses = array();
     $title = $this->get('title');
     if ($title) {
         $clauses[] = "title LIKE %1";
         if (strpos($title, '%') !== false) {
             $params[1] = array(trim($title), 'String', false);
         } else {
             $params[1] = array(trim($title), 'String', true);
         }
     }
     $value = $this->get('event_type_id');
     $val = array();
     if ($value) {
         if (is_array($value)) {
             foreach ($value as $k => $v) {
                 if ($v) {
                     $val[$k] = $k;
                 }
             }
             $type = implode(',', $val);
         }
         $clauses[] = "event_type_id IN ({$type})";
     }
     $eventsByDates = $this->get('eventsByDates');
     if ($this->_searchResult) {
         if ($eventsByDates) {
             require_once 'CRM/Utils/Date.php';
             $from = $this->get('start_date');
             if (!CRM_Utils_System::isNull($from)) {
                 $from = CRM_Utils_date::format($from);
                 $from .= '000000';
                 $clauses[] = '( start_date >= %3 OR start_date IS NULL )';
                 $params[3] = array($from, 'String');
             }
             $to = $this->get('end_date');
             if (!CRM_Utils_System::isNull($to)) {
                 $to = CRM_Utils_date::format($to);
                 $to .= '235959';
                 $clauses[] = '( end_date <= %4 OR end_date IS NULL )';
                 $params[4] = array($to, 'String');
             }
         } else {
             $curDate = date('YmdHis');
             $clauses[5] = "(end_date >= {$curDate} OR end_date IS NULL)";
         }
     } else {
         $curDate = date('YmdHis');
         $clauses[] = "(end_date >= {$curDate} OR end_date IS NULL)";
     }
     if ($sortBy && $this->_sortByCharacter) {
         $clauses[] = 'title LIKE %6';
         $params[6] = array($this->_sortByCharacter . '%', 'String');
     }
     // dont do a the below assignment when doing a
     // AtoZ pager clause
     if ($sortBy) {
         if (count($clauses) > 1 || $eventsByDates) {
             $this->assign('isSearch', 1);
         } else {
             $this->assign('isSearch', 0);
         }
     }
     require_once 'CRM/Core/Permission.php';
     $clauses[] = CRM_Core_Permission::eventClause();
     return implode(' AND ', $clauses);
 }
示例#2
0
文件: Browse.php 项目: ksecor/civicrm
 function whereClause(&$params, $sortBy = true)
 {
     $values = array();
     $clauses = array();
     $title = $this->_parent->get('mailing_name');
     if ($title) {
         $clauses[] = 'name LIKE %1';
         if (strpos($title, '%') !== false) {
             $params[1] = array($title, 'String', false);
         } else {
             $params[1] = array($title, 'String', true);
         }
     }
     require_once 'CRM/Utils/Date.php';
     $from = $this->_parent->get('mailing_from');
     if (!CRM_Utils_System::isNull($from)) {
         $from = CRM_Utils_date::format($from);
         $from .= '000000';
         $clauses[] = 'start_date >= %2';
         $params[2] = array($from, 'String');
     }
     $to = $this->_parent->get('mailing_to');
     if (!CRM_Utils_System::isNull($to)) {
         $to = CRM_Utils_date::format($to);
         $to .= '235959';
         $clauses[] = 'start_date <= %3';
         $params[3] = array($to, 'String');
     }
     if ($this->_parent->get('unscheduled')) {
         $clauses[] = "civicrm_mailing_job.status is null";
     }
     if ($this->_parent->get('archived')) {
         $clauses[] = "civicrm_mailing.is_archived = 1";
     }
     // CRM-4290, do not show archived or unscheduled mails
     // on 'Scheduled and Sent Mailing' page selector
     if ($this->_parent->get('scheduled')) {
         $clauses[] = "civicrm_mailing.is_archived = 0";
         $clauses[] = "civicrm_mailing_job.status IN ('Scheduled', 'Complete', 'Running')";
     }
     if ($sortBy && $this->_parent->_sortByCharacter) {
         $clauses[] = 'name LIKE %3';
         $params[3] = array($this->_parent->_sortByCharacter . '%', 'String');
     }
     // dont do a the below assignement when doing a
     // AtoZ pager clause
     if ($sortBy) {
         if (count($clauses) > 1) {
             $this->_parent->assign('isSearch', 1);
         } else {
             $this->_parent->assign('isSearch', 0);
         }
     }
     $createOrSentBy = $this->_parent->get('sort_name');
     if (!CRM_Utils_System::isNull($createOrSentBy)) {
         $clauses[] = '(createdContact.sort_name LIKE %4 OR scheduledContact.sort_name LIKE %4)';
         $params[4] = array('%' . $createOrSentBy . '%', 'String');
     }
     if (empty($clauses)) {
         return 1;
     }
     return implode(' AND ', $clauses);
 }