|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* class GridfieldInviteResendAction adds the resend button to the CMS for easy re-inviting |
|
5
|
|
|
*/ |
|
6
|
|
|
class GridfieldInviteResendAction implements GridField_ColumnProvider, GridField_ActionProvider |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @param GridField $gridField |
|
11
|
|
|
* @param array $columns |
|
12
|
|
|
*/ |
|
13
|
|
|
public function augmentColumns($gridField, &$columns) |
|
14
|
|
|
{ |
|
15
|
|
|
if (!in_array('Actions', $columns, true)) { |
|
16
|
|
|
$columns[] = 'Actions'; |
|
17
|
|
|
} |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* {@inheritDoc} |
|
22
|
|
|
*/ |
|
23
|
|
|
public function getColumnAttributes($gridField, $record, $columnName) |
|
24
|
|
|
{ |
|
25
|
|
|
return array('class' => 'col-buttons'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritDoc} |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getColumnMetadata($gridField, $columnName) |
|
32
|
|
|
{ |
|
33
|
|
|
if ($columnName === 'Actions') { |
|
34
|
|
|
return array('title' => ''); |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* {@inheritDoc} |
|
40
|
|
|
*/ |
|
41
|
|
|
public function getColumnsHandled($gridField) |
|
42
|
|
|
{ |
|
43
|
|
|
return array('Actions'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param GridField $gridField |
|
48
|
|
|
* @param SlackInvite $record |
|
49
|
|
|
* @param string $columnName |
|
50
|
|
|
* @return HTMLText |
|
|
|
|
|
|
51
|
|
|
*/ |
|
52
|
|
|
public function getColumnContent($gridField, $record, $columnName) |
|
53
|
|
|
{ |
|
54
|
|
|
$config = SiteConfig::current_site_config(); |
|
|
|
|
|
|
55
|
|
|
// No point in showing the re-send button, if there's no token |
|
56
|
|
|
if ($config->SlackToken) { |
|
57
|
|
|
if (!$record->Invited) { |
|
58
|
|
|
$field = GridField_FormAction::create( |
|
|
|
|
|
|
59
|
|
|
$gridField, |
|
60
|
|
|
'Retry' . $record->ID, |
|
61
|
|
|
false, |
|
62
|
|
|
'resend', |
|
63
|
|
|
['RecordID' => $record->ID] |
|
64
|
|
|
) |
|
65
|
|
|
->addExtraClass('gridfield-button-resend') |
|
66
|
|
|
->setAttribute('title', 'Retry invite') |
|
67
|
|
|
->setAttribute('data-icon', 'arrow-circle-135-left') |
|
68
|
|
|
->setDescription(_t('GridfieldInviteResendAction.Resend', 'Retry failed invitation')); |
|
|
|
|
|
|
69
|
|
|
} else { |
|
70
|
|
|
$field = GridField_FormAction::create( |
|
71
|
|
|
$gridField, |
|
72
|
|
|
'Resend', |
|
73
|
|
|
false, |
|
74
|
|
|
'resend', |
|
75
|
|
|
['RecordID' => $record->ID] |
|
76
|
|
|
) |
|
77
|
|
|
->addExtraClass('gridfield-button-resend') |
|
78
|
|
|
->setAttribute('title', 'Resend invite') |
|
79
|
|
|
->setAttribute('data-icon', 'arrow-circle-double') |
|
80
|
|
|
->setDescription('Resend invite'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $field->Field(); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* {@inheritDoc} |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getActions($gridField) |
|
91
|
|
|
{ |
|
92
|
|
|
return array('resend'); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @param GridField $gridField |
|
97
|
|
|
* @param $actionName |
|
98
|
|
|
* @param $arguments |
|
99
|
|
|
* @param $data |
|
100
|
|
|
* @throws \ValidationException |
|
101
|
|
|
*/ |
|
102
|
|
|
public function handleAction(GridField $gridField, $actionName, $arguments, $data) |
|
103
|
|
|
{ |
|
104
|
|
|
if ($actionName === 'resend') { |
|
105
|
|
|
/** @var SlackInvite $item */ |
|
106
|
|
|
$item = SlackInvite::get()->byID($arguments['RecordID']); |
|
107
|
|
|
if (!$item) { |
|
108
|
|
|
return; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$result = $item->resendInvite(); |
|
|
|
|
|
|
112
|
|
|
if ($result === true) { |
|
113
|
|
|
Controller::curr()->getResponse()->setStatusCode( |
|
|
|
|
|
|
114
|
|
|
200, |
|
115
|
|
|
'User successfully invited.' |
|
116
|
|
|
); |
|
117
|
|
|
} else { |
|
118
|
|
|
Controller::curr()->getResponse()->setStatusCode( |
|
119
|
|
|
200, |
|
120
|
|
|
$result |
|
121
|
|
|
); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths