Completed
Push — develop ( d2c836...a4dcb0 )
by Zack
35:56 queued 16:06
created
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Indentation   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	public function prevent_maybe_process_form() {
161 161
 
162 162
 		if( ! empty( $_POST ) ) {
163
-	        gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
163
+			gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
164 164
 		}
165 165
 
166 166
 		if( $this->is_edit_entry_submission() ) {
167 167
 			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
168
-	        remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
168
+			remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
169 169
 		}
170 170
 	}
171 171
 
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 
198 198
 
199 199
 		$entries = $gravityview_view->getEntries();
200
-	    self::$original_entry = $entries[0];
201
-	    $this->entry = $entries[0];
200
+		self::$original_entry = $entries[0];
201
+		$this->entry = $entries[0];
202 202
 
203 203
 		self::$original_form = $gravityview_view->getForm();
204 204
 		$this->form = $gravityview_view->getForm();
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 
320 320
 			GFFormsModel::save_lead( $form, $this->entry );
321 321
 
322
-	        // Delete the values for hidden inputs
323
-	        $this->unset_hidden_field_values();
322
+			// Delete the values for hidden inputs
323
+			$this->unset_hidden_field_values();
324 324
 			
325 325
 			$this->entry['date_created'] = $date_created;
326 326
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 			// Perform actions normally performed after updating a lead
331 331
 			$this->after_update();
332 332
 
333
-	        /**
333
+			/**
334 334
 			 * Must be AFTER after_update()!
335 335
 			 * @see https://github.com/gravityview/GravityView/issues/764
336 336
 			 */
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return void
361 361
 	 */
362 362
 	private function unset_hidden_field_values() {
363
-	    global $wpdb;
363
+		global $wpdb;
364 364
 
365 365
 		/**
366 366
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -382,27 +382,27 @@  discard block
 block discarded – undo
382 382
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
383 383
 		}
384 384
 
385
-	    foreach ( $this->entry as $input_id => $field_value ) {
385
+		foreach ( $this->entry as $input_id => $field_value ) {
386 386
 
387
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
387
+			$field = RGFormsModel::get_field( $this->form, $input_id );
388 388
 
389
-		    // Reset fields that are hidden
390
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
391
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
389
+			// Reset fields that are hidden
390
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
391
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
392 392
 
393
-		        // List fields are stored as empty arrays when empty
394
-			    $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : '';
393
+				// List fields are stored as empty arrays when empty
394
+				$empty_value = $this->is_field_json_encoded( $field ) ? '[]' : '';
395 395
 
396
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
396
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
397 397
 
398
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
398
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
399 399
 
400
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
400
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
401 401
 				// after submission
402
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
403
-			    $_POST[ $post_input_id ] = '';
404
-		    }
405
-	    }
402
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
403
+				$_POST[ $post_input_id ] = '';
404
+			}
405
+		}
406 406
 	}
407 407
 
408 408
 	/**
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 
497 497
 		$form = $this->form;
498 498
 
499
-	    /** @var GF_Field $field */
499
+		/** @var GF_Field $field */
500 500
 		foreach( $form['fields'] as $k => &$field ) {
501 501
 
502 502
 			/**
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
514 514
 				foreach( $field->inputs as $key => $input ) {
515
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
515
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
516 516
 				}
517 517
 			}
518 518
 		}
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
 			foreach ( $this->fields_with_calculation as $calc_field ) {
534 534
 				$inputs = $calc_field->get_entry_inputs();
535 535
 				if ( is_array( $inputs ) ) {
536
-				    foreach ( $inputs as $input ) {
537
-				        $input_name = 'input_' . str_replace( '.', '_', $input['id'] );
538
-				        $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
539
-				    }
536
+					foreach ( $inputs as $input ) {
537
+						$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
538
+						$entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
539
+					}
540 540
 				} else {
541
-				    $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
542
-				    $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
541
+					$input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
542
+					$entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
543 543
 				}
544 544
 			}
545 545
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
588 588
 
589 589
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
590
-	        $ary = stripslashes_deep( $ary );
590
+			$ary = stripslashes_deep( $ary );
591 591
 			$img_url = \GV\Utils::get( $ary, 0 );
592 592
 
593 593
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 	private function maybe_update_post_fields( $form ) {
661 661
 
662 662
 		if( empty( $this->entry['post_id'] ) ) {
663
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
663
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
664 664
 			return;
665 665
 		}
666 666
 
@@ -695,51 +695,51 @@  discard block
 block discarded – undo
695 695
 
696 696
 				switch( $field->type ) {
697 697
 
698
-				    case 'post_title':
699
-				        $post_title = $value;
700
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
701
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
702
-				        }
703
-				        $updated_post->post_title = $post_title;
704
-				        $updated_post->post_name  = $post_title;
705
-				        unset( $post_title );
706
-				        break;
707
-
708
-				    case 'post_content':
709
-				        $post_content = $value;
710
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
711
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
712
-				        }
713
-				        $updated_post->post_content = $post_content;
714
-				        unset( $post_content );
715
-				        break;
716
-				    case 'post_excerpt':
717
-				        $updated_post->post_excerpt = $value;
718
-				        break;
719
-				    case 'post_tags':
720
-				        wp_set_post_tags( $post_id, $value, false );
721
-				        break;
722
-				    case 'post_category':
723
-				        break;
724
-				    case 'post_custom_field':
698
+					case 'post_title':
699
+						$post_title = $value;
700
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
701
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
702
+						}
703
+						$updated_post->post_title = $post_title;
704
+						$updated_post->post_name  = $post_title;
705
+						unset( $post_title );
706
+						break;
707
+
708
+					case 'post_content':
709
+						$post_content = $value;
710
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
711
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
712
+						}
713
+						$updated_post->post_content = $post_content;
714
+						unset( $post_content );
715
+						break;
716
+					case 'post_excerpt':
717
+						$updated_post->post_excerpt = $value;
718
+						break;
719
+					case 'post_tags':
720
+						wp_set_post_tags( $post_id, $value, false );
721
+						break;
722
+					case 'post_category':
723
+						break;
724
+					case 'post_custom_field':
725 725
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
726 726
 							$value = $value[ $field_id ];
727 727
 						}
728 728
 
729
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
730
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
731
-				        }
729
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
730
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
731
+						}
732 732
 
733
-	                    if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) {
734
-		                    $value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value );
735
-	                    }
733
+						if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) {
734
+							$value = function_exists('wp_json_encode') ? wp_json_encode( $value ) : json_encode( $value );
735
+						}
736 736
 
737
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
738
-				        break;
737
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
738
+						break;
739 739
 
740
-				    case 'post_image':
741
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
742
-				        break;
740
+					case 'post_image':
741
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
742
+						break;
743 743
 
744 744
 				}
745 745
 
@@ -784,20 +784,20 @@  discard block
 block discarded – undo
784 784
 	 */
785 785
 	private function is_field_json_encoded( $field ) {
786 786
 
787
-	    $json_encoded = false;
787
+		$json_encoded = false;
788 788
 
789 789
 		$input_type = RGFormsModel::get_input_type( $field );
790 790
 
791
-	    // Only certain custom field types are supported
792
-	    switch( $input_type ) {
793
-		    case 'fileupload':
794
-		    case 'list':
795
-		    case 'multiselect':
796
-			    $json_encoded = true;
797
-			    break;
798
-	    }
791
+		// Only certain custom field types are supported
792
+		switch( $input_type ) {
793
+			case 'fileupload':
794
+			case 'list':
795
+			case 'multiselect':
796
+				$json_encoded = true;
797
+				break;
798
+		}
799 799
 
800
-	    return $json_encoded;
800
+		return $json_encoded;
801 801
 	}
802 802
 
803 803
 	/**
@@ -887,14 +887,14 @@  discard block
 block discarded – undo
887 887
 			?><h2 class="gv-edit-entry-title">
888 888
 				<span><?php
889 889
 
890
-				    /**
891
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
892
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
893
-				     * @param GravityView_Edit_Entry_Render $this This object
894
-				     */
895
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
890
+					/**
891
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
892
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
893
+					 * @param GravityView_Edit_Entry_Render $this This object
894
+					 */
895
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
896 896
 
897
-				    echo esc_attr( $edit_entry_title );
897
+					echo esc_attr( $edit_entry_title );
898 898
 			?></span>
899 899
 			</h2>
900 900
 
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 
1004 1004
 		ob_get_clean();
1005 1005
 
1006
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1006
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1007 1007
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1008 1008
 		remove_filter( 'gform_disable_view_counter', '__return_true' );
1009 1009
 		remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 		// for now we don't support Save and Continue feature.
1059 1059
 		if( ! self::$supports_save_and_continue ) {
1060
-	        unset( $form['save'] );
1060
+			unset( $form['save'] );
1061 1061
 		}
1062 1062
 
1063 1063
 		return $form;
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 			|| ! empty( $field_content )
1133 1133
 			|| in_array( $field->type, array( 'honeypot' ) )
1134 1134
 		) {
1135
-	        return $field_content;
1135
+			return $field_content;
1136 1136
 		}
1137 1137
 
1138 1138
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1140,24 +1140,24 @@  discard block
 block discarded – undo
1140 1140
 
1141 1141
 		$field_value = $this->get_field_value( $field );
1142 1142
 
1143
-	    // Prevent any PHP warnings, like undefined index
1144
-	    ob_start();
1143
+		// Prevent any PHP warnings, like undefined index
1144
+		ob_start();
1145 1145
 
1146
-	    $return = null;
1146
+		$return = null;
1147 1147
 
1148 1148
 		/** @var GravityView_Field $gv_field */
1149 1149
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1150 1150
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1151 1151
 		} else {
1152
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1153
-	    }
1152
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1153
+		}
1154 1154
 
1155
-	    // If there was output, it's an error
1156
-	    $warnings = ob_get_clean();
1155
+		// If there was output, it's an error
1156
+		$warnings = ob_get_clean();
1157 1157
 
1158
-	    if( !empty( $warnings ) ) {
1159
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1160
-	    }
1158
+		if( !empty( $warnings ) ) {
1159
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1160
+		}
1161 1161
 
1162 1162
 		return $return;
1163 1163
 	}
@@ -1192,8 +1192,8 @@  discard block
 block discarded – undo
1192 1192
 				$input_id = strval( $input['id'] );
1193 1193
 				
1194 1194
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1195
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1196
-				    $allow_pre_populated = false;
1195
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1196
+					$allow_pre_populated = false;
1197 1197
 				}
1198 1198
 
1199 1199
 			}
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1218 1218
 				$categories = array();
1219 1219
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1220
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1220
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1221 1221
 				}
1222 1222
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1223 1223
 			}
@@ -1227,25 +1227,25 @@  discard block
 block discarded – undo
1227 1227
 		// if value is empty get the default value if defined
1228 1228
 		$field_value = $field->get_value_default_if_empty( $field_value );
1229 1229
 
1230
-	    /**
1231
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1232
-	     * @since 1.11
1233
-	     * @since 1.20 Added third param
1234
-	     * @param mixed $field_value field value used to populate the input
1235
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1236
-	     * @param GravityView_Edit_Entry_Render $this Current object
1237
-	     */
1238
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1239
-
1240
-	    /**
1241
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1242
-	     * @since 1.17
1243
-	     * @since 1.20 Added third param
1244
-	     * @param mixed $field_value field value used to populate the input
1245
-	     * @param GF_Field $field Gravity Forms field object
1246
-	     * @param GravityView_Edit_Entry_Render $this Current object
1247
-	     */
1248
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1230
+		/**
1231
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1232
+		 * @since 1.11
1233
+		 * @since 1.20 Added third param
1234
+		 * @param mixed $field_value field value used to populate the input
1235
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1236
+		 * @param GravityView_Edit_Entry_Render $this Current object
1237
+		 */
1238
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1239
+
1240
+		/**
1241
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1242
+		 * @since 1.17
1243
+		 * @since 1.20 Added third param
1244
+		 * @param mixed $field_value field value used to populate the input
1245
+		 * @param GF_Field $field Gravity Forms field object
1246
+		 * @param GravityView_Edit_Entry_Render $this Current object
1247
+		 */
1248
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1249 1249
 
1250 1250
 		return $field_value;
1251 1251
 	}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1273 1273
 			// expects certain field array items to be set.
1274 1274
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1275
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1275
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1276 1276
 			}
1277 1277
 
1278 1278
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1286,61 +1286,61 @@  discard block
 block discarded – undo
1286 1286
 				 */
1287 1287
 				case 'fileupload':
1288 1288
 
1289
-				    // Set the previous value
1290
-				    $entry = $this->get_entry();
1289
+					// Set the previous value
1290
+					$entry = $this->get_entry();
1291 1291
 
1292
-				    $input_name = 'input_'.$field->id;
1293
-				    $form_id = $form['id'];
1292
+					$input_name = 'input_'.$field->id;
1293
+					$form_id = $form['id'];
1294 1294
 
1295
-				    $value = NULL;
1295
+					$value = NULL;
1296 1296
 
1297
-				    // Use the previous entry value as the default.
1298
-				    if( isset( $entry[ $field->id ] ) ) {
1299
-				        $value = $entry[ $field->id ];
1300
-				    }
1297
+					// Use the previous entry value as the default.
1298
+					if( isset( $entry[ $field->id ] ) ) {
1299
+						$value = $entry[ $field->id ];
1300
+					}
1301 1301
 
1302
-				    // If this is a single upload file
1303
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1304
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1305
-				        $value = $file_path['url'];
1302
+					// If this is a single upload file
1303
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1304
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1305
+						$value = $file_path['url'];
1306 1306
 
1307
-				    } else {
1307
+					} else {
1308 1308
 
1309
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1310
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1311
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1309
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1310
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1311
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1312 1312
 
1313
-				    }
1313
+					}
1314 1314
 
1315
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1315
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1316 1316
 
1317
-				        // If there are fresh uploads, process and merge them.
1318
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1319
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1320
-				            $value = empty( $value ) ? '[]' : $value;
1321
-				            $value = stripslashes_deep( $value );
1322
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1323
-				        }
1317
+						// If there are fresh uploads, process and merge them.
1318
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1319
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1320
+							$value = empty( $value ) ? '[]' : $value;
1321
+							$value = stripslashes_deep( $value );
1322
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1323
+						}
1324 1324
 
1325
-				    } else {
1325
+					} else {
1326 1326
 
1327
-				        // A file already exists when editing an entry
1328
-				        // We set this to solve issue when file upload fields are required.
1329
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1327
+						// A file already exists when editing an entry
1328
+						// We set this to solve issue when file upload fields are required.
1329
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1330 1330
 
1331
-				    }
1331
+					}
1332 1332
 
1333
-				    $this->entry[ $input_name ] = $value;
1334
-				    $_POST[ $input_name ] = $value;
1333
+					$this->entry[ $input_name ] = $value;
1334
+					$_POST[ $input_name ] = $value;
1335 1335
 
1336
-				    break;
1336
+					break;
1337 1337
 
1338 1338
 				case 'number':
1339
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1340
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1341
-				        $_POST['input_'.$field->id ] = NULL;
1342
-				    }
1343
-				    break;
1339
+					// Fix "undefined index" issue at line 1286 in form_display.php
1340
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1341
+						$_POST['input_'.$field->id ] = NULL;
1342
+					}
1343
+					break;
1344 1344
 			}
1345 1345
 
1346 1346
 		}
@@ -1425,42 +1425,42 @@  discard block
 block discarded – undo
1425 1425
 				case 'fileupload' :
1426 1426
 				case 'post_image':
1427 1427
 
1428
-				    // in case nothing is uploaded but there are already files saved
1429
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1430
-				        $field->failed_validation = false;
1431
-				        unset( $field->validation_message );
1432
-				    }
1428
+					// in case nothing is uploaded but there are already files saved
1429
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1430
+						$field->failed_validation = false;
1431
+						unset( $field->validation_message );
1432
+					}
1433 1433
 
1434
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1435
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1434
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1435
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1436 1436
 
1437
-				        $input_name = 'input_' . $field->id;
1438
-				        //uploaded
1439
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1437
+						$input_name = 'input_' . $field->id;
1438
+						//uploaded
1439
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1440 1440
 
1441
-				        //existent
1442
-				        $entry = $this->get_entry();
1443
-				        $value = NULL;
1444
-				        if( isset( $entry[ $field->id ] ) ) {
1445
-				            $value = json_decode( $entry[ $field->id ], true );
1446
-				        }
1441
+						//existent
1442
+						$entry = $this->get_entry();
1443
+						$value = NULL;
1444
+						if( isset( $entry[ $field->id ] ) ) {
1445
+							$value = json_decode( $entry[ $field->id ], true );
1446
+						}
1447 1447
 
1448
-				        // count uploaded files and existent entry files
1449
-				        $count_files = count( $file_names ) + count( $value );
1448
+						// count uploaded files and existent entry files
1449
+						$count_files = count( $file_names ) + count( $value );
1450 1450
 
1451
-				        if( $count_files > $field->maxFiles ) {
1452
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1453
-				            $field->failed_validation = 1;
1454
-				            $gv_valid = false;
1451
+						if( $count_files > $field->maxFiles ) {
1452
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1453
+							$field->failed_validation = 1;
1454
+							$gv_valid = false;
1455 1455
 
1456
-				            // in case of error make sure the newest upload files are removed from the upload input
1457
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1458
-				        }
1456
+							// in case of error make sure the newest upload files are removed from the upload input
1457
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1458
+						}
1459 1459
 
1460
-				    }
1460
+					}
1461 1461
 
1462 1462
 
1463
-				    break;
1463
+					break;
1464 1464
 
1465 1465
 			}
1466 1466
 
@@ -1471,47 +1471,47 @@  discard block
 block discarded – undo
1471 1471
 
1472 1472
 				switch ( $field_type ) {
1473 1473
 
1474
-				    // Captchas don't need to be re-entered.
1475
-				    case 'captcha':
1474
+					// Captchas don't need to be re-entered.
1475
+					case 'captcha':
1476 1476
 
1477
-				        // Post Image fields aren't editable, so we un-fail them.
1478
-				    case 'post_image':
1479
-				        $field->failed_validation = false;
1480
-				        unset( $field->validation_message );
1481
-				        break;
1477
+						// Post Image fields aren't editable, so we un-fail them.
1478
+					case 'post_image':
1479
+						$field->failed_validation = false;
1480
+						unset( $field->validation_message );
1481
+						break;
1482 1482
 
1483 1483
 				}
1484 1484
 
1485 1485
 				// You can't continue inside a switch, so we do it after.
1486 1486
 				if( empty( $field->failed_validation ) ) {
1487
-				    continue;
1487
+					continue;
1488 1488
 				}
1489 1489
 
1490 1490
 				// checks if the No Duplicates option is not validating entry against itself, since
1491 1491
 				// we're editing a stored entry, it would also assume it's a duplicate.
1492 1492
 				if( !empty( $field->noDuplicates ) ) {
1493 1493
 
1494
-				    $entry = $this->get_entry();
1494
+					$entry = $this->get_entry();
1495 1495
 
1496
-				    // If the value of the entry is the same as the stored value
1497
-				    // Then we can assume it's not a duplicate, it's the same.
1498
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1499
-				        //if value submitted was not changed, then don't validate
1500
-				        $field->failed_validation = false;
1496
+					// If the value of the entry is the same as the stored value
1497
+					// Then we can assume it's not a duplicate, it's the same.
1498
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1499
+						//if value submitted was not changed, then don't validate
1500
+						$field->failed_validation = false;
1501 1501
 
1502
-				        unset( $field->validation_message );
1502
+						unset( $field->validation_message );
1503 1503
 
1504
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1504
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1505 1505
 
1506
-				        continue;
1507
-				    }
1506
+						continue;
1507
+					}
1508 1508
 				}
1509 1509
 
1510 1510
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1511 1511
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1512
-				    unset( $field->validation_message );
1513
-	                $field->validation_message = false;
1514
-				    continue;
1512
+					unset( $field->validation_message );
1513
+					$field->validation_message = false;
1514
+					continue;
1515 1515
 				}
1516 1516
 
1517 1517
 				$gv_valid = false;
@@ -1575,8 +1575,8 @@  discard block
 block discarded – undo
1575 1575
 		// Hide fields depending on admin settings
1576 1576
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1577 1577
 
1578
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1579
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1578
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1579
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1580 1580
 
1581 1581
 		/**
1582 1582
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1636,11 +1636,11 @@  discard block
 block discarded – undo
1636 1636
 		// The edit tab has been configured, so we loop through to configured settings
1637 1637
 		foreach ( $configured_fields as $configured_field ) {
1638 1638
 
1639
-	        /** @var GF_Field $field */
1640
-	        foreach ( $fields as $field ) {
1639
+			/** @var GF_Field $field */
1640
+			foreach ( $fields as $field ) {
1641 1641
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1642
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1643
-				    break;
1642
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1643
+					break;
1644 1644
 				}
1645 1645
 
1646 1646
 			}
@@ -1696,28 +1696,28 @@  discard block
 block discarded – undo
1696 1696
 	 */
1697 1697
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1698 1698
 
1699
-	    /**
1699
+		/**
1700 1700
 		 * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true
1701
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1702
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1703
-	     * @since 1.9.1
1704
-	     * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1705
-	     * @param array $form GF Form array
1706
-	     * @param int $view_id View ID
1707
-	     */
1708
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1709
-
1710
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1701
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1702
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1703
+		 * @since 1.9.1
1704
+		 * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1705
+		 * @param array $form GF Form array
1706
+		 * @param int $view_id View ID
1707
+		 */
1708
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1709
+
1710
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1711 1711
 			foreach( $fields as $k => $field ) {
1712 1712
 				if( $field->adminOnly ) {
1713
-				    unset( $fields[ $k ] );
1713
+					unset( $fields[ $k ] );
1714 1714
 				}
1715 1715
 			}
1716 1716
 			return $fields;
1717 1717
 		}
1718 1718
 
1719
-	    foreach( $fields as &$field ) {
1720
-		    $field->adminOnly = false;
1719
+		foreach( $fields as &$field ) {
1720
+			$field->adminOnly = false;
1721 1721
 		}
1722 1722
 
1723 1723
 		return $fields;
@@ -1750,36 +1750,36 @@  discard block
 block discarded – undo
1750 1750
 
1751 1751
 			if( 'checkbox' === $field->type ) {
1752 1752
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1753
-				    $input_id = $input['id'];
1754
-				    $choice = $field->choices[ $key ];
1755
-				    $value = \GV\Utils::get( $this->entry, $input_id );
1756
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1757
-				    if( $match ) {
1758
-				        $field->choices[ $key ]['isSelected'] = true;
1759
-				    }
1753
+					$input_id = $input['id'];
1754
+					$choice = $field->choices[ $key ];
1755
+					$value = \GV\Utils::get( $this->entry, $input_id );
1756
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
1757
+					if( $match ) {
1758
+						$field->choices[ $key ]['isSelected'] = true;
1759
+					}
1760 1760
 				}
1761 1761
 			} else {
1762 1762
 
1763 1763
 				// We need to run through each field to set the default values
1764 1764
 				foreach ( $this->entry as $field_id => $field_value ) {
1765 1765
 
1766
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1766
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
1767 1767
 
1768
-				        if( 'list' === $field->type ) {
1769
-				            $list_rows = maybe_unserialize( $field_value );
1768
+						if( 'list' === $field->type ) {
1769
+							$list_rows = maybe_unserialize( $field_value );
1770 1770
 
1771
-				            $list_field_value = array();
1772
-				            foreach ( (array) $list_rows as $row ) {
1773
-				                foreach ( (array) $row as $column ) {
1774
-				                    $list_field_value[] = $column;
1775
-				                }
1776
-				            }
1771
+							$list_field_value = array();
1772
+							foreach ( (array) $list_rows as $row ) {
1773
+								foreach ( (array) $row as $column ) {
1774
+									$list_field_value[] = $column;
1775
+								}
1776
+							}
1777 1777
 
1778
-				            $field->defaultValue = serialize( $list_field_value );
1779
-				        } else {
1780
-				            $field->defaultValue = $field_value;
1781
-				        }
1782
-				    }
1778
+							$field->defaultValue = serialize( $list_field_value );
1779
+						} else {
1780
+							$field->defaultValue = $field_value;
1781
+						}
1782
+					}
1783 1783
 				}
1784 1784
 			}
1785 1785
 		}
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
 			return $has_conditional_logic;
1837 1837
 		}
1838 1838
 
1839
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1839
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1840 1840
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1841 1841
 	}
1842 1842
 
@@ -1903,14 +1903,14 @@  discard block
 block discarded – undo
1903 1903
 
1904 1904
 		if( $echo && $error !== true ) {
1905 1905
 
1906
-	        $error = esc_html( $error );
1906
+			$error = esc_html( $error );
1907 1907
 
1908
-	        /**
1909
-	         * @since 1.9
1910
-	         */
1911
-	        if ( ! empty( $this->entry ) ) {
1912
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1913
-	        }
1908
+			/**
1909
+			 * @since 1.9
1910
+			 */
1911
+			if ( ! empty( $this->entry ) ) {
1912
+				$error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1913
+			}
1914 1914
 
1915 1915
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1916 1916
 		}
Please login to merge, or discard this patch.