+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
class CRM_Core_BAO_CustomValue extends CRM_Core_DAO {
/**
- * Validate a value against a CustomField type
+ * Validate a value against a CustomField type.
*
* @param string $type
* The type of the data.
* @param string $value
* The data to be validated.
*
- * @return boolean
+ * @return bool
* True if the value is of the specified type
- * @static
*/
public static function typecheck($type, $value) {
switch ($type) {
*
* @return string|null
* the mysql data store placeholder
- * @static
*/
public static function typeToField($type) {
switch ($type) {
* @param array $formValues
* @return null
*/
- public static function fixFieldValueOfTypeMemo(&$formValues) {
+ public static function fixCustomFieldValue(&$formValues) {
if (empty($formValues)) {
return NULL;
}
$htmlType = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField',
substr($key, 7), 'html_type'
);
- if (($htmlType == 'TextArea') &&
+ $dataType = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_CustomField',
+ substr($key, 7), 'data_type'
+ );
+
+ if (is_array($formValues[$key])) {
+ if (!in_array(key($formValues[$key]), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
+ $formValues[$key] = array('IN' => $formValues[$key]);
+ }
+ }
+ elseif (($htmlType == 'TextArea' ||
+ ($htmlType == 'Text' && $dataType == 'String')
+ ) &&
!((substr($formValues[$key], 0, 1) == '%') ||
(substr($formValues[$key], -1, 1) == '%')
)
) {
- $formValues[$key] = '%' . $formValues[$key] . '%';
+ $formValues[$key] = array('LIKE' => '%' . $formValues[$key] . '%');
}
-
}
}
/**
- * Delete option value give an option value and custom group id
+ * Delete option value give an option value and custom group id.
*
* @param int $customValueID
* Custom value ID.
* Custom group ID.
*
* @return void
- * @static
*/
public static function deleteCustomValue($customValueID, $customGroupID) {
// first we need to find custom value table, from custom group ID
$customValueID
);
}
+
}