forked from mantisbt-plugins/Announce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnnounce.php
106 lines (89 loc) · 2.87 KB
/
Announce.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
<?php
# Copyright (c) 2010 John Reese
# Copyright (c) 2017 Damien Regad
# Licensed under the MIT license
class AnnouncePlugin extends MantisPlugin {
function register() {
$this->name = plugin_lang_get("plugin_title");
$this->description = plugin_lang_get("plugin_description");
$this->page = 'config_page';
$this->version = "2.1.0";
$this->requires = array(
"MantisCore" => "2.0.0",
);
$this->author = "John Reese";
$this->contact = "[email protected]";
$this->url = "https://github.com/mantisbt-plugins/Announce";
}
function config() {
return array(
"manage_threshold" => MANAGER,
);
}
function hooks() {
return array(
"EVENT_CORE_READY" => "api",
"EVENT_LAYOUT_RESOURCES" => "resources",
"EVENT_MENU_MANAGE" => "menu_manage",
"EVENT_LAYOUT_BODY_BEGIN" => "body_begin",
);
}
function api() {
require_once("api/base.php");
require_once("api/message.php");
require_once("api/context.php");
require_once("api/dismiss.php");
}
function resources($event) {
return '<link rel="stylesheet" type="text/css" href="'.plugin_file("announce.css").'"/>
<script type="text/javascript" src="'.plugin_file("announce.js").'"></script>';
}
function menu_manage($event, $user_id) {
if (access_has_global_level(plugin_config_get("manage_threshold"))) {
$page = plugin_page("list");
$label = plugin_lang_get("list_title");
return "<a href=\"{$page}\">{$label}</a>";
}
}
function body_begin() {
Announce::display("header", null, "announcement-header");
}
function schema() {
require_once("api/install.php");
return array(
# 2010-04-08
array( "CreateTableSQL", array( plugin_table( "message" ), "
id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,
timestamp I NOTNULL UNSIGNED,
title C(100) NOTNULL,
message XL NOTNULL
",
array( "mysql" => "DEFAULT CHARSET=utf8" ) ) ),
array( "CreateTableSQL", array( plugin_table( "context" ), "
id I NOTNULL UNSIGNED AUTOINCREMENT PRIMARY,
message_id I NOTNULL UNSIGNED,
project_id I NOTNULL UNSIGNED,
location C(20) NOTNULL,
access I NOTNULL UNSIGNED,
ttl I NOTNULL UNSIGNED DEFAULT \" '0' \",
dismissable L NOTNULL
",
array( "mysql" => "DEFAULT CHARSET=utf8" ) ) ),
array( "CreateTableSQL", array( plugin_table( "dismissed" ), "
context_id I NOTNULL UNSIGNED PRIMARY,
user_id I NOTNULL UNSIGNED PRIMARY
",
array( "mysql" => "DEFAULT CHARSET=utf8" ) ) ),
# 2010-04-14
array( "CreateIndexSQL", array( "idx_plugin_announce_context",
plugin_table( "context" ), "message_id, project_id, location", array( "UNIQUE" ) ) ),
# 2014-03-18
array( 'AddColumnSQL', array( plugin_table( 'dismissed' ),
"timestamp I NOTNULL UNSIGNED DEFAULT 0
",
array( "mysql" => "DEFAULT CHARSET=utf8" ) ) ),
# 2017-10-26 - v2.2.0
array( 'UpdateFunction', 'delete_orphans_dismissals' ),
);
}
}