97 lines
2.8 KiB
PHP
97 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* app/plugins/bugtracker/forms.php
|
|
*
|
|
* This houses all of the form checking functions for this plugin.
|
|
*
|
|
* @package TP ToDo
|
|
* @version 3.0
|
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
* @link https://TheTempusProject.com
|
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
*/
|
|
namespace TheTempusProject\Plugins\Todo;
|
|
|
|
use TheTempusProject\Bedrock\Functions\Input;
|
|
use TheTempusProject\Classes\Forms;
|
|
|
|
class TodoForms extends Forms {
|
|
/**
|
|
* Adds these functions to the form list.
|
|
*/
|
|
public function __construct() {
|
|
self::addHandler( 'createTask', __CLASS__, 'createTask' );
|
|
self::addHandler( 'editTask', __CLASS__, 'editTask' );
|
|
self::addHandler( 'createTaskList', __CLASS__, 'createTaskList' );
|
|
self::addHandler( 'editTaskList', __CLASS__, 'editTaskList' );
|
|
}
|
|
|
|
/**
|
|
* Validates the bug tracker create form.
|
|
*
|
|
* @return {bool}
|
|
*/
|
|
public static function createTask() {
|
|
if ( ! empty(Input::post( 'dueDate' )) && !self::date( Input::post( 'dueDate' ) ) ) {
|
|
self::addUserError( 'Invalid Date.' . Input::post( 'dueDate' ) );
|
|
return false;
|
|
}
|
|
if ( ! empty( Input::post( 'listID' ) ) && !self::id( Input::post( 'listID' ) ) ) {
|
|
self::addUserError( 'Invalid Date.' . Input::post( 'dueDate' ) );
|
|
return false;
|
|
}
|
|
if ( !Input::exists( 'task' ) ) {
|
|
self::addUserError( 'You must specify a task' );
|
|
return false;
|
|
}
|
|
// if ( !self::token() ) {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function createTaskList() {
|
|
if ( !Input::exists( 'listName' ) ) {
|
|
self::addUserError( 'You must specify a title' );
|
|
return false;
|
|
}
|
|
// if ( !self::token() ) {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function editTaskList() {
|
|
if ( !Input::exists( 'listName' ) ) {
|
|
self::addUserError( 'You must specify a title' );
|
|
return false;
|
|
}
|
|
// if ( !self::token() ) {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Validates the bug tracker create form.
|
|
*
|
|
* @return {bool}
|
|
*/
|
|
public static function editTask() {
|
|
if ( !empty(Input::post( 'dueDate' )) && !self::date( Input::post( 'dueDate' ) ) ) {
|
|
self::addUserError( 'Invalid Date.' . Input::post( 'dueDate' ) );
|
|
return false;
|
|
}
|
|
if ( !Input::exists( 'task' ) ) {
|
|
self::addUserError( 'You must specify a task' );
|
|
return false;
|
|
}
|
|
// if ( !self::token() ) {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
}
|
|
|
|
new TodoForms;
|