-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathext.php
More file actions
159 lines (129 loc) · 3.85 KB
/
Copy pathext.php
File metadata and controls
159 lines (129 loc) · 3.85 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
*
* phpBB Studio - Advanced Points System. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2019, phpBB Studio, https://www.phpbbstudio.com
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbbstudio\aps;
/**
* phpBB Studio - Advanced Points System Extension base
*/
class ext extends \phpbb\extension\base
{
public function is_enableable()
{
if (!(phpbb_version_compare(PHPBB_VERSION, '3.2.8', '>=') && phpbb_version_compare(PHPBB_VERSION, '4.0.0@dev', '<')))
{
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<'))
{
$user = $this->container->get('user');
$user->add_lang_ext('phpbbstudio/aps', 'aps_ext');
$lang = $user->lang;
$lang['EXTENSION_NOT_ENABLEABLE'] .= '<br>' . $user->lang('APS_PHPBB_VERSION', '3.2.8', '4.0.0@dev');
$user->lang = $lang;
return false;
}
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '>'))
{
$language= $this->container->get('language');
$language->add_lang('aps_ext', 'phpbbstudio/aps');
return $language->lang('APS_PHPBB_VERSION', '3.2.8', '4.0.0@dev');
}
}
/**
* Now if Ultimate Points is enabled already.
*/
$ext_manager = $this->container->get('ext.manager');
$is_ups_enabled = $ext_manager->is_enabled('dmzx/ultimatepoints');
if ($is_ups_enabled)
{
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '<'))
{
$user = $this->container->get('user');
$user->add_lang_ext('phpbbstudio/aps', 'aps_ext');
$lang = $user->lang;
$lang['EXTENSION_NOT_ENABLEABLE'] .= '<br>' . $user->lang('APS_UP_INSTALLED');
$user->lang = $lang;
return false;
}
if (phpbb_version_compare(PHPBB_VERSION, '3.3.0@dev', '>'))
{
$language= $this->container->get('language');
$language->add_lang('aps_ext', 'phpbbstudio/aps');
return $language->lang('APS_UP_INSTALLED');
}
}
return true;
}
/**
* Enable notifications for the extension
*
* @param mixed $old_state State returned by previous call of this method
*
* @return mixed Returns false after last step, otherwise temporary state
*/
public function enable_step($old_state)
{
if ($old_state === false)
{
$this->container->get('notification_manager')
->enable_notifications('phpbbstudio.aps.notification.type.adjust');
return 'notification';
}
return parent::enable_step($old_state);
}
/**
* Disable notifications for the extension
*
* @param mixed $old_state State returned by previous call of this method
*
* @return mixed Returns false after last step, otherwise temporary state
*/
public function disable_step($old_state)
{
if ($old_state === false)
{
try
{
if ($this->container->hasParameter('phpbbstudio.aps.extended'))
{
$language = $this->container->get('language');
$language->add_lang('aps_ext', 'phpbbstudio/aps');
$message = $language->lang('APS_DISABLE_EXTENDED', $this->container->getParameter('phpbbstudio.aps.extended'));
// Trigger error for the ACP
@trigger_error($message, E_USER_WARNING);
// Throw an exception for the CLI
throw new \RuntimeException($message);
}
}
catch (\InvalidArgumentException $e)
{
// Continue
}
$this->container->get('notification_manager')
->disable_notifications('phpbbstudio.aps.notification.type.adjust');
return 'notification';
}
return parent::disable_step($old_state);
}
/**
* Purge notifications for the extension
*
* @param mixed $old_state State returned by previous call of this method
*
* @return mixed Returns false after last step, otherwise temporary state
*/
public function purge_step($old_state)
{
if ($old_state === false)
{
$this->container->get('notification_manager')
->purge_notifications('phpbbstudio.aps.notification.type.adjust');
return 'notification';
}
return parent::purge_step($old_state);
}
}