` on the state's id, from the * companion bundle the Users app registers, fed this app's facts. * * (Header kept short on purpose: Plugin Check's direct-access scan * reads only the first 50 raw lines, and the guard below must land * inside that window.) * * @package OpenStation */ namespace OpenStation\Apps\UserEdit; use OpenStation\App; use OpenStation\App\Os; use OpenStation\App\State; // Direct access, unless a standalone host is booting on bare PHP. if ( ! defined( 'ABSPATH' ) ) { defined( 'OPENSTATION_STANDALONE' ) || exit; } require_once __DIR__ . '/parts/permissions.php'; require_once __DIR__ . '/parts/account.php'; require_once __DIR__ . '/parts/insights.php'; // The facts (roles, locales, colour schemes, contact methods) and the // profile bundle belong to the Users app; both windows share them. require_once dirname( __DIR__ ) . '/users/parts/permissions.php'; require_once dirname( __DIR__ ) . '/users/parts/color-schemes.php'; require_once dirname( __DIR__ ) . '/users/parts/fields.php'; require_once dirname( __DIR__ ) . '/users/parts/facts.php'; require_once dirname( __DIR__ ) . '/users/parts/profile-script.php'; /** * Point the window at the person the params name, or at the viewer. * * @param State $state State. * @param Os $os Host handle. * @return void */ function retarget( State $state, Os $os ) { $user_id = (int) $os->param( 'userId', 0 ); $state->set( 'userId', $user_id > 0 ? $user_id : (int) get_current_user_id() ); } return App::define( 'desktop-mode-user-edit' ) ->title( __( 'Edit user', 'desktop-mode' ) ) ->icon( 'dashicons-admin-users' ) ->size( 1100, 760 ) ->min_size( 720, 520 ) ->placement( 'none' ) // The profile surface is styled by the Users app's sheet — one set // of rules for the Profile tab and this window. Pointing here // registers the same file under this app's own handle, so the // window is dressed even when the Users window was never opened. ->style( dirname( __DIR__ ) . '/users/users.css' ) ->can( static function () { return openstation_user_edit_window_user_can_register(); } ) // Resolved when the window registers, for the viewer registering it. ->config( 'openstation_users_profile_facts' ) ->state( array( 'userId' => 0 ) ) ->mount( __NAMESPACE__ . '\retarget' ) // The singleton reopened on someone else — the shell wrote the new // params, the runtime dispatched this. ->action( 'reopen', __NAMESPACE__ . '\retarget' ) ->data( static function ( State $state ) { return array( 'userId' => (int) $state->get( 'userId' ) ); } );