Initial commit
This commit is contained in:
58
app/plugins/feedback/controllers/admin/feedback.php
Normal file
58
app/plugins/feedback/controllers/admin/feedback.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/feedback/controllers/admin/feedback.php
|
||||
*
|
||||
* This is the feedback admin controller.
|
||||
*
|
||||
* @package TP Feedback
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers\Admin;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Feedback as FeedbackModel;
|
||||
|
||||
class Feedback extends AdminController {
|
||||
protected static $feedback;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Feedback';
|
||||
self::$feedback = new FeedbackModel;
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/feedback' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
Views::view( 'feedback.admin.view', self::$feedback->findById( $id ) );
|
||||
}
|
||||
|
||||
public function delete( $data = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$data = Input::post( 'F_' );
|
||||
}
|
||||
if ( self::$feedback->delete( (array) $data ) ) {
|
||||
Issues::add( 'success', 'feedback deleted' );
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function clear( $data = null ) {
|
||||
self::$feedback->clear();
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function index( $data = null ) {
|
||||
Views::view( 'feedback.admin.list', self::$feedback->list() );
|
||||
}
|
||||
}
|
47
app/plugins/feedback/controllers/feedback.php
Normal file
47
app/plugins/feedback/controllers/feedback.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/feedback/controllers/feedback.php
|
||||
*
|
||||
* This is the home controller for the feedback plugin.
|
||||
*
|
||||
* @package TP Feedback
|
||||
* @version 3.0
|
||||
* @author Joey Kimsey <Joey@thetempusproject.com>
|
||||
* @link https://TheTempusProject.com
|
||||
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
|
||||
*/
|
||||
namespace TheTempusProject\Controllers;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Models\Feedback as FeedbackModel;
|
||||
|
||||
class Feedback extends Controller {
|
||||
protected static $feedback;
|
||||
|
||||
public function index() {
|
||||
self::$feedback = new FeedbackModel;
|
||||
self::$title = 'Feedback - {SITENAME}';
|
||||
self::$pageDescription = 'At {SITENAME}, we value our users\' input. You can provide any feedback or suggestions using this form.';
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'feedback.feedback' );
|
||||
}
|
||||
if ( !Forms::check( 'feedback' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your form, please check your submission and try again.' => Check::userErrors() ] );
|
||||
return Views::view( 'feedback.feedback' );
|
||||
}
|
||||
$result = self::$feedback->create( Input::post( 'name' ), Input::post( 'feedbackEmail' ), Input::post( 'entry' ) );
|
||||
if ( $result ) {
|
||||
Session::flash( 'success', 'Thank you! Your feedback has been received.' );
|
||||
Redirect::to( 'home/index' );
|
||||
} else {
|
||||
Issues::add( 'error', [ 'There was an error with your form, please check your submission and try again.' => Check::userErrors() ] );
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user