Initial commit
This commit is contained in:
79
app/plugins/comments/controllers/admin/comments.php
Normal file
79
app/plugins/comments/controllers/admin/comments.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/comments/controllers/admin/comments.php
|
||||
*
|
||||
* This is the comments admin controller.
|
||||
*
|
||||
* @package TP Comments
|
||||
* @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\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Comments as CommentsModel;
|
||||
|
||||
class Comments extends AdminController {
|
||||
protected static $comments;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Comments';
|
||||
self::$comments = new CommentsModel;
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/comments' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function edit( $data = null ) {
|
||||
if ( !Input::exists( 'submit' ) ) {
|
||||
return Views::view( 'comments.admin.edit', self::$comments->findById( $data ) );
|
||||
}
|
||||
if ( !Forms::check( 'editComment' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return Views::view( 'comments.admin.edit', self::$comments->findById( $data ) );
|
||||
}
|
||||
if ( self::$comments->update( $data, Input::post( 'comment' ) ) ) {
|
||||
Issues::add( 'success', 'Comment updated' );
|
||||
} else {
|
||||
return Views::view( 'comments.admin.edit', self::$comments->findById( $data ) );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function viewComment( $data = null ) {
|
||||
$commentData = self::$comments->findById( $data );
|
||||
if ( $commentData !== false ) {
|
||||
return Views::view( 'comments.list', $commentData );
|
||||
}
|
||||
Issues::add( 'error', 'Comment not found.' );
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function delete( $data = null ) {
|
||||
if ( $data == null ) {
|
||||
if ( !Input::exists( 'C_' ) ) {
|
||||
return $this->index();
|
||||
}
|
||||
$data = Input::post( 'C_' );
|
||||
}
|
||||
if ( !self::$comments->delete( $data ) ) {
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
} else {
|
||||
Issues::add( 'success', 'Comment has been deleted' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
Views::view( 'comments.admin.list', self::$comments->recent() );
|
||||
}
|
||||
}
|
36
app/plugins/comments/controllers/moderator.php
Normal file
36
app/plugins/comments/controllers/moderator.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* app/plugins/comments/controllers/moderator.php
|
||||
*
|
||||
* This is the Moderator controller.
|
||||
*
|
||||
* @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\Template;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
|
||||
class Moderator extends Controller {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
Template::noIndex();
|
||||
if ( !App::$isMod ) {
|
||||
Session::flash( 'error', 'You do not have permission to view this page.' );
|
||||
return Redirect::home();
|
||||
}
|
||||
}
|
||||
|
||||
public function index() {
|
||||
self::$title = 'Moderator\'s Area';
|
||||
Views::view( 'comments.moderator' );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user