Compare commits

..

4 Commits
4.0.2 ... 4.0.3

Author SHA1 Message Date
35b7be92a6 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
2025-01-26 15:13:34 -05:00
d4751696f3 sendmail bugfix 2025-01-23 22:39:11 -05:00
fa12dd20ba add redirect link to admin 2025-01-23 22:25:33 -05:00
41a6aed209 route bugfix 2025-01-23 22:22:08 -05:00
9 changed files with 62 additions and 15 deletions

View File

@ -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'] );

View File

@ -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] );
}
}
}

View File

@ -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' );
}

View File

@ -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' );

View File

@ -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.' );

View File

@ -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 ) );

View File

@ -3,7 +3,7 @@
<hr>
<div class="row justify-content-center">
<div class="col-md-6">
<form action="" method="post" class="">
<form action="" method="post" class="" enctype="multipart/form-data">
<fieldset>
{PREFERENCES_FORM}
</fieldset>

View File

@ -134,6 +134,10 @@ class TheTempusProject extends Bedrock {
],
],
],
[
'text' => '<i class="fa fa-fw fa-external-link"></i> Redirects',
'url' => '{ROOT_URL}admin/routes',
],
];
public $main_links = [
[
@ -287,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",
@ -300,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,
]
],

View File

@ -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'];