xF1 Unmaintained - How to create a Cron Entry to move threads (with options!) | NulledTeam UnderGround | The Best Scripts Site In The World
  • Read Our Rules

    Dont forget read our rules Nulled Team UnderGround Rules

  • You may not say thanks or replied bad language in a thread - Your reply will be removed and warning! You must be like us "overview" in the resource. You will be access to download in FREE SECTION ONLY! DO NOT PREMIUM SECTION! Is only upgrade to up account.
  • Please support our site and click on the advertised
  • Complete Installation Service

    Review Our XenForo Complete Installation Service
  • Multiple Accounts

    Dont forget we not allowed Multiple Accounts, so all of your accounts as well as your IP will ban

How to create a Cron Entry to move threads (with options!)

xF1 Unmaintained How to create a Cron Entry to move threads (with options!) 1.0

No permission to download
Compatible XF Versions 1.x
1.0, 1.1, 1.2, 1.3
Objective:
This tutorial was made based on this thread.

I will teach you how to create a new cron entry to move all threads with a specified prefix from forum X to forum Y and run it once a day.

Step 1 - Creating the Add-on

First we need to create a new add-on. This is a very simple step. To be able to create you need to be in Debug Mode. You can see how to put your forum in Debug Mode in this link

To create a new add-on go to AdminCP -> Home -> List Add-ons and click in the button Create Add-on. In the following screen you need to fill those fields to create the add-on. Use the info below:

Add-on ID: MoveThreadsCron
Title: Cron to Move Threads Automatically
Add-on is active: Checked
Version String: 1.0.0
Version ID: 1

And the rest of the fields just let in blank. We do not need to fill. This add-on is just simple add-on, so we dont have any installation process or something.

Click Save Add-on and your add-on is created!

Step 2 - Defining the Options

Let's create some options to make our add-on a little more customizable. What we will do here is create a cron entrey to move threads with a specific prefix inside a specifc forum to another specifc forum. Hell yeah, it is a bunch of specifc things, I know. So, instead of specify all those info inside the php file of our cron, let's create options for that.

To create an option, we first need to create a group option for our addon, so go to AdminCp -> Options and click in the +Add Option Group button. This will bring to you a new page:



Use the information bellow to fill the required fields. We are creating a new option group to hold all our options for this add-on.

  • Group ID: MoveThreadCron
  • Title: Cron to Move Threads Automatically
  • Description: Options to the addon Cron to Move Threads Automatically.
  • Display Order: It is your choice, but I always use: 1000000
  • Display this group in debug mode only: NOT checked
  • Add-on: Cron to Move Threads Automatically
After that, we are now able to create new options. All the new options will be placed inside this recetly created option group. If you've followed my steps, you should be in this page:



To add a new option, click in the + Add Option button.

This first option will hold the forum id that we want to get threads from. Follow the info below to fill the required fields.

Option 1

  • Option ID: mtcFromForum
  • Add-on: Cron to Move Threads Automatically
  • Title: Forum to get threads
  • Explanation: Insert the Forum ID of the forum you want to get threads from.
  • Edit Format: SpinBox
  • Format Parameters:
    Min = 1
  • Data Type: Unsigned Integer
  • ... some other fields in the middle, just let they in blank ...
  • Cron to Move Threads Automatically: Checked, value = 10
------------------------------------------------- // ---------------------------------------

Option 2

  • Option ID: mtcFromPrefix
  • Add-on: Cron to Move Threads Automatically
  • Title: Get Threads with this prefix
  • Explanation: Insert the Prefix ID of the prefix you want to get threads. The cron will only take ALL threads that have this specific prefix.
  • Edit Format: SpinBox
  • Format Parameters:
    Min = 1
  • Data Type: Unsigned Integer
  • ... some other fields in the middle, just let they in blank ...
  • Cron to Move Threads Automatically: Checked, value = 20
------------------------------------------------- // ---------------------------------------

Option 3

  • Option ID: mtcToForum
  • Add-on: Cron to Move Threads Automatically
  • Title: Destination Forum
  • Explanation: Insert the ID of the forum that we will move threads to. This is the destination forum of the threads.
  • Edit Format: SpinBox
  • Format Parameters:
    Min = 1
  • Data Type: Unsigned Integer
  • ... some other fields in the middle, just let they in blank ...
  • Cron to Move Threads Automatically: Checked, value = 30
------------------------------------------------- // ---------------------------------------

Option 4

  • Option ID: mtcToPrefix
  • Add-on: Cron to Move Threads Automatically
  • Title: Destination Prefix
  • Explanation: Insert the ID of the prefix that we will set to the moved threads.
  • Edit Format: SpinBox
  • Format Parameters:
    Min = 1
  • Data Type: Unsigned Integer
  • ... some other fields in the middle, just let they in blank ...
  • Cron to Move Threads Automatically: Checked, value = 40
------------------------------------------------- // ---------------------------------------


Option 5

  • Option ID: mtcAmmount
  • Add-on: Cron to Move Threads Automatically
  • Title: Ammount of Threads
  • Explanation: This is the ammount of threads that the cron job will look to move to the destination forum.
  • Edit Format: SpinBox
  • Format Parameters:
    Min = 1
  • Data Type: Unsigned Integer
  • ... some other fields in the middle, just let they in blank ...
  • Cron to Move Threads Automatically: Checked, value = 50

After all that, you should end up with this:



As you see each one of the options is self explanatory. It is important to fill the Explanation field correctly so we will now what this option is for.

Since we're in the right place, fill all these options with what you want. It is important too to fill all them correctly.

But where do I get the Prefix or Forum ID?

Go get the forum ID you go to AdminCP -> Applications -> Display Node Tree and click on the forum to select. Take a look at your URL. It should be something like this:

http://example/example/admin.php?nodes/main-forum.2/edit

The number 2 is your forum ID.

The same you can do with thread prefixes.

Go to AdminCP -> Applications -> Thread Prefixes and click on the prefix to select. Take a look at your URL. It should be something like this:

http://example/example/admin.php?thread-prefixes/videos.1/edit

The number 1 is your prefix ID.

Step 3 - Coding! (It was about time!)

Now that we setup all that we have to make this add-on work, it is only missing the cron entry code (most important, I guess).

So, let's do it!

Go to your XenForo root and find the folder library. Inside of it you will need to create a new folder, the folder for our add-on. Rename the folder to the name of our addonMoveThreadCron. You'll end up with this:




Inside the new folder, create a new file called CronEntry.php. Open this file and put the following code (copy and past to an editor and take a look at the comments, it is very usefull):
PHP:
You don't have permission to view the code content. Please Log in or register now.
(Almost all the lines from the file is explained, so I'll not explain in here)

Step 4 - Insert a new Cron Entry

Its about to finish. Now we need to Create a New Cron Entry, so XenForo will now that we have a new task to run!

Go to AdminCP -> Tools -> Cron Entries and click in the + Create New Cron Entry.

Fill the fields with the following info:
  • Cron Entry ID: MoveThreadCronEntry
  • Title: Cron to Move Threads Automatically
  • Cron Callback: MoveThreadCron_CronEntry::runMoveThreads
  • Run on type of day: This is your choice.
  • Allow cron entry to run automatically when scheduled: Checked
  • Add-on: Cron to Move Threads Automatically
That's it. Click in Save Cron Entrybutton.

You can test the Cron by selecting the menu Controls of the Cron and hit "Run".

That's it. If you followed all the steps as described in this tutorial, your addon should get working. You can also use imagination to insert more options. Something like "Move the Thread and then set a default title". There is a bunch of things you can do.

Author
AnimeHaxor
Downloads
0
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from AnimeHaxor

Share this resource

Dear User!

We found that you are blocking the display of ads on our site.

It looks like you're using an ad blocker. That's okay. Who doesn't?

But without advertising-income, we can't keep making this site awesome.

Thank you for understanding!