CRM-14983 - Sunning Contribution via Search Builder Fails Putting Contacts in Smart...
[civicrm-core.git] / CRM / Event / BAO / Query.php
index 5352e135edb6df94232f4e4b211dfe282c5a96d9..3e4873a60288104c4af1b55732dd770b71e3b564 100644 (file)
@@ -35,6 +35,9 @@
  */
 class CRM_Event_BAO_Query {
 
+  /**
+   * @return array
+   */
   static function &getFields() {
     $fields = array();
     $fields = array_merge($fields, CRM_Event_DAO_Event::import());
@@ -44,6 +47,9 @@ class CRM_Event_BAO_Query {
     return $fields;
   }
 
+  /**
+   * @return array
+   */
   static function &getParticipantFields() {
     $fields = CRM_Event_BAO_Participant::importableFields('Individual', TRUE, TRUE);
     return $fields;
@@ -52,6 +58,8 @@ class CRM_Event_BAO_Query {
   /**
    * build select for CiviEvent
    *
+   * @param $query
+   *
    * @return void
    * @access public
    */
@@ -199,6 +207,9 @@ class CRM_Event_BAO_Query {
     }
   }
 
+  /**
+   * @param $query
+   */
   static function where(&$query) {
     $grouping = NULL;
     foreach (array_keys($query->_params) as $id) {
@@ -217,6 +228,10 @@ class CRM_Event_BAO_Query {
     }
   }
 
+  /**
+   * @param $values
+   * @param $query
+   */
   static function whereClauseSingle(&$values, &$query) {
     list($name, $op, $value, $grouping, $wildcard) = $values;
     switch ($name) {
@@ -318,7 +333,7 @@ class CRM_Event_BAO_Query {
           $status = $value;
         }
 
-        if (count($val) > 1) {
+        if (count($val) > 0) {
           $op = 'IN';
           $status = "({$status})";
         }
@@ -332,7 +347,9 @@ class CRM_Event_BAO_Query {
           }
         }
         else {
-          $names[] = $statusTypes[$value];
+          if (!empty($value)) {
+            $names[] = $statusTypes[$value];
+          }
         }
 
         $query->_qill[$grouping][] = ts('Participant Status %1', array(1 => $op)) . ' ' . implode(' ' . ts('or') . ' ', $names);
@@ -363,7 +380,9 @@ class CRM_Event_BAO_Query {
 
         $names = array();
         foreach ($val as $id => $dontCare) {
-          $names[] = $roleTypes[$id];
+          if (!empty($roleTypes[$id]) ) {
+            $names[] = $roleTypes[$id];
+          }
         }
 
         if (!empty($names)) {
@@ -443,6 +462,13 @@ class CRM_Event_BAO_Query {
     }
   }
 
+  /**
+   * @param $name
+   * @param $mode
+   * @param $side
+   *
+   * @return null|string
+   */
   static function from($name, $mode, $side) {
     $from = NULL;
     switch ($name) {
@@ -492,6 +518,12 @@ class CRM_Event_BAO_Query {
     return (isset($this->_qill)) ? $this->_qill : "";
   }
 
+  /**
+   * @param $mode
+   * @param bool $includeCustomFields
+   *
+   * @return array|null
+   */
   static function defaultReturnProperties($mode,
     $includeCustomFields = TRUE
   ) {
@@ -568,7 +600,6 @@ class CRM_Event_BAO_Query {
     CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE);
 
     $status = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
-    asort($status);
     foreach ($status as $id => $Name) {
       $form->_participantStatus = &$form->addElement('checkbox', "participant_status_id[$id]", NULL, $Name);
     }
@@ -608,8 +639,15 @@ class CRM_Event_BAO_Query {
     $form->setDefaults(array('participant_test' => 0));
   }
 
+  /**
+   * @param $row
+   * @param $id
+   */
   static function searchAction(&$row, $id) {}
 
+  /**
+   * @param $tables
+   */
   static function tableNames(&$tables) {
     //add participant table
     if (!empty($tables['civicrm_event'])) {