<?php
/**
 * app/plugins/bugreport/forms.php
 *
 * This houses all of the form checking functions for this plugin.
 *
 * @package TP BugReports
 * @version 5.0.1
 * @author  Joey Kimsey <Joey@thetempusproject.com>
 * @link    https://TheTempusProject.com
 * @license https://opensource.org/licenses/MIT [MIT LICENSE]
 */
namespace TheTempusProject\Plugins\Bugreport;

use TheTempusProject\Bedrock\Functions\Input;
use TheTempusProject\Classes\Forms;

class BugReportForms extends Forms {
    /**
     * Adds these functions to the form list.
     */
    public function __construct() {
        self::addHandler( 'bugreport', __CLASS__, 'bugreport' );
    }

    /**
     * Validates the bug report form.
     *
     * @return {bool}
     */
    public static function bugreport() {
        if ( !self::url( Input::post( 'url' ) ) ) {
            self::addUserError( 'Invalid url.' );
            return false;
        }
        if ( !self::url( Input::post( 'ourl' ) ) ) {
            self::addUserError( 'Invalid original url.' );
            return false;
        }
        if ( !self::tf( Input::post( 'repeat' ) ) ) {
            self::addUserError( 'Invalid repeat value.' );
            return false;
        }
        if ( !self::token() ) {
            return false;
        }
        return true;
    }
}

new BugReportForms;
