Help with my Bump Throttle plugin

  • I am looking for someone who can help me to develop a Bump throttle

    I have some programming experience (Java, PHP, HTML, etc.) but have no idea where to start, to create a WBB plugin.

    Is there a kind of "start here" for plugin developers? (I can't find it).

    Or is it best to start by looking at the code of an existing plugin?

    My idea is (quite) simple, in its first version it just needs to look at a thread, work out the difference between Now and the last Reply (if any) and disable the Reply button if it's less than 5 days.

    Once I have that working the second version will determine the number of days based on what user groups the user is in.

    For now it does not even need an admin interface.

    Can someone point me in the right direction?

    Thank you :)

    • Offizieller Beitrag

    There is a dedicated permission to prevent double-posts, it checks if the last reply was made by the same user and a specified amount of time has elapsed. This of course does not take into account if someone else has replied last, but I guess that is still okay. Bonus points for being able to configure the time limit (as well as completely disabling it) on a user-group basis.

    If this isn't exactly what you're looking for, please let me know and I can provide you with help building your plugin.

  • Hi Alexander, thanks for your reply.

    If you mean "Delay for Consecutive Posts", in User Group, that would be fine (provided it would accept the number of seconds in a week, 604,800) except that it would affect every post they made, not just posts in certain forums. We only want to restrict like this in sales forums, to prevent too much bumping.

    I would be very grateful for assistance in creating a plugin. This is a key piece of functionality which will alleviate some administrative headaches for us. Besides, I would love to write a plugin :)

    • Offizieller Beitrag

    All right, in that case there are a few things you need:

    • Basic knowledge about packages
    • An event listener containing the logic
    • A template listener to interact with the HTML present to the user

    Step 1) Creating a package

    This is quite easy as packages are pretty much straight-forward, you may want to read the article https://github.com/WoltLab/WCF/wi…-simple-package to understand how everything works. It is basically just a set of instructions and assets that should be deployed on installation.

    Step 2) Event-Listener

    The first thing you need is the eventListener.xml file, it tells the system at which point you want to interact with the software.

    We have registered for two different events, the first is to interact with the thread page itself (e.g. http://example.com/forums/thread/123-foo-bar/) and will be used to hide the reply button. The second event targets the form to add a new post to the thread (basically the form found when clicking on More Options when replying). Because this form can be accessed by simply typing in the URL such as http://example.com/forums/post-add/123/, we're just making sure nobody slips through this.

    I have used the same event listener PHP class for these events, if you want you could simply use a separate class for each event, it doesn't matter.

    One more thing on the file, because you're building a plugin for Burning Board, you must tell the software where to deploy your file. First of all the event listener must be in the files.tar within the path lib/system/event/listener/BumpThrottleListener.class.php. In the package XML you must modify the instruction for files, instead of <instruction type="file">files.tar</instruction> it must read <instruction type="file" application="wbb">files.tar</instruction>. All file paths within files.tar must be relative, the software will figure out where they actually need to go based upon the application attribute (no attribute equals WCF itself).

    Step 3) Template-Listener

    Template-Listeners are considered on template compile-time, which means that their code is directly embedded into the compiled source code. This has the benefit of having access to all variables within and the only performance penalty comes from the code you are actually executing and not any additional payload such as including files (disk I/O) etc. For this listener I have decided to directly embed the code, but you could just use a separate template that you include. The result doesn't change at all.


    Oh and I haven't actually tried this whole code myself, just wrote it down so let me know if something doesn't work and I'll be glad to help you.

  • [Edit] - I think I worked it out, they go in the tar file.... so don't worry for now. I'll report back.


    I finally got round to trying this out, but I've fallen at the first jump. The "Hello World" example is different. I don't know where to put the files:

    eventListener.xml
    templateListener.xml

    Obviously BumpThrottleListener.class.php goes at wbb/lib/system/event/listener/BumpThrottleListener.class.php

    Also I'm confused by "First of all the event listener must be in the files.tar within the path lib/system/event/listener/BumpThrottleListener.class.php." because that's not a directory, but a file. Do you mean in lib/system/event/listener/?

    Sorry to take so long getting back to you on this.

    Einmal editiert, zuletzt von darjeeling (6. August 2016 um 22:47)

  • Ok I think I've got everything in the right place....

    uk.mydomain.bumpthrottle.tar containing:

    - files.tar containing /lib/system/event/listener/BumpThrottleListener.class.php
    - eventListener.xml
    - templateListener.xml

    One slight concern is, if I go to try and install it and there's something wrong, could it bring the site down?

    Oh also, I've changed the package.xml section like this:

    <instructions type="install">
    <instruction type="templateListener">templateListener.xml</instruction>
    <instruction type="file" application="wbb">files.tar</instruction>
    <instruction type="eventListener">eventListener.xml</instruction>
    </instructions>

    3 Mal editiert, zuletzt von darjeeling (6. August 2016 um 23:27)

  • if I go to try and install it and there's something wrong, could it bring the site down?

    Of course it could. If you like I'd give it a try on my development server to see if it runs properly. Just send me the tar package.

    By the way... the code doesn't seem to distinguish by boardID. So it will likely apply for all threads in all forums. I'm new to WCF development however, so perhaps I'm missing something.

  • Of course it could. If you like I'd give it a try on my development server to see if it runs properly. Just send me the tar package.
    By the way... the code doesn't seem to distinguish by boardID. So it will likely apply for all threads in all forums. I'm new to WCF development however, so perhaps I'm missing something.


    Thank you @tobiwan, for your generous offer.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!