|
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 or not the extension can be enabled. |
|
59
|
|
|
* |
|
60
|
|
|
* Requires phpBB >= 3.2.1 due to use of $event->update_subarray() |
|
61
|
|
|
* Also incompatible with SQLite which does not support SQRT in SQL queries |
|
62
|
|
|
* |
|
63
|
|
|
* @return bool |
|
64
|
|
|
* @access public |
|
65
|
|
|
*/ |
|
66
|
|
|
public function is_enableable() |
|
67
|
|
|
{ |
|
68
|
|
|
if (phpbb_version_compare(PHPBB_VERSION, '3.2.1', '<')) |
|
69
|
|
|
{ |
|
70
|
|
|
return false; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$db = $this->container->get('dbal.conn'); |
|
74
|
|
|
return ($db->get_sql_layer() !== 'sqlite3'); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|