* @link https://TheTempusProject.com * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Plugins\Notes; use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Classes\Forms; class NotesForms extends Forms { /** * Adds these functions to the form list. */ public function __construct() { self::addHandler( 'createNote', __CLASS__, 'createNote' ); self::addHandler( 'createNotebook', __CLASS__, 'createNotebook' ); self::addHandler( 'editNote', __CLASS__, 'editNote' ); self::addHandler( 'editNoteSimple', __CLASS__, 'editNoteSimple' ); self::addHandler( 'editNotebook', __CLASS__, 'editNotebook' ); self::addHandler( 'autoUpdateNote', __CLASS__, 'autoUpdateNote' ); } public static function createNote() { if ( ! Input::exists( 'submit' ) ) { return false; } if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'color' ) ) { Check::addUserError( 'You must include a color.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function createNotebook() { if ( ! Input::exists( 'submit' ) ) { return false; } if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'color' ) ) { Check::addUserError( 'You must include a color.' ); return false; } // if ( ! self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function autoUpdateNote() { if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } // if ( ! self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function editNote() { if ( ! Input::exists( 'submit' ) ) { return false; } if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'color' ) ) { Check::addUserError( 'You must include a color.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function editNoteSimple() { if ( ! Input::exists( 'submit' ) ) { return false; } if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function editNotebook() { if ( ! Input::exists( 'submit' ) ) { return false; } if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'color' ) ) { Check::addUserError( 'You must include a color.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } } new NotesForms;