3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
27 class CRM_Contact_Import_Field
{
40 * title of the field to be used in display
51 * is this field required
57 * data to be carried for use by a derived class
63 * regexp to match the CSV header of this column/field
66 public $_columnPattern;
69 * regexp to match the pattern of data from various column/fields
75 * regexp to match the pattern of header from various column/fields
78 public $_headerPattern;
84 public $_hasLocationType;
87 * does this field have a phone type
99 * does this field have a relationship info
105 * does this field have a relationship Contact Type
108 public $_relatedContactType;
111 * does this field have a relationship Contact Details
114 public $_relatedContactDetails;
117 * does this field have a related Contact info of Location Type
120 public $_relatedContactLocType;
123 * does this field have a related Contact info of Phone Type
126 public $_relatedContactPhoneType;
128 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) {
129 $this->_name
= $name;
130 $this->_title
= $title;
131 $this->_type
= $type;
132 $this->_columnPattern
= $columnPattern;
133 $this->_dataPattern
= $dataPattern;
134 $this->_hasLocationType
= $hasLocationType;
135 $this->_phoneType
= $phoneType;
136 $this->_related
= $related;
137 $this->_relatedContactType
= $relatedContactType;
138 $this->_relatedContactDetails
= $relatedContactDetails;
139 $this->_relatedContactLocType
= $relatedContactLocType;
140 $this->_relatedContactPhoneType
= $relatedContactPhoneType;
142 $this->_value
= NULL;
145 function resetValue() {
146 $this->_value
= NULL;
150 * the value is in string format. convert the value to the type of this field
151 * and set the field value with the appropriate type
153 function setValue($value) {
154 $this->_value
= $value;
157 function validate() {
158 // echo $this->_value."===========<br>";
161 if ($this->_value
=== NULL) {
165 // Commented due to bug CRM-150, internationalization/wew.
166 // if ( $this->_name == 'phone' ) {
167 // return CRM_Utils_Rule::phone( $this->_value );
170 if ($this->_name
== 'email') {
171 return CRM_Utils_Rule
::email($this->_value
);