INFRA-132 - CRM/Core - phpcbf
[civicrm-core.git] / CRM / Core / BAO / CustomQuery.php
index 8ca162022e06eefdfc34576835a797f4a35be9db..b36e4daf0a7a322ec097c26e35e0fe5a71b3af33 100644 (file)
@@ -2,7 +2,7 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  *
  */
 class CRM_Core_BAO_CustomQuery {
-  CONST PREFIX = 'custom_value_';
+  const PREFIX = 'custom_value_';
 
   /**
-   * the set of custom field ids
+   * The set of custom field ids
    *
    * @var array
    */
   protected $_ids;
 
   /**
-   * the select clause
+   * The select clause
    *
    * @var array
    */
   public $_select;
 
   /**
-   * the name of the elements that are in the select clause
+   * The name of the elements that are in the select clause
    * used to extract the values
    *
    * @var array
@@ -60,7 +60,7 @@ class CRM_Core_BAO_CustomQuery {
   public $_element;
 
   /**
-   * the tables involved in the query
+   * The tables involved in the query
    *
    * @var array
    */
@@ -68,7 +68,7 @@ class CRM_Core_BAO_CustomQuery {
   public $_whereTables;
 
   /**
-   * the where clause
+   * The where clause
    *
    * @var array
    */
@@ -107,7 +107,6 @@ class CRM_Core_BAO_CustomQuery {
   /**
    * This stores custom data group types and tables that it extends
    *
-   * @todo add comments explaining why survey & campaign are missing from this
    * @var array
    * @static
    */
@@ -127,22 +126,24 @@ class CRM_Core_BAO_CustomQuery {
     'Pledge' => 'civicrm_pledge',
     'Grant' => 'civicrm_grant',
     'Address' => 'civicrm_address',
+    'Campaign' => 'civicrm_campaign',
+    'Survey' => 'civicrm_survey',
   );
 
   /**
-   * class constructor
+   * Class constructor
    *
    * Takes in a set of custom field ids andsets up the data structures to
    * generate a query
    *
-   * @param  array $ids the set of custom field ids
+   * @param array $ids
+   *   The set of custom field ids.
    *
    * @param bool $contactSearch
    * @param array $locationSpecificFields
    *
-   * @access public
    */
-  function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array()) {
+  public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array()) {
     $this->_ids = &$ids;
     $this->_locationSpecificCustomFields = $locationSpecificFields;
 
@@ -255,15 +256,14 @@ SELECT label, value
   }
 
   /**
-   * generate the select clause and the associated tables
+   * Generate the select clause and the associated tables
    * for the from clause
    *
-   * @param  NULL
+   * @param NULL
    *
    * @return void
-   * @access public
    */
-  function select() {
+  public function select() {
     if (empty($this->_fields)) {
       return;
     }
@@ -323,16 +323,15 @@ SELECT label, value
   }
 
   /**
-   * generate the where clause and also the english language
+   * Generate the where clause and also the english language
    * equivalent
    *
    * @param NULL
    *
    * @return void
    *
-   * @access public
    */
-  function where() {
+  public function where() {
     foreach ($this->_ids as $id => $values) {
 
       // Fixed for Isuue CRM 607
@@ -539,6 +538,7 @@ SELECT label, value
                 case 'IS EMPTY':
                   $op = 'IS NULL';
                   break;
+
                 case 'IS NOT EMPTY':
                   $op = 'IS NOT NULL';
                   break;
@@ -553,15 +553,14 @@ SELECT label, value
   }
 
   /**
-   * function that does the actual query generation
+   * Function that does the actual query generation
    * basically ties all the above functions together
    *
    * @param NULL
    *
    * @return  array   array of strings
-   * @access public
    */
-  function query() {
+  public function query() {
     $this->select();
 
     $this->where();
@@ -586,14 +585,14 @@ SELECT label, value
   }
 
   /**
-   * @param $id
+   * @param int $id
    * @param $label
    * @param $type
-   * @param $fieldName
+   * @param string $fieldName
    * @param $value
    * @param $grouping
    */
-  function searchRange(&$id, &$label, $type, $fieldName, &$value, &$grouping) {
+  public function searchRange(&$id, &$label, $type, $fieldName, &$value, &$grouping) {
     $qill = array();
 
     if (isset($value['from'])) {