Completed
Pull Request — develop (#1561)
by Zack
36:00 queued 15:58
created
includes/extensions/delete-entry/class-delete-entry.php 1 patch
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @since 2.9.2
65 65
 	 *
66
-	 * @param $component
66
+	 * @param string $component
67 67
 	 */
68 68
 	private function load_components( $component ) {
69 69
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param array $args Existing reserved args
110 110
 	 *
111
-	 * @return array
111
+	 * @return string[]
112 112
 	 */
113 113
 	public function add_reserved_arg( $args ) {
114 114
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	 * @uses GFAPI::delete_entry()
441 441
 	 * @uses GFAPI::update_entry_property()
442 442
 	 *
443
-	 * @return WP_Error|string "deleted" or "trashed" if successful, WP_Error if GFAPI::delete_entry() or updating entry failed.
443
+	 * @return string "deleted" or "trashed" if successful, WP_Error if GFAPI::delete_entry() or updating entry failed.
444 444
 	 */
445 445
 	private function delete_or_trash_entry( $entry ) {
446 446
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	 *
608 608
 	 * @since 1.5.1
609 609
 	 * @param  array $entry Gravity Forms entry array
610
-	 * @return boolean|WP_Error        True: can edit form. WP_Error: nope.
610
+	 * @return string        True: can edit form. WP_Error: nope.
611 611
 	 */
612 612
 	function user_can_delete_entry( $entry = array(), $view_id = null ) {
613 613
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 	 *
649 649
 	 * @param  array $entry Gravity Forms entry array
650 650
 	 * @param array $field Field settings (optional)
651
-	 * @param int|\GV\View $view Pass a View ID to check caps against. If not set, check against current View (@deprecated no longer optional)
651
+	 * @param integer $view Pass a View ID to check caps against. If not set, check against current View (@deprecated no longer optional)
652 652
 	 * @return bool
653 653
 	 */
654 654
 	public static function check_user_cap_delete_entry( $entry, $field = array(), $view = 0 ) {
Please login to merge, or discard this patch.
includes/extensions/duplicate-entry/class-duplicate-entry.php 1 patch
Doc Comments   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param array $args Existing reserved args
81 81
 	 *
82
-	 * @return array
82
+	 * @return string[]
83 83
 	 */
84 84
 	public function add_reserved_arg( $args ) {
85 85
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param array $fields Array of field types not editable by users
153 153
 	 *
154
-	 * @return array
154
+	 * @return string[]
155 155
 	 */
156 156
 	public function _filter_sortable_fields( $fields ) {
157 157
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @param array $file_paths List of template paths ordered
171 171
 	 *
172
-	 * @return array File paths, with duplicate field path added at index 117
172
+	 * @return string[] File paths, with duplicate field path added at index 117
173 173
 	 */
174 174
 	public function add_template_path( $file_paths ) {
175 175
 
@@ -275,7 +275,6 @@  discard block
 block discarded – undo
275 275
 	 * @since 2.5
276 276
 	 *
277 277
 	 * @param  array 	    $visibility_caps        Array of capabilities to display in field dropdown.
278
-	 * @param  string       $field_type  Type of field options to render (`field` or `widget`)
279 278
 	 * @param  string       $template_id Table slug
280 279
 	 * @param  float|string $field_id    GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
281 280
 	 * @param  string       $context     What context are we in? Example: `single` or `directory`
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 2 patches
Doc Comments   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -64,6 +64,9 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
 
67
+    /**
68
+     * @param string $component
69
+     */
67 70
     private function load_components( $component ) {
68 71
 
69 72
         $dir = trailingslashit( self::$file );
@@ -104,7 +107,7 @@  discard block
 block discarded – undo
104 107
 	 *
105 108
 	 * @param array $args Existing reserved args
106 109
 	 *
107
-	 * @return array
110
+	 * @return string[]
108 111
 	 */
109 112
 	public function add_reserved_arg( $args ) {
110 113
 
@@ -200,7 +203,7 @@  discard block
 block discarded – undo
200 203
      * "You can edit this post from the post page" fields, for example.
201 204
      *
202 205
      * @param $entry array Gravity Forms entry object
203
-     * @param $view_id int GravityView view id
206
+     * @param integer $view_id int GravityView view id
204 207
      * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
205 208
      * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
206 209
      * @return string
@@ -303,7 +306,7 @@  discard block
 block discarded – undo
303 306
      * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
304 307
      *
305 308
      * @param  array $entry Gravity Forms entry array
306
-     * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
309
+     * @param integer $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
307 310
      * @return bool
308 311
      */
309 312
     public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -18,84 +18,84 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 		$this->load_components( 'locking' );
44 44
 
45
-        $this->load_components( 'render' );
45
+		$this->load_components( 'render' );
46 46
 
47
-        // If GF User Registration Add-on exists
48
-        $this->load_components( 'user-registration' );
47
+		// If GF User Registration Add-on exists
48
+		$this->load_components( 'user-registration' );
49 49
 
50
-        $this->add_hooks();
50
+		$this->add_hooks();
51 51
 
52 52
 		// Process hooks for addons that may or may not be present
53 53
 		$this->addon_specific_hooks();
54 54
 	}
55 55
 
56 56
 
57
-    static function getInstance() {
57
+	static function getInstance() {
58 58
 
59
-        if( empty( self::$instance ) ) {
60
-            self::$instance = new GravityView_Edit_Entry;
61
-        }
59
+		if( empty( self::$instance ) ) {
60
+			self::$instance = new GravityView_Edit_Entry;
61
+		}
62 62
 
63
-        return self::$instance;
64
-    }
63
+		return self::$instance;
64
+	}
65 65
 
66 66
 
67
-    private function load_components( $component ) {
67
+	private function load_components( $component ) {
68 68
 
69
-        $dir = trailingslashit( self::$file );
69
+		$dir = trailingslashit( self::$file );
70 70
 
71
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
71
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
72
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
73 73
 
74
-        // Loads component and pass extension's instance so that component can
75
-        // talk each other.
76
-        require_once $filename;
77
-        $this->instances[ $component ] = new $classname( $this );
78
-        $this->instances[ $component ]->load();
74
+		// Loads component and pass extension's instance so that component can
75
+		// talk each other.
76
+		require_once $filename;
77
+		$this->instances[ $component ] = new $classname( $this );
78
+		$this->instances[ $component ]->load();
79 79
 
80
-    }
80
+	}
81 81
 
82
-    private function add_hooks() {
82
+	private function add_hooks() {
83 83
 
84
-        // Add front-end access to Gravity Forms delete file action
85
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
84
+		// Add front-end access to Gravity Forms delete file action
85
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
86 86
 
87
-        // Make sure this hook is run for non-admins
88
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
87
+		// Make sure this hook is run for non-admins
88
+		add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
89 89
 
90
-        add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90
+		add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
91 91
 
92
-        // add template path to check for field
93
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
92
+		// add template path to check for field
93
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
94 94
 
95 95
 		add_filter( 'gravityview/field/is_visible', array( $this, 'maybe_not_visible' ), 10, 3 );
96 96
 
97 97
 		add_filter( 'gravityview/api/reserved_query_args', array( $this, 'add_reserved_arg' ) );
98
-    }
98
+	}
99 99
 
100 100
 	/**
101 101
 	 * Adds "edit" to the list of internal reserved query args
@@ -166,74 +166,74 @@  discard block
 block discarded – undo
166 166
 		return false;
167 167
 	}
168 168
 
169
-    /**
170
-     * Include this extension templates path
171
-     * @param array $file_paths List of template paths ordered
172
-     */
173
-    public function add_template_path( $file_paths ) {
174
-
175
-        // Index 100 is the default GravityView template path.
176
-        $file_paths[ 110 ] = self::$file;
177
-
178
-        return $file_paths;
179
-    }
180
-
181
-    /**
182
-     *
183
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
184
-     *
185
-     * @param $view_id int GravityView view id
186
-     * @param $form_id int Gravity Forms form id
187
-     * @param $entry_id int Gravity Forms entry id
188
-     * @return string
189
-     */
190
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
191
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
192
-    }
193
-
194
-
195
-    /**
196
-     * The edit entry link creates a secure link with a nonce
197
-     *
198
-     * It also mimics the URL structure Gravity Forms expects to have so that
199
-     * it formats the display of the edit form like it does in the backend, like
200
-     * "You can edit this post from the post page" fields, for example.
201
-     *
202
-     * @param $entry array Gravity Forms entry object
203
-     * @param $view_id int GravityView view id
204
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
205
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
206
-     * @return string
207
-     */
208
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
209
-
210
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
211
-
212
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
213
-
214
-        $url = add_query_arg( array(
215
-            'edit' => wp_create_nonce( $nonce_key )
216
-        ), $base );
217
-
218
-        if( $post_id ) {
219
-	        $url = add_query_arg( array( 'gvid' => $view_id ), $url );
220
-        }
221
-
222
-	    /**
223
-	     * Allow passing params to dynamically populate entry with values
224
-	     * @since 1.9.2
225
-	     */
226
-	    if( !empty( $field_values ) ) {
227
-
228
-		    if( is_array( $field_values ) ) {
229
-			    // If already an array, no parse_str() needed
230
-			    $params = $field_values;
231
-		    } else {
232
-			    parse_str( $field_values, $params );
233
-		    }
234
-
235
-		    $url = add_query_arg( $params, $url );
236
-	    }
169
+	/**
170
+	 * Include this extension templates path
171
+	 * @param array $file_paths List of template paths ordered
172
+	 */
173
+	public function add_template_path( $file_paths ) {
174
+
175
+		// Index 100 is the default GravityView template path.
176
+		$file_paths[ 110 ] = self::$file;
177
+
178
+		return $file_paths;
179
+	}
180
+
181
+	/**
182
+	 *
183
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
184
+	 *
185
+	 * @param $view_id int GravityView view id
186
+	 * @param $form_id int Gravity Forms form id
187
+	 * @param $entry_id int Gravity Forms entry id
188
+	 * @return string
189
+	 */
190
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
191
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
192
+	}
193
+
194
+
195
+	/**
196
+	 * The edit entry link creates a secure link with a nonce
197
+	 *
198
+	 * It also mimics the URL structure Gravity Forms expects to have so that
199
+	 * it formats the display of the edit form like it does in the backend, like
200
+	 * "You can edit this post from the post page" fields, for example.
201
+	 *
202
+	 * @param $entry array Gravity Forms entry object
203
+	 * @param $view_id int GravityView view id
204
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
205
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
206
+	 * @return string
207
+	 */
208
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
209
+
210
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
211
+
212
+		$base = gv_entry_link( $entry, $post_id ? : $view_id  );
213
+
214
+		$url = add_query_arg( array(
215
+			'edit' => wp_create_nonce( $nonce_key )
216
+		), $base );
217
+
218
+		if( $post_id ) {
219
+			$url = add_query_arg( array( 'gvid' => $view_id ), $url );
220
+		}
221
+
222
+		/**
223
+		 * Allow passing params to dynamically populate entry with values
224
+		 * @since 1.9.2
225
+		 */
226
+		if( !empty( $field_values ) ) {
227
+
228
+			if( is_array( $field_values ) ) {
229
+				// If already an array, no parse_str() needed
230
+				$params = $field_values;
231
+			} else {
232
+				parse_str( $field_values, $params );
233
+			}
234
+
235
+			$url = add_query_arg( $params, $url );
236
+		}
237 237
 
238 238
 		/**
239 239
 		 * @filter `gravityview/edit/link` Filter the edit URL link.
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		 * @param \GV\View $view The View.
243 243
 		 */
244 244
 		return apply_filters( 'gravityview/edit/link', $url, $entry, \GV\View::by_id( $view_id  ) );
245
-    }
245
+	}
246 246
 
247 247
 	/**
248 248
 	 * Edit mode doesn't allow certain field types.
@@ -297,19 +297,19 @@  discard block
 block discarded – undo
297 297
 	}
298 298
 
299 299
 
300
-    /**
301
-     * checks if user has permissions to edit a specific entry
302
-     *
303
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
304
-     *
305
-     * @param  array $entry Gravity Forms entry array
306
-     * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
307
-     * @return bool
308
-     */
309
-    public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
300
+	/**
301
+	 * checks if user has permissions to edit a specific entry
302
+	 *
303
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
304
+	 *
305
+	 * @param  array $entry Gravity Forms entry array
306
+	 * @param \GV\View|int $view ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
307
+	 * @return bool
308
+	 */
309
+	public static function check_user_cap_edit_entry( $entry, $view = 0 ) {
310 310
 
311
-        // No permission by default
312
-        $user_can_edit = false;
311
+		// No permission by default
312
+		$user_can_edit = false;
313 313
 
314 314
 		// get user_edit setting
315 315
 		if ( empty( $view ) ) {
@@ -327,60 +327,60 @@  discard block
 block discarded – undo
327 327
 			$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
328 328
 		}
329 329
 
330
-        // If they can edit any entries (as defined in Gravity Forms)
331
-        // Or if they can edit other people's entries
332
-        // Then we're good.
333
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
330
+		// If they can edit any entries (as defined in Gravity Forms)
331
+		// Or if they can edit other people's entries
332
+		// Then we're good.
333
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
334 334
 
335
-            gravityview()->log->debug( 'User has ability to edit all entries.' );
335
+			gravityview()->log->debug( 'User has ability to edit all entries.' );
336 336
 
337
-            $user_can_edit = true;
337
+			$user_can_edit = true;
338 338
 
339
-        } else if( !isset( $entry['created_by'] ) ) {
339
+		} else if( !isset( $entry['created_by'] ) ) {
340 340
 
341
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
341
+			gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
342 342
 
343
-            $user_can_edit = false;
343
+			$user_can_edit = false;
344 344
 
345
-        } else {
345
+		} else {
346 346
 
347
-            $current_user = wp_get_current_user();
347
+			$current_user = wp_get_current_user();
348 348
 
349
-            // User edit is disabled
350
-            if( empty( $user_edit ) ) {
349
+			// User edit is disabled
350
+			if( empty( $user_edit ) ) {
351 351
 
352
-                gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
352
+				gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
353 353
 
354
-                $user_can_edit = false;
355
-            }
354
+				$user_can_edit = false;
355
+			}
356 356
 
357
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
358
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
357
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
358
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
359 359
 
360
-                gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
360
+				gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
361 361
 
362
-                $user_can_edit = true;
362
+				$user_can_edit = true;
363 363
 
364
-            } else if( ! is_user_logged_in() ) {
364
+			} else if( ! is_user_logged_in() ) {
365 365
 
366
-                gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
366
+				gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
367 367
 
368
-	            $user_can_edit = false; // Here just for clarity
369
-            }
368
+				$user_can_edit = false; // Here just for clarity
369
+			}
370 370
 
371
-        }
371
+		}
372 372
 
373
-        /**
374
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
375
-         * @since 1.15 Added `$entry` and `$view_id` parameters
376
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
377
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
378
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
379
-         */
380
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
373
+		/**
374
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
375
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
376
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
377
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
378
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
379
+		 */
380
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
381 381
 
382
-        return (bool) $user_can_edit;
383
-    }
382
+		return (bool) $user_can_edit;
383
+	}
384 384
 
385 385
 
386 386
 
Please login to merge, or discard this patch.