136 lines
4.2 KiB
PHP
136 lines
4.2 KiB
PHP
<?php
|
|
/**
|
|
* app/plugins/calendar/forms.php
|
|
*
|
|
* This houses all of the form checking functions for this plugin.
|
|
*
|
|
* @package TP Calendar
|
|
* @version 3.0
|
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
* @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; |