3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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
{
44 * title of the field to be used in display
55 * is this field required
61 * data to be carried for use by a derived class
67 * regexp to match the CSV header of this column/field
70 public $_columnPattern;
73 * regexp to match the pattern of data from various column/fields
79 * regexp to match the pattern of header from various column/fields
82 public $_headerPattern;
88 public $_hasLocationType;
91 * does this field have a phone type
103 * does this field have a relationship info
109 * does this field have a relationship Contact Type
112 public $_relatedContactType;
115 * does this field have a relationship Contact Details
118 public $_relatedContactDetails;
121 * does this field have a related Contact info of Location Type
124 public $_relatedContactLocType;
127 * does this field have a related Contact info of Phone Type
130 public $_relatedContactPhoneType;
136 * @param string $columnPattern
137 * @param string $dataPattern
138 * @param null $hasLocationType
139 * @param null $phoneType
140 * @param null $related
141 * @param null $relatedContactType
142 * @param null $relatedContactDetails
143 * @param null $relatedContactLocType
144 * @param null $relatedContactPhoneType
146 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) {
147 $this->_name
= $name;
148 $this->_title
= $title;
149 $this->_type
= $type;
150 $this->_columnPattern
= $columnPattern;
151 $this->_dataPattern
= $dataPattern;
152 $this->_hasLocationType
= $hasLocationType;
153 $this->_phoneType
= $phoneType;
154 $this->_related
= $related;
155 $this->_relatedContactType
= $relatedContactType;
156 $this->_relatedContactDetails
= $relatedContactDetails;
157 $this->_relatedContactLocType
= $relatedContactLocType;
158 $this->_relatedContactPhoneType
= $relatedContactPhoneType;
160 $this->_value
= NULL;
163 function resetValue() {
164 $this->_value
= NULL;
168 * the value is in string format. convert the value to the type of this field
169 * and set the field value with the appropriate type
171 function setValue($value) {
172 $this->_value
= $value;
178 function validate() {
179 // echo $this->_value."===========<br>";
182 if ($this->_value
=== NULL) {
186 // Commented due to bug CRM-150, internationalization/wew.
187 // if ( $this->_name == 'phone' ) {
188 // return CRM_Utils_Rule::phone( $this->_value );
191 if ($this->_name
== 'email') {
192 return CRM_Utils_Rule
::email($this->_value
);