1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* returns a bunch of form fields that inform the user about the configuration |
4
|
|
|
* of the connection and communication with Salesforce. |
5
|
|
|
*/ |
6
|
|
|
class MySalesforceConfigViewerApi extends Object |
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
public static function list_of_contact_record_types( |
10
|
|
|
$fieldName = 'ListOfContactRecordTypes', |
|
|
|
|
11
|
|
|
$title = 'Contact Record Types Available' |
12
|
|
|
) |
13
|
|
|
{ |
14
|
|
|
$data = MySalesforcePartnerApi::retrieve_contact_record_types(); |
|
|
|
|
15
|
|
|
|
16
|
|
|
return LiteralField::create( |
17
|
|
|
'ListOfContactRecordTypes', |
18
|
|
|
'<h2>'.$title.'</h2>'. |
19
|
|
|
'<pre>'.print_r($data).'</pre>' |
20
|
|
|
); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Needs to link to a many-many relationship (SalesforceDefaultContactFields) |
25
|
|
|
* @param array $array fields to send |
26
|
|
|
* |
27
|
|
|
* @return CheckboxSetField |
28
|
|
|
*/ |
29
|
|
|
public static function select_field( |
30
|
|
|
$fieldName = 'SalesforceDefaultContactFields', |
31
|
|
|
$title = 'Select Default Fields' |
32
|
|
|
) |
33
|
|
|
{ |
34
|
|
|
return CheckboxSetField::create( |
35
|
|
|
$fieldName, |
36
|
|
|
$title, |
37
|
|
|
SalesforceDefaultContactField::get()->map()->toArray() |
38
|
|
|
) |
39
|
|
|
->setDescription(' |
40
|
|
|
Select the default fields that are always sent to Salesforce |
41
|
|
|
when a contact signs up from this page. |
42
|
|
|
<br /> |
43
|
|
|
<br /> |
44
|
|
|
You can |
45
|
|
|
<a href="/admin/salesforceadmin/'.SalesforceDefaultContactField::class.'/">Add or Edit the options</a> |
46
|
|
|
as required. |
47
|
|
|
Please change with care. |
48
|
|
|
'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* |
53
|
|
|
* @param array|DataList|null $array fields to send |
54
|
|
|
* @param string $title fields to send |
55
|
|
|
* |
56
|
|
|
* @return LiteralField |
57
|
|
|
*/ |
58
|
|
|
public static function fields_to_send_field( |
59
|
|
|
$mixed = null, |
60
|
|
|
$title = 'Fields Added' |
61
|
|
|
) |
62
|
|
|
{ |
63
|
|
|
$array = SalesforceDefaultContactField::get_fields_to_send($mixed); |
64
|
|
|
return LiteralField::create( |
65
|
|
|
'FieldsToSendToSalesforce', |
66
|
|
|
'<h2>'.$title.'</h2>'. |
67
|
|
|
self::array_to_html($array) |
68
|
|
|
); |
69
|
|
|
} |
70
|
|
|
/** |
71
|
|
|
* |
72
|
|
|
* @param array|DataList|null $mixed fields to send |
73
|
|
|
* @param string $title fields to send |
74
|
|
|
* |
75
|
|
|
* @return LiteralField |
76
|
|
|
*/ |
77
|
|
|
public static function fields_to_filter_field( |
78
|
|
|
$mixed = null, |
79
|
|
|
$title = 'Filter Fields' |
80
|
|
|
) |
81
|
|
|
{ |
82
|
|
|
$array = SalesforceDefaultContactField::get_fields_to_send($mixed); |
83
|
|
|
return LiteralField::create( |
84
|
|
|
'FieldsToFilterForSalesforce', |
85
|
|
|
'<h2>'.$title.'</h2>'. |
86
|
|
|
self::array_to_html($array) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* |
92
|
|
|
* @param [type] $array [description] |
|
|
|
|
93
|
|
|
* @return [type] [description] |
|
|
|
|
94
|
|
|
*/ |
95
|
|
|
protected static function array_to_html($array) : string |
96
|
|
|
{ |
97
|
|
|
$htmlArray = []; |
98
|
|
|
foreach($array as $field => $value) { |
99
|
|
|
$htmlArray[] = $field.' = '.$value.' ('.gettype($value).')'; |
100
|
|
|
} |
101
|
|
|
if(count($htmlArray) == 0) { |
102
|
|
|
$htmlArray[] = 'none'; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return '<p>- '.implode('</p><p> - ', $htmlArray).'</p>'; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.