-
Notifications
You must be signed in to change notification settings - Fork 1
/
TicketList.php
95 lines (87 loc) · 2.82 KB
/
TicketList.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
<?php
require_once __DIR__ . '/EventHooks.php';
/**
* Overloads some of the parent's methods in order to define the plugin.
*
* @author François Gannaz <francois.gannaz@silecs.info>
*/
class TicketListPlugin extends MantisPlugin
{
use EventHooks;
/**
* Init the plugin attributes.
*/
public function register()
{
$this->name = 'Ticket List';
$this->description = "Plugin that displays the state of a list of issues.";
$this->page = 'index';
$this->version = '2.1';
$this->requires = [
'MantisCore' => '2.0.0',
];
$this->author = 'François Gannaz / Silecs';
$this->contact = 'francois.gannaz@silecs.info';
$this->url = '';
}
public function init()
{
// Autoload classes whose FQDN is ticketlist\**
spl_autoload_register(function ($className) {
if (strncmp($className, 'ticketlist\\', 11) === 0) {
$path = str_replace('\\', '/', substr($className, 11));
require __DIR__ . "/lib/{$path}.php";
}
});
}
/**
* Declare hooks on Mantis events.
*
* @return array
*/
public function hooks()
{
// Event hooks must be public methods of this plugin object.
// They will be called from an external function.
// See the trait EventHooks for the hook methods.
return [
'EVENT_CORE_HEADERS' => 'onBeforeOutput',
'EVENT_MENU_MAIN' => 'onMenu',
'EVENT_LAYOUT_RESOURCES' => 'addHtmlHeadContent',
];
}
/**
* Define the SQL schema of new tables.
*
* This is not mentionned in the official documentation,
* but appears in the parent class, MantisPlugin.
*
* I guess it is called at install time, and not for upgrades.
* But I haven't reverse engineered its usage.
*/
public function schema() {
return [
// operations
[
// first operation
'CreateTableSQL',
[
plugin_table('persistent'), // the table name
<<<EOTEXT
id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,
project_id I DEFAULT NULL UNSIGNED,
name C(255) NOTNULL DEFAULT '',
ids C(255) NOTNULL DEFAULT '',
history XL NOTNULL,
author_id I DEFAULT NULL UNSIGNED,
last_update T
EOTEXT
],
],
[
'CreateIndexSQL',
['persistent_name_u', plugin_table('persistent'), 'project_id, name', ['UNIQUE']],
]
];
}
}