diff --git a/app/config/local/constants.php b/app/config/constants.php similarity index 100% rename from app/config/local/constants.php rename to app/config/constants.php diff --git a/app/controllers/home.php b/app/controllers/home.php index 7629389..3c9e13a 100644 --- a/app/controllers/home.php +++ b/app/controllers/home.php @@ -95,12 +95,6 @@ class Home extends Controller { Views::view( 'about' ); } - public function contact() { - self::$title = 'Contact Us - {SITENAME}'; - self::$pageDescription = 'On this page, you\'ll be able to reach out to the team directly with any questions, comments, or concerns you may have.'; - Views::view( 'contact' ); - } - public function privacy() { self::$title = 'Privacy Policy - {SITENAME}'; self::$pageDescription = 'At {SITENAME} you privacy is very important to us. On this page you can find a detailed outline of all the information we collect and how its used.'; diff --git a/app/controllers/usercp.php b/app/controllers/usercp.php index c0b13cf..39a5444 100644 --- a/app/controllers/usercp.php +++ b/app/controllers/usercp.php @@ -139,11 +139,9 @@ class Usercp extends Controller { $prefs = new Preferences; $fields1 = $prefs->convertFormToArray( true, false ); - $fields2 = []; $fields3 = $fields1; if ( isset( $fields1[ $name ] ) ) { - $fields2[ $name ] = $value; $fields3[ $name ] = $value; } $result = self::$user->updatePrefs( $fields3, App::$activeUser->ID ); diff --git a/app/js/main.js b/app/js/main.js index 3173ece..d759dd5 100644 --- a/app/js/main.js +++ b/app/js/main.js @@ -95,12 +95,31 @@ $(document).ready(function() { }); document.addEventListener('DOMContentLoaded', function () { + const ttpDarkmode = document.getElementById('dark-mode-pref'); const toggleButton = document.getElementById('dark-mode-toggle'); const enableButton = document.getElementById('dark-mode-toggle-button'); const darkModeStylesheet = document.getElementById('dark-mode-stylesheet'); + let currentState = ''; - // Check if dark mode is saved in localStorage - if (localStorage.getItem('darkMode') === 'enabled') { + // Check if dark mode is set by ttp + if ( ttpDarkmode ) { + if ( 'true' == ttpDarkmode.value ) { + currentState = 'enabled'; + } + if ( 'false' == ttpDarkmode.value ) { + currentState = 'disabled'; + } + } + + // Check if dark mode is set in localStorage + if ( '' == currentState ) { + if ( localStorage.getItem('darkMode') === 'enabled' ) { + currentState = 'enabled'; + } + } + + // Update current button states + if ( 'enabled' == currentState ) { darkModeStylesheet.disabled = false; toggleButton.checked = true; @@ -109,8 +128,9 @@ document.addEventListener('DOMContentLoaded', function () { } } + // Style striped table elements document.querySelectorAll('.table-striped').forEach((table) => { - if (localStorage.getItem('darkMode') === 'enabled') { + if ( 'enabled' == currentState ) { table.classList.add('table-dark'); } else { table.classList.add('table-light') @@ -119,7 +139,7 @@ document.addEventListener('DOMContentLoaded', function () { if ( enableButton ) { enableButton.addEventListener('click', function () { - if (darkModeStylesheet.disabled) { + if ( darkModeStylesheet.disabled ) { darkModeStylesheet.disabled = false; localStorage.setItem('darkMode', 'enabled'); enableButton.innerText = 'Disable Now'; @@ -141,7 +161,7 @@ document.addEventListener('DOMContentLoaded', function () { darkModeStylesheet.disabled = true; localStorage.setItem('darkMode', 'disabled'); } - + document.querySelectorAll('.table-striped').forEach((table) => { if (localStorage.getItem('darkMode') === 'enabled') { table.classList.add('table-dark'); diff --git a/app/models/group.php b/app/models/group.php index bbc512b..f5331a3 100644 --- a/app/models/group.php +++ b/app/models/group.php @@ -31,13 +31,16 @@ class Group extends DatabaseModel { 'defaultGroup' => [ 'type' => 'customSelect', 'pretty' => 'The Default Group for new registrations.', - 'default' => 5, + 'default' => 4, ], ]; public $databaseMatrix = [ [ 'name', 'varchar', '32' ], [ 'permissions', 'text', '' ], ]; + public $searchFields = [ + 'name', + ]; public $permissionMatrix = [ 'adminAccess' => [ 'pretty' => 'Access Administrator Areas', diff --git a/app/models/log.php b/app/models/log.php index efd7b4a..135758b 100644 --- a/app/models/log.php +++ b/app/models/log.php @@ -46,6 +46,9 @@ class Log extends DatabaseModel { [ 'source', 'varchar', '64' ], [ 'action', 'text', '' ], ]; + public $searchFields = [ + 'source', + ]; /** * The model constructor. diff --git a/app/models/routes.php b/app/models/routes.php index 8333692..a48b834 100644 --- a/app/models/routes.php +++ b/app/models/routes.php @@ -24,6 +24,9 @@ class Routes extends DatabaseModel { [ 'original_url', 'varchar', '32' ], [ 'forwarded_url', 'text', '' ], ]; + public $searchFields = [ + 'nickname', + ]; public $resourceMatrix = [ [ 'original_url' => 'fb', diff --git a/app/models/sessions.php b/app/models/sessions.php index 9edde85..427d573 100644 --- a/app/models/sessions.php +++ b/app/models/sessions.php @@ -36,6 +36,9 @@ class Sessions extends DatabaseModel { [ 'username', 'varchar', '20' ], [ 'token', 'varchar', '120' ], ]; + public $searchFields = [ + 'username', + ]; public static $activeSession = false; /** diff --git a/app/models/token.php b/app/models/token.php index fe9198a..59cb422 100644 --- a/app/models/token.php +++ b/app/models/token.php @@ -31,6 +31,10 @@ class Token extends DatabaseModel { [ 'createdBy', 'int', '10' ], [ 'expiresAt', 'int', '10' ], ]; + public $searchFields = [ + 'name', + 'token', + ]; public $permissionMatrix = [ 'addAppToken' => [ 'pretty' => 'Add Application Tokens', diff --git a/app/models/user.php b/app/models/user.php index 62012fa..0c520d6 100644 --- a/app/models/user.php +++ b/app/models/user.php @@ -44,6 +44,9 @@ class User extends DatabaseModel { [ 'confirmationCode', 'varchar', '80' ], [ 'prefs', 'text', '' ], ]; + public $searchFields = [ + 'username', + ]; public $permissionMatrix = [ 'uploadImages' => [ 'pretty' => 'Upload images (such as avatars)', diff --git a/app/plugins/blog/controllers/blog.php b/app/plugins/blog/controllers/blog.php index b14100b..e9803fd 100644 --- a/app/plugins/blog/controllers/blog.php +++ b/app/plugins/blog/controllers/blog.php @@ -62,12 +62,17 @@ class Blog extends Controller { return $this->index(); } - $plugin = new Comments; - if ( ! $plugin->checkEnabled() ) { - Issues::add( 'error', 'Comments are disabled.' ); + if ( class_exists( 'TheTempusProject\Plugins\Comments' ) ) { + $plugin = new Comments; + if ( ! $plugin->checkEnabled() ) { + Issues::add( 'error', 'Comments are disabled.' ); + return $this->index(); + } + $comments = new CommentsModel; + } else { + Debug::info( 'error', 'Comments plugin missing.' ); return $this->index(); } - $comments = new CommentsModel; switch ( $sub ) { case 'post': @@ -111,21 +116,22 @@ class Blog extends Controller { Components::set( 'CONTENT_ID', $id ); Components::set( 'COMMENT_TYPE', self::$posts->tableName ); + Components::set( 'NEWCOMMENT', '' ); + Components::set( 'count', '0' ); + Components::set( 'COMMENTS', '' ); - $plugin = new Comments; - if ( ! $plugin->checkEnabled() ) { - Components::set( 'NEWCOMMENT', '' ); - Components::set( 'count', '0' ); - Components::set( 'COMMENTS', '' ); - } else { - $comments = new CommentsModel; - if ( App::$isLoggedIn ) { - Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) ); - } else { - Components::set( 'NEWCOMMENT', '' ); + if ( class_exists( 'TheTempusProject\Plugins\Comments' ) ) { + $plugin = new Comments; + if ( $plugin->checkEnabled() ) { + $comments = new CommentsModel; + if ( App::$isLoggedIn ) { + Components::set( 'NEWCOMMENT', Views::simpleView( 'comments.create' ) ); + } else { + Components::set( 'NEWCOMMENT', '' ); + } + Components::set( 'count', $comments->count( self::$posts->tableName, $post->ID ) ); + Components::set( 'COMMENTS', Views::simpleView( 'comments.list', $comments->display( 10, self::$posts->tableName, $post->ID ) ) ); } - Components::set( 'count', $comments->count( self::$posts->tableName, $post->ID ) ); - Components::set( 'COMMENTS', Views::simpleView( 'comments.list', $comments->display( 10, self::$posts->tableName, $post->ID ) ) ); } $post = self::$posts->findById( $id ); diff --git a/app/plugins/comments/controllers/admin/comments.php b/app/plugins/comments/controllers/admin/comments.php index 8967873..4c9ead6 100644 --- a/app/plugins/comments/controllers/admin/comments.php +++ b/app/plugins/comments/controllers/admin/comments.php @@ -49,13 +49,13 @@ class Comments extends AdminController { $this->index(); } - public function viewComments( $contentIID = null ) { - if ( empty( $contentIID ) ) { + public function viewComments( $contentID = null ) { + if ( empty( $contentID ) ) { Issues::add( 'error', 'Content ID not found.' ); return $this->index(); } $contentData = self::$comments->findById( $data ); - if ( empty( $contentIID ) ) { + if ( empty( $contentID ) ) { return Views::view( 'comments.list', $commentData ); } Issues::add( 'error', 'Comment not found.' ); diff --git a/app/plugins/messages/controllers/messages.php b/app/plugins/messages/controllers/messages.php index 7bcd560..c07e8cc 100644 --- a/app/plugins/messages/controllers/messages.php +++ b/app/plugins/messages/controllers/messages.php @@ -19,6 +19,9 @@ use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Houdini\Classes\Issues; use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Input; +use TheTempusProject\TheTempusProject as App; +use TheTempusProject\Hermes\Functions\Redirect; +use TheTempusProject\Bedrock\Functions\Session; class Messages extends Controller { private static $message; @@ -27,6 +30,10 @@ class Messages extends Controller { parent::__construct(); self::$title = 'Messages'; self::$message = new Message; + if ( ! App::$isLoggedIn ) { + Session::flash( 'error', 'You do not have permission to access this page.' ); + return Redirect::home(); + } } public function create() { @@ -71,8 +78,9 @@ class Messages extends Controller { } public function index() { - Views::view( 'messages.inbox', self::$message->getInbox() ); - Views::view( 'messages.outbox', self::$message->getOutbox() ); + Components::set( 'message_inbox', Views::simpleView( 'messages.inbox', self::$message->getInbox() ) ); + Components::set( 'message_outbox', Views::simpleView( 'messages.outbox', self::$message->getOutbox() ) ); + Views::view( 'messages.index' ); } public function read( $id = '' ) { diff --git a/app/plugins/messages/views/badge.html b/app/plugins/messages/views/badge.html index 9e3a4ca..0a248f2 100644 --- a/app/plugins/messages/views/badge.html +++ b/app/plugins/messages/views/badge.html @@ -1 +1 @@ -{MESSAGE_COUNT} \ No newline at end of file +{MESSAGE_COUNT} \ No newline at end of file diff --git a/app/plugins/messages/views/inbox.html b/app/plugins/messages/views/inbox.html index b1ababa..71b1c34 100644 --- a/app/plugins/messages/views/inbox.html +++ b/app/plugins/messages/views/inbox.html @@ -1,7 +1,6 @@