1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class ContactFormSubmission extends DataObject |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* @var array |
7
|
|
|
*/ |
8
|
|
|
private static $db = array( |
9
|
|
|
'Name' => 'Varchar(100)', |
10
|
|
|
'Email' => 'Varchar(255)', |
11
|
|
|
'Phone' => 'Varchar(20)', |
12
|
|
|
'Comment' => 'Text', |
13
|
|
|
'Created' => 'SS_DateTime', |
14
|
|
|
); |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var array |
18
|
|
|
*/ |
19
|
|
|
private static $has_one = array( |
20
|
|
|
'Product' => 'ChardProduct', |
21
|
|
|
); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private static $default_sort = 'Created DESC'; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var array |
30
|
|
|
*/ |
31
|
|
|
private static $summary_fields = array( |
32
|
|
|
'Name' => 'Name', |
33
|
|
|
'Email' => 'Email', |
34
|
|
|
'Phone' => 'Phone', |
35
|
|
|
'Product.Title' => 'Product', |
36
|
|
|
'Created.NiceUS' => 'Date', |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var array |
41
|
|
|
*/ |
42
|
|
|
private static $searchable_fields = array( |
43
|
|
|
'Name', |
44
|
|
|
'Email', |
45
|
|
|
'Phone', |
46
|
|
|
'Comment', |
47
|
|
|
'Product.ID' => array( |
48
|
|
|
'title' => 'Product', |
49
|
|
|
), |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
public function getCMSFields() |
53
|
|
|
{ |
54
|
|
|
$fields = parent::getCMSFields(); |
55
|
|
|
|
56
|
|
|
$fields->removeByName(array( |
57
|
|
|
'ProductID' |
58
|
|
|
)); |
59
|
|
|
|
60
|
|
|
$fields->addFieldToTab( |
61
|
|
|
'Root.Main', |
62
|
|
|
DropdownField::create('ProductID', 'Product', ChardProduct::get()->map()), |
63
|
|
|
'Created' |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
return $fields; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Set permissions, allow all users to access by default. |
71
|
|
|
* Override in descendant classes, or use PermissionProvider. |
72
|
|
|
*/ |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param null $member |
76
|
|
|
* |
77
|
|
|
* @return bool |
78
|
|
|
*/ |
79
|
|
|
public function canCreate($member = null) |
80
|
|
|
{ |
81
|
|
|
return true; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param null $member |
86
|
|
|
* |
87
|
|
|
* @return bool |
88
|
|
|
*/ |
89
|
|
|
public function canView($member = null) |
90
|
|
|
{ |
91
|
|
|
return true; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param null $member |
96
|
|
|
* |
97
|
|
|
* @return bool |
98
|
|
|
*/ |
99
|
|
|
public function canEdit($member = null) |
100
|
|
|
{ |
101
|
|
|
return false; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param null $member |
106
|
|
|
* |
107
|
|
|
* @return bool |
108
|
|
|
*/ |
109
|
|
|
public function canDelete($member = null) |
110
|
|
|
{ |
111
|
|
|
return true; |
112
|
|
|
} |
113
|
|
|
} |
This check marks private properties in classes that are never used. Those properties can be removed.