93 lines
2.8 KiB
PHP
93 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* app/plugins/bugtracker/forms.php
|
|
*
|
|
* This houses all of the form checking functions for this plugin.
|
|
*
|
|
* @package TP BugTracker
|
|
* @version 3.0
|
|
* @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 BugTrackerForms extends Forms {
|
|
/**
|
|
* Adds these functions to the form list.
|
|
*/
|
|
public function __construct() {
|
|
self::addHandler( 'newBugTracker', __CLASS__, 'newBugTracker' );
|
|
self::addHandler( 'editBugTracker', __CLASS__, 'editBugTracker' );
|
|
}
|
|
|
|
/**
|
|
* Validates the bug tracker create form.
|
|
*
|
|
* @return {bool}
|
|
*/
|
|
public static function newBugTracker() {
|
|
if ( !empty(Input::post( 'url' )) && !self::url( Input::post( 'url' ) ) ) {
|
|
self::addUserError( 'Invalid url: <code>' . Input::post( 'url' ) . '</code>' );
|
|
return false;
|
|
}
|
|
if ( !self::tf( Input::post( 'repeat' ) ) ) {
|
|
self::addUserError( 'Invalid repeat value: ' . Input::post( 'repeat' ) );
|
|
return false;
|
|
}
|
|
if ( !Input::exists( 'title' ) ) {
|
|
self::addUserError( 'You must specify title' );
|
|
return false;
|
|
}
|
|
if ( !self::dataTitle( Input::post( 'title' ) ) ) {
|
|
self::addUserError( 'Invalid title' );
|
|
return false;
|
|
}
|
|
if ( !Input::exists( 'description' ) ) {
|
|
self::addUserError( 'You must specify a description' );
|
|
return false;
|
|
}
|
|
// if ( !self::token() ) {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Validates the bug tracker create form.
|
|
*
|
|
* @return {bool}
|
|
*/
|
|
public static function editBugTracker() {
|
|
if ( !empty(Input::post( 'url' )) && !self::url( Input::post( 'url' ) ) ) {
|
|
self::addUserError( 'Invalid url.' . Input::post( 'url' ) );
|
|
return false;
|
|
}
|
|
if ( !self::tf( Input::post( 'repeat' ) ) ) {
|
|
self::addUserError( 'Invalid repeat value.' );
|
|
return false;
|
|
}
|
|
if ( !Input::exists( 'title' ) ) {
|
|
self::addUserError( 'You must specify title' );
|
|
return false;
|
|
}
|
|
if ( !self::dataTitle( Input::post( 'title' ) ) ) {
|
|
self::addUserError( 'Invalid title' );
|
|
return false;
|
|
}
|
|
if ( !Input::exists( 'description' ) ) {
|
|
self::addUserError( 'You must specify a description' );
|
|
return false;
|
|
}
|
|
// if ( !self::token() ) {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
}
|
|
|
|
new BugTrackerForms;
|