forked from clonemeagain/osticket-slack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
76 lines (69 loc) · 3.08 KB
/
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
<?php
require_once INCLUDE_DIR . 'class.plugin.php';
class SlackPluginConfig extends PluginConfig {
// Provide compatibility function for versions of osTicket prior to
// translation support (v1.9.4)
function translate() {
if (!method_exists('Plugin', 'translate')) {
return array(
function ($x) {
return $x;
},
function ($x, $y, $n) {
return $n != 1 ? $y : $x;
}
);
}
return Plugin::translate('slack');
}
function pre_save($config, &$errors) {
if ($config['slack-regex-subject-ignore'] && false === @preg_match("/{$config['slack-regex-subject-ignore']}/i", null)) {
$errors['err'] = 'Your regex was invalid, try something like "spam", it will become: "/spam/i" when we use it.';
return FALSE;
}
return TRUE;
}
function getOptions() {
list ($__, $_N) = self::translate();
return array(
'slack' => new SectionBreakField(array(
'label' => $__('Slack notifier'),
'hint' => $__('Readme first: https://github.com/clonemeagain/osticket-slack')
)),
'slack-webhook-url' => new TextboxField(array(
'label' => $__('Webhook URL'),
'configuration' => array(
'size' => 100,
'length' => 200
),
)),
'slack-regex-subject-ignore' => new TextboxField([
'label' => $__('Ignore when subject equals regex'),
'hint' => $__('Auto delimited, always case-insensitive'),
'configuration' => [
'size' => 30,
'length' => 200
],
]),
'slack-update-types' => new ChoiceField([
'label' => $__('Update Types'),
'hint' => $__('What types of updates should be sent via Slack?'),
'choices' => array('both' => 'New & Updated Tickets', 'updatesOnly' => 'Only Ticket Updates', 'newOnly' => 'Only New Tickets'),
'default' => 'both',
'configuration' => [
'size' => 30,
'length' => 200
],
]),
'message-template' => new TextareaField([
'label' => $__('Message Template'),
'hint' => $__('The main text part of the Slack message, uses Ticket Variables, for what the user typed, use variable: %{slack_safe_message}'),
// "<%{url}/scp/tickets.php?id=%{ticket.id}|%{ticket.subject}>\n" // Already included as Title
'default' => "%{ticket.name.full} (%{ticket.email}) in *%{ticket.dept}* _%{ticket.topic}_\n\n```%{slack_safe_message}```",
'configuration' => [
'html' => FALSE,
]
])
);
}
}