<?php
/**
 * ###############################################
 *
 * SWIFT Framework
 * _______________________________________________
 *
 * @author		Varun Shoor
 *
 * @package		SWIFT
 * @copyright	Copyright (c) 2001-2012, Kayako
 * @license		http://www.kayako.com/license
 * @link		http://www.kayako.com
 *
 * ###############################################
 */

/**
 * Email Queue Type (Tickets) Management Class
 *
 * @author Varun Shoor
 */
class SWIFT_EmailQueueType_Tickets extends SWIFT_EmailQueueType
{
	/**
	 * Constructor
	 *
	 * @author Varun Shoor
	 * @param int $_templateGroupID The Template Group ID
	 * @param int $_departmentID The Department ID
	 * @param int $_ticketTypeID The Ticket Type ID
	 * @param int $_ticketPriorityID The Ticket Priority ID
	 * @param int $_ticketStatusID The Ticket Status ID
	 * @param bool $_ticketAutoResponder Whether to send the Ticket Auto Responder for this Queue
	 * @return bool "true" on Success, "false" otherwise
	 */
	public function __construct($_templateGroupID, $_departmentID, $_ticketTypeID, $_ticketPriorityID, $_ticketStatusID, $_ticketAutoResponder)
	{
		parent::__construct(self::TYPE_TICKETS);

		$this->SetValue('tgroupid', intval($_templateGroupID));
		$this->SetValue('departmentid', intval($_departmentID));
		$this->SetValue('tickettypeid', intval($_ticketTypeID));
		$this->SetValue('priorityid', intval($_ticketPriorityID));
		$this->SetValue('ticketstatusid', intval($_ticketStatusID));
		$this->SetValue('ticketautoresponder', intval($_ticketAutoResponder));

		return true;
	}

	/**
	 * Destructor
	 *
	 * @author Varun Shoor
	 * @return bool "true" on Success, "false" otherwise
	 */
	public function __destruct()
	{
		parent::__destruct();

		return true;
	}

	/**
	 * Process the incoming email
	 *
	 * @author Varun Shoor
	 * @param SWIFT_MailParserEmail $_SWIFT_MailParserEmailObject The Mail Parser Email Objects
	 * @param SWIFT_MailParser $_SWIFT_MailParserObject The SWIFT_MailParser Object Pointer
	 * @param SWIFT_ParserRuleManager $_SWIFT_ParserRuleManagerObject The Parser Rule Manager Object
	 * @return bool "true" on Success, "false" otherwise
	 * @throws SWIFT_Exception If the Class is not Loaded
	 */
	public function Process(SWIFT_MailParserEmail $_SWIFT_MailParserEmailObject, SWIFT_MailParser $_SWIFT_MailParserObject, SWIFT_ParserRuleManager $_SWIFT_ParserRuleManagerObject)
	{
		if (!$this->GetIsClassLoaded())
		{
			throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED);

			return false;
		}

		SWIFT_Loader::LoadLibrary('EmailParser:TicketEmailParser', APP_TICKETS);

		$this->Load->Library('EmailParser:TicketEmailParser', array($_SWIFT_MailParserEmailObject, $this->GetEmailQueue(), $_SWIFT_MailParserObject, $_SWIFT_ParserRuleManagerObject));
		$this->TicketEmailParser->Process();

		return true;
	}
}
?>