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