_name = $name; $this->_title = $title; $this->_type = $type; $this->_headerPattern = $headerPattern; $this->_dataPattern = $dataPattern; $this->_value = NULL; } public function resetValue() { $this->_value = NULL; } /** * Convert the value to the type of this field and set the field value with the appropriate type. * * @param string $value */ public function setValue($value) { $this->_value = $value; } /** * @return bool */ public function validate() { if (CRM_Utils_System::isNull($this->_value)) { return TRUE; } switch ($this->_name) { case 'contact_id': // note: we validate extistence of the contact in API, upon // insert (it would be too costlty to do a db call here) return CRM_Utils_Rule::integer($this->_value); case 'register_date': return CRM_Utils_Rule::date($this->_value); /* @codingStandardsIgnoreStart case 'event_id': static $events = null; if (!$events) { $events = CRM_Event_PseudoConstant::event(); } if (in_array($this->_value, $events)) { return true; } else { return false; } break; @codingStandardsIgnoreEnd */ default: break; } // check whether that's a valid custom field id // and if so, check the contents' validity if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) { static $customFields = NULL; if (!$customFields) { $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); } if (!array_key_exists($customFieldID, $customFields)) { return FALSE; } return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value); } return TRUE; } }