3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Event_Import_Field
15 class CRM_Event_Import_Field
{
29 * Title of the field to be used in display
41 * Regexp to match the CSV header of this column/field
44 public $_headerPattern;
47 * Regexp to match the pattern of data from various column/fields
62 * @param string $headerPattern
63 * @param string $dataPattern
65 public function __construct($name, $title, $type = CRM_Utils_Type
::T_INT
, $headerPattern = '//', $dataPattern = '//') {
67 $this->_title
= $title;
69 $this->_headerPattern
= $headerPattern;
70 $this->_dataPattern
= $dataPattern;
75 public function resetValue() {
80 * Convert the value to the type of this field and set the field value with the appropriate type.
82 * @param string $value
84 public function setValue($value) {
85 $this->_value
= $value;
91 public function validate() {
92 if (CRM_Utils_System
::isNull($this->_value
)) {
96 switch ($this->_name
) {
98 // note: we validate extistence of the contact in API, upon
99 // insert (it would be too costlty to do a db call here)
100 return CRM_Utils_Rule
::integer($this->_value
);
102 case 'register_date':
103 return CRM_Utils_Rule
::date($this->_value
);
105 /* @codingStandardsIgnoreStart
107 static $events = null;
109 $events = CRM_Event_PseudoConstant::event();
111 if (in_array($this->_value, $events)) {
118 @codingStandardsIgnoreEnd */
124 // check whether that's a valid custom field id
125 // and if so, check the contents' validity
126 if ($customFieldID = CRM_Core_BAO_CustomField
::getKeyID($this->_name
)) {
127 static $customFields = NULL;
128 if (!$customFields) {
129 $customFields = CRM_Core_BAO_CustomField
::getFields('Participant');
131 if (!array_key_exists($customFieldID, $customFields)) {
134 return CRM_Core_BAO_CustomValue
::typecheck($customFields[$customFieldID]['data_type'], $this->_value
);