forked from nbcommunication/WireMailgun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWireMailgunConfig.php
155 lines (132 loc) · 4.15 KB
/
WireMailgunConfig.php
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php namespace ProcessWire;
/**
* WireMail Mailgun Configuration
*
*/
class WireMailgunConfig extends ModuleConfig {
/**
* Returns default values for module variables
*
* @return array
*
*/
public function getDefaults() {
return [
"region" => "us",
"batchMode" => (int) $this->wire("modules")->isInstalled("ProMailer"),
"trackOpens" => 1,
"trackClicks" => 1,
];
}
/**
* Returns inputs for module configuration
*
* @return InputfieldWrapper
*
*/
public function getInputfields() {
$modules = $this->wire("modules");
$inputfields = parent::getInputfields();
$mgUrl = "https://app.mailgun.com/app";
$mgLink = "[Mailgun]($mgUrl/sending/domains)";
$hasProMailer = $modules->isInstalled("ProMailer");
// API Setup
$fieldset = $modules->get("InputfieldFieldset");
$fieldset->label = $this->_("API Setup");
$fieldset->icon = "key";
$fieldset->add([
"type" => "text",
"name" => "apiKey",
"label" => $this->_("Key"),
"notes" => sprintf($this->_("You can find your API Key on %s."), $mgLink),
"required" => true,
"columnWidth" => 40,
]);
$fieldset->add([
"type" => "text",
"name" => "domain",
"label" => $this->_("Domain Name"),
"notes" => sprintf($this->_("The domain name must be setup and verified on %s."), $mgLink),
"required" => true,
"columnWidth" => 40,
]);
$fieldset->add([
"type" => "radios",
"name" => "region",
"label" => $this->_("Region"),
"required" => true,
"columnWidth" => 20,
"optionColumns" => 1,
"options" => $modules->get("WireMailgun")::regions,
]);
$inputfields->add($fieldset);
// Default Sender
$fieldset = $modules->get("InputfieldFieldset");
$fieldset->label = $this->_("Default Sender");
$fieldset->icon = "envelope";
$fieldset->add([
"type" => "text",
"name" => "fromEmail",
"label" => $this->_("Email Address"),
"description" => $this->_("The *from* email address."),
"notes" => sprintf($this->_("When left empty, defaults to %s."), "*processwire@[domainName]*"),
"columnWidth" => 50,
]);
$fieldset->add([
"type" => "text",
"name" => "fromEmailName",
"label" => $this->_("Name"),
"description" => $this->_("The *from* email name."),
"notes" => sprintf($this->_("When left empty, defaults to %s."), "*ProcessWire*"),
"columnWidth" => 50,
]);
$inputfields->add($fieldset);
// Options
$fieldset = $modules->get("InputfieldFieldset");
$fieldset->label = $this->_("Options");
$fieldset->icon = "cog";
$fieldset->add([
"type" => "checkbox",
"name" => "trackOpens",
"label" => $this->_("Track Message Opens"),
"notes" => sprintf($this->_("Only enabled if %s is passed."), "`bodyHTML`"),
"columnWidth" => 50,
]);
$fieldset->add([
"type" => "checkbox",
"name" => "trackClicks",
"label" => $this->_("Track Message Clicks"),
"notes" => sprintf($this->_("Only enabled if %s is passed."), "`bodyHTML`"),
"columnWidth" => 50,
]);
$fieldset->add([
"type" => "checkbox",
"name" => "batchMode",
"label" => $this->_("Batch Mode"),
"description" => $this->_("When enabled, emails will be sent individually to each address."),
"notes" => ($hasProMailer ? sprintf($this->_('When %1$s is installed, %2$s is recommended.'), "`ProMailer`", "`batchMode`") . "\n" : "") .
sprintf($this->_("See %s method of this class for more information."), "`setBatchMode()`"),
"collapsed" => ($hasProMailer ? 0 : 2),
]);
$fieldset->add([
"type" => "checkbox",
"name" => "testMode",
"label" => $this->_("Enable Test Mode"),
"description" => $this->_("When enabled, Mailgun will accept messages but will not send them."),
"collapsed" => 2,
]);
$fieldset->add([
"type" => "checkbox",
"name" => "disableSslCheck",
"label" => $this->_("Disable cURL SSL Check"),
"description" => sprintf(
$this->_("This option will allow you to work around the following error: %s."),
"*cURL Error: SSL certificate problem: unable to get local issuer certificate*"
),
"notes" => $this->_("It is recommended that you leave this option unchecked on production servers."),
"collapsed" => 2,
]);
$inputfields->add($fieldset);
return $inputfields;
}
}