Skip to content

Commit 891faea

Browse files
committed
1.0.1
1 parent bfedcc8 commit 891faea

9 files changed

+53
-58
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "lukewcs/limitreplies",
33
"type": "phpbb-extension",
4-
"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.",
4+
"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.0",
7-
"time": "2024-06-23",
6+
"version": "1.0.1",
7+
"time": "2024-07-06",
88
"license": "GPL-2.0-only",
99
"authors": [
1010
{
@@ -15,7 +15,7 @@
1515
],
1616
"require": {
1717
"php": ">=7.1.3,<8.4.0@dev",
18-
"composer/installers": "~1.0"
18+
"composer/installers": "~1.0.0"
1919
},
2020
"extra": {
2121
"display-name": "Limit Multiple Replies",

config/services.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ services:
88
- '@auth'
99
- '@user'
1010
- '@dbal.conn'
11-
- '%core.root_path%'
12-
- '%core.php_ext%'
1311
tags:
1412
- { name: event.listener }
1513
lukewcs.limitreplies.controller.acp:

docs/limit-multiple-replies_build_changelog.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
### 1.0.1
2+
* Release (2024-07-06)
3+
* Gründer sind jetzt generell ausgeschlossen.
4+
* Listener:
5+
* Nicht mehr benötigten Code von 1.0.0-rc1 entfernt.
6+
* Code Optimierung.
7+
* Foren-Template:
8+
* Twig Code Optimierung.
9+
* JS:
10+
* Objektname gemäss JS Richtlinien benannt.
11+
112
### 1.0.0
213
* Release (2024-06-23)
314
* Fix: Wenn die Wartezeit auf 1 Minute eingestellt war, dann wurde das als "1 Minuten" ausgegeben, weil die Plural-Funktion von `lang()` offensichtlich explizit einen Integer als Key benötigt, damit das funktioniert.
@@ -18,13 +29,13 @@
1829
* Texte überarbeitet.
1930

2031
#### 1.0.0-b2
21-
* ACP Modul:
32+
* ACP-Template:
2233
* Den Schalter bei "Erklärung anzeigen" durch ein Auswahlmenü ersetzt, damit diese Einstellung intuitiver und gleichzeitig flexibler wird.
2334
* Twig Makro `select()` von FAR übernommen, mit dem Auswahlmenüs in Templates einfacher und effizienter realisiert werden können.
24-
* ACP Controller:
25-
* Controller an das neue Auswahlmenü angepasst.
35+
* ACP-Controller:
36+
* An das neue Auswahlmenü angepasst.
2637
* Funktion `select_struct` von FAR übernommen zum Bauen einer Select Struktur fürs Template.
27-
* Foren Frontend:
38+
* Foren-Template:
2839
* Bei der Klick-abhängigen Anzeige der Erklärung wird nicht mehr die bisherige Variante für die permanente Anzeige verwendet, sondern die phpBB Popup Funktion `phpbb.alert()`. Dadurch wurde es jetzt möglich, dass man auch bei den Zitat-Buttons die Erklärung anzeigen kann.
2940
* Bei der permanenten Anzeige der Erklärung wird jetzt ein `not-allowed` Pointer bei den Antwort- und Zitat-Buttons verwendet. [Vorschlag von Kirk (phpBB.de)]
3041
* Listener:
@@ -42,7 +53,7 @@
4253
#### 1.0.0-b1
4354
* Erste interne Testversion.
4455
* Online Versionsprüfung bereits eingebaut und im Repo eingerichtet. Die VP zeigt jedoch während der Beta immer, dass die Version aktuell ist.
45-
* Änderungen/Neuerungen gegenüber "Deny double posts":
56+
* Änderungen/Neuerungen gegenüber "Deny double post":
4657
* Statt einem hardcodet Wert für die Anzahl Sekunden gibts jetzt ein ACP Modul mit paar Einstellungen.
4758
* Statt einem hardcodet Foren-Recht (Moderator Recht) gibt es jetzt ein eigenes Gruppen-Recht mit dem bei jeder Gruppe individuell festgelegt werden kann, ob sie die Sperre umgehen darf. Bei Admins und GlobMods ist das Recht per Standard bereits gesetzt.
4859
* Gruppenrechte > Beiträge > Mehrfachantworten begrenzen: Kann Wartezeit umgehen

docs/limit-multiple-replies_changelog_de.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 1.0.1
2+
(2024-07-06)
3+
4+
* Gründer sind jetzt ebenfalls ausgeschlossen.
5+
* Nicht mehr benötigten Code entfernt und Code Optimierung.
6+
17
### 1.0.0
28
(2024-06-23)
39

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.0",
4+
"current": "1.0.1",
55
"announcement": "https://github.com/LukeWCS/limit-multiple-replies/releases",
66
"eol": null,
77
"security": false

event/listener.php

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,14 @@ class listener implements EventSubscriberInterface
2323
protected $auth;
2424
protected $user;
2525
protected $db;
26-
protected $phpbb_root_path;
27-
protected $php_ext;
28-
29-
protected $wait_time;
3026

3127
public function __construct(
3228
\phpbb\language\language $language,
3329
\phpbb\template\template $template,
3430
\phpbb\config\config $config,
3531
\phpbb\auth\auth $auth,
3632
\phpbb\user $user,
37-
\phpbb\db\driver\driver_interface $db,
38-
$phpbb_root_path,
39-
$php_ext
33+
\phpbb\db\driver\driver_interface $db
4034
)
4135
{
4236
$this->language = $language;
@@ -45,24 +39,20 @@ public function __construct(
4539
$this->auth = $auth;
4640
$this->user = $user;
4741
$this->db = $db;
48-
$this->phpbb_root_path = $phpbb_root_path;
49-
$this->php_ext = $php_ext;
50-
51-
$this->wait_time = $this->config['limitreplies_number_wait_time'] * 60;
5242
}
5343

5444
public static function getSubscribedEvents(): array
5545
{
56-
return array(
46+
return [
5747
'core.viewtopic_modify_page_title' => 'set_template_vars',
5848
'core.modify_posting_auth' => 'check_posting',
5949
'core.permissions' => 'add_permissions',
60-
);
50+
];
6151
}
6252

6353
public function set_template_vars($event): void
6454
{
65-
if ($this->user->data['user_type'] == USER_IGNORE
55+
if ($this->user->data['user_type'] != USER_NORMAL
6656
|| $this->auth->acl_get('u_limitreplies_bypass_lock')
6757
|| !$this->config['limitreplies_switch_enable']
6858
|| $event['topic_data']['topic_status'] == ITEM_LOCKED
@@ -77,15 +67,15 @@ public function set_template_vars($event): void
7767
{
7868
$this->template->assign_vars([
7969
'S_QUICK_REPLY' => false,
80-
'LIMITREPLIES_MESSAGE' => (string) $this->create_message($locked_until_time),
70+
'LIMITREPLIES_MESSAGE' => $this->create_message($locked_until_time),
8171
'LIMITREPLIES_SELECT_HINT_MODE' => (int) $this->config['limitreplies_select_hint_mode'],
8272
]);
8373
}
8474
}
8575

8676
public function check_posting($event): void
8777
{
88-
if ($this->user->data['user_type'] == USER_IGNORE
78+
if ($this->user->data['user_type'] != USER_NORMAL
8979
|| !in_array($event['mode'], ['reply', 'quote', 'bump'])
9080
|| $this->auth->acl_get('u_limitreplies_bypass_lock')
9181
|| !$this->config['limitreplies_switch_enable']
@@ -108,46 +98,36 @@ public function add_permissions($event): void
10898
$event->update_subarray('permissions', 'u_limitreplies_bypass_lock', ['lang' => 'ACL_U_LIMITREPLIES_BYPASS_LOCK', 'cat' => 'post']);
10999
}
110100

111-
private function get_last_unapproved_post(int $topic_id, int $poster_id): ?array
112-
{
113-
$sql = 'SELECT post_id, post_time
114-
FROM ' . POSTS_TABLE . '
115-
WHERE topic_id = ' . (int) $topic_id . '
116-
AND poster_id = ' . (int) $poster_id . '
117-
AND post_visibility = 0
118-
ORDER BY post_time DESC LIMIT 1';
119-
$result = $this->db->sql_query($sql);
120-
$post_row = $this->db->sql_fetchrow($result);
121-
$this->db->sql_freeresult($result);
122-
123-
return $post_row !== false ? $post_row : null;
124-
}
125-
126101
private function get_lock_time(array $topic_data): int
127102
{
128-
if (!function_exists('group_memberships'))
129-
{
130-
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
131-
}
132-
133-
$locked_until_time = 0;
103+
$wait_time = $this->config['limitreplies_number_wait_time'] * 60;
104+
$locked_until_time = 0;
134105

135106
// Check whether there are posts in the queue of the topic.
136107
if ($topic_data['topic_posts_unapproved'])
137108
{
138-
$last_unapproved_post = $this->get_last_unapproved_post($topic_data['topic_id'], $this->user->data['user_id']);
109+
// Get the data of the user's last post in the topic queue, if such a post exists.
110+
$sql = 'SELECT post_id, post_time
111+
FROM ' . POSTS_TABLE . '
112+
WHERE topic_id = ' . (int) $topic_data['topic_id'] . '
113+
AND poster_id = ' . (int) $this->user->data['user_id'] . '
114+
AND post_visibility = 0
115+
ORDER BY post_time DESC LIMIT 1';
116+
$result = $this->db->sql_query($sql);
117+
$last_unapproved_post = $this->db->sql_fetchrow($result);
118+
$this->db->sql_freeresult($result);
139119

140120
// Check if the timestamp of the user's last post in the queue is greater than the timestamp of the last visible post.
141-
if ($last_unapproved_post !== null && $last_unapproved_post['post_time'] > $topic_data['topic_last_post_time'])
121+
if ($last_unapproved_post !== false && $last_unapproved_post['post_time'] > $topic_data['topic_last_post_time'])
142122
{
143-
$locked_until_time = $last_unapproved_post['post_time'] + $this->wait_time;
123+
$locked_until_time = $last_unapproved_post['post_time'] + $wait_time;
144124
}
145125
}
146126

147127
// Check if the last visible post was from the same user.
148128
if ($locked_until_time == 0 && $topic_data['topic_last_poster_id'] == $this->user->data['user_id'])
149129
{
150-
$locked_until_time = $topic_data['topic_last_post_time'] + $this->wait_time;
130+
$locked_until_time = $topic_data['topic_last_post_time'] + $wait_time;
151131
}
152132

153133
return $locked_until_time > time() ? $locked_until_time : 0;

styles/all/template/event/viewtopic_body_footer_before.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
*
1111
#}
1212

13-
{% if LIMITREPLIES_MESSAGE is defined && LIMITREPLIES_SELECT_HINT_MODE == 2 %}
13+
{% if (LIMITREPLIES_SELECT_HINT_MODE ?? 0) == 2 %}
1414
{% INCLUDE '@lukewcs_limitreplies/show_message.html' %}
1515
{% endif %}

styles/all/template/event/viewtopic_body_poll_before.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{% endif %}
1919

2020
<script>
21-
const limitreplies = Object.freeze({
21+
const LimitReplies = Object.freeze({
2222
MessageTitle : {{ lang('INFORMATION')|json_encode }},
2323
MessageText : {{ LIMITREPLIES_MESSAGE|json_encode }},
2424
HintMode : {{ LIMITREPLIES_SELECT_HINT_MODE|json_encode }},

styles/all/template/limitreplies.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ const HintModeAlways = 2;
2020
$(function () {
2121
$('a[href*="mode=quote"],a[href*="mode=reply"]').on('click', function (e) {
2222
e.preventDefault();
23-
if (limitreplies.HintMode == HintModeOnClick) {
24-
phpbb.alert(limitreplies.MessageTitle, limitreplies.MessageText);
23+
if (LimitReplies.HintMode == HintModeOnClick) {
24+
phpbb.alert(LimitReplies.MessageTitle, LimitReplies.MessageText);
2525
}
2626
});
2727

28-
if (limitreplies.HintMode == HintModeAlways) {
28+
if (LimitReplies.HintMode == HintModeAlways) {
2929
$('a[href*="mode=quote"],a[href*="mode=reply"]').addClass('limitreplies_lock');
3030
};
3131
});

0 commit comments

Comments
 (0)