1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* Ideas extension for the phpBB Forum Software package. |
5
|
|
|
* |
6
|
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com> |
7
|
|
|
* @license GNU General Public License, version 2 (GPL-2.0) |
8
|
|
|
* |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace phpbb\ideas; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* This ext class is optional and can be omitted if left empty. |
15
|
|
|
* However, you can add special (un)installation commands in the |
16
|
|
|
* methods enable_step(), disable_step() and purge_step(). As it is, |
17
|
|
|
* these methods are defined in \phpbb\extension\base, which this |
18
|
|
|
* class extends, but you can overwrite them to give special |
19
|
|
|
* instructions for those cases. |
20
|
|
|
*/ |
21
|
|
|
class ext extends \phpbb\extension\base |
22
|
|
|
{ |
23
|
|
|
public const SORT_AUTHOR = 'author'; |
24
|
|
|
public const SORT_DATE = 'date'; |
25
|
|
|
public const SORT_NEW = 'new'; |
26
|
|
|
public const SORT_SCORE = 'score'; |
27
|
|
|
public const SORT_TITLE = 'title'; |
28
|
|
|
public const SORT_TOP = 'top'; |
29
|
|
|
public const SORT_VOTES = 'votes'; |
30
|
|
|
public const SORT_MYIDEAS = 'egosearch'; |
31
|
|
|
public const SUBJECT_LENGTH = 120; |
32
|
|
|
public const NUM_IDEAS = 5; |
33
|
|
|
|
34
|
|
|
/** @var array Idea status names and IDs */ |
35
|
|
|
public static $statuses = array( |
36
|
|
|
'NEW' => 1, |
37
|
|
|
'IN_PROGRESS' => 2, |
38
|
|
|
'IMPLEMENTED' => 3, |
39
|
|
|
'DUPLICATE' => 4, |
40
|
|
|
'INVALID' => 5, |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Return the status name from the status ID. |
45
|
|
|
* |
46
|
|
|
* @param int $id ID of the status. |
47
|
|
|
* |
48
|
|
|
* @return string The status name. |
49
|
|
|
* @static |
50
|
|
|
* @access public |
51
|
|
|
*/ |
52
|
|
|
public static function status_name($id) |
53
|
|
|
{ |
54
|
|
|
return array_flip(self::$statuses)[$id]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Check whether the extension can be enabled. |
59
|
|
|
* |
60
|
|
|
* Requires phpBB >= 3.2.3 due to removal of deprecated Twig functions (ie Twig_SimpleFunction) |
61
|
|
|
* Requires phpBB >= 3.3.0 due to use of PHP 7 features |
62
|
|
|
* Requires PHP >= 7.1.0 |
63
|
|
|
* |
64
|
|
|
* @return bool |
65
|
|
|
* @access public |
66
|
|
|
*/ |
67
|
|
|
public function is_enableable() |
68
|
|
|
{ |
69
|
|
|
return !(PHP_VERSION_ID < 70100 || |
70
|
|
|
phpbb_version_compare(PHPBB_VERSION, '3.3.0', '<') || |
71
|
|
|
phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>=')); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Enable notifications for the extension |
76
|
|
|
* |
77
|
|
|
* @param mixed $old_state |
78
|
|
|
* @return bool|string |
79
|
|
|
*/ |
80
|
|
|
public function enable_step($old_state) |
81
|
|
|
{ |
82
|
|
|
if ($old_state === false) |
83
|
|
|
{ |
84
|
|
|
$this->container->get('notification_manager') |
85
|
|
|
->enable_notifications('phpbb.ideas.notification.type.status'); |
86
|
|
|
|
87
|
|
|
return 'notification'; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return parent::enable_step($old_state); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Disable notifications for the extension |
95
|
|
|
* |
96
|
|
|
* @param mixed $old_state |
97
|
|
|
* @return bool|string |
98
|
|
|
*/ |
99
|
|
|
public function disable_step($old_state) |
100
|
|
|
{ |
101
|
|
|
if ($old_state === false) |
102
|
|
|
{ |
103
|
|
|
$this->container->get('notification_manager') |
104
|
|
|
->disable_notifications('phpbb.ideas.notification.type.status'); |
105
|
|
|
|
106
|
|
|
return 'notification'; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return parent::disable_step($old_state); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Purge notifications for the extension |
114
|
|
|
* |
115
|
|
|
* @param mixed $old_state |
116
|
|
|
* @return bool|string |
117
|
|
|
*/ |
118
|
|
|
public function purge_step($old_state) |
119
|
|
|
{ |
120
|
|
|
if ($old_state === false) |
121
|
|
|
{ |
122
|
|
|
$this->container->get('notification_manager') |
123
|
|
|
->purge_notifications('phpbb.ideas.notification.type.status'); |
124
|
|
|
|
125
|
|
|
return 'notification'; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
return parent::purge_step($old_state); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|