-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathContactRecipientGridView.class.php
More file actions
114 lines (103 loc) · 3.79 KB
/
ContactRecipientGridView.class.php
File metadata and controls
114 lines (103 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace wcf\system\gridView\admin;
use wcf\acp\form\ContactRecipientEditForm;
use wcf\data\contact\recipient\ContactRecipient;
use wcf\data\contact\recipient\ContactRecipientList;
use wcf\event\gridView\admin\ContactRecipientGridViewInitialized;
use wcf\system\gridView\AbstractGridView;
use wcf\system\gridView\filter\I18nTextFilter;
use wcf\system\gridView\filter\NumericFilter;
use wcf\system\gridView\filter\ObjectIdFilter;
use wcf\system\gridView\GridViewColumn;
use wcf\system\gridView\GridViewRowLink;
use wcf\system\gridView\renderer\EmailColumnRenderer;
use wcf\system\gridView\renderer\NumberColumnRenderer;
use wcf\system\gridView\renderer\ObjectIdColumnRenderer;
use wcf\system\gridView\renderer\PhraseColumnRenderer;
use wcf\system\interaction\admin\ContactRecipientInteractions;
use wcf\system\interaction\Divider;
use wcf\system\interaction\EditInteraction;
use wcf\system\interaction\ToggleInteraction;
use wcf\system\WCF;
/**
* Grid view for the list of contact recipients.
*
* @author Olaf Braun
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*
* @extends AbstractGridView<ContactRecipient, ContactRecipientList>
*/
final class ContactRecipientGridView extends AbstractGridView
{
public function __construct()
{
$this->addColumns([
GridViewColumn::for("recipientID")
->label("wcf.global.objectID")
->renderer(new ObjectIdColumnRenderer())
->filter(new ObjectIdFilter())
->sortable(),
GridViewColumn::for("name")
->label("wcf.global.name")
->filter(new I18nTextFilter())
->titleColumn()
->renderer(new PhraseColumnRenderer())
->sortable(sortByDatabaseColumn: $this->subqueryName()),
GridViewColumn::for("email")
->label("wcf.user.email")
->renderer(new EmailColumnRenderer())
->sortable(),
GridViewColumn::for("showOrder")
->label("wcf.acp.customOption.showOrder")
->filter(new NumericFilter())
->renderer(new NumberColumnRenderer())
->sortable(),
]);
$provider = new ContactRecipientInteractions();
$provider->addInteractions([
new Divider(),
new EditInteraction(ContactRecipientEditForm::class),
]);
$this->setInteractionProvider($provider);
$this->addQuickInteraction(
new ToggleInteraction(
"isDisabled",
"core/contact/recipients/%s/enable",
"core/contact/recipients/%s/disable"
)
);
$this->addRowLink(new GridViewRowLink(ContactRecipientEditForm::class));
$this->setDefaultSortField("showOrder");
$this->setDefaultSortOrder("ASC");
}
#[\Override]
public function isAccessible(): bool
{
return \MODULE_CONTACT_FORM
&& WCF::getSession()->getPermission("admin.contact.canManageContactForm");
}
#[\Override]
protected function createObjectList(): ContactRecipientList
{
return new ContactRecipientList();
}
private function subqueryName(): string
{
$languageID = WCF::getLanguage()->languageID;
return "
COALESCE((
SELECT languageItemValue
FROM wcf1_language_item
WHERE languageItem = contact_recipient.name
AND languageID = {$languageID}
), contact_recipient.name)
";
}
#[\Override]
protected function getInitializedEvent(): ContactRecipientGridViewInitialized
{
return new ContactRecipientGridViewInitialized($this);
}
}