*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
*/
/**
- * This class if for search builder processing
+ * This class is for search builder processing.
*/
class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search {
/**
* Build the form object.
- *
- * @return void
*/
public function preProcess() {
$this->set('searchFormName', 'Builder');
}
}
+ /**
+ * Build quick form.
+ */
public function buildQuickForm() {
$fields = self::fields();
// Get fields of type date
/**
* Add local and global form rules.
- *
- *
- * @return void
*/
public function addRules() {
$this->addFormRule(array('CRM_Contact_Form_Search_Builder', 'formRule'), $this);
/**
* Global validation rules for the form.
*
- * @param $values
- * @param $files
- * @param $self
+ * @param array $values
+ * @param array $files
+ * @param CRM_Core_Form $self
*
* @return array
* list of errors to be posted back to the form
// CRM-10338
$v[2] = self::checkArrayKeyEmpty($v[2]);
- if (in_array($v[1], array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY')) &&
+ if (in_array($v[1], array(
+ 'IS NULL',
+ 'IS NOT NULL',
+ 'IS EMPTY',
+ 'IS NOT EMPTY',
+ )) &&
!empty($v[2])
) {
$errorMsg["value[$v[3]][$v[4]]"] = ts('Please clear your value if you want to use %1 operator.', array(1 => $v[1]));
}
- elseif (($v[0] == 'group' || $v[0] == 'tag') && !empty($v[2])) {
- $grpId = array_keys($v[2]);
- if (!key($v[2])) {
- $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter a value.");
- }
-
- if (count($grpId) > 1) {
- if ($v[1] != 'IN' && $v[1] != 'NOT IN') {
- $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter a valid value.");
- }
- foreach ($grpId as $val) {
- $error = CRM_Utils_Type::validate($val, 'Integer', FALSE);
- if ($error != $val) {
- $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter a valid value.");
- break;
- }
- }
- }
- else {
- $error = CRM_Utils_Type::validate($grpId[0], 'Integer', FALSE);
- if ($error != $grpId[0]) {
- $errorMsg["value[$v[3]][$v[4]]"] = ts('Please enter valid %1 id.', array(1 => $v[0]));
- }
- }
- }
elseif (substr($v[0], 0, 7) === 'do_not_' or substr($v[0], 0, 3) === 'is_') {
if (isset($v[2])) {
$v2 = array($v[2]);
return TRUE;
}
+ /**
+ * Normalise form values.
+ */
public function normalizeFormValues() {
}
/**
- * @param $formValues
+ * Convert form values.
+ *
+ * @param array $formValues
*
* @return array
*/
}
/**
+ * Get return properties.
+ *
* @return array
*/
public function &returnProperties() {
/**
* Process the uploaded file.
- *
- * @return void
*/
public function postProcess() {
$this->set('isAdvanced', '2');
}
/**
+ * Get fields.
+ *
* @return array
*/
public static function fields() {
/**
* CRM-9434 Hackish function to fetch fields with options.
+ *
* FIXME: When our core fields contain reliable metadata this will be much simpler.
* @return array
* (string => string) key: field_name value: api entity name
}
/**
- * CRM-10338
- * tags and groups use array keys for selection list.
+ * CRM-10338 tags and groups use array keys for selection list.
+ *
* if using IS NULL/NOT NULL, an array with no array key is created
* convert that to simple NULL so processing can proceed
+ *
+ * @param string $val
+ *
+ * @return null
*/
public static function checkArrayKeyEmpty($val) {
if (is_array($val)) {