<?php
	require_once( "../../local.config.inc.php" );
	require_once( $GLOBALS["site_root"] . "/includes/models/TaskManager.inc.php" );

	if (!isset( $getparams["task"] )) return;
	switch ($getparams["task"]) {
	case "shuffle_members":
	case "status_regen":
	case "status_send":
		break;
	default:
		return;
	}	
	
	// akkor valami task tuti van			
	$tm = new TaskManagerModel();
	$tm->newTask();
	
	switch ($getparams["task"]) {
	case "shuffle_members":
		$tm->setTaskType( "shuffle_members" );
		$tm->setTaskName( "shuffling members" );
		$tm->setTaskDescription( "mixing up members" );
		$tm->setTaskUID( fo3_time() );
		break;
	case "status_regen":
		$tm->setTaskType( "status_regen" );
		$tm->setTaskName( "Regenerating statuses" );
		$tm->setTaskDescription( "Regenerating user statuses" );
		$tm->setTaskUID( fo3_time() );
		break;
	case "status_send":
		$tm->setTaskType( "status_send" );
		$tm->setTaskName( sprintf( "automatically sending status" ) );
		$tm->setTaskDescription( "status auto-sending" );
		$tm->setTaskState(
			array( "member_ids" => FNTH_db_get_column( "select member_id from members where status_senttstamp is null and not is_deleted" , "member_id" ) )
		);
		break;
	}
	$tm->saveNewTask();
?>
