-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloseasanswered.php
69 lines (54 loc) · 1.48 KB
/
closeasanswered.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
<?php
require_once(INCLUDE_DIR.'class.signal.php');
require_once(INCLUDE_DIR.'class.plugin.php');
class CloseAsAnsweredPlugin extends Plugin {
var $log_activity = true;
var $config_class = 'CloseAsAnsweredConfig';
function bootstrap() {
$this->log_activity = $this->getConfig()->get('log_activity', true);
Signal::connect('object.edited', array($this, 'onObjectEdited'), 'Ticket');
}
function isMultiInstance() {
return false;
}
/**
* @global $ost
* @param Ticket $ticket
* @param Array $data
*/
function onObjectEdited($ticket, $data) {
global $ost;
if (isset($data['key']) && $data['key'] == 'status_id') {
try {
if ($ticket->isClosed() && !$ticket->isAnswered()) {
$ticket->markAnswered();
if ($this->log_activity) {
$ticket->logActivity(sprintf(__('Ticket Marked %s'), 'Answered'),
sprintf(__('Ticket flagged as %s by %s'), 'Answered', 'CloseAsAnsweredPlugin'));
}
}
} catch(Exception $e) {
$ost->logError('CloseAsAnsweredPlugin Exception', $e->getMessage());
}
}
}
}
class CloseAsAnsweredConfig extends PluginConfig {
function getOptions() {
return array(
'log_activity' => new BooleanField(array(
'label' => __('Log Activity'),
'default' => true,
'configuration' => array(
'desc' => __('Add a message to the activity log')
)
)),
);
}
function pre_save(&$config, &$errors) {
global $msg;
if (!$errors)
$msg = __('Configuration updated successfully');
return true;
}
}