diff --git a/wire/config.php b/wire/config.php index a6ba5c3b..ed0c7ba9 100644 --- a/wire/config.php +++ b/wire/config.php @@ -523,6 +523,18 @@ $config->sessionHistory = 0; */ $config->userAuthHashType = 'sha1'; +/** + * Enable output formatting for current $user API variable at boot? + * + * EXPERIMENTAL: May not be compatible with with all usages, so if setting to `true` + * then be sure to test thoroughly on anything that works with $user API variable. + * + * @var bool + * @since 3.0.241 + * + */ +$config->userOutputFormatting = false; + /** * Names (string) or IDs (int) of roles that are not allowed to login * diff --git a/wire/core/Config.php b/wire/core/Config.php index f107ab10..86439d6f 100644 --- a/wire/core/Config.php +++ b/wire/core/Config.php @@ -156,6 +156,7 @@ * * @property string $userAuthSalt Salt generated at install time to be used as a secondary/non-database salt for the password system. #pw-group-session * @property string $userAuthHashType Default is 'sha1' - used only if Blowfish is not supported by the system. #pw-group-session + * @property bool $userOutputFormatting Enable output formatting for current $user API variable at boot? (default=false) #pw-group-session @since 3.0.241 * @property string $tableSalt Additional hash for other (non-authentication) purposes. #pw-group-system @since 3.0.164 * * @property bool $internal This is automatically set to FALSE when PW is externally bootstrapped. #pw-group-runtime diff --git a/wire/core/ProcessWire.php b/wire/core/ProcessWire.php index 436324cb..48a4f369 100644 --- a/wire/core/ProcessWire.php +++ b/wire/core/ProcessWire.php @@ -601,7 +601,9 @@ class ProcessWire extends Wire { // the current user can only be determined after the session has been initiated $session = $this->wire('session', new Session($this), true); $this->initVar('session', $session); - $this->wire('user', $users->getCurrentUser()); + $user = $users->getCurrentUser(); + if($config->userOutputFormatting) $user->of(true); + $this->wire('user', $user); $input = $this->wire('input', new WireInput(), true); if($config->wireInputLazy) $input->setLazy(true); diff --git a/wire/modules/Process/ProcessProfile/ProcessProfile.module b/wire/modules/Process/ProcessProfile/ProcessProfile.module index 5fe1b482..1c8cda3d 100644 --- a/wire/modules/Process/ProcessProfile/ProcessProfile.module +++ b/wire/modules/Process/ProcessProfile/ProcessProfile.module @@ -72,11 +72,15 @@ class ProcessProfile extends Process implements ConfigurableModule, WirePageEdit } $this->user = $this->wire()->user; + $of = $this->user->of(); + if($of) $this->user->of(false); + $this->headline($this->_("Profile:") . ' ' . $this->user->name); // Primary Headline (precedes the username) $form = $this->buildForm($fieldName); if($input->post('submit_save_profile') || $fieldName) { $this->processInput($form, $fieldName); + if($of) $this->user->of(true); if($fieldName) { // no need to redirect } else { @@ -84,7 +88,9 @@ class ProcessProfile extends Process implements ConfigurableModule, WirePageEdit } } else { - return $form->render(); + $out = $form->render(); + if($of) $this->user->of(true); + return $out; } return ''; }