projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 4.6 into master
[civicrm-core.git]
/
CRM
/
Core
/
BAO
/
CustomQuery.php
diff --git
a/CRM/Core/BAO/CustomQuery.php
b/CRM/Core/BAO/CustomQuery.php
index d6433e956fe4f049624cd612e705482797100d04..512b7595c4d85899d70025da6a330e9981648dce 100644
(file)
--- a/
CRM/Core/BAO/CustomQuery.php
+++ b/
CRM/Core/BAO/CustomQuery.php
@@
-1,10
+1,9
@@
<?php
<?php
-
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-201
4
|
+ | Copyright CiviCRM LLC (c) 2004-201
5
|
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
@@
-24,13
+23,13
@@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+
*/
/**
*
*
* @package CRM
/**
*
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-201
4
+ * @copyright CiviCRM LLC (c) 2004-201
5
* $Id$
*
*/
* $Id$
*
*/
@@
-38,21
+37,21
@@
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;
/**
*
* @var array
*/
protected $_ids;
/**
- * The select clause
+ * The select clause
.
*
* @var array
*/
public $_select;
/**
*
* @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
* used to extract the values
*
* @var array
@@
-60,7
+59,7
@@
class CRM_Core_BAO_CustomQuery {
public $_element;
/**
public $_element;
/**
- * The tables involved in the query
+ * The tables involved in the query
.
*
* @var array
*/
*
* @var array
*/
@@
-68,28
+67,28
@@
class CRM_Core_BAO_CustomQuery {
public $_whereTables;
/**
public $_whereTables;
/**
- * The where clause
+ * The where clause
.
*
* @var array
*/
public $_where;
/**
*
* @var array
*/
public $_where;
/**
- * The english language version of the query
+ * The english language version of the query
.
*
* @var array
*/
public $_qill;
/**
*
* @var array
*/
public $_qill;
/**
- * The cache to translate the option values into labels
+ * The cache to translate the option values into labels
.
*
* @var array
*/
public $_options;
/**
*
* @var array
*/
public $_options;
/**
- * The custom fields information
+ * The custom fields information
.
*
* @var array
*/
*
* @var array
*/
@@
-105,10
+104,9
@@
class CRM_Core_BAO_CustomQuery {
protected $_locationSpecificCustomFields;
/**
protected $_locationSpecificCustomFields;
/**
- * This stores custom data group types and tables that it extends
+ * This stores custom data group types and tables that it extends
.
*
* @var array
*
* @var array
- * @static
*/
static $extendsMap = array(
'Contact' => 'civicrm_contact',
*/
static $extendsMap = array(
'Contact' => 'civicrm_contact',
@@
-131,7
+129,7
@@
class CRM_Core_BAO_CustomQuery {
);
/**
);
/**
- * Class constructor
+ * Class constructor
.
*
* Takes in a set of custom field ids andsets up the data structures to
* generate a query
*
* Takes in a set of custom field ids andsets up the data structures to
* generate a query
@@
-141,19
+139,18
@@
class CRM_Core_BAO_CustomQuery {
*
* @param bool $contactSearch
* @param array $locationSpecificFields
*
* @param bool $contactSearch
* @param array $locationSpecificFields
- *
*/
public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array()) {
$this->_ids = &$ids;
$this->_locationSpecificCustomFields = $locationSpecificFields;
*/
public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array()) {
$this->_ids = &$ids;
$this->_locationSpecificCustomFields = $locationSpecificFields;
- $this->_select
= array();
- $this->_element
= array();
- $this->_tables
= array();
+ $this->_select = array();
+ $this->_element = array();
+ $this->_tables = array();
$this->_whereTables = array();
$this->_whereTables = array();
- $this->_where
= array();
- $this->_qill
= array();
- $this->_options
= array();
+ $this->_where = array();
+ $this->_qill = array();
+ $this->_options = array();
$this->_fields = array();
$this->_contactSearch = $contactSearch;
$this->_fields = array();
$this->_contactSearch = $contactSearch;
@@
-165,7
+162,7
@@
class CRM_Core_BAO_CustomQuery {
// initialize the field array
$tmpArray = array_keys($this->_ids);
$idString = implode(',', $tmpArray);
// initialize the field array
$tmpArray = array_keys($this->_ids);
$idString = implode(',', $tmpArray);
- $query
= "
+ $query = "
SELECT f.id, f.label, f.data_type,
f.html_type, f.is_search_range,
f.option_group_id, f.custom_group_id,
SELECT f.id, f.label, f.data_type,
f.html_type, f.is_search_range,
f.option_group_id, f.custom_group_id,
@@
-256,11
+253,9
@@
SELECT label, value
}
/**
}
/**
- * Generate the select clause and the associated tables
+ * Generate the select clause and the associated tables
.
* for the from clause
*
* for the from clause
*
- * @param NULL
- *
* @return void
*/
public function select() {
* @return void
*/
public function select() {
@@
-323,13
+318,10
@@
SELECT label, value
}
/**
}
/**
- * Generate the where clause and also the english language
+ * Generate the where clause and also the english language
.
* equivalent
*
* equivalent
*
- * @param NULL
- *
* @return void
* @return void
- *
*/
public function where() {
foreach ($this->_ids as $id => $values) {
*/
public function where() {
foreach ($this->_ids as $id => $values) {
@@
-359,7
+351,10
@@
SELECT label, value
if (is_array($value) && !$field['is_search_range']) {
$isSerialized = CRM_Core_BAO_CustomField::isSerialized($field);
$wildcard = $isSerialized ? $wildcard : TRUE;
if (is_array($value) && !$field['is_search_range']) {
$isSerialized = CRM_Core_BAO_CustomField::isSerialized($field);
$wildcard = $isSerialized ? $wildcard : TRUE;
- $options = CRM_Utils_Array::value('values', civicrm_api3('contact', 'getoptions', array('field' => $name, 'context' => 'search'), array()));
+ $options = CRM_Utils_Array::value('values', civicrm_api3('contact', 'getoptions', array(
+ 'field' => $name,
+ 'context' => 'search',
+ ), array()));
$qillValue = '';
$sqlOP = $wildcard ? ' OR ' : ' AND ';
$sqlValue = array();
$qillValue = '';
$sqlOP = $wildcard ? ' OR ' : ' AND ';
$sqlValue = array();
@@
-408,7
+403,7
@@
SELECT label, value
if ($wildcard) {
$val = $strtolower(CRM_Core_DAO::escapeString($val));
$val = "%$val%";
if ($wildcard) {
$val = $strtolower(CRM_Core_DAO::escapeString($val));
$val = "%$val%";
- $op
= 'LIKE';
+ $op = 'LIKE';
}
//FIX for custom data query fired against no value(NULL/NOT NULL)
}
//FIX for custom data query fired against no value(NULL/NOT NULL)
@@
-487,7
+482,7
@@
SELECT label, value
$toValue = CRM_Utils_Array::value('to', $value);
if (!$fromValue && !$toValue) {
$toValue = CRM_Utils_Array::value('to', $value);
if (!$fromValue && !$toValue) {
- if (!CRM_Utils_Date::processDate($value) &&
$op != 'IS NULL' && $op != 'IS NOT NULL'
) {
+ if (!CRM_Utils_Date::processDate($value) &&
!in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))
) {
continue;
}
continue;
}
@@
-553,12
+548,11
@@
SELECT label, value
}
/**
}
/**
- * Function that does the actual query generation
+ * Function that does the actual query generation
.
* basically ties all the above functions together
*
* basically ties all the above functions together
*
- * @param NULL
- *
- * @return array array of strings
+ * @return array
+ * array of strings
*/
public function query() {
$this->select();
*/
public function query() {
$this->select();
@@
-578,7
+572,8
@@
SELECT label, value
}
}
}
}
- return array(implode(' , ', $this->_select),
+ return array(
+ implode(' , ', $this->_select),
implode(' ', $this->_tables),
$whereStr,
);
implode(' ', $this->_tables),
$whereStr,
);
@@
-622,4
+617,5
@@
SELECT label, value
$this->_qill[$grouping][] = $label . ' - ' . implode(' ' . ts('and') . ' ', $qill);
}
}
$this->_qill[$grouping][] = $label . ' - ' . implode(' ' . ts('and') . ' ', $qill);
}
}
+
}
}