Minimum Characters to Count Post

Started by Gluz, June 10, 2017, 03:30:00 PM

Previous topic - Next topic

Gluz

Link to Mod

Minimum Characters to Count Post

Information
This MOD will add a setting to set the minimum characters that a post need to be in order to modify the post count in the boards that have enabled the post count increase.
If a post have less than the characters specified in the setting the post count will not be increased.
It strip down the Quote BBCode to count only the real message.

Usage
Install and then go to the Admin Panel, in the Forum section, in the Posts and Topics area, in the Posts Settings tab.
You will find an option to enter the number of characters from where the message posted will increase the post count.
Set that to your liking.



(c) 2017
@author   Gluz
@license   BSD http://opensource.org/licenses/BSD-3-Clause
@mod       Minimum Characters to Count Post


Changelog:

Version 1.0.1
-Fix for the postcount decrement when a valid size post is deleted but $modSettings['search_custom_index_config'] was empty.

Version 1.0.0
-Initial Release.

Shambles

Good work.

However, if a valid-length post is removed from a thread, the posters postcount is not decremented to account for that post's removal.

d3vcho

"Greeting Death as an old friend, they departed this life as equals"

Gluz

Quote from: Shambles on June 10, 2017, 04:39:22 PM
However, if a valid-length post is removed from a thread, the posters postcount is not decremented to account for that post's removal.

I just fixed one thing the Team Pointed out, that is a post with the exact number of characters as in the setting was not counted as valid, but it does account for it when deleting posts, that's what the edit in the RemoveTopic.php file does.

Shambles

Quote from: Shambles
However, if a valid-length post is removed from a thread, the posters postcount is not decremented to account for that post's removal.

Caused by the following:

Sources/RemoveTopic.php
SELECT
m.id_member, m.icon, m.poster_time, m.subject,' . (empty($modSettings['search_custom_index_config']) ? '' : ' m.body,') . '
m.approved, t.id_topic, t.id_first_msg, t.id_last_msg, t.num_replies, t.id_board,
t.id_member_started AS id_member_poster,
b.count_posts


if $modSettings['search_custom_index_config'] has no value then body is not selected, yet $row['body'] is required by the mod:

Code (mod content) Select
if (!empty($modSettings['minCount_messageLength']))
{
$aux = preg_replace('~\n?\[quote.*?\].+?\[/quote\]\n?~is', '', $row['body']);
$minLenght = $smcFunc['strlen']($aux) >= $modSettings['minCount_messageLength'] ? true : false;
}
else
$minLenght = true;


This manifests itself as "Undefined index: body" and fails to perform the decrement as outlined above  8)

Gluz

Oh, I see, nice catch.

I tested in a clean forum and in some test forums copy of actual live forums I manage, all have the body in it when I dumped some vars.


°Fixed that by deleting that conditional in the Query.
°Updated the package, you can upgrade from one version to another or uninstall the old version and install the new version.

Advertisement: