News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Post Limit

Started by Suki, February 11, 2013, 07:30:41 PM

Previous topic - Next topic

Dave J

Hi Suki,

I've installed the new version on the clean test site and now I'm getting 2 other errors

See attached for the errors.

I set a member with allowance of only 1 post, I then logged in as that member and posted 3 posts although the limit was set to 1.

In each instance of posting it gave 5 errors each was in number order from '2: Parameter 1 to 2: Parameter 5

The hooks issue still remains, again see attached.


FYI: I have also installed this on a localhost with the same results, except the cron error, that didn't happen on the local host

Suki

Yeah the hooks issue will still happen, it doesn't actually interfere with the mod normal operation.

Can you run this query in your phpMyAdmin or another tool that let you run queries and paste the result:

select * from smf_settings where value LIKE  "%PostLimit%";
This is assuming that your tables as "smf_" as prefix, if not, change it to your prefix.

Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J

#42
Sorry Suki I've only just seen your reply.

See attached below

Suki

Thanks can you now run this query:

select *
from smf_scheduled_tasks
where task like "%PostLimit%"

And make sure this function:

    public static function s(): bool
    {
        $repository = new PostLimitRepository();
        $repository->resetPostCount();

        // Make sure we are the last hook call, don't ask, just sage nod and move on
        self::reOrderHookCall($repository);

        //No point in keeping alerts
        $repository->deleteAllAlerts();

        return true;
    }


Exists on your Sources/PostLimit/PostLimit.php file
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J


Suki

Sorry for the late reply.  I made a few fixes that should cover the issues you were having:

- Fixed the hooks not enable on Integration hooks page
- Added the file to upload directly on the hook call for the scheduled task
- Used the callable field instead of the task_name for the scheduled task
- Uses SMF's autoloader

If you could give it a try, uninstall the previous one first and make sure the hooks and the scheduled task were removed correctly before installing this new version.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J


Dave J

I uninstalled the previous version and cleared all info from the tables (it leaves info in the settings table that's not cleared when the mod is deleted).

Then set the limit for the member and the messages. Checked the permissions were set and then logged in the as the limited member.

I set the limit to 14 posts as I had already posted 12 but I managed to get up to 26 posts with no warning of not being allowed to post.

The hooks are showing as working.

Not sure what the issue is but it's still not working for me.

Just one bit of clarification please. In the settings for the permissions you have

Guests
Regular Members
Global Moderator

I think this must be wrong; why would you let guests or regular members set limits for anyone?

Perhaps this is what's causing the mod not to function correctly.

Suki

Its been years but I vaguely remember the idea behind the permission was that some forum owners have membergroups they would want to have the permission to set post limits, I believe this was a request from the original mod request. The downside is, post based permissions are also included which means you could potentially give guest the ability to set post limit.

I also fixed leaving info in settings table when uninstalling, this new version should left any data.

Do you have any error in your error log? What is the configuration your user has? on which boards does the user is been limited or does the limit is been applied on all boards?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J

The only error in the error log is
Hook call: The file at path: public_html/SMF214/Sources/$sourcedir\PostLimit\PostLimit.php could not be loaded.
All hooks are enabled

The member has no primary membergroup as image 2 and the settings are as image 1. Not sure if anyone else is following this to give their opinion but sure would help.

Suki

oh I see where the error is, it should be a forward slash:

$sourcedir/PostLimit/PostLimit.php
instead of $sourcedir\PostLimit\PostLimit.php



The can set limit permission only refers to the ability to actually set a limit on users, to give a particular user a limit you need to go to their profile:

?action=profile;area=postlimit;u=5

Replace "5" with the user ID you want to set the limit to. You should be able to see a page like the one I'm attaching.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J

Quote from: Suki on February 03, 2025, 04:33:57 PMoh I see where the error is, it should be a forward slash:

$sourcedir/PostLimit/PostLimit.php
instead of $sourcedir\PostLimit\PostLimit.php



The can set limit permission only refers to the ability to actually set a limit on users, to give a particular user a limit you need to go to their profile:

?action=profile;area=postlimit;u=5

Replace "5" with the user ID you want to set the limit to. You should be able to see a page like the one I'm attaching.


Yes I did that, sorry that was a setting I forgot to attach

Suki

and what was the configuration for that user?
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J


Suki

Thanks I saw where the error is, somehow between commits I removed or moved a bunch of lines then a few days later I comeback at the code and I thought it was ready to ship, basically, the code that handles the post count increase was never called and thus, the alert or the error for surpassing the limit was never called.

Will try to do some more proper testing and caught all possible user cases, its somehow difficult because using the same hook the mod needs to check for 2 possible cases:

- The user reaching the percentage needed to send an alert.
- The user surpassing the limit and being unable to complete the action.

One solution I'm pondering is using 2 hooks, before and after posting, will see how that works out.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Dave J

Ok thanks for the reply

Advertisement: