PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.9
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.9
1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 0.8.6 All 33 releases
desktop-mode / apps / user-edit / user-edit.os.php

user-edit.os.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.9, at apps/user-edit/user-edit.os.php

83 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * User Edit — the profile editor, as an OpenStation app.
4 *
5 * Claims the FROZEN id `desktop-mode-user-edit` (see AGENTS.md). A
6 * singleton that opens on the person carried in its open-time params
7 * (`{ userId }` — the `user-edit.php?user_id=N` remap, a Users row,
8 * WP Explorer, the agents roster; `0`, or none, is the viewer's own
9 * profile, how `profile.php` opens). A live window asked to open on
10 * someone else retargets through the `reopen` lifecycle. The body is
11 * `user-edit.os.ts`: `<os-user-profile>` on the state's id, from the
12 * companion bundle the Users app registers, fed this app's facts.
13 *
14 * (Header kept short on purpose: Plugin Check's direct-access scan
15 * reads only the first 50 raw lines, and the guard below must land
16 * inside that window.)
17 *
18 * @package OpenStation
19 */
20
21 namespace OpenStation\Apps\UserEdit;
22
23 use OpenStation\App;
24 use OpenStation\App\Os;
25 use OpenStation\App\State;
26
27 // Direct access, unless a standalone host is booting on bare PHP.
28 if ( ! defined( 'ABSPATH' ) ) {
29 defined( 'OPENSTATION_STANDALONE' ) || exit;
30 }
31
32 require_once __DIR__ . '/parts/permissions.php';
33 require_once __DIR__ . '/parts/account.php';
34 require_once __DIR__ . '/parts/insights.php';
35 // The facts (roles, locales, colour schemes, contact methods) and the
36 // profile bundle belong to the Users app; both windows share them.
37 require_once dirname( __DIR__ ) . '/users/parts/permissions.php';
38 require_once dirname( __DIR__ ) . '/users/parts/color-schemes.php';
39 require_once dirname( __DIR__ ) . '/users/parts/fields.php';
40 require_once dirname( __DIR__ ) . '/users/parts/facts.php';
41 require_once dirname( __DIR__ ) . '/users/parts/profile-script.php';
42
43 /**
44 * Point the window at the person the params name, or at the viewer.
45 *
46 * @param State $state State.
47 * @param Os $os Host handle.
48 * @return void
49 */
50 function retarget( State $state, Os $os ) {
51 $user_id = (int) $os->param( 'userId', 0 );
52 $state->set( 'userId', $user_id > 0 ? $user_id : (int) get_current_user_id() );
53 }
54
55 return App::define( 'desktop-mode-user-edit' )
56 ->title( __( 'Edit user', 'desktop-mode' ) )
57 ->icon( 'dashicons-admin-users' )
58 ->size( 1100, 760 )
59 ->min_size( 720, 520 )
60 ->placement( 'none' )
61 // The profile surface is styled by the Users app's sheet — one set
62 // of rules for the Profile tab and this window. Pointing here
63 // registers the same file under this app's own handle, so the
64 // window is dressed even when the Users window was never opened.
65 ->style( dirname( __DIR__ ) . '/users/users.css' )
66 ->can(
67 static function () {
68 return openstation_user_edit_window_user_can_register();
69 }
70 )
71 // Resolved when the window registers, for the viewer registering it.
72 ->config( 'openstation_users_profile_facts' )
73 ->state( array( 'userId' => 0 ) )
74 ->mount( __NAMESPACE__ . '\retarget' )
75 // The singleton reopened on someone else — the shell wrote the new
76 // params, the runtime dispatched this.
77 ->action( 'reopen', __NAMESPACE__ . '\retarget' )
78 ->data(
79 static function ( State $state ) {
80 return array( 'userId' => (int) $state->get( 'userId' ) );
81 }
82 );
83