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_default_contact_fields( |
30
|
|
|
$fieldName = 'SalesforceDefaultContactFields', |
31
|
|
|
$title = 'Select Default Fields' |
32
|
|
|
) |
33
|
|
|
{ |
34
|
|
|
$count = SalesforceDefaultContactField::count(); |
|
|
|
|
35
|
|
|
if($count === 0) { |
36
|
|
|
return HiddenField::create( |
|
|
|
|
37
|
|
|
$fieldName, |
38
|
|
|
$title |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
return CheckboxSetField::create( |
42
|
|
|
$fieldName, |
43
|
|
|
$title, |
44
|
|
|
SalesforceDefaultContactField::get()->map()->toArray() |
45
|
|
|
) |
46
|
|
|
->setDescription(' |
47
|
|
|
Select the default fields that are always sent to Salesforce |
48
|
|
|
when a contact signs up from this page. |
49
|
|
|
<br /> |
50
|
|
|
<br /> |
51
|
|
|
You can |
52
|
|
|
<a href="/admin/salesforceadmin/'.SalesforceDefaultContactField::class.'/">Add or Edit the options</a> |
53
|
|
|
as required. |
54
|
|
|
Please change with care. |
55
|
|
|
'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
* @param array|DataList|null $array fields to send |
61
|
|
|
* @param string $title fields to send |
62
|
|
|
* |
63
|
|
|
* @return LiteralField |
64
|
|
|
*/ |
65
|
|
|
public static function fields_to_send_field( |
66
|
|
|
$mixed = null, |
67
|
|
|
$title = 'Fields Added' |
68
|
|
|
) |
69
|
|
|
{ |
70
|
|
|
$array = SalesforceDefaultContactField::get_fields_to_send($mixed); |
71
|
|
|
return LiteralField::create( |
72
|
|
|
'FieldsToSendToSalesforce', |
73
|
|
|
'<h2>'.$title.'</h2>'. |
74
|
|
|
self::array_to_html($array) |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
/** |
78
|
|
|
* |
79
|
|
|
* @param array|DataList|null $mixed fields to send |
80
|
|
|
* @param string $title fields to send |
81
|
|
|
* |
82
|
|
|
* @return LiteralField |
83
|
|
|
*/ |
84
|
|
|
public static function fields_to_filter_field( |
85
|
|
|
$mixed = null, |
86
|
|
|
$title = 'Filter Fields' |
87
|
|
|
) |
88
|
|
|
{ |
89
|
|
|
$array = SalesforceDefaultContactField::get_fields_to_send($mixed); |
90
|
|
|
return LiteralField::create( |
91
|
|
|
'FieldsToFilterForSalesforce', |
92
|
|
|
'<h2>'.$title.'</h2>'. |
93
|
|
|
self::array_to_html($array) |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* |
99
|
|
|
* @param [type] $array [description] |
|
|
|
|
100
|
|
|
* @return [type] [description] |
|
|
|
|
101
|
|
|
*/ |
102
|
|
|
protected static function array_to_html($array) : string |
103
|
|
|
{ |
104
|
|
|
$htmlArray = []; |
105
|
|
|
foreach($array as $field => $value) { |
106
|
|
|
$htmlArray[] = $field.' = '.$value.' ('.gettype($value).')'; |
107
|
|
|
} |
108
|
|
|
if(count($htmlArray) == 0) { |
109
|
|
|
$htmlArray[] = 'none'; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return '<p>- '.implode('</p><p> - ', $htmlArray).'</p>'; |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.