XF 1.1 Turn Off Forums Automatically

tafreehm

Well-known member
Hello,
Is there anyway to automatically turn off/close and then turn back on forums a specific time of the day ? maybe through a cron job or something ?

Please guide.
Thanks
 
It would require an add-on.

I looked into it once, but couldn't get it to work. That may have been my inexperience at the time.

If I get time I'll have another look.

For now, no it isn't possible right now but could be with an add-on. I recommend posting at the Resource Requests forum.
 
I get the feeling the hard part is what he'd struggle with :)

I've actually pretty much written this already. I misunderstood earlier I thought it was individual nodes for some reason rather than the entire board.

So it's only taken less than 30 minutes :D

I have asked a question in the resource requests page to find out how long the board needs to be off for, but basically, here's the code. I'm going to add a few admin CP options which don't feature yet. It needs a Board On Cron Entry and a Board Off Cron Entry.

PHP:
<?php
  
class BoardActiveCron_CronEntry_BoardOnOff
{
	public static function boardOn()
	{				
		$db = XenForo_Application::getDb();
		
		$db->update('xf_option', array('option_value' => 1), 'option_id = "boardActive"');
		
		XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache();
	}
	
	public static function boardOff()
	{
		$db = XenForo_Application::getDb();
		
		$db->update('xf_option', array('option_value' => 0), 'option_id = "boardActive"');
		
		XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache();
	}
}
 
Looking good!

It'd be a lot easier if there was a function. For example, there's XenForo_Application::get('options'), it'd be better if we could update options with something like:
XenForo_Application::set('options', 'boardActive', 0);
 
Looking good!

It'd be a lot easier if there was a function. For example, there's XenForo_Application::get('options'), it'd be better if we could update options with something like:
XenForo_Application::set('options', 'boardActive', 0);
Thanks!

I agree. Maybe such a thing exists - I didn't really check :p

Though the only difference I'd expect is for that function (if it existed) to automatically rebuild the option cache.
 
Would you believe it... there is a function :p

XenForo_Options::set($option, $subOption, $value);

Still doesn't rebuild the option cache (as far as I can tell) but cuts out one line of code from calling the database. I will test it and report back.
 
Top Bottom