Skip to content

Commit ce06d27

Browse files
committed
1.0.2
1 parent 891faea commit ce06d27

File tree

9 files changed

+94
-58
lines changed

9 files changed

+94
-58
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ env:
44
EXTNAME: lukewcs/limitreplies # Your extension vendor/package name
55
SNIFF: 1 # Run code sniffer on your code? 1 or 0
66
IMAGE_ICC: 1 # Run icc profile sniffer on your images? 1 or 0
7-
EPV: 1 # Run EPV (Extension Pre Validator) on your code? 1 or 0
7+
EPV: 0 # Run EPV (Extension Pre Validator) on your code? 1 or 0
88
EXECUTABLE_FILES: 1 # Run check for executable files? 1 or 0
99
PHPBB_BRANCH: 3.3.x # The phpBB branch to run tests on
1010

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ Extension for phpBB - Forces a waiting period between two posts in a topic if th
55

66
### Requirements
77
* phpBB 3.3.2 - 3.3.x
8-
* PHP 7.1.3 - 8.3.x
8+
* PHP 7.4.0 - 8.4.x
99

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "phpbb-extension",
44
"description": "Forces a waiting period between two posts in a topic if the last post was from the same user. Posts in the topic’s moderation queue are also taken into account.",
55
"homepage": "https://github.com/LukeWCS/limit-multiple-replies",
6-
"version": "1.0.1",
7-
"time": "2024-07-06",
6+
"version": "1.0.2",
7+
"time": "2024-12-13",
88
"license": "GPL-2.0-only",
99
"authors": [
1010
{
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"require": {
17-
"php": ">=7.1.3,<8.4.0@dev",
17+
"php": ">=7.4.0,<8.5.0@dev",
1818
"composer/installers": "~1.0.0"
1919
},
2020
"extra": {

controller/acp_limitreplies_controller.php

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515

1616
class acp_limitreplies_controller
1717
{
18-
protected $language;
19-
protected $template;
20-
protected $config;
21-
protected $request;
22-
protected $ext_manager;
18+
protected object $language;
19+
protected object $template;
20+
protected object $config;
21+
protected object $request;
22+
protected object $ext_manager;
2323

24-
protected $u_action;
25-
26-
private $metadata;
24+
protected string $u_action;
25+
private array $metadata;
2726

2827
public function __construct(
2928
\phpbb\language\language $language,
@@ -51,7 +50,10 @@ public function module_settings(): void
5150

5251
if ($this->request->is_set_post('submit'))
5352
{
54-
$this->check_form_key_error('lukewcs_limitreplies');
53+
if (!check_form_key('lukewcs_limitreplies'))
54+
{
55+
trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
56+
}
5557

5658
$this->config->set('limitreplies_switch_enable' , $this->request->variable('limitreplies_switch_enable' , 0));
5759
$this->config->set('limitreplies_number_wait_time' , $this->request->variable('limitreplies_number_wait_time' , 60));
@@ -71,9 +73,9 @@ public function module_settings(): void
7173

7274
'LIMITREPLIES_SWITCH_ENABLE' => (bool) $this->config['limitreplies_switch_enable'],
7375
'LIMITREPLIES_NUMBER_WAIT_TIME' => (int) $this->config['limitreplies_number_wait_time'],
74-
'LIMITREPLIES_SELECT_HINT_MODE_OPTS' => $this->select_struct($this->config['limitreplies_select_hint_mode'], [
75-
['LIMITREPLIES_HINT_MODE_ONCLICK' , 1],
76-
['LIMITREPLIES_HINT_MODE_ALWAYS' , 2],
76+
'LIMITREPLIES_SELECT_HINT_MODE_OPTS' => $this->select_struct((int) $this->config['limitreplies_select_hint_mode'], [
77+
'LIMITREPLIES_HINT_MODE_ONCLICK' => 1,
78+
'LIMITREPLIES_HINT_MODE_ALWAYS' => 2,
7779
]),
7880
]);
7981

@@ -85,14 +87,6 @@ public function set_page_url($u_action): void
8587
$this->u_action = $u_action;
8688
}
8789

88-
private function check_form_key_error(string $key): void
89-
{
90-
if (!check_form_key($key))
91-
{
92-
trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
93-
}
94-
}
95-
9690
private function set_meta_template_vars(string $tpl_prefix, string $copyright): void
9791
{
9892
$template_vars = [
@@ -110,12 +104,22 @@ private function set_meta_template_vars(string $tpl_prefix, string $copyright):
110104
$this->template->assign_vars([$tpl_prefix . '_METADATA' => $template_vars]);
111105
}
112106

113-
// Check the language pack version for the minimum version and generate notice if outdated
107+
/*
108+
Determine the version of the language pack with fallback to 0.0.0
109+
*/
110+
private function get_lang_ver(string $lang_ext_ver): string
111+
{
112+
preg_match('/^([0-9]+\.[0-9]+\.[0-9]+.*)/', $this->language->lang($lang_ext_ver), $matches);
113+
return ($matches[1] ?? '0.0.0');
114+
}
115+
116+
/*
117+
Check the language pack version for the minimum version and generate notice if outdated
118+
*/
114119
private function lang_ver_check_msg(string $lang_version_var, string $lang_outdated_var): string
115120
{
116121
$lang_outdated_msg = '';
117-
preg_match('/^([0-9]+\.[0-9]+\.[0-9]+)/', $this->language->lang($lang_version_var), $matches);
118-
$ext_lang_ver = $matches[1] ?? '0.0.0';
122+
$ext_lang_ver = $this->get_lang_ver($lang_version_var);
119123
$ext_lang_min_ver = $this->metadata['extra']['lang-min-ver'];
120124

121125
if (phpbb_version_compare($ext_lang_ver, $ext_lang_min_ver, '<'))
@@ -124,8 +128,7 @@ private function lang_ver_check_msg(string $lang_version_var, string $lang_outda
124128
{
125129
$lang_outdated_msg = $this->language->lang($lang_outdated_var);
126130
}
127-
// Fallback if the current language package does not yet have the required variable.
128-
else
131+
else /* Fallback if the current language package does not yet have the required variable. */
129132
{
130133
$lang_outdated_msg = 'Note: The language pack for the extension <strong>%1$s</strong> is no longer up-to-date. (installed: %2$s / needed: %3$s)';
131134
}
@@ -135,20 +138,24 @@ private function lang_ver_check_msg(string $lang_version_var, string $lang_outda
135138
return $lang_outdated_msg;
136139
}
137140

138-
private function select_struct($value, array $options_params): array
141+
private function select_struct($cfg_value, array $options): array
139142
{
140-
$is_array_value = is_array($value);
141-
$options = [];
142-
foreach ($options_params as $params)
143+
$options_tpl = [];
144+
145+
foreach ($options as $opt_key => $opt_value)
143146
{
144-
$options[] = [
145-
'label' => $params[0],
146-
'value' => $params[1],
147-
'bold' => $params[2] ?? false,
148-
'selected' => $is_array_value ? in_array($params[1], $value) : $params[1] == $value,
147+
if (!is_array($opt_value))
148+
{
149+
$opt_value = [$opt_value];
150+
}
151+
$options_tpl[] = [
152+
'label' => $opt_key,
153+
'value' => $opt_value[0],
154+
'bold' => $opt_value[1] ?? false,
155+
'selected' => is_array($cfg_value) ? in_array($opt_value[0], $cfg_value) : $opt_value[0] == $cfg_value,
149156
];
150157
}
151158

152-
return $options;
159+
return $options_tpl;
153160
}
154161
}

docs/limit-multiple-replies_build_changelog.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
### 1.0.2
2+
* Release (2024-12-13)
3+
* PHP:
4+
* Code verwendet jetzt 7.4 Features.
5+
* ACP-Controller:
6+
* Aktuelle Funktionen von EMP 3.0 übernommen:
7+
* `select_struct()`
8+
* `get_lang_ver()`
9+
* `lang_ver_check_msg()`
10+
* Code entsprechend angepasst.
11+
* ext.php`/`composer.json` angepasst:
12+
* PHP: 7.1.3-8.3.x -> 7.4.0-8.4.x
13+
114
### 1.0.1
215
* Release (2024-07-06)
316
* Gründer sind jetzt generell ausgeschlossen.

docs/limit-multiple-replies_changelog_de.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### 1.0.2
2+
(2024-12-13)
3+
4+
* Die Voraussetzungen haben sich geändert:
5+
* PHP: 7.4.0 - 8.4.x (Bisher: 7.1.3 - 8.3.x)
6+
* Technik auf den Stand von EMP 3.0 gebracht, Details im Build Changelog.
7+
18
### 1.0.1
29
(2024-07-06)
310

docs/version_check.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"stable": {
33
"3.3": {
4-
"current": "1.0.1",
4+
"current": "1.0.2",
55
"announcement": "https://github.com/LukeWCS/limit-multiple-replies/releases",
66
"eol": null,
77
"security": false

event/listener.php

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
class listener implements EventSubscriberInterface
1919
{
20-
protected $language;
21-
protected $template;
22-
protected $config;
23-
protected $auth;
24-
protected $user;
25-
protected $db;
20+
protected object $language;
21+
protected object $template;
22+
protected object $config;
23+
protected object $auth;
24+
protected object $user;
25+
protected object $db;
2626

2727
public function __construct(
2828
\phpbb\language\language $language,
@@ -33,12 +33,12 @@ public function __construct(
3333
\phpbb\db\driver\driver_interface $db
3434
)
3535
{
36-
$this->language = $language;
37-
$this->template = $template;
38-
$this->config = $config;
39-
$this->auth = $auth;
40-
$this->user = $user;
41-
$this->db = $db;
36+
$this->language = $language;
37+
$this->template = $template;
38+
$this->config = $config;
39+
$this->auth = $auth;
40+
$this->user = $user;
41+
$this->db = $db;
4242
}
4343

4444
public static function getSubscribedEvents(): array
@@ -50,6 +50,9 @@ public static function getSubscribedEvents(): array
5050
];
5151
}
5252

53+
/*
54+
EVENT: core.viewtopic_modify_page_title
55+
*/
5356
public function set_template_vars($event): void
5457
{
5558
if ($this->user->data['user_type'] != USER_NORMAL
@@ -73,6 +76,9 @@ public function set_template_vars($event): void
7376
}
7477
}
7578

79+
/*
80+
EVENT: core.modify_posting_auth
81+
*/
7682
public function check_posting($event): void
7783
{
7884
if ($this->user->data['user_type'] != USER_NORMAL
@@ -93,6 +99,9 @@ public function check_posting($event): void
9399
}
94100
}
95101

102+
/*
103+
EVENT: core.permissions
104+
*/
96105
public function add_permissions($event): void
97106
{
98107
$event->update_subarray('permissions', 'u_limitreplies_bypass_lock', ['lang' => 'ACL_U_LIMITREPLIES_BYPASS_LOCK', 'cat' => 'post']);
@@ -103,10 +112,10 @@ private function get_lock_time(array $topic_data): int
103112
$wait_time = $this->config['limitreplies_number_wait_time'] * 60;
104113
$locked_until_time = 0;
105114

106-
// Check whether there are posts in the queue of the topic.
115+
/* Check whether there are posts in the queue of the topic. */
107116
if ($topic_data['topic_posts_unapproved'])
108117
{
109-
// Get the data of the user's last post in the topic queue, if such a post exists.
118+
/* Get the data of the user's last post in the topic queue, if such a post exists. */
110119
$sql = 'SELECT post_id, post_time
111120
FROM ' . POSTS_TABLE . '
112121
WHERE topic_id = ' . (int) $topic_data['topic_id'] . '
@@ -117,14 +126,14 @@ private function get_lock_time(array $topic_data): int
117126
$last_unapproved_post = $this->db->sql_fetchrow($result);
118127
$this->db->sql_freeresult($result);
119128

120-
// Check if the timestamp of the user's last post in the queue is greater than the timestamp of the last visible post.
129+
/* Check if the timestamp of the user's last post in the queue is greater than the timestamp of the last visible post. */
121130
if ($last_unapproved_post !== false && $last_unapproved_post['post_time'] > $topic_data['topic_last_post_time'])
122131
{
123132
$locked_until_time = $last_unapproved_post['post_time'] + $wait_time;
124133
}
125134
}
126135

127-
// Check if the last visible post was from the same user.
136+
/* Check if the last visible post was from the same user. */
128137
if ($locked_until_time == 0 && $topic_data['topic_last_poster_id'] == $this->user->data['user_id'])
129138
{
130139
$locked_until_time = $topic_data['topic_last_post_time'] + $wait_time;

ext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ext extends \phpbb\extension\base
1818
public function is_enableable()
1919
{
2020
$valid_phpbb = phpbb_version_compare(PHPBB_VERSION, '3.3.2', '>=') && phpbb_version_compare(PHPBB_VERSION, '3.4.0-dev', '<');
21-
$valid_php = phpbb_version_compare(PHP_VERSION, '7.1.3', '>=') && phpbb_version_compare(PHP_VERSION, '8.4.0-dev', '<');
21+
$valid_php = phpbb_version_compare(PHP_VERSION, '7.4.0', '>=') && phpbb_version_compare(PHP_VERSION, '8.5.0-dev', '<');
2222

2323
return $valid_phpbb && $valid_php;
2424
}

0 commit comments

Comments
 (0)