PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 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 All 34 releases
← All changes | includes/desktop-files/sharing.php +15 -15 0.9.81.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Folder sharing visibility logic.
3 + * OpenStation — Folder sharing visibility logic.
4 4 *
5 5 * Computes which folders a viewer can see from each folder's
6 6 * `share_mode` plus the shares / decisions tables:
7 7 *
@@ -10,16 +10,16 @@
10 10 * grant in the `_desktop_mode_folder_shares` table (role grants
11 11 * additionally require a per-user accepted row in the decisions
12 12 * table). The folders row's `share_meta` column is
13 13 * diagnostic-only and is never consulted for visibility.
14 - * - `all` — every desktop-mode user on the site.
14 + * - `all` — every openstation user on the site.
15 15 *
16 - * Hooked at priority 5 on `desktop_mode_files_visible_folders`
16 + * Hooked at priority 5 on `openstation_files_visible_folders`
17 17 * so plugins layering custom share modes (registered via
18 - * `desktop_mode_files_share_modes`) can run later in the chain
18 + * `openstation_files_share_modes`) can run later in the chain
19 19 * without competing for the early slot.
20 20 *
21 - * @package WPDesktopMode
21 + * @package OpenStation
22 22 */
23 23
24 24 defined( 'ABSPATH' ) || exit;
25 25
@@ -30,9 +30,9 @@
30 30 * @param array $owned Owner-only folders (default from the store).
31 31 * @param int $user_id Viewer.
32 32 * @return array
33 33 */
34 -function desktop_mode_files_compute_visible_folders( $owned, $user_id ) {
34 +function openstation_files_compute_visible_folders( $owned, $user_id ) {
35 35 global $wpdb;
36 36 $user_id = (int) $user_id;
37 37 if ( $user_id <= 0 ) {
38 38 return is_array( $owned ) ? $owned : array();
@@ -37,9 +37,9 @@
37 37 if ( $user_id <= 0 ) {
38 38 return is_array( $owned ) ? $owned : array();
39 39 }
40 40
41 - $tables = desktop_mode_files_table_names();
41 + $tables = openstation_files_table_names();
42 42 $user = get_userdata( $user_id );
43 43 $roles = $user ? array_values( (array) $user->roles ) : array();
44 44
45 45 // Source 1 — `share_mode='all'`. Pull straight from the folders
@@ -80,9 +80,9 @@
80 80 // invites (we don't flip a role share to 'accepted' on behalf of
81 81 // every member of the role — that would be a "first to click
82 82 // decides for all" bug). The per-user acceptance lives in the
83 83 // decisions table, mirroring the resolution logic in
84 - // `desktop_mode_folder_share_user_capability`.
84 + // `openstation_folder_share_user_capability`.
85 85 //
86 86 // Without this join the role recipient could see the folder via
87 87 // REST `list_placements` (which routes through
88 88 // `_user_capability`, which DOES consult decisions) but their
@@ -119,21 +119,21 @@
119 119 foreach ( $visible as $row ) {
120 120 $seen_ids[ (int) $row['id'] ] = true;
121 121 }
122 122 foreach ( array_merge( (array) $all_rows, (array) $share_rows ) as $raw ) {
123 - $row = desktop_mode_files_normalize_folder_row( $raw );
123 + $row = openstation_files_normalize_folder_row( $raw );
124 124 $id = (int) $row['id'];
125 125 if ( isset( $seen_ids[ $id ] ) ) {
126 126 continue;
127 127 }
128 - if ( desktop_mode_files_user_can_see_folder( $row, $user_id, $roles ) ) {
129 - $visible[] = $row;
128 + if ( openstation_files_user_can_see_folder( $row, $user_id, $roles ) ) {
129 + $visible[] = $row;
130 130 $seen_ids[ $id ] = true;
131 131 }
132 132 }
133 133 return $visible;
134 134 }
135 -add_filter( 'desktop_mode_files_visible_folders', 'desktop_mode_files_compute_visible_folders', 5, 2 );
135 +add_filter( 'openstation_files_visible_folders', 'openstation_files_compute_visible_folders', 5, 2 );
136 136
137 137 /**
138 138 * Whether the viewer's identity satisfies a folder's share rules.
139 139 *
@@ -141,9 +141,9 @@
141 141 * @param int $user_id Viewer.
142 142 * @param string[] $user_roles Viewer's roles.
143 143 * @return bool
144 144 */
145 -function desktop_mode_files_user_can_see_folder( $folder, $user_id, $user_roles ) {
145 +function openstation_files_user_can_see_folder( $folder, $user_id, $user_roles ) {
146 146 $mode = (string) $folder['share_mode'];
147 147
148 148 // Owner always sees the folder.
149 149 if ( (int) $folder['owner_id'] === (int) $user_id ) {
@@ -157,9 +157,9 @@
157 157 // drafts had a fallback that silently re-granted access
158 158 // to revoked recipients; reviewer caught the
159 159 // revocation-bypass and we dropped the fallback before
160 160 // the feature shipped.)
161 - $cap = desktop_mode_folder_share_user_capability( (int) $folder['id'], (int) $user_id );
161 + $cap = openstation_folder_share_user_capability( (int) $folder['id'], (int) $user_id );
162 162 $can = 'none' !== $cap;
163 163 }
164 164
165 165 /**
@@ -171,6 +171,6 @@
171 171 * @param array $folder Folder row.
172 172 * @param int $user_id Viewer.
173 173 * @param string[] $roles Viewer's roles.
174 174 */
175 - return (bool) apply_filters( 'desktop_mode_files_user_can_see_folder', $can, $folder, $user_id, $user_roles );
175 + return (bool) apply_filters( 'openstation_files_user_can_see_folder', $can, $folder, $user_id, $user_roles );
176 176 }