225 lines
7.4 KiB
PHP
225 lines
7.4 KiB
PHP
<?php
|
|
/**
|
|
* app/plugins/bookmarks/forms.php
|
|
*
|
|
* This houses all of the form checking functions for this plugin.
|
|
*
|
|
* @package TP Bookmarks
|
|
* @version 3.0
|
|
* @author Joey Kimsey <Joey@thetempusproject.com>
|
|
* @link https://TheTempusProject.com
|
|
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
|
*/
|
|
namespace TheTempusProject\Plugins\Bookmarks;
|
|
|
|
use TheTempusProject\Bedrock\Functions\Input;
|
|
use TheTempusProject\Bedrock\Functions\Check;
|
|
use TheTempusProject\Classes\Forms;
|
|
|
|
class BookmarksForms extends Forms {
|
|
/**
|
|
* Adds these functions to the form list.
|
|
*/
|
|
public function __construct() {
|
|
self::addHandler( 'createBookmark', __CLASS__, 'createBookmark' );
|
|
self::addHandler( 'createFolder', __CLASS__, 'createFolder' );
|
|
self::addHandler( 'editBookmark', __CLASS__, 'editBookmark' );
|
|
self::addHandler( 'editFolder', __CLASS__, 'editFolder' );
|
|
self::addHandler( 'importBookmarks', __CLASS__, 'importBookmarks' );
|
|
self::addHandler( 'exportBookmarks', __CLASS__, 'exportBookmarks' );
|
|
self::addHandler( 'createDashboard', __CLASS__, 'createDashboard' );
|
|
self::addHandler( 'editDashboard', __CLASS__, 'editDashboard' );
|
|
self::addHandler( 'updateDashboard', __CLASS__, 'updateDashboard' );
|
|
}
|
|
|
|
public static function createBookmark() {
|
|
// if ( ! Input::exists( 'title' ) ) {
|
|
// Check::addUserError( 'You must include a title.' );
|
|
// return false;
|
|
// }
|
|
if ( ! Input::exists( 'url' ) ) {
|
|
Check::addUserError( 'You must include a url.' );
|
|
return false;
|
|
}
|
|
// if ( ! Input::exists( 'color' ) ) {
|
|
// Check::addUserError( 'You must include a color.' );
|
|
// return false;
|
|
// }
|
|
// if ( ! Input::exists( 'privacy' ) ) {
|
|
// Check::addUserError( 'You must include a privacy.' );
|
|
// return false;
|
|
// }
|
|
// if ( !self::token() ) {
|
|
// Check::addUserError( 'token - comment out later.' );
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function createFolder() {
|
|
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 ( ! Input::exists( 'privacy' ) ) {
|
|
// Check::addUserError( 'You must include a privacy.' );
|
|
// return false;
|
|
// }
|
|
// if ( ! self::token() ) {
|
|
// Check::addUserError( 'token - comment out later.' );
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function editBookmark() {
|
|
// if ( ! Input::exists( 'title' ) ) {
|
|
// Check::addUserError( 'You must include a title.' );
|
|
// return false;
|
|
// }
|
|
if ( ! Input::exists( 'url' ) ) {
|
|
Check::addUserError( 'You must include a url.' );
|
|
return false;
|
|
}
|
|
// if ( ! Input::exists( 'color' ) ) {
|
|
// Check::addUserError( 'You must include a color.' );
|
|
// return false;
|
|
// }
|
|
// if ( ! Input::exists( 'privacy' ) ) {
|
|
// Check::addUserError( 'You must include a privacy.' );
|
|
// return false;
|
|
// }
|
|
// if ( !self::token() ) {
|
|
// Check::addUserError( 'token - comment out later.' );
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function editFolder() {
|
|
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 ( ! Input::exists( 'privacy' ) ) {
|
|
// Check::addUserError( 'You must include a privacy.' );
|
|
// return false;
|
|
// }
|
|
// if ( !self::token() ) {
|
|
// Check::addUserError( 'token - comment out later.' );
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function importBookmarks() {
|
|
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 ( ! Input::exists( 'privacy' ) ) {
|
|
// Check::addUserError( 'You must include a privacy.' );
|
|
// return false;
|
|
// }
|
|
// if ( !self::token() ) {
|
|
// Check::addUserError( 'token - comment out later.' );
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function exportBookmarks() {
|
|
if ( ! Input::exists( 'submit' ) ) {
|
|
return false;
|
|
}
|
|
if ( ! Input::exists( 'BF_' ) ) {
|
|
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 ( ! Input::exists( 'privacy' ) ) {
|
|
// Check::addUserError( 'You must include a privacy.' );
|
|
// return false;
|
|
// }
|
|
// if ( !self::token() ) {
|
|
// Check::addUserError( 'token - comment out later.' );
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
|
|
public static function createDashboard() {
|
|
if ( ! Input::exists( 'submit' ) ) {
|
|
return false;
|
|
}
|
|
if ( ! Input::exists( 'title' ) ) {
|
|
Check::addUserError( 'You must include a title.' );
|
|
return false;
|
|
}
|
|
if ( ! Input::exists( 'link_order' ) ) {
|
|
Check::addUserError( 'You must include at least 1 link or folder.' );
|
|
return false;
|
|
}
|
|
if ( !self::token() ) {
|
|
Check::addUserError( 'There was an issue with your request.' );
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static function updateDashboard() {
|
|
if ( ! Input::exists( 'submit' ) ) {
|
|
return false;
|
|
}
|
|
if ( !self::token() ) {
|
|
Check::addUserError( 'There was an issue with your request.' );
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static function editDashboard() {
|
|
if ( ! Input::exists( 'submit' ) ) {
|
|
return false;
|
|
}
|
|
if ( ! Input::exists( 'title' ) ) {
|
|
Check::addUserError( 'You must include a title.' );
|
|
return false;
|
|
}
|
|
if ( ! Input::exists( 'link_order' ) ) {
|
|
Check::addUserError( 'You must include at least 1 link or folder.' );
|
|
return false;
|
|
}
|
|
if ( !self::token() ) {
|
|
Check::addUserError( 'There was an issue with your request.' );
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
new BookmarksForms; |