1
|
|
|
<?php |
2
|
|
|
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); |
3
|
|
|
/********************************************************************************* |
4
|
|
|
* SugarCRM Community Edition is a customer relationship management program developed by |
5
|
|
|
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc. |
6
|
|
|
|
7
|
|
|
* SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd. |
8
|
|
|
* Copyright (C) 2011 - 2014 Salesagility Ltd. |
9
|
|
|
* |
10
|
|
|
* This program is free software; you can redistribute it and/or modify it under |
11
|
|
|
* the terms of the GNU Affero General Public License version 3 as published by the |
12
|
|
|
* Free Software Foundation with the addition of the following permission added |
13
|
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK |
14
|
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY |
15
|
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. |
16
|
|
|
* |
17
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT |
18
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more |
20
|
|
|
* details. |
21
|
|
|
* |
22
|
|
|
* You should have received a copy of the GNU Affero General Public License along with |
23
|
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free |
24
|
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25
|
|
|
* 02110-1301 USA. |
26
|
|
|
* |
27
|
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, |
28
|
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address [email protected]. |
29
|
|
|
* |
30
|
|
|
* The interactive user interfaces in modified source and object code versions |
31
|
|
|
* of this program must display Appropriate Legal Notices, as required under |
32
|
|
|
* Section 5 of the GNU Affero General Public License version 3. |
33
|
|
|
* |
34
|
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3, |
35
|
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by |
36
|
|
|
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not |
37
|
|
|
* reasonably feasible for technical reasons, the Appropriate Legal Notices must |
38
|
|
|
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM". |
39
|
|
|
********************************************************************************/ |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* source is the parent class of any source object. |
44
|
|
|
* @api |
45
|
|
|
*/ |
46
|
|
|
abstract class source{ |
47
|
|
|
/** |
48
|
|
|
* The name of an wrapper to use if the class wants to provide an override |
49
|
|
|
*/ |
50
|
|
|
public $wrapperName; |
51
|
|
|
protected $_config; |
52
|
|
|
protected $_mapping; |
53
|
|
|
protected $_field_defs; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var bool enable_in_wizard Boolean value marking whether or not the connector may appear in the wizard (Get Data) views |
57
|
|
|
*/ |
58
|
|
|
protected $_enable_in_wizard = true; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var bool enable_in_hover Boolean value marking whether or not a hover link could be applied to the connector |
62
|
|
|
*/ |
63
|
|
|
protected $_enable_in_hover = false; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @var bool enable_in_admin_mapping Boolean value marking whether or not this connector should be shown in the Modify Mapping view |
67
|
|
|
*/ |
68
|
|
|
protected $_enable_in_admin_mapping = true; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @var bool enable_in_admin_properties Boolean value marking whether or not this connector should appear in the Set Connector Properties view |
72
|
|
|
*/ |
73
|
|
|
protected $_enable_in_admin_properties = true; |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @var bool enable_in_admin_display Boolean value marking whether or not this connector should appear in the Enable Connectors view |
77
|
|
|
*/ |
78
|
|
|
protected $_enable_in_admin_display = true; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @var bool enable_in_admin_search Boolean value marking whether or not this connector should appear in the Manage Connector Search view |
82
|
|
|
*/ |
83
|
|
|
protected $_enable_in_admin_search = true; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @var bool has_testing_enabled Boolean value marking whether or not the connector should display the test button in administration view |
87
|
|
|
*/ |
88
|
|
|
protected $_has_testing_enabled = false; |
89
|
|
|
|
90
|
|
|
protected $_required_config_fields = array(); |
91
|
|
|
protected $_required_config_fields_for_button = array(); |
92
|
|
|
protected $config_decrypted = false; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* The ExternalAPI Base that instantiated this connector. |
96
|
|
|
* @var _eapm |
97
|
|
|
*/ |
98
|
|
|
protected $_eapm = null; |
99
|
|
|
|
100
|
|
|
public function __construct(){ |
101
|
|
|
$this->loadConfig(); |
102
|
|
|
$this->loadMapping(); |
103
|
|
|
$this->loadVardefs(); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function init(){} |
107
|
|
|
|
108
|
|
|
//////// CALLED FROM component.php /////// |
109
|
|
|
public function loadMapping() { |
110
|
|
|
$mapping = array(); |
111
|
|
|
$dir = str_replace('_','/',get_class($this)); |
112
|
|
|
if(file_exists("custom/modules/Connectors/connectors/sources/{$dir}/mapping.php")) { |
113
|
|
|
require("custom/modules/Connectors/connectors/sources/{$dir}/mapping.php"); |
114
|
|
|
} else if(file_exists("modules/Connectors/connectors/sources/{$dir}/mapping.php")){ |
115
|
|
|
require("modules/Connectors/connectors/sources/{$dir}/mapping.php"); |
116
|
|
|
} |
117
|
|
|
$this->_mapping = $mapping; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function saveMappingHook($mapping) { |
121
|
|
|
// Most classes don't care that the mapping has changed, but this is here if they do. |
122
|
|
|
return; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Load source's vardef file |
127
|
|
|
*/ |
128
|
|
|
public function loadVardefs() { |
129
|
|
|
$class = get_class($this); |
130
|
|
|
$dir = str_replace('_','/',$class); |
131
|
|
|
if(file_exists("custom/modules/Connectors/connectors/sources/{$dir}/vardefs.php")) { |
132
|
|
|
require("custom/modules/Connectors/connectors/sources/{$dir}/vardefs.php"); |
133
|
|
|
} else if(file_exists("modules/Connectors/connectors/sources/{$dir}/vardefs.php")){ |
134
|
|
|
require("modules/Connectors/connectors/sources/{$dir}/vardefs.php"); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
$this->_field_defs = !empty($dictionary[$class]['fields']) ? $dictionary[$class]['fields'] : array(); |
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
|
|
|
|
141
|
|
|
* Given a parameter in a vardef field, return the list of fields that match the param and value |
142
|
|
|
* |
143
|
|
|
* @param string $param_name |
144
|
|
|
* @param string $param_value |
145
|
|
|
* @return array |
146
|
|
|
*/ |
147
|
|
|
public function getFieldsWithParams($param_name, $param_value) |
148
|
|
|
{ |
149
|
|
|
if(empty($this->_field_defs)){ |
150
|
|
|
$this->loadVardefs(); |
151
|
|
|
} |
152
|
|
|
$fields_with_param = array(); |
153
|
|
|
foreach($this->_field_defs as $key => $def){ |
154
|
|
|
if(!empty($def[$param_name]) && ($def[$param_name] == $param_value)){ |
155
|
|
|
$fields_with_param[$key] = $def; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
return $fields_with_param; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
|
|
|
|
162
|
|
|
* Save source's config to custom directory |
163
|
|
|
*/ |
164
|
|
|
public function saveConfig() |
165
|
|
|
{ |
166
|
|
|
$config_str = "<?php\n/***CONNECTOR SOURCE***/\n"; |
167
|
|
|
|
168
|
|
|
// Handle encryption |
169
|
|
|
if(!empty($this->_config['encrypt_properties']) && is_array($this->_config['encrypt_properties']) && !empty($this->_config['properties'])){ |
170
|
|
|
require_once('include/utils/encryption_utils.php'); |
171
|
|
|
foreach($this->_config['encrypt_properties'] as $name) { |
172
|
|
|
if(!empty($this->_config['properties'][$name])) { |
173
|
|
|
$this->_config['properties'][$name] = blowfishEncode(blowfishGetKey('encrypt_field'),$this->_config['properties'][$name]); |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
|
179
|
|
|
foreach($this->_config as $key => $val) { |
180
|
|
|
if(!empty($val)){ |
181
|
|
|
$config_str .= override_value_to_string_recursive2('config', $key, $val, false); |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
$dir = str_replace('_', '/', get_class($this)); |
185
|
|
|
|
186
|
|
|
if(!file_exists("custom/modules/Connectors/connectors/sources/{$dir}")) { |
187
|
|
|
mkdir_recursive("custom/modules/Connectors/connectors/sources/{$dir}"); |
188
|
|
|
} |
189
|
|
|
file_put_contents("custom/modules/Connectors/connectors/sources/{$dir}/config.php", $config_str); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
|
|
|
|
193
|
|
|
* Initialize config - decrypt encrypted fields |
194
|
|
|
*/ |
195
|
|
|
public function initConfig() |
196
|
|
|
{ |
197
|
|
|
if($this->config_decrypted) return; |
198
|
|
|
// Handle decryption |
199
|
|
|
require_once('include/utils/encryption_utils.php'); |
200
|
|
|
if(!empty($this->_config['encrypt_properties']) && is_array($this->_config['encrypt_properties']) && !empty($this->_config['properties'])){ |
201
|
|
|
foreach($this->_config['encrypt_properties'] as $name) { |
202
|
|
|
if(!empty($this->_config['properties'][$name])) { |
203
|
|
|
$this->_config['properties'][$name] = blowfishDecode(blowfishGetKey('encrypt_field'),$this->_config['properties'][$name]); |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
$this->config_decrypted = true; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
/** |
|
|
|
|
211
|
|
|
* Load config.php for this source |
212
|
|
|
*/ |
213
|
|
|
public function loadConfig() |
214
|
|
|
{ |
215
|
|
|
$config = array(); |
216
|
|
|
$dir = str_replace('_','/',get_class($this)); |
217
|
|
|
if(file_exists("modules/Connectors/connectors/sources/{$dir}/config.php")){ |
218
|
|
|
require("modules/Connectors/connectors/sources/{$dir}/config.php"); |
219
|
|
|
} |
220
|
|
|
if(file_exists("custom/modules/Connectors/connectors/sources/{$dir}/config.php")) { |
221
|
|
|
require("custom/modules/Connectors/connectors/sources/{$dir}/config.php"); |
222
|
|
|
} |
223
|
|
|
$this->_config = $config; |
224
|
|
|
|
225
|
|
|
//If there are no required config fields specified, we will default them to all be required |
226
|
|
|
if(empty($this->_required_config_fields)) { |
227
|
|
|
foreach($this->_config['properties'] as $id=>$value) { |
228
|
|
|
$this->_required_config_fields[] = $id; |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
// Helper function for the settings panels |
234
|
|
|
/** |
235
|
|
|
* Filter which modules are allowed to connect |
236
|
|
|
* @param array $moduleList |
237
|
|
|
* @return array Allowed modules |
238
|
|
|
*/ |
239
|
|
|
public function filterAllowedModules( $moduleList ) |
240
|
|
|
{ |
241
|
|
|
// Most modules can connect to everything, no further filtering necessary |
242
|
|
|
return $moduleList; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
////////////// GETTERS and SETTERS //////////////////// |
246
|
|
|
public function getMapping() |
247
|
|
|
{ |
248
|
|
|
return $this->_mapping; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
public function getOriginalMapping() { |
252
|
|
|
$mapping = array(); |
253
|
|
|
$dir = str_replace('_','/',get_class($this)); |
254
|
|
|
if(file_exists("modules/Connectors/connectors/sources/{$dir}/mapping.php")) { |
255
|
|
|
require("modules/Connectors/connectors/sources/{$dir}/mapping.php"); |
256
|
|
|
} else if(file_exists("custom/modules/Connectors/connectors/sources/{$dir}/mapping.php")){ |
257
|
|
|
require("custom/modules/Connectors/connectors/sources/{$dir}/mapping.php"); |
258
|
|
|
} |
259
|
|
|
return $mapping; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function setMapping($mapping) |
263
|
|
|
{ |
264
|
|
|
$this->_mapping = $mapping; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
public function getFieldDefs() |
268
|
|
|
{ |
269
|
|
|
return $this->_field_defs; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
public function getConfig() |
273
|
|
|
{ |
274
|
|
|
if(!$this->config_decrypted) $this->initConfig(); |
275
|
|
|
return $this->_config; |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
public function setConfig($config) |
279
|
|
|
{ |
280
|
|
|
$this->_config = $config; |
281
|
|
|
$this->config_decrypted = true; // Don't decrypt external configs |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
public function setEAPM(ExternalAPIBase $eapm) |
285
|
|
|
{ |
286
|
|
|
$this->_eapm = $eapm; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
public function getEAPM() |
290
|
|
|
{ |
291
|
|
|
return $this->_eapm; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
public function setProperties($properties=array()) |
295
|
|
|
{ |
296
|
|
|
if(!empty($this->_config) && isset($this->_config['properties'])) { |
297
|
|
|
$this->_config['properties'] = $properties; |
298
|
|
|
$this->config_decrypted = true; // Don't decrypt external configs |
299
|
|
|
} |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
public function getProperties() |
303
|
|
|
{ |
304
|
|
|
if(!empty($this->_config) && isset($this->_config['properties'])) { |
305
|
|
|
if(!$this->config_decrypted) $this->initConfig(); |
306
|
|
|
return $this->_config['properties']; |
307
|
|
|
} |
308
|
|
|
return array(); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Check if certain property contains non-empty value |
313
|
|
|
* @param string $name |
314
|
|
|
* @return bool |
315
|
|
|
*/ |
316
|
|
|
public function propertyExists($name) |
317
|
|
|
{ |
318
|
|
|
return !empty($this->_config['properties'][$name]); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
public function getProperty($name) |
322
|
|
|
{ |
323
|
|
|
if(!empty($this->_config) && isset($this->_config['properties'][$name])) { |
324
|
|
|
// check if we're asking for encrypted property and we didn't decrypt yet |
325
|
|
|
if(!$this->config_decrypted && !empty($this->_config['encrypt_properties']) && in_array($name, $this->_config['encrypt_properties']) && !empty($this->_config['properties'][$name])) { |
326
|
|
|
$this->initConfig(); |
327
|
|
|
} |
328
|
|
|
return $this->_config['properties'][$name]; |
329
|
|
|
} else { |
330
|
|
|
return ''; |
331
|
|
|
} |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
|
|
|
|
335
|
|
|
* hasTestingEnabled |
336
|
|
|
* This method is used to indicate whether or not a data source has testing enabled so that |
337
|
|
|
* the administration interface may call the test method on the data source instance |
338
|
|
|
* |
339
|
|
|
* @return enabled boolean value indicating whether or not testing is enabled |
340
|
|
|
*/ |
341
|
|
|
public function hasTestingEnabled() { |
342
|
|
|
return $this->_has_testing_enabled; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
|
|
|
|
346
|
|
|
* test |
347
|
|
|
* This method is called from the administration interface to run a test of the service |
348
|
|
|
* It is up to subclasses to implement a test and set _has_testing_enabled to true so that |
349
|
|
|
* a test button is rendered in the administration interface |
350
|
|
|
* |
351
|
|
|
* @return result boolean result of the test function |
352
|
|
|
*/ |
353
|
|
|
public function test() { |
354
|
|
|
return false; |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
|
358
|
|
|
/** |
359
|
|
|
* isEnabledInWizard |
360
|
|
|
* This method indicates whether or not the connector should be enabled in the wizard |
361
|
|
|
* Connectors that do not support the getList/getItem methods via API calls should |
362
|
|
|
* set the protected class variable _enable_in_wizard to false. |
363
|
|
|
* |
364
|
|
|
* @return $enabled boolean variable indicating whether or not the connector is enabled for the wizard |
|
|
|
|
365
|
|
|
*/ |
366
|
|
|
public function isEnabledInWizard() { |
367
|
|
|
return $this->_enable_in_wizard; |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* isEnabledInHover |
373
|
|
|
* This method indicates whether or not the connector should be enabled for the hover links |
374
|
|
|
* Connectors that do not provide a formatter implementation should not |
375
|
|
|
* set the protected class variable _enable_in_hover to true. |
376
|
|
|
* |
377
|
|
|
* @return $enabled boolean variable indicating whether or not the connector is enabled for the hover links |
|
|
|
|
378
|
|
|
* |
379
|
|
|
*/ |
380
|
|
|
public function isEnabledInHover() { |
381
|
|
|
return $this->_enable_in_hover; |
382
|
|
|
} |
383
|
|
|
|
384
|
|
|
/** |
385
|
|
|
* isEnabledInAdminProperties |
386
|
|
|
* This method indicates whether or not the connector should be shown in the Set Connector Properties view. |
387
|
|
|
* The Admin views call each source's isEnabledInAdminProperties method to verify whether or not the connector should be |
388
|
|
|
* displayed. Connectors that do not have any administrative properties should set the protected class variable |
389
|
|
|
* _enable_in_admin_properties to false. |
390
|
|
|
* |
391
|
|
|
* @return boolean value indicating whether or not the connector is enabled for admin views |
392
|
|
|
*/ |
393
|
|
|
public function isEnabledInAdminProperties() |
394
|
|
|
{ |
395
|
|
|
return $this->_enable_in_admin_properties; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* isEnabledInAdminMapping |
400
|
|
|
* This method indicates whether or not the connector should be shown in the Map Connector Fields view. |
401
|
|
|
* The Admin views call each source's isEnabledInAdminMapping method to verify whether or not the connector should be |
402
|
|
|
* displayed. Connectors that do not have any administrative mapping properties should set the protected class variable |
403
|
|
|
* _enable_in_admin_mapping to false. |
404
|
|
|
* |
405
|
|
|
* @return boolean value indicating whether or not the connector is enabled for admin views |
406
|
|
|
*/ |
407
|
|
|
public function isEnabledInAdminMapping() |
408
|
|
|
{ |
409
|
|
|
return $this->_enable_in_admin_mapping; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* isEnabledInAdminDisplay |
414
|
|
|
* This method indicates whether or not the connector should be shown in the Enable Connectors view. |
415
|
|
|
* The Admin views call each source's isEnabledInAdminDisplay method to verify whether or not the connector should be |
416
|
|
|
* displayed. Connectors that do not have any administrative display settings should set the protected class variable |
417
|
|
|
* _enable_in_admin_display to false. |
418
|
|
|
* |
419
|
|
|
* @return boolean value indicating whether or not the connector is enabled for admin views |
420
|
|
|
*/ |
421
|
|
|
public function isEnabledInAdminDisplay() |
422
|
|
|
{ |
423
|
|
|
return $this->_enable_in_admin_display; |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* isEnabledInAdminSearch |
428
|
|
|
* This method indicates whether or not the connector should be shown in the Manage Connectors Search view. |
429
|
|
|
* The Admin views call each source's isEnabledInAdminSearch method to verify whether or not the connector should be |
430
|
|
|
* displayed. Connectors that do not have any administrative search settings should set the protected class variable |
431
|
|
|
* _enable_in_admin_search to false. |
432
|
|
|
* |
433
|
|
|
* @return boolean value indicating whether or not the connector is enabled for admin views |
434
|
|
|
*/ |
435
|
|
|
public function isEnabledInAdminSearch() |
436
|
|
|
{ |
437
|
|
|
return $this->_enable_in_admin_search; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* getRequiredConfigFields |
442
|
|
|
* This method returns an Array of the configuration keys that are required for the Connector. |
443
|
|
|
* Subclasses should set the class variable _required_config_fields to |
444
|
|
|
* return an Array of keys as specified in the Connector's config.php that are required. |
445
|
|
|
* |
446
|
|
|
* @return $fields Array of Connector config fields that are required |
|
|
|
|
447
|
|
|
*/ |
448
|
|
|
public function getRequiredConfigFields() { |
449
|
|
|
return $this->_required_config_fields; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* isRequiredConfigFieldsSet |
455
|
|
|
* This method checks the configuration parameters against the required config fields |
456
|
|
|
* to see if they are set |
457
|
|
|
* |
458
|
|
|
* @return $set boolean value indicating whether or not the required config fields are set |
|
|
|
|
459
|
|
|
*/ |
460
|
|
|
public function isRequiredConfigFieldsSet() { |
461
|
|
|
//Check if required fields are set |
462
|
|
|
foreach($this->_required_config_fields as $field) { |
463
|
|
|
if(empty($this->_config['properties'][$field])) { |
464
|
|
|
return false; |
465
|
|
|
} |
466
|
|
|
} |
467
|
|
|
return true; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* getRequiredConfigFieldsForButton |
473
|
|
|
* This method returns an Array of the configuration keys that are required before the |
474
|
|
|
* "Get Data" button will include the Connector. We use it as a subset of the |
475
|
|
|
* $this->_required_config_fields Array. |
476
|
|
|
* |
477
|
|
|
* @return $fields Array of Connector config fields that are required to be set for the "Get Data" button to appear |
|
|
|
|
478
|
|
|
*/ |
479
|
|
|
public function getRequiredConfigFieldsForButton() { |
480
|
|
|
return $this->_required_config_fields_for_button; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
|
|
484
|
|
|
/** |
485
|
|
|
* isRequiredConfigFieldsForButtonSet |
486
|
|
|
* This method checks the configuration parameters against the required config fields |
487
|
|
|
* for the "Get Button" to see if they are set |
488
|
|
|
* |
489
|
|
|
* @return $set boolean value indicating whether or not the required config fields are set |
|
|
|
|
490
|
|
|
*/ |
491
|
|
|
public function isRequiredConfigFieldsForButtonSet() { |
492
|
|
|
//Check if required fields for button are set |
493
|
|
|
foreach($this->_required_config_fields_for_button as $field) { |
494
|
|
|
if(empty($this->_config['properties'][$field])) { |
495
|
|
|
return false; |
496
|
|
|
} |
497
|
|
|
} |
498
|
|
|
return true; |
499
|
|
|
} |
500
|
|
|
|
501
|
|
|
|
502
|
|
|
/** |
503
|
|
|
* Allow data sources to log information |
504
|
|
|
* |
505
|
|
|
* @param string $log_data |
506
|
|
|
*/ |
507
|
|
|
protected function log($log_data){ |
508
|
|
|
$name = get_class($this); |
509
|
|
|
$property_name = $this->getProperty('name'); |
510
|
|
|
if(!empty($property_name)){ |
511
|
|
|
$name = $property_name; |
512
|
|
|
} |
513
|
|
|
$GLOBALS['log']->info($name. ': '.$log_data); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
|
|
|
|
517
|
|
|
* getItem |
518
|
|
|
* Returns an array containing a key/value pair(s) of a connector record. To be overridden by the implementation |
519
|
|
|
* source. |
520
|
|
|
* |
521
|
|
|
* @param $args Array of arguments to search/filter by |
522
|
|
|
* @param $module String optional value of the module that the connector framework is attempting to map to |
523
|
|
|
* @return Array of key/value pair(s) of connector record; empty Array if no results are found |
524
|
|
|
*/ |
525
|
|
|
public abstract function getItem($args=array(), $module=null); |
|
|
|
|
526
|
|
|
|
527
|
|
|
|
528
|
|
|
/** |
|
|
|
|
529
|
|
|
* getList |
530
|
|
|
* Returns a nested array containing a key/value pair(s) of a connector record. To be overridden by the |
531
|
|
|
* implementation source. |
532
|
|
|
* |
533
|
|
|
* @param $args Array of arguments to search/filter by |
534
|
|
|
* @param $module String optional value of the module that the connector framework is attempting to map to |
535
|
|
|
* @return Array of key/value pair(s) of connector record; empty Array if no results are found |
536
|
|
|
*/ |
537
|
|
|
public abstract function getList($args=array(), $module=null); |
|
|
|
|
538
|
|
|
|
539
|
|
|
/** |
540
|
|
|
* Default destructor |
541
|
|
|
* |
542
|
|
|
*/ |
543
|
|
|
public function __destruct(){ |
544
|
|
|
// Bug # 47233 - This desctructor was originally removed by bug # 44533. |
545
|
|
|
// We have to add this destructor back in |
546
|
|
|
// because there are customers who upgrade from 61x to 623 |
547
|
|
|
// who have the Jigsaw connector enabled, and the jigsaw connector |
548
|
|
|
// makes a call to this destructor. |
549
|
|
|
|
550
|
|
|
} |
551
|
|
|
} |
552
|
|
|
|
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.