1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use SForce\Wsdl\SaveResult; |
4
|
|
|
|
5
|
|
|
class SalesforceContactLog extends DataObject |
6
|
|
|
{ |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* create contact log |
10
|
|
|
* @param string $type |
11
|
|
|
* @param array $fieldsSent |
12
|
|
|
* @param array $filters |
13
|
|
|
* |
14
|
|
|
* @return SalesforceContactLog |
15
|
|
|
*/ |
16
|
|
|
public static function create_contact_log($type, array $fieldsSent, array $filters) : SalesforceContactLog |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
$fieldsSent = serialize($fieldsSent); |
19
|
|
|
$filters = serialize($fieldsSent); |
20
|
|
|
$obj = SalesforceContactLog::create( |
21
|
|
|
[ |
22
|
|
|
'Type' => $type, |
23
|
|
|
'FieldsSent' => $fieldsSent, |
24
|
|
|
'Filters' => $filters, |
25
|
|
|
] |
26
|
|
|
); |
27
|
|
|
$id = $obj->write(); |
28
|
|
|
|
29
|
|
|
return SalesforceContactLog::get()->byID($id); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* returns true if the contact update was successful |
34
|
|
|
* @param mixed $response |
35
|
|
|
* |
36
|
|
|
* @return bool |
37
|
|
|
*/ |
38
|
|
|
public function confirmContactLog($response) : bool |
39
|
|
|
{ |
40
|
|
|
$id = ''; |
|
|
|
|
41
|
|
|
$errors = ''; |
|
|
|
|
42
|
|
|
print_r($response); |
43
|
|
|
die(); |
|
|
|
|
44
|
|
|
$this->SalesforceIdentifier = $id; |
|
|
|
|
45
|
|
|
$this->Errors = $errors; |
46
|
|
|
$this->write(); |
47
|
|
|
|
48
|
|
|
return $this->hasError(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function hasError() : bool |
52
|
|
|
{ |
53
|
|
|
return $this->SalesforceIdentifier ? false : true; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Singular name for CMS |
58
|
|
|
* @var string |
59
|
|
|
*/ |
60
|
|
|
private static $singular_name = 'Sales Force Contact Log'; |
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Plural name for CMS |
64
|
|
|
* @var string |
65
|
|
|
*/ |
66
|
|
|
private static $plural_name = 'Sales Force Contact Log Entries'; |
|
|
|
|
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* SS4 prep! |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
private static $table_name = 'SalesforceContactLog'; |
|
|
|
|
73
|
|
|
|
74
|
|
|
private static $db = [ |
|
|
|
|
75
|
|
|
'SalesforceIdentifier' => 'Varchar(40)', |
76
|
|
|
'Type' => 'Enum("Created,Updated")', |
77
|
|
|
'FieldsSent' => 'Text', |
78
|
|
|
'Filters' => 'Text', |
79
|
|
|
'Errors' => 'Text', |
80
|
|
|
]; |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
private static $default_sort = [ |
|
|
|
|
84
|
|
|
'ID' => 'DESC' |
85
|
|
|
]; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Defines a default list of filters for the search context |
89
|
|
|
* @var array |
90
|
|
|
*/ |
91
|
|
|
private static $searchable_fields = [ |
|
|
|
|
92
|
|
|
'Type' => 'ExactMatchFilter', |
93
|
|
|
'SalesforceIdentifier' => 'PartialMatchField', |
94
|
|
|
'FieldsSent' => 'PartialMatchField', |
95
|
|
|
'Filters' => 'PartialMatchField', |
96
|
|
|
'Errors' => 'PartialMatchField', |
97
|
|
|
]; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Defines summary fields commonly used in table columns |
101
|
|
|
* as a quick overview of the data for this dataobject |
102
|
|
|
* @var array |
103
|
|
|
*/ |
104
|
|
|
private static $summary_fields = [ |
|
|
|
|
105
|
|
|
'SalesforceIdentifier' => 'SF ID', |
106
|
|
|
'Type' => 'Type', |
107
|
|
|
'Errors' => 'Errors' |
108
|
|
|
]; |
109
|
|
|
|
110
|
|
|
private static $indexes = [ |
|
|
|
|
111
|
|
|
'SalesforceIdentifier' => true |
112
|
|
|
]; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* CMS Fields |
116
|
|
|
* @return FieldList |
117
|
|
|
*/ |
118
|
|
|
public function getCMSFields() |
119
|
|
|
{ |
120
|
|
|
$fields = parent::getCMSFields(); |
121
|
|
|
$fields->addFieldsToTab( |
122
|
|
|
'Root.Main', |
123
|
|
|
[ |
124
|
|
|
ReadonlyField::create( |
125
|
|
|
'SalesforceIdentifier', |
126
|
|
|
'Sales Force Identifier' |
127
|
|
|
), |
128
|
|
|
ReadonlyField::create( |
129
|
|
|
'FieldsSent', |
130
|
|
|
'Fields Sent', |
131
|
|
|
$this->serializedToHTML($this->FieldsSent) |
|
|
|
|
132
|
|
|
), |
133
|
|
|
ReadonlyField::create( |
134
|
|
|
'Type', |
135
|
|
|
'Type' |
136
|
|
|
), |
137
|
|
|
ReadonlyField::create( |
138
|
|
|
'Filters', |
139
|
|
|
'Filters', |
140
|
|
|
$this->serializedToHTML($this->Filters) |
|
|
|
|
141
|
|
|
), |
142
|
|
|
ReadonlyField::create( |
143
|
|
|
'Errors', |
144
|
|
|
'Communication Errors' |
145
|
|
|
)->setRightTitle('Separated by three ||| symbols.') |
146
|
|
|
] |
147
|
|
|
); |
148
|
|
|
|
149
|
|
|
return $fields; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* DataObject create permissions |
154
|
|
|
* @param Member $member |
155
|
|
|
* @return bool |
156
|
|
|
*/ |
157
|
|
|
public function canCreate($member = null) |
158
|
|
|
{ |
159
|
|
|
return false; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* DataObject edit permissions |
164
|
|
|
* @param Member $member |
165
|
|
|
* @return bool |
166
|
|
|
*/ |
167
|
|
|
public function canEdit($member = null) |
168
|
|
|
{ |
169
|
|
|
return false; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* DataObject delete permissions |
174
|
|
|
* @param Member $member |
175
|
|
|
* @return bool |
176
|
|
|
*/ |
177
|
|
|
public function canDelete($member = null) |
178
|
|
|
{ |
179
|
|
|
return false; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* |
184
|
|
|
* @param string $serializedString (serialised data) |
185
|
|
|
* @return string (html) |
186
|
|
|
*/ |
187
|
|
|
protected function serializedToHTML($serializedString) |
188
|
|
|
{ |
189
|
|
|
$s = unserialize($serializedString); |
190
|
|
|
|
191
|
|
|
return '<pre>'.print_r($s, 1).'</pre>'; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
} |
195
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.