1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom cron job to evaluate group membership for members

Discussion in 'Custom Service/Development Requests' started by fredrikse, Oct 22, 2012.

  1. fredrikse

    fredrikse Active Member

    Hi,

    I believe I'm in need of a custom cron job that can evaluate group membership and based on that do certain things in the XenForo database.

    Short background information
    At the very beginning RagTek helped me out creating a function that would be able to control the use of the "Watch thread" function (http://xenforo.com/community/threads/whatch-thread-permission-not-working.38717/#post-433387) which is incorporated in XenForo. The reason for me wanting this is that I want to be able to offer this specific function in a premium membership.

    We started out by hiding "Watch thread" in the thread itself based on the membership of a certain group. That was that. After a while I realized there were more things related to this function that we had not taken care of. With help of TMS I have managed to pin point all visible links related to it. But my great head ache now is the part in the thread create view where the user has options to watch the thread which is about to be created. Once again I used TMS to hide the options and to set values to "0" instead of "1" so that the checkboxes were unchecked. But the threads kept on being watched upon creation. I didn't understand why at the beginning. But I kept on troubleshooting and tried to remove these options from the user settings page. Then there were no "watch thread" anymore because this time the values were actually saved to the database. That's why it didn't work before by just unchecking the boxes "visually".

    How to solve this
    To solve this I think a cron job would be the best way to go. I want to make a check and filter out all members that are not member of this premium group. For those members I want to execute an SQL UPDATE query to set the "correct" settings, for instance regarding "watch thread". By doing this I will only have to take care of the visible parts of this function in the differents views.

    Is this easy to solve? How long time would it take to accomplish?
     
  2. HWS

    HWS Well-Known Member

    This would be just a bad band-aid solution.

    You should ask a developer to create an addon for that.

    There is an old addon from ragtek that looks like it could do that, but I never took a look at it:
    https://github.com/ragtek/WTP
     
  3. fredrikse

    fredrikse Active Member

    That's exactly the add-on which I'm reffering to in my summary.
     
  4. HWS

    HWS Well-Known Member

    Okay, so it seems to be rather useless. :)
    Ragtek doesn't do any Xenforo coding any more, so you have to ask another coder to help you.
     
  5. fredrikse

    fredrikse Active Member

    You could put it that way :)
     
  6. ragtek

    ragtek Guest

    As i wrote in the conversation (1 month ago) , this is IMO a xenforo bug, because xenforo isn't checking the permissions in the template and that's why it's showing the watch thread feature to all registered users.... so the method "canWatchThread" doesn't make sense ATM because it's not used everywhere.....

    And i can't include every small xenforo bugfix into my addons because several small changes would break some other xenforo features again...
    XenForo Devs should start to fix the bugs...


    so you'll need to change in post_edit & thread_create template:
    <xen:if is="{$visitor.user_id}">
    <fieldset>
    <dl class="ctrlUnit">
    <dt>{xen:phrase options}:</dt>
    <dd><ul>
    <li><xen:include template="helper_thread_watch_input" /></li>
    </ul></dd>
    </dl>
    </fieldset>
    </xen:if>


    the fix would be to include this check
    Code:
    'canWatchThread' => $threadModel->canWatchThread($thread, $forum)
     
  7. fredrikse

    fredrikse Active Member

    I have done all the workarounds that you wrote to me about. The most of it I have modified with TMS apart from that fix which had to be edited directly in the source file. The big issue for me now is that I can't control the user settings which is presented when a user is about to create a thread. It does not matter that I hide those checkboxes. Believe me, I have tried. It seems like the create thread process takes these settings from the database (see picture) when the thread is created. That's why I want a cron job the restore the settings to a baseline which is valid for all members that does not have a premium membership, which this "watch thread" function will be a part of.

    db.png
     
  8. ragtek

    ragtek Guest

    hmmmmmmmmmmmmmmmm

    i'm going to install xenforo again and check the problem just because of you.. i hope it's easy to fix:D
     
    Luis and fredrikse like this.
  9. fredrikse

    fredrikse Active Member

    I do too :) Thanks!

    Regarding the cron job I still think it would be useful regardless if it will be a part of the solution for the "watch thread" function. Let's say that members sign up for the premium membership for one month. When that month is over they will not be a member of that specific group which is linked to the premium membership. But they will STILL have the correct settings for the "watch thread" function to work which mean that they still will get notices in XenForo and to their e-mail. That's why I want to be able to adjust the settings to a predefined baseline for non premium members.
     
  10. ragtek

    ragtek Guest

    Hm, probably the best way would be to change the "default_watch_state" while the user downgrade instead of the cronjob
     
  11. fredrikse

    fredrikse Active Member

    Ragtek, any status update?

    Anyone who can point me in the right direction on how to create a custom cron job?
     

Share This Page