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
This commit is contained in:
@ -35,7 +35,7 @@ class Config extends BedrockConfig {
|
|||||||
case 'radio':
|
case 'radio':
|
||||||
case 'bool':
|
case 'bool':
|
||||||
case 'boolean':
|
case 'boolean':
|
||||||
$fieldHtml = Forms::getSwitchHtml( $fieldname, [ 'true', 'false' ], $node['value'] );
|
$fieldHtml = Forms::getSwitchHtml( $fieldname, $node['value'] );
|
||||||
break;
|
break;
|
||||||
case 'select':
|
case 'select':
|
||||||
$fieldHtml = Forms::getSelectHtml( $fieldname, $options, $node['value'] );
|
$fieldHtml = Forms::getSelectHtml( $fieldname, $options, $node['value'] );
|
||||||
|
@ -19,6 +19,7 @@ use TheTempusProject\Bedrock\Functions\Check;
|
|||||||
use TheTempusProject\Bedrock\Functions\Upload;
|
use TheTempusProject\Bedrock\Functions\Upload;
|
||||||
use TheTempusProject\Bedrock\Functions\Input;
|
use TheTempusProject\Bedrock\Functions\Input;
|
||||||
use TheTempusProject\TheTempusProject as App;
|
use TheTempusProject\TheTempusProject as App;
|
||||||
|
use TheTempusProject\Bedrock\Classes\Config;
|
||||||
|
|
||||||
class Preferences {
|
class Preferences {
|
||||||
public static $preferences = false;
|
public static $preferences = false;
|
||||||
@ -208,6 +209,15 @@ class Preferences {
|
|||||||
if ( $tempPrefsArray['type'] == 'checkbox' ) {
|
if ( $tempPrefsArray['type'] == 'checkbox' ) {
|
||||||
$tempPrefsArray['type'] = 'switch';
|
$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'] );
|
$inputTypes[ $tempPrefsArray['type'] ][] = self::getFormFieldHtml( $name, $tempPrefsArray['pretty'], $tempPrefsArray['type'], $tempPrefsArray['value'], $tempPrefsArray['options'] );
|
||||||
}
|
}
|
||||||
foreach ( $inputTypes as $skip => $items ) {
|
foreach ( $inputTypes as $skip => $items ) {
|
||||||
@ -295,6 +305,7 @@ class Preferences {
|
|||||||
$prefsArray[$name] = $route . Upload::last();
|
$prefsArray[$name] = $route . Upload::last();
|
||||||
} else {
|
} else {
|
||||||
Issues::add( 'error', [ 'There was an error with your upload.' => Check::userErrors() ] );
|
Issues::add( 'error', [ 'There was an error with your upload.' => Check::userErrors() ] );
|
||||||
|
unset( $prefsArray[$name] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ use TheTempusProject\Houdini\Classes\Views;
|
|||||||
use TheTempusProject\TheTempusProject as App;
|
use TheTempusProject\TheTempusProject as App;
|
||||||
use TheTempusProject\Classes\Controller;
|
use TheTempusProject\Classes\Controller;
|
||||||
use TheTempusProject\Classes\Forms;
|
use TheTempusProject\Classes\Forms;
|
||||||
|
use TheTempusProject\Bedrock\Classes\Config;
|
||||||
|
|
||||||
class Register extends Controller {
|
class Register extends Controller {
|
||||||
public function confirm( $code = null ) {
|
public function confirm( $code = null ) {
|
||||||
@ -46,6 +47,11 @@ class Register extends Controller {
|
|||||||
public function index() {
|
public function index() {
|
||||||
self::$title = '{SITENAME} Sign Up';
|
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.';
|
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' ) );
|
Components::set( 'TERMS', Views::simpleView( 'terms' ) );
|
||||||
if ( App::$isLoggedIn ) {
|
if ( App::$isLoggedIn ) {
|
||||||
return Issues::add( 'notice', 'You are currently logged in.' );
|
return Issues::add( 'notice', 'You are currently logged in.' );
|
||||||
|
@ -101,15 +101,17 @@ class Usercp extends Controller {
|
|||||||
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
||||||
Navigation::activePageSelect( $menu, null, true, true );
|
Navigation::activePageSelect( $menu, null, true, true );
|
||||||
$prefs = new Preferences;
|
$prefs = new Preferences;
|
||||||
$fields = App::$activePrefs;
|
$userPrefs = App::$activePrefs;
|
||||||
if ( Input::exists( 'submit' ) ) {
|
if ( Input::exists( 'submit' ) ) {
|
||||||
$fields = $prefs->convertFormToArray( true, false );
|
$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 );
|
self::$user->updatePrefs( $fields, App::$activeUser->ID );
|
||||||
Issues::add( 'success', 'Your preferences have been updated.' );
|
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( 'AVATAR_SETTINGS', $fields['avatar'] );
|
||||||
Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) );
|
Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) );
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<form action="" method="post" class="">
|
<form action="" method="post" class="" enctype="multipart/form-data">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
{PREFERENCES_FORM}
|
{PREFERENCES_FORM}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
@ -291,6 +291,11 @@ class TheTempusProject extends Bedrock {
|
|||||||
"pretty" => "Enable CSRF Token for all forms.",
|
"pretty" => "Enable CSRF Token for all forms.",
|
||||||
"default" => true
|
"default" => true
|
||||||
],
|
],
|
||||||
|
"registrationEnabled" => [
|
||||||
|
"type" => "radio",
|
||||||
|
"pretty" => "Allow new users to register an account.",
|
||||||
|
"default" => true
|
||||||
|
],
|
||||||
"loginLimit" => [
|
"loginLimit" => [
|
||||||
"type" => "text",
|
"type" => "text",
|
||||||
"pretty" => "Maximum Login Attempts per hour",
|
"pretty" => "Maximum Login Attempts per hour",
|
||||||
@ -304,17 +309,15 @@ class TheTempusProject extends Bedrock {
|
|||||||
],
|
],
|
||||||
"uploads" => [
|
"uploads" => [
|
||||||
"images" => [
|
"images" => [
|
||||||
"type"=> "radio",
|
"type" => "radio",
|
||||||
"pretty"=> "Upload Images Enabled",
|
"pretty" => "Upload Images Enabled",
|
||||||
"default"=> true,
|
"default" => true,
|
||||||
"protected"=> true,
|
"value" => true,
|
||||||
"value"=> true,
|
|
||||||
],
|
],
|
||||||
"maxImageSize"=> [
|
"maxImageSize"=> [
|
||||||
"type" => "text",
|
"type" => "text",
|
||||||
"pretty" => "Maximum size for image uploads",
|
"pretty" => "Maximum size for image uploads",
|
||||||
"default" => 500000,
|
"default" => 500000,
|
||||||
"protected" => true,
|
|
||||||
"value" => 500000,
|
"value" => 500000,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -195,16 +195,22 @@ class Install extends Controller {
|
|||||||
public function configure() {
|
public function configure() {
|
||||||
if ( Forms::Check( 'installConfigure' ) ) {
|
if ( Forms::Check( 'installConfigure' ) ) {
|
||||||
$logo = 'images/logo.png';
|
$logo = 'images/logo.png';
|
||||||
|
$logoLarge = 'images/logoLarge.png';
|
||||||
if ( Input::exists( 'logo' ) && Upload::image( 'logo', 'System' ) ) {
|
if ( Input::exists( 'logo' ) && Upload::image( 'logo', 'System' ) ) {
|
||||||
$logo = 'Uploads/Images/System/' . Upload::last();
|
$logo = 'Uploads/Images/System/' . Upload::last();
|
||||||
}
|
}
|
||||||
TheTempusProject::$activeConfig->load( BEDROCK_CONFIG_JSON );
|
TheTempusProject::$activeConfig->load( BEDROCK_CONFIG_JSON );
|
||||||
$baseConfig = TheTempusProject::$configMatrix;
|
$baseConfig = TheTempusProject::$configMatrix;
|
||||||
$baseConfig['main']['logo']['value'] = $logo;
|
$baseConfig['main']['logo']['value'] = $logo;
|
||||||
|
$baseConfig['main']['logoLarge']['value'] = $logoLarge;
|
||||||
$baseConfig['main']['name']['value'] = Input::postNull( 'siteName' );
|
$baseConfig['main']['name']['value'] = Input::postNull( 'siteName' );
|
||||||
$baseConfig['main']['template']['value'] = $baseConfig['main']['template']['default'];
|
$baseConfig['main']['template']['value'] = $baseConfig['main']['template']['default'];
|
||||||
$baseConfig['main']['tokenEnabled']['value'] = $baseConfig['main']['tokenEnabled']['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']['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']['dbEnabled']['value'] = $baseConfig['database']['dbEnabled']['default'];
|
||||||
$baseConfig['database']['dbHost']['value'] = Input::postNull( 'dbHost' );
|
$baseConfig['database']['dbHost']['value'] = Input::postNull( 'dbHost' );
|
||||||
$baseConfig['database']['dbMaxQuery']['value'] = $baseConfig['database']['dbMaxQuery']['default'];
|
$baseConfig['database']['dbMaxQuery']['value'] = $baseConfig['database']['dbMaxQuery']['default'];
|
||||||
|
Reference in New Issue
Block a user