These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Firesphere\PartialUserforms\Models; |
||
4 | |||
5 | use SilverStripe\Forms\FieldList; |
||
6 | use SilverStripe\Forms\GridField\GridField; |
||
7 | use SilverStripe\Forms\GridField\GridFieldConfig; |
||
8 | use SilverStripe\Forms\GridField\GridFieldDataColumns; |
||
9 | use SilverStripe\Forms\GridField\GridFieldExportButton; |
||
10 | use SilverStripe\Forms\GridField\GridFieldPrintButton; |
||
11 | use SilverStripe\ORM\DataObject; |
||
12 | use SilverStripe\UserForms\Model\Submission\SubmittedForm; |
||
13 | |||
14 | /** |
||
15 | * Class \Firesphere\PartialUserforms\Models\PartialFormSubmission |
||
16 | * |
||
17 | * @property boolean $IsSend |
||
18 | * @property int $UserDefinedFormID |
||
19 | * @method \SilverStripe\ORM\DataObject UserDefinedForm() |
||
20 | * @method \SilverStripe\ORM\DataList|\Firesphere\PartialUserforms\Models\PartialFieldSubmission[] PartialFields() |
||
21 | */ |
||
22 | class PartialFormSubmission extends SubmittedForm |
||
23 | { |
||
24 | private static $table_name = 'PartialFormSubmission'; |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
25 | |||
26 | private static $db = [ |
||
0 ignored issues
–
show
|
|||
27 | 'IsSend' => 'Boolean(false)' |
||
28 | ]; |
||
29 | |||
30 | private static $has_one = [ |
||
0 ignored issues
–
show
|
|||
31 | 'UserDefinedForm' => DataObject::class |
||
32 | ]; |
||
33 | |||
34 | private static $has_many = [ |
||
0 ignored issues
–
show
|
|||
35 | 'PartialFields' => PartialFieldSubmission::class |
||
36 | ]; |
||
37 | |||
38 | public function getCMSFields() |
||
39 | { |
||
40 | /** @var FieldList $fields */ |
||
41 | $fields = parent::getCMSFields(); |
||
42 | $fields->removeByName(['Values', 'IsSend', 'PartialFields']); |
||
43 | |||
44 | $values = GridField::create( |
||
45 | 'PartialFields', |
||
46 | _t(static::class . '.PARTIALFIELDS', 'Partial fields'), |
||
47 | $this->PartialFields()->sort('Created', 'ASC') |
||
48 | ); |
||
49 | |||
50 | $exportColumns = array( |
||
51 | 'Title' => 'Title', |
||
52 | 'ExportValue' => 'Value' |
||
53 | ); |
||
54 | |||
55 | $config = new GridFieldConfig(); |
||
56 | $config->addComponent(new GridFieldDataColumns()); |
||
57 | $config->addComponent(new GridFieldExportButton('after', $exportColumns)); |
||
58 | $config->addComponent(new GridFieldPrintButton()); |
||
59 | |||
60 | $values->setConfig($config); |
||
61 | |||
62 | $fields->addFieldToTab('Root.Main', $values); |
||
63 | |||
64 | return $fields; |
||
65 | } |
||
66 | |||
67 | public function getParent() |
||
68 | { |
||
69 | return $this->UserDefinedForm(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param Member |
||
74 | * |
||
75 | * @return boolean|string |
||
76 | */ |
||
77 | public function canCreate($member = null, $context = []) |
||
78 | { |
||
79 | if ($this->UserDefinedForm()) { |
||
80 | return $this->UserDefinedForm()->canCreate($member, $context); |
||
0 ignored issues
–
show
|
|||
81 | } |
||
82 | |||
83 | return parent::canCreate($member); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param Member |
||
88 | * |
||
89 | * @return boolean|string |
||
90 | */ |
||
91 | public function canView($member = null) |
||
92 | { |
||
93 | if ($this->UserDefinedForm()) { |
||
94 | return $this->UserDefinedForm()->canView($member); |
||
0 ignored issues
–
show
|
|||
95 | } |
||
96 | |||
97 | return parent::canView($member); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param Member |
||
102 | * |
||
103 | * @return boolean|string |
||
104 | */ |
||
105 | public function canEdit($member = null) |
||
106 | { |
||
107 | if ($this->UserDefinedForm()) { |
||
108 | return $this->UserDefinedForm()->canEdit($member); |
||
0 ignored issues
–
show
|
|||
109 | } |
||
110 | |||
111 | return parent::canEdit($member); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @param Member |
||
116 | * |
||
117 | * @return boolean|string |
||
118 | */ |
||
119 | public function canDelete($member = null) |
||
120 | { |
||
121 | if ($this->UserDefinedForm()) { |
||
122 | return $this->UserDefinedForm()->canDelete($member); |
||
0 ignored issues
–
show
|
|||
123 | } |
||
124 | |||
125 | return parent::canDelete($member); |
||
126 | } |
||
127 | } |
||
128 |