PluginProbe ʕ •ᴥ•ʔ
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 2.12.3
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v2.12.3
2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / inc / abilities / entries / get-entry.php
sureforms / inc / abilities / entries Last commit date
bulk-get-entries.php 3 weeks ago delete-entry.php 5 months ago entry-parser.php 3 weeks ago get-entry.php 3 weeks ago list-entries.php 3 weeks ago update-entry-status.php 5 months ago
get-entry.php
131 lines
1 <?php
2 /**
3 * Get Entry Ability.
4 *
5 * @package sureforms
6 * @since 2.5.2
7 */
8
9 namespace SRFM\Inc\Abilities\Entries;
10
11 use SRFM\Inc\Abilities\Abstract_Ability;
12 use SRFM\Inc\Database\Tables\Entries as EntriesTable;
13 use SRFM\Inc\Helper;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Get_Entry ability class.
21 *
22 * Retrieves detailed information about a specific form submission entry,
23 * including parsed form data with decoded labels.
24 *
25 * @since 2.5.2
26 */
27 class Get_Entry extends Abstract_Ability {
28 use Entry_Parser;
29
30 /**
31 * Constructor.
32 *
33 * @since 2.5.2
34 */
35 public function __construct() {
36 $this->id = 'sureforms/get-entry';
37 $this->label = __( 'Get Entry Details', 'sureforms' );
38 $this->description = __( 'Retrieve detailed information about a specific SureForms form submission entry, including all submitted field data with labels.', 'sureforms' );
39 $this->capability = 'manage_options';
40 }
41
42 /**
43 * {@inheritDoc}
44 *
45 * @since 2.5.2
46 */
47 public function get_annotations() {
48 return [
49 'readonly' => true,
50 'destructive' => false,
51 'idempotent' => true,
52 'priority' => 1.0,
53 'openWorldHint' => false,
54 ];
55 }
56
57 /**
58 * {@inheritDoc}
59 *
60 * @since 2.5.2
61 */
62 public function get_input_schema() {
63 return [
64 'type' => 'object',
65 'additionalProperties' => false,
66 'properties' => [
67 'entry_id' => [
68 'type' => 'integer',
69 'description' => __( 'The ID of the entry to retrieve.', 'sureforms' ),
70 ],
71 ],
72 'required' => [ 'entry_id' ],
73 ];
74 }
75
76 /**
77 * {@inheritDoc}
78 *
79 * @since 2.5.2
80 */
81 public function get_output_schema() {
82 return [
83 'type' => 'object',
84 'properties' => [
85 'id' => [ 'type' => 'integer' ],
86 'form_id' => [ 'type' => 'integer' ],
87 'form_name' => [ 'type' => 'string' ],
88 'status' => [ 'type' => 'string' ],
89 'created_at' => [ 'type' => 'string' ],
90 'form_data' => [
91 'type' => 'array',
92 'items' => [
93 'type' => 'object',
94 'properties' => [
95 'label' => [ 'type' => 'string' ],
96 'value' => [],
97 'block_name' => [ 'type' => 'string' ],
98 ],
99 ],
100 ],
101 'submission_info' => [ 'type' => 'object' ],
102 'user' => [ 'type' => [ 'object', 'null' ] ],
103 ],
104 ];
105 }
106
107 /**
108 * Execute the get-entry ability.
109 *
110 * @param array<string,mixed> $input Validated input data.
111 * @since 2.5.2
112 * @return array<string,mixed>|\WP_Error
113 */
114 public function execute( $input ) {
115 $entry_id = Helper::get_integer_value( $input['entry_id'] ?? 0 );
116 $entry = EntriesTable::get( $entry_id );
117
118 if ( empty( $entry ) ) {
119 return new \WP_Error(
120 'srfm_entry_not_found',
121 __( 'Entry not found.', 'sureforms' ),
122 [ 'status' => 404 ]
123 );
124 }
125
126 $parsed = $this->parse_entry( $entry );
127
128 return array_merge( [ 'id' => $entry_id ], $parsed );
129 }
130 }
131