| @@ -56,9 +56,24 @@ | ||
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $options = $this->addUserDataAsSelectorOption($users); |
| 60 | + if ('users' === $optionKey && $options) { | |
| 61 | + // Resolve plugin admins once for this result set instead of querying per user. | |
| 62 | + $adminIds = Meta::where('object_type', Constant::FLUENT_BOARD_ADMIN) | |
| 63 | + ->whereIn('object_id', array_column($options, 'id')) | |
| 64 | + ->pluck('object_id') | |
| 65 | + ->toArray(); | |
| 66 | + $adminLookup = array_fill_keys($adminIds, true); | |
| 60 | 67 | |
| 68 | + foreach ($options as &$option) { | |
| 69 | + $option['is_admin'] = isset($adminLookup[$option['id']]) | |
| 70 | + || PermissionManager::isWPAdmin($option['id']); | |
| 71 | + } | |
| 72 | + unset($option); | |
| 73 | + } | |
| 74 | + | |
| 75 | + | |
| 61 | 76 | } elseif ('board_create_users' === $optionKey) { |
| 62 | 77 | if (!PermissionManager::userHasBoardCreationPermission()) { |
| 63 | 78 | throw new \Exception(esc_html__('You do not have permission to access this route', 'fluent-boards')); |
| 64 | 79 | } |
| @@ -119,9 +134,9 @@ | ||
| 119 | 134 | throw new \Exception(esc_html__('You do not have permission to access this route', 'fluent-boards')); |
| 120 | 135 | } |
| 121 | 136 | |
| 122 | 137 | $users = (new BoardService())->getAssigneesByBoard($boardId, $search); |
| 123 | - $options = $this->addUserDataAsSelectorOption($users); | |
| 138 | + $options = $this->maskSelectorEmailsForViewer($this->addUserDataAsSelectorOption($users)); | |
| 124 | 139 | } else { |
| 125 | 140 | $options = apply_filters('fluent_boards/ajax_options_' . $optionKey, [], $search, $includedIds); |
| 126 | 141 | } |
| 127 | 142 | |