-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hook.php
47 lines (43 loc) · 1.21 KB
/
Hook.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
<?php
namespace Acms\Plugins\Slack;
use ACMS_POST_Form_Submit;
class Hook
{
/**
* POSTモジュール処理前
* $thisModuleのプロパティを参照・操作するなど
*
* @param \ACMS_POST $thisModule
*/
public function afterPostFire($thisModule)
{
if (!($thisModule instanceof ACMS_POST_Form_Submit)) {
return;
}
$formCode = $thisModule->Post->get('id');
if(!$formCode) {
return;
}
$info = $thisModule->loadForm($formCode);
if($info['data']->getChild('mail')->get('slack_void') !== 'on') {
return;
}
if (!$thisModule->Post->isValidAll()) {
return;
}
$step = $thisModule->Post->get('error');
if (empty($step)) {
$step = $thisModule->Get->get('step');
}
$step = $thisModule->Post->get('step', $step);
if (in_array($step, array('forbidden', 'repeated'))) {
return;
}
try {
$engine = new Engine($formCode, $thisModule);
$engine->send();
} catch (\Exception $e) {
userErrorLog('ACMS Warning: Slack plugin, ' . $e->getMessage());
}
}
}