Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeWCS committed Jun 23, 2024
1 parent 8561b3e commit bfedcc8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 60 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"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.",
"homepage": "https://github.com/LukeWCS/limit-multiple-replies",
"version": "1.0.0-rc2",
"time": "2024-06-22",
"version": "1.0.0",
"time": "2024-06-23",
"license": "GPL-2.0-only",
"authors": [
{
Expand Down
6 changes: 5 additions & 1 deletion docs/limit-multiple-replies_build_changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### 1.0.0
* Release (2024-06-23)
* 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.

#### 1.0.0-rc2
* Fix: Die Situation Foren-Freigabe in Kombination mit normalen Benutzern - also keine NRUs - führte dazu, dass ein Benutzer beliebig viele Beiträge in die Warteschlange des Themas setzen konnte. Ursache war die unnötige Ermittlung, ob ein Benutzer ein NRU ist, denn nur bei einem NRU wurde die Warteschlange geprüft.
* Fix: Die Situation Foren-Freigabe in Kombination mit normalen Benutzern - also keine NRUs - führte dazu, dass ein Benutzer beliebig viele Beiträge in die Warteschlange des Themas setzen konnte. Ursache war die unnötige Prüfung, ob ein Benutzer ein NRU ist, denn nur bei einem NRU wurde die Warteschlange geprüft.
* Foren Frontend:
* CSS erneut überarbeitet: Padding und Margin wieder reaktiviert und etwas angepasst, da es sonst bei bestimmten Styles zu einer sehr ungünstigen Darstellung bei der dauerhaften Info-Box kommen kann.

Expand Down
2 changes: 1 addition & 1 deletion docs/limit-multiple-replies_changelog_de.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.0.0
(2024--)
(2024-06-23)

* Erste offizielle Version.
2 changes: 1 addition & 1 deletion docs/version_check.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"stable": {
"3.3": {
"current": "0.0.0",
"current": "1.0.0",
"announcement": "https://github.com/LukeWCS/limit-multiple-replies/releases",
"eol": null,
"security": false
Expand Down
52 changes: 4 additions & 48 deletions event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ public static function getSubscribedEvents(): array

public function set_template_vars($event): void
{
// var_dump($event);
// var_dump('set_template_vars');

if ($this->user->data['user_type'] == USER_IGNORE
|| $this->auth->acl_get('u_limitreplies_bypass_lock')
|| !$this->config['limitreplies_switch_enable']
Expand All @@ -88,9 +85,6 @@ public function set_template_vars($event): void

public function check_posting($event): void
{
// var_dump($event);
// var_dump('check_posting');

if ($this->user->data['user_type'] == USER_IGNORE
|| !in_array($event['mode'], ['reply', 'quote', 'bump'])
|| $this->auth->acl_get('u_limitreplies_bypass_lock')
Expand All @@ -111,26 +105,9 @@ public function check_posting($event): void

public function add_permissions($event): void
{
// $permissions = $event['permissions'];
// $permissions['u_limitreplies_bypass_lock'] = ['lang' => 'ACL_U_LIMITREPLIES_BYPASS_LOCK', 'cat' => 'post'];
// $event['permissions'] = $permissions;

$event->update_subarray('permissions', 'u_limitreplies_bypass_lock', ['lang' => 'ACL_U_LIMITREPLIES_BYPASS_LOCK', 'cat' => 'post']);
}

private function get_nru_group_id(): ?int
{
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
WHERE group_name = "NEWLY_REGISTERED"
AND group_type = ' . GROUP_SPECIAL;
$result = $this->db->sql_query($sql, 86400);
$nru_group_id = $this->db->sql_fetchfield('group_id');
$this->db->sql_freeresult($result);

return $nru_group_id !== false ? $nru_group_id : null;
}

private function get_last_unapproved_post(int $topic_id, int $poster_id): ?array
{
$sql = 'SELECT post_id, post_time
Expand All @@ -148,51 +125,30 @@ private function get_last_unapproved_post(int $topic_id, int $poster_id): ?array

private function get_lock_time(array $topic_data): int
{
// var_dump('topic_status', $topic_data['topic_status']);
// var_dump('topic_posts_unapproved', $topic_data['topic_posts_unapproved']);
// var_dump('user_id', $this->user->data['user_id']);
// var_dump('topic_id', $topic_data['topic_id']);

if (!function_exists('group_memberships'))
{
include($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
}

$locked_until_time = 0;
$nru_group_id = $this->get_nru_group_id();

// Check whether there are posts in the queue of the topic and the user is an NRU.
if ($topic_data['topic_posts_unapproved']
// && $nru_group_id !== null && group_memberships($nru_group_id, $this->user->data['user_id'], true)
)
// Check whether there are posts in the queue of the topic.
if ($topic_data['topic_posts_unapproved'])
{
// var_dump('IF #1');
$last_unapproved_post = $this->get_last_unapproved_post($topic_data['topic_id'], $this->user->data['user_id']);
// var_dump('last_unapproved_post_row', $last_unapproved_post !== null);
// var_dump('unapproved:post_id', $last_unapproved_post['post_id'] ?? null);
// var_dump('unapproved:post_time', $last_unapproved_post['post_time'] ?? null);

// Check if the timestamp of the user's last post in the queue is greater than the timestamp of the last visible post.
if ($last_unapproved_post !== null && $last_unapproved_post['post_time'] > $topic_data['topic_last_post_time'])
{
// var_dump('IF #2');
$locked_until_time = $last_unapproved_post['post_time'] + $this->wait_time;
}
// Check if the last visible post was from the same user.
// else if ($topic_data['topic_last_poster_id'] == $this->user->data['user_id'])
// {
// var_dump('IF #3');
// $locked_until_time = $topic_data['topic_last_post_time'] + $this->wait_time;
// }
}

// Check if the last visible post was from the same user.
// else if ($topic_data['topic_last_poster_id'] == $this->user->data['user_id'])
if ($locked_until_time == 0 && $topic_data['topic_last_poster_id'] == $this->user->data['user_id'])
{
// var_dump('IF #4');
$locked_until_time = $topic_data['topic_last_post_time'] + $this->wait_time;
}
// var_dump('get_lock_time', $locked_until_time);

return $locked_until_time > time() ? $locked_until_time : 0;
}
Expand All @@ -202,7 +158,7 @@ private function create_message(int $locked_until_time): string
$this->language->add_lang('limitreplies', 'lukewcs/limitreplies');

return $this->language->lang('LIMITREPLIES_MSG_REPLY_DENIED',
$this->language->lang('LIMITREPLIES_MINUTES_PLURAL', $this->config['limitreplies_number_wait_time']),
$this->language->lang('LIMITREPLIES_MINUTES_PLURAL', (int) $this->config['limitreplies_number_wait_time']),
$this->user->format_date($locked_until_time)
);
}
Expand Down
7 changes: 0 additions & 7 deletions styles/all/theme/limitreplies.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
.limitreplies_hint {
margin: 0.5em 0;
padding: 0.5em 1em;
/* border-radius: 5px; */
font-size: 1.2em;
/* border: 1px solid skyblue; */
/* background-color: aliceblue; */
}

/* .limitreplies_hint .icon { */
/* color: dodgerblue; */
/* } */

.limitreplies_lock {
cursor: not-allowed;
}
Expand Down

0 comments on commit bfedcc8

Please sign in to comment.