Initial commit
This commit is contained in:
48
app/controllers/admin/admin.php
Normal file
48
app/controllers/admin/admin.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/admin.php
|
||||
*
|
||||
* This is the admin log 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\Admin;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Log;
|
||||
|
||||
class Admin extends AdminController {
|
||||
public static $log;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Admin Logs';
|
||||
self::$log = new Log;
|
||||
}
|
||||
|
||||
public function delete( $id = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$id = Input::post( 'A_' );
|
||||
}
|
||||
if ( self::$log->delete( $id ) ) {
|
||||
Issues::add( 'success', 'Admin-log deleted' );
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error deleting log(s)' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
return Views::view( 'admin.logs.admin_list', self::$log->list( 'admin' ) );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
return Views::view( 'admin.logs.admin', self::$log->findById( $id ) );
|
||||
}
|
||||
}
|
64
app/controllers/admin/composer.php
Normal file
64
app/controllers/admin/composer.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/composer.php
|
||||
*
|
||||
* This is the composer controller. Its only very effective when using composer for autoloading.
|
||||
*
|
||||
* @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\Views;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Classes\Installer;
|
||||
|
||||
class Composer extends AdminController {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Composer Dependencies';
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$installer = new Installer;
|
||||
|
||||
// Files
|
||||
$composerJson = $installer->getComposerJson();
|
||||
if ( empty( $composerJson ) ) {
|
||||
return Issues::add( 'error', 'Composer json is missing.' );
|
||||
}
|
||||
$composerLock = $installer->getComposerLock();
|
||||
if ( empty( $composerLock ) ) {
|
||||
return Issues::add( 'error', 'Composer lock file is missing.' );
|
||||
}
|
||||
|
||||
// Required Packages
|
||||
$requiredPackages = $composerJson[ 'require' ];
|
||||
foreach ( $requiredPackages as $name => $version ) {
|
||||
$versionsRequired[ strtolower( $name ) ] = $version;
|
||||
}
|
||||
|
||||
// Installed Packages
|
||||
$installedPackages = $composerLock[ 'packages' ];
|
||||
foreach ( $installedPackages as $package ) {
|
||||
$name = strtolower( $package[ 'name' ] );
|
||||
$versionsInstalled[ $name ] = $package;
|
||||
}
|
||||
|
||||
// Versioning
|
||||
foreach ( $versionsInstalled as $package ) {
|
||||
$name = strtolower( $package[ 'name' ] );
|
||||
if ( !empty( $versionsRequired[ $name ] ) ) {
|
||||
$versionsInstalled[ $name ][ 'requiredVersion' ] = $versionsRequired[ $name ];
|
||||
} else {
|
||||
$versionsInstalled[ $name ][ 'requiredVersion' ] = 'sub-dependency';
|
||||
}
|
||||
$out[] = (object) $versionsInstalled[ $name ];
|
||||
}
|
||||
|
||||
Views::view( 'admin.dependencies', $out );
|
||||
}
|
||||
}
|
94
app/controllers/admin/contact.php
Normal file
94
app/controllers/admin/contact.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/contact.php
|
||||
*
|
||||
* This is the admin contact controller. The only real use is to send out emails to the various lists.
|
||||
*
|
||||
* @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\Classes\AdminController;
|
||||
use TheTempusProject\Classes\Email;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Models\User;
|
||||
use TheTempusProject\Models\Subscribe;
|
||||
|
||||
class Contact extends AdminController {
|
||||
public static $user;
|
||||
public static $subscribe;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Contact';
|
||||
self::$user = new User;
|
||||
self::$subscribe = new Subscribe;
|
||||
}
|
||||
|
||||
private function emailSubscribers( $params ) {
|
||||
$list = self::$subscribe->list();
|
||||
if ( empty( $list ) ) {
|
||||
Issues::add( 'error', 'No subscribers found' );
|
||||
return;
|
||||
}
|
||||
foreach ( $list as $recipient ) {
|
||||
$params[ 'confirmationCode' ] = $recipient->confirmationCode;
|
||||
Email::send( $recipient->email, 'contact', $params, [ 'template' => true, 'unsubscribe' => true ] );
|
||||
}
|
||||
}
|
||||
|
||||
private function emailUsers( $params, $limit = null ) {
|
||||
$list = self::$user->userList( $limit );
|
||||
foreach ( $list as $recipient ) {
|
||||
Email::send( $recipient->email, 'contact', $params, [ 'template' => true ] );
|
||||
}
|
||||
}
|
||||
|
||||
public function index() {
|
||||
if ( Input::exists( 'mailType' ) ) {
|
||||
$params = [
|
||||
'subject' => Input::post( 'mailSubject' ),
|
||||
'title' => Input::post( 'mailTitle' ),
|
||||
'message' => Input::post( 'mailMessage' ),
|
||||
];
|
||||
switch ( Input::post( 'mailType' ) ) {
|
||||
case 'registered':
|
||||
$this->emailUsers( $params );
|
||||
Issues::add( 'success', 'Email(s) Sent' );
|
||||
break;
|
||||
|
||||
case 'newsletter':
|
||||
$this->emailUsers( $params, 'newsletter' );
|
||||
Issues::add( 'success', 'Email(s) Sent' );
|
||||
break;
|
||||
|
||||
case 'all':
|
||||
$this->emailUsers( $params );
|
||||
$this->emailSubscribers( $params );
|
||||
Issues::add( 'success', 'Email(s) Sent' );
|
||||
break;
|
||||
|
||||
case 'opt':
|
||||
$this->emailUsers( $params, 'newsletter' );
|
||||
$this->emailSubscribers( $params );
|
||||
Issues::add( 'success', 'Email(s) Sent' );
|
||||
break;
|
||||
|
||||
case 'subscribers':
|
||||
$this->emailSubscribers( $params );
|
||||
Issues::add( 'success', 'Email(s) Sent' );
|
||||
break;
|
||||
|
||||
default:
|
||||
Issues::add( 'error', 'Invalid Request' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
Views::view( 'admin.contact' );
|
||||
}
|
||||
}
|
54
app/controllers/admin/errors.php
Normal file
54
app/controllers/admin/errors.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/errors.php
|
||||
*
|
||||
* This is the error logs 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\Admin;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Log;
|
||||
|
||||
class Errors extends AdminController {
|
||||
public static $log;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Error Logs';
|
||||
self::$log = new Log;
|
||||
}
|
||||
|
||||
public function delete( $id = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$id = Input::post( 'E_' );
|
||||
}
|
||||
if ( self::$log->delete( $id ) ) {
|
||||
Issues::add( 'success', 'Error-log deleted' );
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error deleting log(s)' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
return Views::view( 'admin.logs.error_list', self::$log->list( 'error' ) );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
return Views::view( 'admin.logs.error', self::$log->findById( $id ) );
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
self::$log->clear( 'error' );
|
||||
Issues::add( 'success', 'Error Logs Cleared' );
|
||||
$this->index();
|
||||
}
|
||||
}
|
128
app/controllers/admin/groups.php
Normal file
128
app/controllers/admin/groups.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/groups.php
|
||||
*
|
||||
* This is the groups admin 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\Admin;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Forms;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Classes\Permissions;
|
||||
use TheTempusProject\Models\Group;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
|
||||
class Groups extends AdminController {
|
||||
public static $group;
|
||||
public static $permissions;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Groups';
|
||||
self::$group = new Group;
|
||||
self::$permissions = new Permissions;
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/groups' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function create( $data = null ) {
|
||||
$perms = self::$group->getDefaultPermissions();
|
||||
if ( Input::exists( 'name' ) ) {
|
||||
$perms = self::$permissions->convertFormToArray();
|
||||
if ( self::$group->create( Input::post( 'name' ), $perms ) ) {
|
||||
Issues::add( 'success', 'Group created' );
|
||||
return $this->index();
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error creating your group.' );
|
||||
}
|
||||
}
|
||||
Components::set( 'PERMISSIONS_FORM', self::$permissions->getFormHtml( $perms ) );
|
||||
Views::view( 'admin.groups.create' );
|
||||
}
|
||||
|
||||
public function delete( $id = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$id = Input::post( 'G_' );
|
||||
}
|
||||
if ( self::$group->delete( $id ) ) {
|
||||
Issues::add( 'success', 'Group deleted' );
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error deleting group(s)' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function edit( $data = null ) {
|
||||
$group = self::$group->findById( $data );
|
||||
if ( in_array( $group->name, self::$group::$protectedGroups ) ) {
|
||||
switch ( $group->name ) {
|
||||
case 'Super':
|
||||
if ( 'Super' !== App::$activeGroup->name ) {
|
||||
Issues::add( 'error', 'You do not have permission to do that.' );
|
||||
return $this->index();
|
||||
}
|
||||
case 'Admin':
|
||||
if ( 'Moderator' === App::$activeGroup->name ) {
|
||||
Issues::add( 'error', 'You do not have permission to do that.' );
|
||||
return $this->index();
|
||||
}
|
||||
}
|
||||
}
|
||||
$perms = $group->perms;
|
||||
if ( Input::exists( 'name' ) ) {
|
||||
$perms = self::$permissions->convertFormToArray();
|
||||
// @ todo need to come up with a way to check these forms....
|
||||
if ( self::$group->update( $data, Input::post( 'name' ), $perms ) ) {
|
||||
Issues::add( 'success', 'Group updated' );
|
||||
return $this->index();
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error with your request.' );
|
||||
}
|
||||
}
|
||||
Components::set( 'PERMISSIONS_FORM', self::$permissions->getFormHtml( $perms ) );
|
||||
Views::view( 'admin.groups.edit', $group );
|
||||
}
|
||||
|
||||
public function index( $data = null ) {
|
||||
Views::view( 'admin.groups.list', self::$group->list() );
|
||||
}
|
||||
|
||||
public function listmembers( $data = null ) {
|
||||
$groupData = self::$group->findById( $data );
|
||||
if ( $groupData !== false ) {
|
||||
Components::set( 'groupName', $groupData->name );
|
||||
return Views::view( 'admin.groups.list_members', self::$group->listMembers( $groupData->ID ) );
|
||||
}
|
||||
Issues::add( 'error', 'Group not found' );
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function view( $data = null ) {
|
||||
$groupData = self::$group->findById( $data );
|
||||
if ( $groupData == false ) {
|
||||
Issues::add( 'error', 'Group not found' );
|
||||
return $this->index();
|
||||
}
|
||||
$out = '';
|
||||
foreach ( self::$group->getDefaultPermissions() as $name => $default ) {
|
||||
$node_name = $name . '_pretty';
|
||||
$pretty_name = $groupData->$node_name;
|
||||
$node_name2 = $name . '_text';
|
||||
$pretty_value = $groupData->$node_name2;
|
||||
$out .= '<tr><td>' . $pretty_name . '</td><td>' . $pretty_value . '</td></tr>';
|
||||
}
|
||||
Components::set( 'PERMISSIONS_ROWS', $out );
|
||||
Views::view( 'admin.groups.view', $groupData );
|
||||
}
|
||||
}
|
52
app/controllers/admin/home.php
Normal file
52
app/controllers/admin/home.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/home.php
|
||||
*
|
||||
* This is the admin dashboard 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\Admin;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\User;
|
||||
use TheTempusProject\Plugins\Comments;
|
||||
use TheTempusProject\Plugins\Blog;
|
||||
|
||||
class Home extends AdminController {
|
||||
public static $user;
|
||||
public static $comments;
|
||||
public static $posts;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Home';
|
||||
}
|
||||
|
||||
public function index() {
|
||||
if ( class_exists( 'TheTempusProject\Plugins\Comments' ) ) {
|
||||
$comments = new Comments;
|
||||
self::$comments = $comments->getModel();
|
||||
$comments = Views::simpleView( 'comments.admin.dashboard', self::$comments->recent( 'all', 5 ) );
|
||||
Components::set( 'commentDash', $comments );
|
||||
}
|
||||
|
||||
if ( class_exists( 'TheTempusProject\Plugins\Blog' ) ) {
|
||||
$blog = new Blog;
|
||||
self::$posts = $blog->posts;
|
||||
$posts = Views::simpleView( 'blog.admin.dashboard', self::$posts->recent( 5 ) );
|
||||
Components::set( 'blogDash', $posts );
|
||||
}
|
||||
|
||||
self::$user = new User;
|
||||
$users = Views::simpleView( 'admin.dashboard.users', self::$user->recent( 5 ) );
|
||||
Components::set( 'userDash', $users );
|
||||
|
||||
Views::view( 'admin.dashboard.dash' );
|
||||
}
|
||||
}
|
54
app/controllers/admin/logins.php
Normal file
54
app/controllers/admin/logins.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/logins.php
|
||||
*
|
||||
* This is the login logs 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\Admin;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Log;
|
||||
|
||||
class Logins extends AdminController {
|
||||
public static $log;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Login Logs';
|
||||
self::$log = new Log;
|
||||
}
|
||||
|
||||
public function delete( $id = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$id = Input::post( 'L_' );
|
||||
}
|
||||
if ( self::$log->delete( $id ) ) {
|
||||
Issues::add( 'success', 'Login-log deleted' );
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error deleting log(s)' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
return Views::view( 'admin.logs.login_list', self::$log->list( 'login' ) );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
return Views::view( 'admin.logs.login', self::$log->findById( $id ) );
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
self::$log->clear( 'login' );
|
||||
Issues::add( 'success', 'Login Logs Cleared' );
|
||||
$this->index();
|
||||
}
|
||||
}
|
33
app/controllers/admin/logs.php
Normal file
33
app/controllers/admin/logs.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/logs.php
|
||||
*
|
||||
* This is the generic logs 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\Admin;
|
||||
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Log;
|
||||
|
||||
class Logs extends AdminController {
|
||||
public static $log;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Logs';
|
||||
self::$log = new Log;
|
||||
}
|
||||
|
||||
public function index( $data = null ) {
|
||||
Views::view( 'admin.logs.error_list', self::$log->list( 'error' ) );
|
||||
Views::view( 'admin.logs.admin_list', self::$log->list( 'admin' ) );
|
||||
Views::view( 'admin.logs.login_list', self::$log->list( 'login' ) );
|
||||
}
|
||||
}
|
126
app/controllers/admin/plugins.php
Normal file
126
app/controllers/admin/plugins.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/installed.php
|
||||
*
|
||||
* This is the installed plugins 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\Admin;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Classes\Installer;
|
||||
use TheTempusProject\Classes\Plugin;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
|
||||
class Plugins extends AdminController {
|
||||
public $installer;
|
||||
public $plugins;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Installed Plugins';
|
||||
$this->installer = new Installer;
|
||||
$this->plugins = $this->installer->getAvailablePlugins();
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/plugins' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function index() {
|
||||
Views::view( 'admin.modules.plugins.list', $this->plugins );
|
||||
}
|
||||
|
||||
public function disable( $name = null ) {
|
||||
Components::set( 'PLUGIN', $name );
|
||||
if ( !Input::exists( 'installHash' ) ) {
|
||||
return Views::view( 'admin.modules.plugins.disable' );
|
||||
}
|
||||
if ( !Plugin::disable( $name ) ) {
|
||||
Session::flash( 'error', 'There was an error disabling the plugin.' );
|
||||
} else {
|
||||
Session::flash( 'success', 'Plugin has been disabled.' );
|
||||
}
|
||||
Redirect::to( 'admin/plugins' );
|
||||
}
|
||||
|
||||
public function enable( $name = null ) {
|
||||
Components::set( 'PLUGIN', $name );
|
||||
if ( !Input::exists( 'installHash' ) ) {
|
||||
return Views::view( 'admin.modules.plugins.enable' );
|
||||
}
|
||||
if ( !Plugin::enable( $name ) ) {
|
||||
Session::flash( 'error', 'There was an error enabling the plugin.' );
|
||||
} else {
|
||||
Session::flash( 'success', 'Plugin has been enabled.' );
|
||||
}
|
||||
Redirect::to( 'admin/plugins' );
|
||||
}
|
||||
|
||||
public function install( $name = null ) {
|
||||
if ( empty( $name ) ) {
|
||||
Session::flash( 'error', 'Unknown Plugin.' );
|
||||
Redirect::to( 'admin/plugins' );
|
||||
}
|
||||
$name = strtolower( $name );
|
||||
Components::set( 'PLUGIN', $name );
|
||||
if ( ! Input::exists( 'installHash' ) ) {
|
||||
return Views::view( 'admin.modules.plugins.install' );
|
||||
}
|
||||
|
||||
if ( empty( $this->plugins[$name] ) ) {
|
||||
Session::flash( 'error', 'Unknown Plugin.' );
|
||||
} else {
|
||||
$result = $this->installer->installPlugin( $this->plugins[$name] );
|
||||
if ( empty( $result ) ) {
|
||||
Session::flash( 'error', [ 'There was an error with the install.' => $this->installer->getErrors() ] );
|
||||
} else {
|
||||
Session::flash( 'success', 'Plugin has been installed.' );
|
||||
}
|
||||
}
|
||||
Redirect::to( 'admin/plugins' );
|
||||
}
|
||||
|
||||
public function uninstall( $name = null ) {
|
||||
if ( empty($name)) {
|
||||
Session::flash( 'error', 'Unknown Plugin.' );
|
||||
Redirect::to( 'admin/plugins' );
|
||||
}
|
||||
$name = strtolower($name);
|
||||
Components::set( 'PLUGIN', $name );
|
||||
|
||||
if ( !Input::exists( 'uninstallHash' ) ) {
|
||||
return Views::view( 'admin.modules.plugins.uninstall' );
|
||||
}
|
||||
|
||||
if ( empty( $this->plugins[$name] ) ) {
|
||||
Session::flash( 'error', 'Unknown Plugin.' );
|
||||
} else {
|
||||
$result = $this->installer->uninstallPlugin( $this->plugins[$name] );
|
||||
if ( empty($result) ) {
|
||||
Session::flash( 'error', [ 'There was an error with the uninstall.' => $this->installer->getErrors() ] );
|
||||
} else {
|
||||
Session::flash( 'success', 'Plugin has been uninstalled.' );
|
||||
}
|
||||
}
|
||||
Redirect::to( 'admin/plugins' );
|
||||
}
|
||||
|
||||
public function view( $name = null ) {
|
||||
$name = strtolower($name);
|
||||
|
||||
if ( empty( $this->plugins[$name] ) ) {
|
||||
Session::flash( 'error', 'Unknown Plugin.' );
|
||||
Redirect::to( 'admin/plugins' );
|
||||
} else {
|
||||
Views::view( 'admin.modules.plugins.view', $this->plugins[$name] );
|
||||
}
|
||||
}
|
||||
}
|
97
app/controllers/admin/routes.php
Normal file
97
app/controllers/admin/routes.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/routes.php
|
||||
*
|
||||
* This is the admin routes/redirects 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\Admin;
|
||||
|
||||
use TheTempusProject\TTPForms;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Forms;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Routes as RoutesClass;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
|
||||
class Routes extends AdminController {
|
||||
public static $routes;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Redirects';
|
||||
self::$routes = new RoutesClass;
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/routes' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function create() {
|
||||
if ( Input::exists( 'redirect_type' ) ) {
|
||||
if ( !TTPForms::check( 'createRoute' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your route.' => Check::userErrors() ] );
|
||||
}
|
||||
if ( self::$routes->create(
|
||||
Input::post( 'original_url' ),
|
||||
Input::post( 'forwarded_url' ),
|
||||
Input::post( 'nickname' ),
|
||||
Input::post( 'redirect_type' )
|
||||
) ) {
|
||||
Session::flash( 'success', 'Route Created' );
|
||||
Redirect::to( 'admin/routes' );
|
||||
}
|
||||
}
|
||||
Views::view( 'admin.routes.create' );
|
||||
}
|
||||
|
||||
public function delete( $id = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$id = Input::post( 'R_' );
|
||||
}
|
||||
if ( self::$routes->delete( [ $id ] ) ) {
|
||||
Session::flash( 'success', 'Route(s) deleted.' );
|
||||
} else {
|
||||
Session::flash( 'error', 'There was an error with your request.' );
|
||||
}
|
||||
Redirect::to( 'admin/routes' );
|
||||
}
|
||||
|
||||
public function edit( $id = null ) {
|
||||
$route = self::$routes->findById( $id );
|
||||
if ( Input::exists( 'redirect_type' ) ) {
|
||||
if ( !TTPForms::check( 'editRoute' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your route.' => Check::userErrors() ] );
|
||||
} else {
|
||||
if ( self::$routes->update(
|
||||
$id,
|
||||
Input::post( 'original_url' ),
|
||||
Input::post( 'forwarded_url' ),
|
||||
Input::post( 'nickname' ),
|
||||
Input::post( 'redirect_type' )
|
||||
) ) {
|
||||
Session::flash( 'success', 'Route Updated' );
|
||||
Redirect::to( 'admin/routes' );
|
||||
}
|
||||
}
|
||||
}
|
||||
Forms::selectOption( $route->redirect_type );
|
||||
return Views::view( 'admin.routes.edit', $route );
|
||||
}
|
||||
|
||||
public function index() {
|
||||
return Views::view( 'admin.routes.list', self::$routes->list() );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
return Views::view( 'admin.routes.view', self::$routes->findById( $id ) );
|
||||
}
|
||||
}
|
48
app/controllers/admin/settings.php
Normal file
48
app/controllers/admin/settings.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/settings.php
|
||||
*
|
||||
* This is the configuration and settings 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\Admin;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Forms;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\Group;
|
||||
use TheTempusProject\Classes\Config;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
|
||||
class Settings extends AdminController {
|
||||
public static $group;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Settings';
|
||||
self::$group = new Group;
|
||||
}
|
||||
|
||||
public function index() {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
if ( !App::$activeConfig->updateFromForm( true ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
} else {
|
||||
Issues::add( 'success', 'Settings Updated' );
|
||||
}
|
||||
}
|
||||
Components::set( 'configForm', Config::getEditHtml() );
|
||||
Components::set(
|
||||
'group-defaultGroup-options',
|
||||
Forms::getOptionsHtml( self::$group->listGroupsSimple(), Config::getValue( 'group/defaultGroup' ) )
|
||||
);
|
||||
Views::view( 'admin.settings' );
|
||||
}
|
||||
}
|
156
app/controllers/admin/users.php
Normal file
156
app/controllers/admin/users.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/admin/users.php
|
||||
*
|
||||
* This is the users admin 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\Admin;
|
||||
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Code;
|
||||
use TheTempusProject\Bedrock\Functions\Hash;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Forms;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Bedrock\Classes\Config;
|
||||
use TheTempusProject\Classes\Forms as FormChecker;
|
||||
use TheTempusProject\Classes\AdminController;
|
||||
use TheTempusProject\Models\User;
|
||||
use TheTempusProject\Models\Group;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
|
||||
class Users extends AdminController {
|
||||
public static $user;
|
||||
public static $group;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$title = 'Admin - Users';
|
||||
self::$user = new User;
|
||||
self::$group = new Group;
|
||||
$view = Navigation::activePageSelect( 'nav.admin', '/admin/users' );
|
||||
Components::set( 'ADMINNAV', $view );
|
||||
}
|
||||
|
||||
public function create() {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
if ( !FormChecker::check( 'createUser' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
} else {
|
||||
$fields = [
|
||||
'username' => Input::post( 'username' ),
|
||||
'password' => Hash::make( Input::post( 'password' ) ),
|
||||
'email' => Input::post( 'email' ),
|
||||
'userGroup' => Input::post( 'groupSelect' ),
|
||||
'terms' => 0,
|
||||
];
|
||||
if ( !Input::exists( 'confirmation' ) ) {
|
||||
$fields['confirmed'] = 1;
|
||||
}
|
||||
if ( self::$user->create( $fields ) ) {
|
||||
Issues::add( 'success', 'User Created' );
|
||||
return $this->index();
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error creating the user' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$select = Forms::getFormFieldHtml( 'groupSelect', 'User Group', 'select', Config::getValue( 'group/defaultGroup' ), self::$group->listGroupsSimple() );
|
||||
Components::set( 'groupSelect', $select );
|
||||
Views::view( 'admin.users.create' );
|
||||
}
|
||||
|
||||
public function delete( $id = null ) {
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$id = Input::post( 'U_' );
|
||||
}
|
||||
if ( self::$user->delete( $id ) ) {
|
||||
Issues::add( 'success', 'User deleted' );
|
||||
} else {
|
||||
Issues::add( 'error', 'There was an error deleting user(s)' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function edit( $id = null ) {
|
||||
if ( !Check::id( $id ) ) {
|
||||
return Issues::add( 'error', 'Invalid user' );
|
||||
}
|
||||
$userData = self::$user->findById( $id );
|
||||
if ( in_array( $userData->groupName, self::$group::$protectedGroups ) ) {
|
||||
switch ( $userData->groupName ) {
|
||||
case 'Super':
|
||||
if ( 'Super' !== App::$activeGroup->name ) {
|
||||
Issues::add( 'error', 'You do not have permission to do that.' );
|
||||
return $this->index();
|
||||
}
|
||||
case 'Admin':
|
||||
if ( 'Super' !== App::$activeGroup->name ) {
|
||||
Issues::add( 'error', 'You do not have permission to do that.' );
|
||||
return $this->index();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
if ( !FormChecker::check( 'editUser' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
} else {
|
||||
$fields = [
|
||||
'username' => Input::post( 'username' ),
|
||||
'email' => Input::post( 'email' ),
|
||||
'userGroup' => Input::post( 'groupSelect' ),
|
||||
];
|
||||
if ( Input::exists( 'confirmed' ) ) {
|
||||
$fields['confirmed'] = 1;
|
||||
} else {
|
||||
if ( Input::exists( 'confirmation' ) ) {
|
||||
$fields['confirmationCode'] = Code::genConfirmation();
|
||||
}
|
||||
}
|
||||
if ( self::$user->update( $userData->ID, $fields ) ) {
|
||||
Issues::add( 'success', 'User Updated.' );
|
||||
return $this->index();
|
||||
} else {
|
||||
Issues::add( 'notice', 'There was an error with your request, please try again.' );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( empty( $avatarLocation ) ) {
|
||||
$avatarLocation = $userData->prefs['avatar'];
|
||||
}
|
||||
if ( empty( $userGroup ) ) {
|
||||
$userGroup = $userData->userGroup;
|
||||
}
|
||||
Forms::selectRadio( 'confirmed', $userData->confirmed );
|
||||
$avatar = Forms::getFormFieldHtml( 'avatar', 'User Avatar', 'file', $avatarLocation );
|
||||
$select = Forms::getFormFieldHtml( 'groupSelect', 'User Group', 'select', $userGroup, self::$group->listGroupsSimple() );
|
||||
Components::set( 'AvatarSettings', $avatar );
|
||||
Components::set( 'groupSelect', $select );
|
||||
Views::view( 'admin.users.edit', $userData );
|
||||
}
|
||||
|
||||
public function index() {
|
||||
Views::view( 'admin.users.list', self::$user->userList() );
|
||||
}
|
||||
|
||||
public function view( $id = null ) {
|
||||
if ( !empty( $id ) ) {
|
||||
$userData = self::$user->findById( $id );
|
||||
if ( $userData !== false ) {
|
||||
return Views::view( 'admin.users.view', $userData );
|
||||
}
|
||||
Issues::add( 'error', 'User not found.' );
|
||||
}
|
||||
$this->index();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user