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_Contact_Import_Field
15 class CRM_Contact_Import_Field
{
29 * Title of the field to be used in display
41 * Is this field required
47 * Data to be carried for use by a derived class
53 * Regexp to match the CSV header of this column/field
56 public $_columnPattern;
59 * Regexp to match the pattern of data from various column/fields
65 * Regexp to match the pattern of header from various column/fields
68 public $_headerPattern;
74 public $_hasLocationType;
77 * Does this field have a phone type
89 * Does this field have a relationship info
95 * Does this field have a relationship Contact Type
98 public $_relatedContactType;
101 * Does this field have a relationship Contact Details
104 public $_relatedContactDetails;
107 * Does this field have a related Contact info of Location Type
110 public $_relatedContactLocType;
113 * Does this field have a related Contact info of Phone Type
116 public $_relatedContactPhoneType;
119 * @param string $name
122 * @param string $columnPattern
123 * @param string $dataPattern
124 * @param null $hasLocationType
125 * @param null $phoneType
126 * @param null $related
127 * @param null $relatedContactType
128 * @param null $relatedContactDetails
129 * @param null $relatedContactLocType
130 * @param null $relatedContactPhoneType
132 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) {
133 $this->_name
= $name;
134 $this->_title
= $title;
135 $this->_type
= $type;
136 $this->_columnPattern
= $columnPattern;
137 $this->_dataPattern
= $dataPattern;
138 $this->_hasLocationType
= $hasLocationType;
139 $this->_phoneType
= $phoneType;
140 $this->_related
= $related;
141 $this->_relatedContactType
= $relatedContactType;
142 $this->_relatedContactDetails
= $relatedContactDetails;
143 $this->_relatedContactLocType
= $relatedContactLocType;
144 $this->_relatedContactPhoneType
= $relatedContactPhoneType;
146 $this->_value
= NULL;
149 public function resetValue() {
150 $this->_value
= NULL;
154 * The value is in string format.
156 * Convert the value to the type of this field
157 * and set the field value with the appropriate type
159 * @param mixed $value
161 public function setValue($value) {
162 $this->_value
= $value;
166 * Validate something we didn't document.
170 public function validate() {
171 // echo $this->_value."===========<br>";
174 if ($this->_value
=== NULL) {
178 // Commented due to bug CRM-150, internationalization/wew.
179 // if ( $this->_name == 'phone' ) {
180 // return CRM_Utils_Rule::phone( $this->_value );
183 if ($this->_name
== 'email') {
184 return CRM_Utils_Rule
::email($this->_value
);