wip from ATB
This commit is contained in:
@ -36,12 +36,12 @@ class Usercp extends Controller {
|
||||
Redirect::home();
|
||||
}
|
||||
Template::noIndex();
|
||||
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
||||
Navigation::activePageSelect( $menu, null, true, true );
|
||||
}
|
||||
|
||||
public function email() {
|
||||
self::$title = 'Email Settings';
|
||||
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
||||
Navigation::activePageSelect( $menu, null, true, true );
|
||||
if ( App::$activeUser->confirmed != '1' ) {
|
||||
return Issues::add( 'notice', 'You need to confirm your email address before you can make modifications. If you would like to resend that confirmation link, please <a href="/register/resend">click here</a>', true );
|
||||
}
|
||||
@ -68,11 +68,15 @@ class Usercp extends Controller {
|
||||
|
||||
public function index() {
|
||||
self::$title = 'User Control Panel';
|
||||
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
||||
Navigation::activePageSelect( $menu, null, true, true );
|
||||
Views::view( 'profile', App::$activeUser );
|
||||
}
|
||||
|
||||
public function password() {
|
||||
self::$title = 'Password Settings';
|
||||
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
||||
Navigation::activePageSelect( $menu, null, true, true );
|
||||
if ( !Input::exists() ) {
|
||||
return Views::view( 'user_cp.password_change' );
|
||||
}
|
||||
@ -94,11 +98,12 @@ class Usercp extends Controller {
|
||||
|
||||
public function settings() {
|
||||
self::$title = 'Preferences';
|
||||
$menu = Views::simpleView( 'nav.usercp', App::$userCPlinks );
|
||||
Navigation::activePageSelect( $menu, null, true, true );
|
||||
$prefs = new Preferences;
|
||||
$fields = App::$activePrefs;
|
||||
if ( Input::exists( 'submit' ) ) {
|
||||
$fields = $prefs->convertFormToArray( true, false );
|
||||
// dv( $fields );
|
||||
// @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() ] );
|
||||
@ -110,4 +115,37 @@ class Usercp extends Controller {
|
||||
Components::set( 'PREFERENCES_FORM', $prefs->getFormHtml( $fields ) );
|
||||
Views::view( 'user_cp.settings', App::$activeUser );
|
||||
}
|
||||
|
||||
public function updatePref() {
|
||||
Template::setTemplate( 'api' );
|
||||
if ( ! App::$isLoggedIn ) {
|
||||
return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Not Logged In' ], true )]);
|
||||
}
|
||||
if ( ! Forms::check( 'updatePreference' ) ) {
|
||||
return Views::view( 'api.response', ['response' => json_encode( [ 'error' => Check::userErrors() ], true )]);
|
||||
}
|
||||
$name = Input::post( 'prefName' );
|
||||
$value = Input::post('prefValue' );
|
||||
|
||||
if ( 'false' === $value ) {
|
||||
$value = false;
|
||||
} elseif ( 'true' === $value ) {
|
||||
$value = true;
|
||||
}
|
||||
|
||||
if ( empty( Preferences::get( $name ) ) ) {
|
||||
return Views::view( 'api.response', ['response' => json_encode( [ 'error' => 'Unknown Preference' ], true )]);
|
||||
}
|
||||
|
||||
$prefs = new Preferences;
|
||||
$fields1 = $prefs->convertFormToArray( true, false );
|
||||
$fields3 = $fields1;
|
||||
|
||||
if ( isset( $fields1[ $name ] ) ) {
|
||||
$fields3[ $name ] = $value;
|
||||
}
|
||||
$result = self::$user->updatePrefs( $fields3, App::$activeUser->ID );
|
||||
|
||||
return Views::view( 'api.response', ['response' => json_encode( $result, true )]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user