Plugin Directory


Ignore:
Timestamp:
10/15/2026 11:59:50 AM (45 hours ago)
Author:
wpdienstplan
Message:

Update to version 3.10.0 from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dienstplan/trunk/src/Dienstplan/EntryActions.php

    r3744969 r3748373  
    2020     * @param array{
    2121     *   user_id: int,
    22      *   is_admin: bool,
     22     *   can_manage_plan?: bool,
     23     *   is_admin?: bool,
    2324     *   is_past?: bool,
    2425     *   type?: array<string, mixed>|null,
    … …  
    3738    public static function forShift(array $shift, array $context): array
    3839    {
    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) {
    4445            $actions[] = [
    4546                'key'         => 'remove',
    … …  
    5960         * @param array<string, mixed>             $shift
    6061         * @param int                              $userId
    61          * @param bool                             $isAdmin
     62         * @param bool                             $canManagePlan Darf diesen Plan verwalten (Admin oder Schichtleiter).
    6263         */
    63         $filtered = apply_filters('dienstplan_entry_actions', $actions, $shift, $userId, $isAdmin);
     64        $filtered = apply_filters('dienstplan_entry_actions', $actions, $shift, $userId, $canManagePlan);
    6465
    6566        if (!is_array($filtered)) {
    … …  
    157158        $headerLine  = implode(' · ', $headerParts);
    158159
    159         /* translators: 1: person name, 2: shift type and date summary */
    160160        $ariaLabel = sprintf(
     161            /* translators: 1: person name, 2: shift type and date summary */
    161162            __('Actions for %1$s, %2$s', 'dienstplan'),
    162163            $displayName,
    … …  
    205206     * Shared assign / take-over member list for the calendar (once per shortcode).
    206207     *
    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     * }
    209213     */
    210214    public static function calendarMembersPayload(
    … …  
    221225            : __('Me', 'dienstplan');
    222226
    223         $others = [];
     227        /** @var array<int, bool> $meQualified */
     228        $meQualified = [];
     229        $others      = [];
    224230        foreach ($members as $member) {
    225231            $id = (int) ($member->ID ?? 0);
    226             if ($id <= 0 || $id === $currentUserId) {
     232            if ($id <= 0) {
    227233                continue;
    228234            }
     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            }
    229241            $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,
    232245            ];
    233246        }
    … …  
    235248        return [
    236249            'me'      => [
    237                 'id'    => $currentUserId,
    238                 'label' => $meLabel,
     250                'id'        => $currentUserId,
     251                'label'     => $meLabel,
     252                'qualified' => $meQualified,
    239253            ],
    240254            'members' => $others,
Note: See TracChangeset for help on using the changeset viewer.