Advertisement:

Author Topic: Minimum Characters to Count Post  (Read 1342 times)

Offline Gluz

  • Sr. Member
  • ****
  • Posts: 985
  • Gender: Male
Minimum Characters to Count Post
« on: June 10, 2017, 03:30:00 PM »
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.
Need help with PHP, HTML, CSS, Themes or MODs?

Quote
Think in spanish, habla en inglés.

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,167
  • Gender: Male
    • i30 Owners Club
Re: Minimum Characters to Count Post
« Reply #1 on: June 10, 2017, 04:39:22 PM »
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.

Offline d3vcho();

  • Sempiterno
  • Lead Localizer
  • SMF Hero
  • *
  • Posts: 3,865
  • Gender: Male
    • frandominguez03 on GitHub
Re: Minimum Characters to Count Post
« Reply #2 on: June 10, 2017, 04:56:52 PM »
Nice work! Looks great :)

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

Offline Gluz

  • Sr. Member
  • ****
  • Posts: 985
  • Gender: Male
Re: Minimum Characters to Count Post
« Reply #3 on: June 10, 2017, 05:10:40 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.
Need help with PHP, HTML, CSS, Themes or MODs?

Quote
Think in spanish, habla en inglés.

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,167
  • Gender: Male
    • i30 Owners Club
Re: Minimum Characters to Count Post
« Reply #4 on: June 11, 2017, 04:08:22 AM »
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
Code: [Select]
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)

Offline Gluz

  • Sr. Member
  • ****
  • Posts: 985
  • Gender: Male
Re: Minimum Characters to Count Post
« Reply #5 on: June 11, 2017, 03:03:08 PM »
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.
Need help with PHP, HTML, CSS, Themes or MODs?

Quote
Think in spanish, habla en inglés.