-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_config.php
338 lines (235 loc) · 11 KB
/
admin_config.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
// Generated e107 Plugin Admin Area
require_once('../../class2.php');
if (!getperms('P'))
{
e107::redirect('admin');
exit;
}
// e107::lan('mailfloss',true);
class mailfloss_adminArea extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'mailfloss_ui',
'path' => null,
'ui' => 'mailfloss_form_ui',
'uipath' => null
),
);
protected $adminMenu = array(
'main/list' => array('caption'=> "Log", 'perm' => 'P'),
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'),
// 'main/div0' => array('divider'=> true),
'main/test' => array('caption'=> 'Test', 'perm' => 'P'),
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);
protected $menuTitle = 'Mailfloss';
}
class mailfloss_ui extends e_admin_ui
{
protected $pluginTitle = 'Mailfloss';
protected $pluginName = 'mailfloss';
// protected $eventName = 'mailfloss-mailfloss'; // remove comment to enable event triggers in admin.
protected $table = 'mailfloss';
protected $pid = 'mailfloss_id';
protected $perPage = 10;
protected $batchDelete = true;
protected $batchExport = true;
// protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $sortParent = 'somefield_parent';
// protected $treePrefix = 'somefield_title';
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = 'mailfloss_id DESC';
protected $fields = array (
'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => 'value', 'class' => 'center', 'toggle' => 'e-multiselect', 'readParms' => array (), 'writeParms' => array (),),
'mailfloss_id' => array ( 'title' => LAN_ID, 'type'=>'number', 'data' => 'int', 'width' => '5%', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_date' => array ( 'title' => LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'filter'=>true, 'width' => 'auto', 'readonly' => '1', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_email' => array ( 'title' => LAN_EMAIL, 'type' => 'email', 'data' => 'safestr', 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_suggestion' => array ( 'title' => 'Suggestion', 'type' => 'text', 'data' => 'safestr', 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_status' => array ( 'title' => 'Status', 'type' => 'method', 'data' => 'safestr', 'filter'=>true, 'batch'=>true, 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_reason' => array ( 'title' => 'Reason', 'type' => 'text', 'data' => 'safestr', 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_role' => array ( 'title' => 'Role', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'filter' => 'value', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_disposable' => array ( 'title' => 'Disposable', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'filter' => 'value', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_free' => array ( 'title' => 'Free', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'filter' => 'value', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_passed' => array ( 'title' => 'Passed', 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'inline'=>true, 'filter' => true, 'batch'=>true, 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_domain' => array ( 'title' => 'Domain', 'type' => 'text', 'data' => 'safestr', 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'mailfloss_meta' => array ( 'title' => 'Meta', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left', 'filter' => false, 'batch' => false,),
'mailfloss_uri' => array ( 'title' => 'URI', 'type' => 'text', 'data' => 'safestr', 'width' => 'auto', 'readonly' => 'value', 'help' => '', 'readParms' => array (), 'writeParms' => array (), 'class' => 'left', 'thclass' => 'left',),
'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => 'value', 'readParms' => array (), 'writeParms' => array (),),
);
protected $fieldpref = array();
// protected $preftabs = array('General', 'Other' );
protected $prefs = array(
'active' => array('title'=> 'Active', 'tab'=>0, 'type'=>'boolean', 'data' => 'str', 'help'=>'When enabled mailfloss will be used for email validation', 'writeParms' => array()),
'apikey' => array('title'=> 'Apikey', 'tab'=>0, 'type'=>'text', 'data' => 'str', 'help'=>'Enter your mailfloss api key', 'writeParms' => array()),
'unknown' => array('title'=> 'Accept Unknown', 'tab'=>0, 'type'=>'bool', 'data' => 'int', 'help'=>"When enabled will mark an unknown email as 'passed'", 'writeParms' => array()),
);
public function init()
{
// This code may be removed once plugin development is complete.
if(!e107::isInstalled('mailfloss'))
{
e107::getMessage()->addWarning("This plugin is not yet installed. Saving and loading of preference or table data will fail.");
}
// Set drop-down values (if any).
}
// ------- Customize Create --------
public function beforeCreate($new_data,$old_data)
{
return $new_data;
}
public function afterCreate($new_data, $old_data, $id)
{
// do something
}
public function onCreateError($new_data, $old_data)
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate($new_data, $old_data, $id)
{
return $new_data;
}
public function afterUpdate($new_data, $old_data, $id)
{
// do something
}
public function onUpdateError($new_data, $old_data, $id)
{
// do something
}
// left-panel help menu area. (replaces e_help.php used in old plugins)
public function renderHelp()
{
/* $caption = LAN_HELP;
$text = 'Some help text';
return array('caption'=>$caption,'text'=> $text);*/
}
// optional - a custom page.
public function testPage()
{
if(!empty($_POST['testGo']))
{
$result = mailfloss_module::getResponse($_POST['testEmail']);
e107::getMessage()->setTitle("Result",E_MESSAGE_INFO)->addInfo($result);
$arr = e107::unserialize($result);
mailfloss_module::log($arr);
}
$frm = $this->getUI();
$text = $frm->open('test');
$text .= "<div class='input-group input-xlarge'>";
$text .= $frm->text('testEmail', '', 80, ['size'=>'xlarge','placeholder'=>'[email protected]']);
$text .= "<span class='input-group-btn'>";
$text .= $frm->button('testGo', LAN_TEST, 'submit', '', ['class'=>'btn btn-primary']);
$text .= "</span>";
$text .= "</div>";
$text .= $frm->close();
return $text;
}
/*
// Handle batch options as defined in mailfloss_form_ui::mailfloss_meta; 'handle' + action + field + 'Batch'
// @important $fields['mailfloss_meta']['batch'] must be true for this method to be detected.
// @param $selected
// @param $type
function handleListMailflossMetaBatch($selected, $type)
{
$ids = implode(',', $selected);
switch($type)
{
case 'custombatch_1':
// do something
e107::getMessage()->addSuccess('Executed custombatch_1');
break;
case 'custombatch_2':
// do something
e107::getMessage()->addSuccess('Executed custombatch_2');
break;
}
}
// Handle filter options as defined in mailfloss_form_ui::mailfloss_meta; 'handle' + action + field + 'Filter'
// @important $fields['mailfloss_meta']['filter'] must be true for this method to be detected.
// @param $selected
// @param $type
function handleListMailflossMetaFilter($type)
{
$this->listOrder = 'mailfloss_meta ASC';
switch($type)
{
case 'customfilter_1':
// return ' mailfloss_meta != 'something' ';
e107::getMessage()->addSuccess('Executed customfilter_1');
break;
case 'customfilter_2':
// return ' mailfloss_meta != 'something' ';
e107::getMessage()->addSuccess('Executed customfilter_2');
break;
}
}
*/
}
class mailfloss_form_ui extends e_admin_form_ui
{
private $mailflossStatus = [];
function init()
{
if($d = e107::getDb()->retrieve('mailfloss','mailfloss_status','GROUP BY mailfloss_status ORDER BY mailfloss_status',true))
{
foreach($d as $row)
{
if($val = $row['mailfloss_status'])
{
$this->mailflossStatus[$val] = $val;
}
}
}
}
// Custom Method/Function
function mailfloss_meta($curVal,$mode)
{
switch($mode)
{
case 'read': // List Page
return $curVal;
break;
case 'write': // Edit Page
return $this->text('mailfloss_meta',$curVal, 255, 'size=large');
break;
case 'filter':
return array('customfilter_1' => 'Custom Filter 1', 'customfilter_2' => 'Custom Filter 2');
break;
case 'batch':
return array('custombatch_1' => 'Custom Batch 1', 'custombatch_2' => 'Custom Batch 2');
break;
}
return null;
}
function mailfloss_status($curVal,$mode)
{
switch($mode)
{
case 'read': // List Page
return $curVal;
break;
case 'write': // Edit Page
return $this->select('mailfloss_meta',$this->mailflossStatus,$curVal, 'size=large');
break;
case 'filter':
case 'batch':
return $this->mailflossStatus;
break;
}
return null;
}
}
new mailfloss_adminArea();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php");
exit;