* @link https://TheTempusProject.com * @license https://opensource.org/licenses/MIT [MIT LICENSE] */ namespace TheTempusProject\Plugins\Calendar; use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Classes\Forms; class CalendarForms extends Forms { /** * Adds these functions to the form list. */ public function __construct() { self::addHandler( 'calendarSelect', __CLASS__, 'calendarSelect' ); self::addHandler( 'createEvent', __CLASS__, 'createEvent' ); self::addHandler( 'createCalendar', __CLASS__, 'createCalendar' ); self::addHandler( 'editEvent', __CLASS__, 'editEvent' ); self::addHandler( 'editCalendar', __CLASS__, 'editCalendar' ); } /** * Validates the password re-send form. * * @return {bool} */ public static function calendarSelect() { if ( ! Input::exists( 'calendar_id' ) ) { 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 createEvent() { if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'date' ) ) { Check::addUserError( 'You must include a date.' ); return false; } if ( ! Input::exists( 'time' ) ) { Check::addUserError( 'You must include a time.' ); return false; } if ( ! Input::exists( 'repeats' ) ) { Check::addUserError( 'You must include a frequency.' ); return false; } if ( ! Input::exists( 'calendar_id' ) ) { Check::addUserError( 'You must select a calendar.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function createCalendar() { if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'timezone' ) ) { Check::addUserError( 'You must include a timezone.' ); return false; } // if ( ! self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function editEvent() { if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'date' ) ) { Check::addUserError( 'You must include a date.' ); return false; } if ( ! Input::exists( 'time' ) ) { Check::addUserError( 'You must include a time.' ); return false; } if ( ! Input::exists( 'repeats' ) ) { Check::addUserError( 'You must include a frequency.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } public static function editCalendar() { if ( ! Input::exists( 'submit' ) ) { return false; } if ( ! Input::exists( 'title' ) ) { Check::addUserError( 'You must include a title.' ); return false; } if ( ! Input::exists( 'timezone' ) ) { Check::addUserError( 'You must include a timezone.' ); return false; } // if ( !self::token() ) { // Check::addUserError( 'token - comment out later.' ); // return false; // } return true; } } new CalendarForms;