Changeset 3748373 for dienstplan/trunk/src/Dienstplan/EntryActions.php
- Timestamp:
- 10/15/2026 11:59:50 AM (45 hours ago)
- File:
-
- 1 edited
-
dienstplan/trunk/src/Dienstplan/EntryActions.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dienstplan/trunk/src/Dienstplan/EntryActions.php
r3744969 r3748373 20 20 * @param array{ 21 21 * user_id: int, 22 * is_admin: bool, 22 * can_manage_plan?: bool, 23 * is_admin?: bool, 23 24 * is_past?: bool, 24 25 * type?: array<string, mixed>|null, … … 37 38 public static function forShift(array $shift, array $context): array 38 39 { 39 $userId = (int) ($context['user_id'] ?? 0);40 $ isAdmin = ! empty($context['is_admin']);41 $actions = [];42 43 if ($ isAdmin) {40 $userId = (int) ($context['user_id'] ?? 0); 41 $canManagePlan = ! empty( $context['can_manage_plan'] ) || ! empty( $context['is_admin'] ); 42 $actions = []; 43 44 if ($canManagePlan) { 44 45 $actions[] = [ 45 46 'key' => 'remove', … … 59 60 * @param array<string, mixed> $shift 60 61 * @param int $userId 61 * @param bool $ isAdmin62 * @param bool $canManagePlan Darf diesen Plan verwalten (Admin oder Schichtleiter). 62 63 */ 63 $filtered = apply_filters('dienstplan_entry_actions', $actions, $shift, $userId, $ isAdmin);64 $filtered = apply_filters('dienstplan_entry_actions', $actions, $shift, $userId, $canManagePlan); 64 65 65 66 if (!is_array($filtered)) { … … 157 158 $headerLine = implode(' · ', $headerParts); 158 159 159 /* translators: 1: person name, 2: shift type and date summary */160 160 $ariaLabel = sprintf( 161 /* translators: 1: person name, 2: shift type and date summary */ 161 162 __('Actions for %1$s, %2$s', 'dienstplan'), 162 163 $displayName, … … 205 206 * Shared assign / take-over member list for the calendar (once per shortcode). 206 207 * 207 * @param list<\WP_User|\stdClass> $members Admin assignable members (may be empty). 208 * @return array{me: array{id: int, label: string}, members: list<array{id: int, label: string}>} 208 * @param list<\WP_User|\stdClass> $members Assignable members (may be empty). 209 * @return array{ 210 * me: array{id: int, label: string, qualified: array<int, bool>}, 211 * members: list<array{id: int, label: string, qualified: array<int, bool>}> 212 * } 209 213 */ 210 214 public static function calendarMembersPayload( … … 221 225 : __('Me', 'dienstplan'); 222 226 223 $others = []; 227 /** @var array<int, bool> $meQualified */ 228 $meQualified = []; 229 $others = []; 224 230 foreach ($members as $member) { 225 231 $id = (int) ($member->ID ?? 0); 226 if ($id <= 0 || $id === $currentUserId) {232 if ($id <= 0) { 227 233 continue; 228 234 } 235 /** @var array<int, bool> $qualified */ 236 $qualified = is_array( $member->qualified ?? null ) ? $member->qualified : []; 237 if ($id === $currentUserId) { 238 $meQualified = $qualified; 239 continue; 240 } 229 241 $others[] = [ 230 'id' => $id, 231 'label' => (string) ($member->assign_label ?? $member->display_name ?? (string) $id), 242 'id' => $id, 243 'label' => (string) ($member->assign_label ?? $member->display_name ?? (string) $id), 244 'qualified' => $qualified, 232 245 ]; 233 246 } … … 235 248 return [ 236 249 'me' => [ 237 'id' => $currentUserId, 238 'label' => $meLabel, 250 'id' => $currentUserId, 251 'label' => $meLabel, 252 'qualified' => $meQualified, 239 253 ], 240 254 'members' => $others,
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)