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();
|
||||
}
|
||||
}
|
35
app/controllers/alpha.php
Normal file
35
app/controllers/alpha.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/alpha.php
|
||||
*
|
||||
* This is the friends and family alpha 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\Classes\Controller;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
|
||||
class Alpha extends Controller {
|
||||
public function index() {
|
||||
self::$title = 'Friends and Family Alpha';
|
||||
self::$pageDescription = 'The Tempus Project friends and family alpha has begun. Please join me and take part in bringing a dream to reality.';
|
||||
Views::view( 'alpha.index' );
|
||||
}
|
||||
|
||||
public function crashcourse() {
|
||||
self::$title = 'Friends and Family Crash-Course';
|
||||
self::$pageDescription = 'The Tempus Project runs not only this site, but it can be used and deployed for any number of sites. This crash course is intended to give you all the knowledge you will need to start building your own applications powered by The Tempus Project.';
|
||||
Views::view( 'alpha.crashcourse' );
|
||||
}
|
||||
|
||||
public function certification() {
|
||||
self::$title = 'Friends and Family Certification';
|
||||
self::$pageDescription = 'The Tempus Project runs not only this site, but it can be used and deployed for any number of sites. This certification course is intended to give experienced users all the information they will need to start building your own applications powered by The Tempus Project.';
|
||||
Views::view( 'alpha.certification' );
|
||||
}
|
||||
}
|
37
app/controllers/api/users.php
Normal file
37
app/controllers/api/users.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/api/users.php
|
||||
*
|
||||
* This is the users' api 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\Api;
|
||||
|
||||
use TheTempusProject\Models\User;
|
||||
use TheTempusProject\Classes\ApiController;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
|
||||
class Users extends ApiController {
|
||||
public static $user;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
self::$user = new User;
|
||||
}
|
||||
|
||||
public function find( $id = null ) {
|
||||
$user = self::$user->get( $id );
|
||||
if ( ! $user ) {
|
||||
$responseType = 'error';
|
||||
$response = 'No user found.';
|
||||
} else {
|
||||
$responseType = 'data';
|
||||
$response = $user;
|
||||
}
|
||||
Views::view( 'api.response', ['response' => json_encode( [ $responseType => $response ], true )]);
|
||||
}
|
||||
}
|
27
app/controllers/error.php
Normal file
27
app/controllers/error.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/error.php
|
||||
*
|
||||
* This is the error 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\Classes\Controller;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
|
||||
class Error extends Controller {
|
||||
public function index() {
|
||||
self::$title = 'Error';
|
||||
self::$pageDescription = 'The application has encountered an error.';
|
||||
Views::view( 'errors.generic' );
|
||||
}
|
||||
|
||||
public function upload404() {
|
||||
Views::view( 'errors.upload404' );
|
||||
}
|
||||
}
|
101
app/controllers/home.php
Normal file
101
app/controllers/home.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/home.php
|
||||
*
|
||||
* This is the home or 'index' 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\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Hermes\Functions\Route as Routes;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Template;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
|
||||
class Home extends Controller {
|
||||
public function index() {
|
||||
self::$title = '{SITENAME}';
|
||||
self::$pageDescription = 'This is the homepage of your new Tempus Project Installation. Thank you for installing. find more info at https://thetempusproject.com';
|
||||
Views::view( 'index' );
|
||||
}
|
||||
|
||||
public function login() {
|
||||
self::$title = 'Portal - {SITENAME}';
|
||||
self::$pageDescription = 'Please log in to use {SITENAME} member features.';
|
||||
if ( App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'You are already logged in. Please <a href="' . Routes::getAddress() . 'home/logout">click here</a> to log out.' );
|
||||
}
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'login' );
|
||||
}
|
||||
if ( !Forms::check( 'login' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your login.' => Check::userErrors() ] );
|
||||
return Views::view( 'login' );
|
||||
}
|
||||
if ( !self::$user->logIn( Input::post( 'username' ), Input::post( 'password' ), Input::post( 'remember' ) ) ) {
|
||||
Issues::add( 'error', 'Username or password was incorrect.' );
|
||||
return Views::view( 'login' );
|
||||
}
|
||||
Session::flash( 'success', 'You have been logged in.' );
|
||||
if ( Input::exists( 'rurl' ) ) {
|
||||
Redirect::to( Input::post( 'rurl' ) );
|
||||
} else {
|
||||
Redirect::to( 'home/index' );
|
||||
}
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
self::$title = 'Log Out - {SITENAME}';
|
||||
Template::noIndex();
|
||||
if ( !App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'You are not logged in.' );
|
||||
}
|
||||
self::$user->logOut();
|
||||
Session::flash( 'success', 'You have been logged out.' );
|
||||
Redirect::to( 'home/index' );
|
||||
}
|
||||
|
||||
public function profile( $id = null ) {
|
||||
self::$title = 'User Profile - {SITENAME}';
|
||||
self::$pageDescription = 'User Profiles for {SITENAME}';
|
||||
if ( !App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'You must be logged in to view this page.' );
|
||||
}
|
||||
$user = self::$user->get( $id );
|
||||
if ( !$user ) {
|
||||
return Issues::add( 'notice', 'No user found.' );
|
||||
}
|
||||
self::$title = $user->username . '\'s Profile - {SITENAME}';
|
||||
self::$pageDescription = 'User Profile for ' . $user->username . ' - {SITENAME}';
|
||||
Views::view( 'profile', $user );
|
||||
}
|
||||
|
||||
public function terms() {
|
||||
self::$title = 'Terms and Conditions - {SITENAME}';
|
||||
self::$pageDescription = '{SITENAME} Terms and Conditions of use. Please use {SITENAME} safely.';
|
||||
Components::set( 'TERMS', Views::simpleView( 'terms' ) );
|
||||
Views::raw( '<div class="terms-page">{TERMS}</div>' );
|
||||
}
|
||||
|
||||
public function hashtag( $id = null ) {
|
||||
self::$title = 'HashTag - {SITENAME}';
|
||||
self::$pageDescription = 'HashTags for {SITENAME}';
|
||||
if ( !App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'You must be logged in to view this page.' );
|
||||
}
|
||||
// this should look up comments and blog posts with the hashtag in them
|
||||
Views::view( 'hashtags' );
|
||||
}
|
||||
}
|
3
app/controllers/plugins.php
Normal file
3
app/controllers/plugins.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// the idea is that this will be info pages for the plugin various/info
|
||||
?>
|
139
app/controllers/register.php
Normal file
139
app/controllers/register.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/register.php
|
||||
*
|
||||
* This is the user registration 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\Classes\Email;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Hash;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
|
||||
class Register extends Controller {
|
||||
public function confirm( $code = null ) {
|
||||
self::$title = 'Confirm Email';
|
||||
if ( !isset( $code ) && !Input::exists( 'confirmationCode' ) ) {
|
||||
return Views::view( 'email.confirmation' );
|
||||
}
|
||||
if ( Forms::check( 'emailConfirmation' ) ) {
|
||||
$code = Input::post( 'confirmationCode' );
|
||||
}
|
||||
if ( !self::$user->confirm( $code ) ) {
|
||||
Issues::add( 'error', 'There was an error confirming your account, please try again.' );
|
||||
return Views::view( 'email.confirmation' );
|
||||
}
|
||||
Session::flash( 'success', 'You have successfully confirmed your email address.' );
|
||||
Redirect::to( 'home/index' );
|
||||
}
|
||||
|
||||
public function index() {
|
||||
self::$title = 'Register';
|
||||
self::$pageDescription = 'Many features of the site are disabled or even hidden from unregistered users. On this page you can sign up for an account to access all the app has to offer.';
|
||||
Components::set( 'TERMS', Views::simpleView( 'terms' ) );
|
||||
if ( App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'You are currently logged in.' );
|
||||
}
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'register' );
|
||||
}
|
||||
if ( !Forms::check( 'register' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your registration.' => Check::userErrors() ] );
|
||||
return Views::view( 'register' );
|
||||
}
|
||||
self::$user->create( [
|
||||
'username' => Input::post( 'username' ),
|
||||
'password' => Hash::make( Input::post( 'password' ) ),
|
||||
'email' => Input::post( 'email' ),
|
||||
'terms' => 1,
|
||||
] );
|
||||
Session::flash( 'success', 'Thank you for registering! Please check your email to confirm your account.' );
|
||||
Redirect::to( 'home/index' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Come back and separate this into multiple forms because this is gross.
|
||||
*/
|
||||
public function recover() {
|
||||
self::$title = 'Recover Account - {SITENAME}';
|
||||
Template::noIndex();
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'forgot' );
|
||||
}
|
||||
if ( Check::email( Input::post( 'entry' ) ) && self::$user->findByEmail( Input::post( 'entry' ) ) ) {
|
||||
$userData = self::$user->data();
|
||||
Email::send( $userData->email, 'forgotUsername', $userData->username, [ 'template' => true ] );
|
||||
Session::flash( 'notice', 'Your Username has been sent to your registered email address.' );
|
||||
Redirect::to( 'home/login' );
|
||||
} elseif ( self::$user->get( Input::post( 'entry' ) ) ) {
|
||||
self::$user->newCode( self::$user->data()->ID );
|
||||
self::$user->get( Input::post( 'entry' ) );
|
||||
$userData = self::$user->data();
|
||||
Email::send( $userData->email, 'forgotPassword', $userData->confirmationCode, [ 'template' => true ] );
|
||||
Session::flash( 'notice', 'Details for resetting your password have been sent to your registered email address' );
|
||||
Redirect::to( 'home/login' );
|
||||
}
|
||||
Issues::add( 'error', 'User not found.' );
|
||||
Views::view( 'forgot' );
|
||||
}
|
||||
|
||||
public function resend() {
|
||||
self::$title = 'Resend Confirmation';
|
||||
if ( !App::$isLoggedIn ) {
|
||||
return Issues::add( 'notice', 'Please log in to resend your confirmation email.' );
|
||||
}
|
||||
if ( App::$activeUser->data()->confirmed == '1' ) {
|
||||
return Issues::add( 'notice', 'Your account has already been confirmed.' );
|
||||
}
|
||||
if ( !Forms::check( 'confirmationResend' ) ) {
|
||||
return Views::view( 'email.confirmation_resend' );
|
||||
}
|
||||
Email::send( App::$activeUser->data()->email, 'confirmation', App::$activeUser->data()->confirmationCode, [ 'template' => true ] );
|
||||
Session::flash( 'success', 'Your confirmation email has been sent to the email for your account.' );
|
||||
Redirect::to( 'home/index' );
|
||||
}
|
||||
|
||||
public function reset( $code = null ) {
|
||||
self::$title = 'Password Reset';
|
||||
if ( !isset( $code ) && !Input::exists( 'resetCode' ) ) {
|
||||
Issues::add( 'error', 'No reset code provided.' );
|
||||
return Views::view( 'password_reset_code' );
|
||||
}
|
||||
if ( Input::exists( 'resetCode' ) ) {
|
||||
if ( Forms::check( 'password_reset_code' ) ) {
|
||||
$code = Input::post( 'resetCode' );
|
||||
}
|
||||
}
|
||||
if ( !self::$user->checkCode( $code ) ) {
|
||||
Issues::add( 'error', 'There was an error with your reset code. Please try again.' );
|
||||
return Views::view( 'password_reset_code' );
|
||||
}
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'password_reset' );
|
||||
}
|
||||
if ( !Forms::check( 'passwordReset' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return Views::view( 'password_reset' );
|
||||
}
|
||||
Components::set( 'resetCode', $code );
|
||||
self::$user->changePassword( $code, Input::post( 'password' ) );
|
||||
Email::send( self::$user->data()->email, 'passwordChange', null, [ 'template' => true ] );
|
||||
Session::flash( 'success', 'Your Password has been changed, please use your new password to log in.' );
|
||||
Redirect::to( 'home/login' );
|
||||
}
|
||||
}
|
111
app/controllers/usercp.php
Normal file
111
app/controllers/usercp.php
Normal file
@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* app/controllers/usercp.php
|
||||
*
|
||||
* This is the user control panel 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\Classes\Email;
|
||||
use TheTempusProject\Bedrock\Functions\Code;
|
||||
use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Functions\Input;
|
||||
use TheTempusProject\Bedrock\Functions\Hash;
|
||||
use TheTempusProject\Houdini\Classes\Components;
|
||||
use TheTempusProject\Houdini\Classes\Views;
|
||||
use TheTempusProject\Houdini\Classes\Issues;
|
||||
use TheTempusProject\Houdini\Classes\Navigation;
|
||||
use TheTempusProject\TheTempusProject as App;
|
||||
use TheTempusProject\Classes\Controller;
|
||||
use TheTempusProject\Classes\Preferences;
|
||||
use TheTempusProject\Classes\Forms;
|
||||
use TheTempusProject\Hermes\Functions\Redirect;
|
||||
use TheTempusProject\Bedrock\Functions\Session;
|
||||
|
||||
class Usercp extends Controller {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
if ( !App::$isLoggedIn ) {
|
||||
Session::flash( 'notice', 'You must be logged in to view this page!' );
|
||||
Redirect::home();
|
||||
}
|
||||
Template::noIndex();
|
||||
Navigation::activePageSelect( 'nav.usercp', null, true );
|
||||
}
|
||||
|
||||
public function email() {
|
||||
self::$title = 'Email Settings';
|
||||
if ( App::$activeUser->confirmed != '1' ) {
|
||||
return Issues::add( 'notice', 'You need to confirm your email address before you can make modifications. If you would like to resend that confirmation link, please <a href="{BASE}register/resend">click here</a>', true );
|
||||
}
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'user_cp.email_change' );
|
||||
}
|
||||
if ( !Forms::check( 'changeEmail' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return Views::view( 'user_cp.email_change' );
|
||||
}
|
||||
$code = Code::genConfirmation();
|
||||
self::$user->update(
|
||||
App::$activeUser->ID,
|
||||
[
|
||||
'confirmed' => 0,
|
||||
'email' => Input::post( 'email' ),
|
||||
'confirmationCode' => $code,
|
||||
],
|
||||
);
|
||||
Email::send( App::$activeUser->email, 'emailChangeNotice', $code, [ 'template' => true ] );
|
||||
Email::send( Input::post( 'email' ), 'emailChange', $code, [ 'template' => true ] );
|
||||
Issues::add( 'notice', 'Email has been changed, please check your email to confirm it.' );
|
||||
}
|
||||
|
||||
public function index() {
|
||||
self::$title = 'User Control Panel';
|
||||
Views::view( 'profile', App::$activeUser );
|
||||
}
|
||||
|
||||
public function password() {
|
||||
self::$title = 'Password Settings';
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'user_cp.password_change' );
|
||||
}
|
||||
if ( !Hash::check( Input::post( 'curpass' ), App::$activeUser->password ) ) {
|
||||
Issues::add( 'error', 'Current password was incorrect.' );
|
||||
return Views::view( 'user_cp.password_change' );
|
||||
}
|
||||
if ( !Forms::check( 'changePassword' ) ) {
|
||||
Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
return Views::view( 'user_cp.password_change' );
|
||||
}
|
||||
self::$user->update(
|
||||
App::$activeUser->ID,
|
||||
[ 'password' => Hash::make( Input::post( 'password' ) ) ],
|
||||
);
|
||||
Email::send( App::$activeUser->email, 'passwordChange', null, [ 'template' => true ] );
|
||||
Issues::add( 'notice', 'Your Password has been changed!' );
|
||||
}
|
||||
|
||||
public function settings() {
|
||||
self::$title = 'Preferences';
|
||||
$prefs = new Preferences;
|
||||
$fields = App::$activePrefs;
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$fields = $prefs->convertFormToArray( true, false );
|
||||
// @TODO now i may need to rework the form checker to work with this....
|
||||
// if (!Forms::check('userPrefs')) {
|
||||
// Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] );
|
||||
// }
|
||||
self::$user->updatePrefs( $fields, App::$activeUser->ID );
|
||||
Issues::add( 'success', 'Your preferences have been updated.' );
|
||||
}
|
||||
Components::set( 'AVATAR_SETTINGS', $fields['avatar'] );
|
||||
Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) );
|
||||
Views::view( 'user_cp.settings', App::$activeUser );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user