3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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_Contact_Import_Field
31 class CRM_Contact_Import_Field
{
45 * Title of the field to be used in display
57 * Is this field required
63 * Data to be carried for use by a derived class
69 * Regexp to match the CSV header of this column/field
72 public $_columnPattern;
75 * Regexp to match the pattern of data from various column/fields
81 * Regexp to match the pattern of header from various column/fields
84 public $_headerPattern;
90 public $_hasLocationType;
93 * Does this field have a phone type
105 * Does this field have a relationship info
111 * Does this field have a relationship Contact Type
114 public $_relatedContactType;
117 * Does this field have a relationship Contact Details
120 public $_relatedContactDetails;
123 * Does this field have a related Contact info of Location Type
126 public $_relatedContactLocType;
129 * Does this field have a related Contact info of Phone Type
132 public $_relatedContactPhoneType;
135 * @param string $name
138 * @param string $columnPattern
139 * @param string $dataPattern
140 * @param null $hasLocationType
141 * @param null $phoneType
142 * @param null $related
143 * @param null $relatedContactType
144 * @param null $relatedContactDetails
145 * @param null $relatedContactLocType
146 * @param null $relatedContactPhoneType
148 public function __construct($name, $title, $type = CRM_Utils_Type
::T_INT
, $columnPattern = '//', $dataPattern = '//', $hasLocationType = NULL, $phoneType = NULL, $related = NULL, $relatedContactType = NULL, $relatedContactDetails = NULL, $relatedContactLocType = NULL, $relatedContactPhoneType = NULL) {
149 $this->_name
= $name;
150 $this->_title
= $title;
151 $this->_type
= $type;
152 $this->_columnPattern
= $columnPattern;
153 $this->_dataPattern
= $dataPattern;
154 $this->_hasLocationType
= $hasLocationType;
155 $this->_phoneType
= $phoneType;
156 $this->_related
= $related;
157 $this->_relatedContactType
= $relatedContactType;
158 $this->_relatedContactDetails
= $relatedContactDetails;
159 $this->_relatedContactLocType
= $relatedContactLocType;
160 $this->_relatedContactPhoneType
= $relatedContactPhoneType;
162 $this->_value
= NULL;
165 public function resetValue() {
166 $this->_value
= NULL;
170 * The value is in string format.
172 * Convert the value to the type of this field
173 * and set the field value with the appropriate type
175 * @param mixed $value
177 public function setValue($value) {
178 $this->_value
= $value;
182 * Validate something we didn't document.
186 public function validate() {
187 // echo $this->_value."===========<br>";
190 if ($this->_value
=== NULL) {
194 // Commented due to bug CRM-150, internationalization/wew.
195 // if ( $this->_name == 'phone' ) {
196 // return CRM_Utils_Rule::phone( $this->_value );
199 if ($this->_name
== 'email') {
200 return CRM_Utils_Rule
::email($this->_value
);