<?php
	require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'class.api.php');

	class API_SUBMITTEDQUESTION extends API
	{
		var $subquestid = 0;
		var $name = '';
		var $email = '';
		var $subject = '';
		var $status = '';
		var $posted = 0;

		var $fields = array (
			'subquestid',
			'name',
			'email',
			'subject',
			'message',
			'posted',
		);

		var $pk = 'subquestid';

		/**
		* create
		* create a submitted question database entry
		* the parent is overriden here so we can manually set the posted time
		*
		* @return bool was the creation a success ?
		*/
		function create()
		{
			$_POST['posted'] = date('Y-m-d H:i:s');
			return parent::create();
		}

		/**
		* validate_subquestid
		*
		* Ensure the submitted question id is a pos int
		*
		* @param string $var
		*
		* @return bool
		*/
		function validate_subquestid($var)
		{
			return $this->is_positive_int($var);
		}

		/**
		* validate_email
		*
		* Ensure the email address is in a valid format
		*
		* @param string $var
		*
		* @return bool
		*/
		function validate_email($var)
		{
			return is_email_address($var);
		}

		/**
		* validate_message
		*
		* Ensure the message isn't empty
		*
		* @param string $var
		*
		* @return bool
		*/
		function validate_message($var)
		{
			return !empty($var);
		}

		/**
		* validate_posted
		*
		* Ensure the posted date is in the correct format
		*
		* @param string $var
		*
		* @return bool
		*/
		function validate_posted($var)
		{
			return $this->is_standard_date($var);
		}

	}

?>
