3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2020 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Class CRM_Event_Import_Field
31 class CRM_Event_Import_Field
{
45 * Title of the field to be used in display
57 * Regexp to match the CSV header of this column/field
60 public $_headerPattern;
63 * Regexp to match the pattern of data from various column/fields
78 * @param string $headerPattern
79 * @param string $dataPattern
81 public function __construct($name, $title, $type = CRM_Utils_Type
::T_INT
, $headerPattern = '//', $dataPattern = '//') {
83 $this->_title
= $title;
85 $this->_headerPattern
= $headerPattern;
86 $this->_dataPattern
= $dataPattern;
91 public function resetValue() {
96 * Convert the value to the type of this field and set the field value with the appropriate type.
98 * @param string $value
100 public function setValue($value) {
101 $this->_value
= $value;
107 public function validate() {
108 if (CRM_Utils_System
::isNull($this->_value
)) {
112 switch ($this->_name
) {
114 // note: we validate extistence of the contact in API, upon
115 // insert (it would be too costlty to do a db call here)
116 return CRM_Utils_Rule
::integer($this->_value
);
118 case 'register_date':
119 return CRM_Utils_Rule
::date($this->_value
);
121 /* @codingStandardsIgnoreStart
123 static $events = null;
125 $events = CRM_Event_PseudoConstant::event();
127 if (in_array($this->_value, $events)) {
134 @codingStandardsIgnoreEnd */
140 // check whether that's a valid custom field id
141 // and if so, check the contents' validity
142 if ($customFieldID = CRM_Core_BAO_CustomField
::getKeyID($this->_name
)) {
143 static $customFields = NULL;
144 if (!$customFields) {
145 $customFields = CRM_Core_BAO_CustomField
::getFields('Participant');
147 if (!array_key_exists($customFieldID, $customFields)) {
150 return CRM_Core_BAO_CustomValue
::typecheck($customFields[$customFieldID]['data_type'], $this->_value
);