-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
ext.php
78 lines (72 loc) · 2.03 KB
/
ext.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
<?php
/**
*
* Ideas extension for the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\ideas;
/**
* This ext class is optional and can be omitted if left empty.
* However, you can add special (un)installation commands in the
* methods enable_step(), disable_step() and purge_step(). As it is,
* these methods are defined in \phpbb\extension\base, which this
* class extends, but you can overwrite them to give special
* instructions for those cases.
*/
class ext extends \phpbb\extension\base
{
public const SORT_AUTHOR = 'author';
public const SORT_DATE = 'date';
public const SORT_NEW = 'new';
public const SORT_SCORE = 'score';
public const SORT_TITLE = 'title';
public const SORT_TOP = 'top';
public const SORT_VOTES = 'votes';
public const SORT_MYIDEAS = 'egosearch';
public const SUBJECT_LENGTH = 120;
public const NUM_IDEAS = 5;
/** @var array Idea status names and IDs */
public static $statuses = array(
'NEW' => 1,
'IN_PROGRESS' => 2,
'IMPLEMENTED' => 3,
'DUPLICATE' => 4,
'INVALID' => 5,
);
/**
* Return the status name from the status ID.
*
* @param int $id ID of the status.
*
* @return string The status name.
* @static
* @access public
*/
public static function status_name($id)
{
return array_flip(self::$statuses)[$id];
}
/**
* Check whether the extension can be enabled.
*
* Requires phpBB >= 3.2.3 due to removal of deprecated Twig functions (ie Twig_SimpleFunction)
* Requires phpBB >= 3.3.0 due to use of PHP 7 features
* Requires PHP >= 7.1.0
* Also incompatible with SQLite which does not support SQRT in SQL queries
*
* @return bool
* @access public
*/
public function is_enableable()
{
if (PHP_VERSION_ID < 70100 || phpbb_version_compare(PHPBB_VERSION, '3.3.0', '<') || phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>='))
{
return false;
}
$db = $this->container->get('dbal.conn');
return ($db->get_sql_layer() !== 'sqlite3');
}
}