| @@ -384,63 +384,8 @@ | ||
| 384 | 384 | $this->media_ownership_migration_notice->remove_hooks(); |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - /** | |
| 389 | - * Names of Media fields (any value format) that the current user is not allowed to | |
| 390 | - * change, because they lack the field's "user access" capability. | |
| 391 | - * | |
| 392 | - * File_Uploader checks that capability only when a file is uploaded, so a submission without | |
| 393 | - * a file would otherwise still be able to write attachment IDs. The value is not emptied: | |
| 394 | - * a permission failure must never turn an unchanged field into a removal request, so callers | |
| 395 | - * skip these fields entirely and leave the stored meta (and its attachments) untouched. | |
| 396 | - * Other fields mapped to the same target are not affected. | |
| 397 | - * | |
| 398 | - * @param object $modifier Insert/Update Post modifier (uses `fields_map`). | |
| 399 | - * | |
| 400 | - * @return string[] Field names. | |
| 401 | - */ | |
| 402 | - public static function get_locked_media_field_names( $modifier ): array { | |
| 403 | - $form_id = jet_fb_action_handler()->get_form_id(); | |
| 404 | - if ( ! $form_id || empty( $modifier->fields_map ) ) { | |
| 405 | - return array(); | |
| 406 | - } | |
| 407 | - // Parse the form once: get_field_by_name() reparses it on every call without $blocks. | |
| 408 | - $blocks = \Jet_Form_Builder\Blocks\Block_Helper::get_blocks_by_post( $form_id ); | |
| 409 | - if ( empty( $blocks ) ) { | |
| 410 | - return array(); | |
| 411 | - } | |
| 412 | - $names = array(); | |
| 413 | - foreach ( $modifier->fields_map as $field_name => $meta_key ) { | |
| 414 | - if ( empty( $field_name ) || empty( $meta_key ) ) { | |
| 415 | - continue; | |
| 416 | - } | |
| 417 | - $field = jet_form_builder()->form->get_field_by_name( | |
| 418 | - $form_id, | |
| 419 | - $field_name, | |
| 420 | - $blocks | |
| 421 | - ); | |
| 422 | - if ( self::is_media_field_locked( $field ) ) { | |
| 423 | - $names[] = $field_name; | |
| 424 | - } | |
| 425 | - } | |
| 426 | - return $names; | |
| 427 | - } | |
| 428 | - | |
| 429 | - /** | |
| 430 | - * @param mixed $field Parsed block array. | |
| 431 | - * | |
| 432 | - * @return bool | |
| 433 | - */ | |
| 434 | - public static function is_media_field_locked( $field ): bool { | |
| 435 | - if ( ! is_array( $field ) || 'jet-forms/media-field' !== ( $field['blockName'] ?? '' ) ) { | |
| 436 | - return false; | |
| 437 | - } | |
| 438 | - // Regardless of value format / insert_attachment: without a file the parser passes the | |
| 439 | - // submitted value (a URL included) through as is, so the capability applies to every format. | |
| 440 | - return ! \JFB_Modules\Block_Parsers\File_Uploader::is_permitted( $field['attrs'] ?? array() ); | |
| 441 | - } | |
| 442 | - | |
| 443 | 388 | public static function get_post_meta_keys_for_cleanup( $modifier ): array { |
| 444 | 389 | $form_id = jet_fb_action_handler()->get_form_id(); |
| 445 | 390 | if ( ! $form_id || empty( $modifier->fields_map ) ) { |
| 446 | 391 | return array(); |