From 41a6aed209613ecfea02962fb6258c094273d18b Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Thu, 23 Jan 2025 22:22:08 -0500 Subject: [PATCH 1/4] route bugfix --- app/controllers/admin/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/routes.php b/app/controllers/admin/routes.php index 0f65ccc..1f8b84c 100644 --- a/app/controllers/admin/routes.php +++ b/app/controllers/admin/routes.php @@ -36,7 +36,7 @@ class Routes extends AdminController { } public function create() { - if ( Input::exists( 'redirect_type' ) ) { + if ( ! Input::exists( 'redirect_type' ) ) { return Views::view( 'admin.routes.create' ); } From fa12dd20bab3f6c184119eb894e94716b289cbbb Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Thu, 23 Jan 2025 22:25:33 -0500 Subject: [PATCH 2/4] add redirect link to admin --- bin/tempus_project.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/tempus_project.php b/bin/tempus_project.php index 1184cc9..e39c284 100644 --- a/bin/tempus_project.php +++ b/bin/tempus_project.php @@ -134,6 +134,10 @@ class TheTempusProject extends Bedrock { ], ], ], + [ + 'text' => ' Redirects', + 'url' => '{ROOT_URL}admin/routes', + ], ]; public $main_links = [ [ From d4751696f33ec7aff9c8f785bbda684d7565fbe9 Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Thu, 23 Jan 2025 22:39:11 -0500 Subject: [PATCH 3/4] sendmail bugfix --- app/controllers/admin/send_mail.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/send_mail.php b/app/controllers/admin/send_mail.php index e89a3dd..e2065e5 100644 --- a/app/controllers/admin/send_mail.php +++ b/app/controllers/admin/send_mail.php @@ -18,6 +18,7 @@ use TheTempusProject\Houdini\Classes\Issues; use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\Models\User; use TheTempusProject\Models\Subscribe; +use TheTempusProject\Plugins\Subscribe as Plugin; class SendMail extends AdminController { public static $user; @@ -27,10 +28,24 @@ class SendMail extends AdminController { parent::__construct(); self::$title = 'Admin - Send Mail'; self::$user = new User; - self::$subscribe = new Subscribe; + + if ( class_exists( 'TheTempusProject\Plugins\Subscribe' ) ) { + $plugin = new Plugin; + if ( ! $plugin->checkEnabled() ) { + Issues::add( 'notice', 'Subscriptions are disabled so those feature will be unavailable.' ); + } else { + self::$subscribe = new Subscribe; + } + } else { + Issues::add( 'notice', 'Subscriptions plugin is not installed so those feature will be unavailable.' ); + } } private function emailSubscribers( $params ) { + if ( empty( self::$subscribe ) ) { + Issues::add( 'error', 'Subscriptions plugin is unavailable' ); + return; + } $list = self::$subscribe->list(); if ( empty( $list ) ) { Issues::add( 'error', 'No subscribers found' ); From 35b7be92a6fa771d8c9297995510344bcadebc59 Mon Sep 17 00:00:00 2001 From: Joey Kimsey Date: Sun, 26 Jan 2025 15:13:34 -0500 Subject: [PATCH 4/4] bugfixes and small features Fixed config switches not registering the correct current value Added better ux when image uploads are disabled Fixed an issue where uploaded files were not being handled correctly Added the ability to disable user registrations Fixed some variables being unintendedly protected --- app/classes/config.php | 2 +- app/classes/preferences.php | 11 +++++++++++ app/controllers/register.php | 6 ++++++ app/controllers/usercp.php | 12 +++++++----- app/views/user_cp/settings.html | 2 +- bin/tempus_project.php | 15 +++++++++------ install.php | 6 ++++++ 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/app/classes/config.php b/app/classes/config.php index b8f99d8..6f3609c 100644 --- a/app/classes/config.php +++ b/app/classes/config.php @@ -35,7 +35,7 @@ class Config extends BedrockConfig { case 'radio': case 'bool': case 'boolean': - $fieldHtml = Forms::getSwitchHtml( $fieldname, [ 'true', 'false' ], $node['value'] ); + $fieldHtml = Forms::getSwitchHtml( $fieldname, $node['value'] ); break; case 'select': $fieldHtml = Forms::getSelectHtml( $fieldname, $options, $node['value'] ); diff --git a/app/classes/preferences.php b/app/classes/preferences.php index 3bf15fa..3f05c9e 100644 --- a/app/classes/preferences.php +++ b/app/classes/preferences.php @@ -19,6 +19,7 @@ use TheTempusProject\Bedrock\Functions\Check; use TheTempusProject\Bedrock\Functions\Upload; use TheTempusProject\Bedrock\Functions\Input; use TheTempusProject\TheTempusProject as App; +use TheTempusProject\Bedrock\Classes\Config; class Preferences { public static $preferences = false; @@ -208,6 +209,15 @@ class Preferences { if ( $tempPrefsArray['type'] == 'checkbox' ) { $tempPrefsArray['type'] = 'switch'; } + + if ( 'file' === $tempPrefsArray['type'] ) { + // dv( Config::getValue( 'uploads/images' ) ); + if ( ! Config::getValue( 'uploads/images' ) ) { + Debug::info( 'Preference hidden because uploads are disabled.' ); + continue; + } + } + $inputTypes[ $tempPrefsArray['type'] ][] = self::getFormFieldHtml( $name, $tempPrefsArray['pretty'], $tempPrefsArray['type'], $tempPrefsArray['value'], $tempPrefsArray['options'] ); } foreach ( $inputTypes as $skip => $items ) { @@ -295,6 +305,7 @@ class Preferences { $prefsArray[$name] = $route . Upload::last(); } else { Issues::add( 'error', [ 'There was an error with your upload.' => Check::userErrors() ] ); + unset( $prefsArray[$name] ); } } } diff --git a/app/controllers/register.php b/app/controllers/register.php index 275fdc2..da84cc5 100644 --- a/app/controllers/register.php +++ b/app/controllers/register.php @@ -24,6 +24,7 @@ use TheTempusProject\Houdini\Classes\Views; use TheTempusProject\TheTempusProject as App; use TheTempusProject\Classes\Controller; use TheTempusProject\Classes\Forms; +use TheTempusProject\Bedrock\Classes\Config; class Register extends Controller { public function confirm( $code = null ) { @@ -46,6 +47,11 @@ class Register extends Controller { public function index() { self::$title = '{SITENAME} Sign Up'; self::$pageDescription = 'Many features of {SITENAME} are disabled or hidden from unregistered users. On this page you can sign up for an account to access all the app has to offer.'; + + if ( ! Config::getValue( 'main/registrationEnabled' ) ) { + return Issues::add( 'notice', 'The site administrator has disable the ability to register a new account.' ); + } + Components::set( 'TERMS', Views::simpleView( 'terms' ) ); if ( App::$isLoggedIn ) { return Issues::add( 'notice', 'You are currently logged in.' ); diff --git a/app/controllers/usercp.php b/app/controllers/usercp.php index 39a5444..c35ad0d 100644 --- a/app/controllers/usercp.php +++ b/app/controllers/usercp.php @@ -101,15 +101,17 @@ class Usercp extends Controller { $menu = Views::simpleView( 'nav.usercp', App::$userCPlinks ); Navigation::activePageSelect( $menu, null, true, true ); $prefs = new Preferences; - $fields = App::$activePrefs; + $userPrefs = 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.' ); + // if the image upload fails, need to fall back on original + if ( empty( $fields['avatar'] ) ) { + $fields['avatar'] = $userPrefs['avatar']; + } + } else { + $fields = $userPrefs; } Components::set( 'AVATAR_SETTINGS', $fields['avatar'] ); Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) ); diff --git a/app/views/user_cp/settings.html b/app/views/user_cp/settings.html index 50d92a9..5a6faa8 100644 --- a/app/views/user_cp/settings.html +++ b/app/views/user_cp/settings.html @@ -3,7 +3,7 @@
-
+
{PREFERENCES_FORM}
diff --git a/bin/tempus_project.php b/bin/tempus_project.php index e39c284..ef2a22f 100644 --- a/bin/tempus_project.php +++ b/bin/tempus_project.php @@ -291,6 +291,11 @@ class TheTempusProject extends Bedrock { "pretty" => "Enable CSRF Token for all forms.", "default" => true ], + "registrationEnabled" => [ + "type" => "radio", + "pretty" => "Allow new users to register an account.", + "default" => true + ], "loginLimit" => [ "type" => "text", "pretty" => "Maximum Login Attempts per hour", @@ -304,17 +309,15 @@ class TheTempusProject extends Bedrock { ], "uploads" => [ "images" => [ - "type"=> "radio", - "pretty"=> "Upload Images Enabled", - "default"=> true, - "protected"=> true, - "value"=> true, + "type" => "radio", + "pretty" => "Upload Images Enabled", + "default" => true, + "value" => true, ], "maxImageSize"=> [ "type" => "text", "pretty" => "Maximum size for image uploads", "default" => 500000, - "protected" => true, "value" => 500000, ] ], diff --git a/install.php b/install.php index 6892434..c40bace 100644 --- a/install.php +++ b/install.php @@ -195,16 +195,22 @@ class Install extends Controller { public function configure() { if ( Forms::Check( 'installConfigure' ) ) { $logo = 'images/logo.png'; + $logoLarge = 'images/logoLarge.png'; if ( Input::exists( 'logo' ) && Upload::image( 'logo', 'System' ) ) { $logo = 'Uploads/Images/System/' . Upload::last(); } TheTempusProject::$activeConfig->load( BEDROCK_CONFIG_JSON ); $baseConfig = TheTempusProject::$configMatrix; $baseConfig['main']['logo']['value'] = $logo; + $baseConfig['main']['logoLarge']['value'] = $logoLarge; $baseConfig['main']['name']['value'] = Input::postNull( 'siteName' ); $baseConfig['main']['template']['value'] = $baseConfig['main']['template']['default']; $baseConfig['main']['tokenEnabled']['value'] = $baseConfig['main']['tokenEnabled']['default']; + $baseConfig['main']['registrationEnabled']['value'] = $baseConfig['main']['registrationEnabled']['default']; $baseConfig['main']['loginLimit']['value'] = $baseConfig['main']['loginLimit']['default']; + $baseConfig['main']['loginTimer']['value'] = $baseConfig['main']['loginTimer']['default']; + $baseConfig['uploads']['images']['value'] = $baseConfig['uploads']['images']['default']; + $baseConfig['uploads']['maxImageSize']['value'] = $baseConfig['uploads']['maxImageSize']['default']; $baseConfig['database']['dbEnabled']['value'] = $baseConfig['database']['dbEnabled']['default']; $baseConfig['database']['dbHost']['value'] = Input::postNull( 'dbHost' ); $baseConfig['database']['dbMaxQuery']['value'] = $baseConfig['database']['dbMaxQuery']['default'];