Completed
Push — master ( 1d6dad...eb200b )
by Stephanie
03:09
created
classes/models/FrmFormAction.php 1 patch
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 	public $action_options;     // Option array passed to wp_register_sidebar_widget()
9 9
 	public $control_options;	// Option array passed to wp_register_widget_control()
10 10
 
11
-    public $form_id;        // The ID of the form to evaluate
11
+	public $form_id;        // The ID of the form to evaluate
12 12
 	public $number = false;	// Unique ID number of the current instance.
13 13
 	public $id = '';		// Unique ID string of the current instance (id_base-number)
14 14
 	public $updated = false;	// Set true when we update the data after a POST submit - makes sure we don't do it twice.
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 
31 31
 	/**
32
-     * Echo the settings update form
32
+	 * Echo the settings update form
33 33
 	 *
34 34
 	 * @param array $instance Current settings
35 35
 	 */
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 	 * @return array of the default options
43 43
 	 */
44 44
 	public function get_defaults() {
45
-	    return array();
45
+		return array();
46 46
 	}
47 47
 
48 48
 	public function get_switch_fields() {
49
-	    return array();
49
+		return array();
50 50
 	}
51 51
 
52 52
 	public function migrate_values( $action, $form ) {
53
-	    return $action;
53
+		return $action;
54 54
 	}
55 55
 
56 56
 	// Functions you'll need to call.
@@ -69,24 +69,24 @@  discard block
 block discarded – undo
69 69
 	 *	 - height: currently not used but may be needed in the future
70 70
 	 */
71 71
 	public function __construct( $id_base, $name, $action_options = array(), $control_options = array() ) {
72
-	    if ( ! defined('ABSPATH') ) {
73
-            die('You are not allowed to call this page directly.');
74
-        }
72
+		if ( ! defined('ABSPATH') ) {
73
+			die('You are not allowed to call this page directly.');
74
+		}
75 75
 
76 76
 		$this->id_base = strtolower($id_base);
77 77
 		$this->name = $name;
78 78
 		$this->option_name = 'frm_' . $this->id_base . '_action';
79 79
 
80
-        $default_options = array(
81
-            'classes'   => '',
82
-            'active'    => true,
80
+		$default_options = array(
81
+			'classes'   => '',
82
+			'active'    => true,
83 83
 			'event'     => array( 'create' ),
84
-            'limit'     => 1,
85
-            'force_event' => false,
86
-            'priority'  => 20,
87
-            'ajax_load' => true,
88
-            'tooltip'   => $name,
89
-        );
84
+			'limit'     => 1,
85
+			'force_event' => false,
86
+			'priority'  => 20,
87
+			'ajax_load' => true,
88
+			'tooltip'   => $name,
89
+		);
90 90
 
91 91
 		$action_options = apply_filters( 'frm_' . $id_base . '_action_options', $action_options );
92 92
 		$this->action_options = wp_parse_args( $action_options, $default_options );
@@ -135,132 +135,132 @@  discard block
 block discarded – undo
135 135
 	}
136 136
 
137 137
 	public function prepare_new( $form_id = false ) {
138
-        if ( $form_id ) {
139
-            $this->form_id = $form_id;
140
-        }
141
-
142
-        $post_content = array();
143
-        $default_values = $this->get_global_defaults();
144
-
145
-        // fill default values
146
-        $post_content = wp_parse_args( $post_content, $default_values);
147
-
148
-        if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
-            $post_content['event'] = array( reset($this->action_options['event']) );
150
-        }
151
-
152
-        $form_action = array(
153
-            'post_title'    => $this->name,
154
-            'post_content'  => $post_content,
155
-            'post_excerpt'  => $this->id_base,
156
-            'ID'            => '',
157
-            'post_status'   => 'publish',
158
-            'post_type'     => FrmFormActionsController::$action_post_type,
138
+		if ( $form_id ) {
139
+			$this->form_id = $form_id;
140
+		}
141
+
142
+		$post_content = array();
143
+		$default_values = $this->get_global_defaults();
144
+
145
+		// fill default values
146
+		$post_content = wp_parse_args( $post_content, $default_values);
147
+
148
+		if ( ! isset($post_content['event']) && ! $this->action_options['force_event'] ) {
149
+			$post_content['event'] = array( reset($this->action_options['event']) );
150
+		}
151
+
152
+		$form_action = array(
153
+			'post_title'    => $this->name,
154
+			'post_content'  => $post_content,
155
+			'post_excerpt'  => $this->id_base,
156
+			'ID'            => '',
157
+			'post_status'   => 'publish',
158
+			'post_type'     => FrmFormActionsController::$action_post_type,
159 159
 			'post_name'     => $this->form_id . '_' . $this->id_base . '_' . $this->number,
160
-            'menu_order'    => $this->form_id,
161
-        );
162
-        unset($post_content);
160
+			'menu_order'    => $this->form_id,
161
+		);
162
+		unset($post_content);
163 163
 
164
-        return (object) $form_action;
165
-    }
164
+		return (object) $form_action;
165
+	}
166 166
 
167 167
 	public function create( $form_id ) {
168
-        $this->form_id = $form_id;
168
+		$this->form_id = $form_id;
169 169
 
170
-        $action = $this->prepare_new();
170
+		$action = $this->prepare_new();
171 171
 
172
-        return $this->save_settings($action);
173
-    }
172
+		return $this->save_settings($action);
173
+	}
174 174
 
175 175
 	public function duplicate_form_actions( $form_id, $old_id ) {
176
-        if ( $form_id == $old_id ) {
177
-            // don't duplicate the actions if this is a template getting updated
178
-            return;
179
-        }
180
-
181
-        $this->form_id = $old_id;
182
-        $actions = $this->get_all( $old_id );
183
-
184
-        $this->form_id = $form_id;
185
-        foreach ( $actions as $action ) {
186
-            $this->duplicate_one($action, $form_id);
187
-            unset($action);
188
-        }
189
-    }
190
-
191
-    /* Check if imported action should be created or updated
176
+		if ( $form_id == $old_id ) {
177
+			// don't duplicate the actions if this is a template getting updated
178
+			return;
179
+		}
180
+
181
+		$this->form_id = $old_id;
182
+		$actions = $this->get_all( $old_id );
183
+
184
+		$this->form_id = $form_id;
185
+		foreach ( $actions as $action ) {
186
+			$this->duplicate_one($action, $form_id);
187
+			unset($action);
188
+		}
189
+	}
190
+
191
+	/* Check if imported action should be created or updated
192 192
     *
193 193
     * Since 2.0
194 194
     *
195 195
     * @param array $action
196 196
     * @return integer $post_id
197 197
     */
198
-    public function maybe_create_action( $action, $forms ) {
198
+	public function maybe_create_action( $action, $forms ) {
199 199
 		if ( isset( $action['ID'] ) && is_numeric( $action['ID'] ) && $forms[ $action['menu_order'] ] == 'updated' ) {
200
-            // Update action only
201
-            $action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
-            $post_id = $this->save_settings( $action );
203
-        } else {
204
-            // Create action
205
-            $action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
-            $post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
-        }
208
-        return $post_id;
209
-    }
200
+			// Update action only
201
+			$action['post_content'] = FrmAppHelper::maybe_json_decode( $action['post_content'] );
202
+			$post_id = $this->save_settings( $action );
203
+		} else {
204
+			// Create action
205
+			$action['post_content'] = FrmAppHelper::maybe_json_decode($action['post_content']);
206
+			$post_id = $this->duplicate_one( (object) $action, $action['menu_order']);
207
+		}
208
+		return $post_id;
209
+	}
210 210
 
211 211
 	public function duplicate_one( $action, $form_id ) {
212
-        global $frm_duplicate_ids;
212
+		global $frm_duplicate_ids;
213 213
 
214
-        $action->menu_order = $form_id;
215
-        $switch = $this->get_global_switch_fields();
216
-        foreach ( (array) $action->post_content as $key => $val ) {
214
+		$action->menu_order = $form_id;
215
+		$switch = $this->get_global_switch_fields();
216
+		foreach ( (array) $action->post_content as $key => $val ) {
217 217
 			if ( is_numeric( $val ) && isset( $frm_duplicate_ids[ $val ] ) ) {
218 218
 				$action->post_content[ $key ] = $frm_duplicate_ids[ $val ];
219
-            } else if ( ! is_array( $val ) ) {
219
+			} else if ( ! is_array( $val ) ) {
220 220
 				$action->post_content[ $key ] = FrmFieldsHelper::switch_field_ids( $val );
221 221
 			} else if ( isset( $switch[ $key ] ) && is_array( $switch[ $key ] ) ) {
222
-                // loop through each value if empty
222
+				// loop through each value if empty
223 223
 				if ( empty( $switch[ $key ] ) ) {
224 224
 					$switch[ $key ] = array_keys( $val );
225 225
 				}
226 226
 
227 227
 				foreach ( $switch[ $key ] as $subkey ) {
228 228
 					$action->post_content[ $key ] = $this->duplicate_array_walk( $action->post_content[ $key ], $subkey, $val );
229
-                }
230
-            }
229
+				}
230
+			}
231 231
 
232
-            unset($key, $val);
233
-        }
234
-        unset($action->ID);
232
+			unset($key, $val);
233
+		}
234
+		unset($action->ID);
235 235
 
236
-        return $this->save_settings($action);
237
-    }
236
+		return $this->save_settings($action);
237
+	}
238 238
 
239 239
 	private function duplicate_array_walk( $action, $subkey, $val ) {
240
-        global $frm_duplicate_ids;
240
+		global $frm_duplicate_ids;
241 241
 
242
-        if ( is_array($subkey) ) {
243
-            foreach ( $subkey as $subkey2 ) {
244
-                foreach ( (array) $val as $ck => $cv ) {
245
-                    if ( is_array($cv) ) {
242
+		if ( is_array($subkey) ) {
243
+			foreach ( $subkey as $subkey2 ) {
244
+				foreach ( (array) $val as $ck => $cv ) {
245
+					if ( is_array($cv) ) {
246 246
 						$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey2, $cv );
247 247
 					} else if ( isset( $cv[ $subkey ] ) && is_numeric( $cv[ $subkey ] ) && isset( $frm_duplicate_ids[ $cv[ $subkey ] ] ) ) {
248 248
 						$action[ $ck ][ $subkey ] = $frm_duplicate_ids[ $cv[ $subkey ] ];
249
-                    }
250
-                }
251
-            }
252
-        } else {
253
-            foreach ( (array) $val as $ck => $cv ) {
254
-                if ( is_array($cv) ) {
249
+					}
250
+				}
251
+			}
252
+		} else {
253
+			foreach ( (array) $val as $ck => $cv ) {
254
+				if ( is_array($cv) ) {
255 255
 					$action[ $ck ] = $this->duplicate_array_walk( $action[ $ck ], $subkey, $cv );
256 256
 				} else if ( $ck == $subkey && isset( $frm_duplicate_ids[ $cv ] ) ) {
257 257
 					$action[ $ck ] = $frm_duplicate_ids[ $cv ];
258
-                }
259
-            }
260
-        }
258
+				}
259
+			}
260
+		}
261 261
 
262
-        return $action;
263
-    }
262
+		return $action;
263
+	}
264 264
 
265 265
 	/**
266 266
 	 * Deal with changed settings.
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 */
271 271
  	public function update_callback( $form_id ) {
272
-        $this->form_id = $form_id;
272
+		$this->form_id = $form_id;
273 273
 
274 274
  		$all_instances = $this->get_settings();
275 275
 
@@ -284,25 +284,25 @@  discard block
 block discarded – undo
284 284
  			return;
285 285
  		}
286 286
 
287
-        $action_ids = array();
287
+		$action_ids = array();
288 288
 
289 289
  		foreach ( $settings as $number => $new_instance ) {
290 290
  			$this->_set($number);
291 291
 
292 292
  			if ( ! isset($new_instance['post_title']) ) {
293
- 			    // settings were never opened, so don't update
294
- 			    $action_ids[] = $new_instance['ID'];
295
-         		$this->updated = true;
296
-         		continue;
293
+ 				// settings were never opened, so don't update
294
+ 				$action_ids[] = $new_instance['ID'];
295
+		 		$this->updated = true;
296
+		 		continue;
297 297
  			}
298 298
 
299 299
 			$old_instance = isset( $all_instances[ $number ] ) ? $all_instances[ $number ] : array();
300 300
 
301 301
  			$new_instance['post_type']  = FrmFormActionsController::$action_post_type;
302 302
 			$new_instance['post_name']  = $this->form_id . '_' . $this->id_base . '_' . $this->number;
303
-            $new_instance['menu_order']   = $this->form_id;
304
-            $new_instance['post_status']  = 'publish';
305
-            $new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
303
+			$new_instance['menu_order']   = $this->form_id;
304
+			$new_instance['post_status']  = 'publish';
305
+			$new_instance['post_date'] = isset( $old_instance->post_date ) ? $old_instance->post_date : '';
306 306
 
307 307
  			$instance = $this->update( $new_instance, $old_instance );
308 308
 
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
 				$all_instances[ $number ] = $instance;
329 329
 			}
330 330
 
331
-            $action_ids[] = $this->save_settings($instance);
331
+			$action_ids[] = $this->save_settings($instance);
332 332
 
333
-     		$this->updated = true;
333
+	 		$this->updated = true;
334 334
  		}
335 335
 
336 336
  		return $action_ids;
@@ -342,61 +342,61 @@  discard block
 block discarded – undo
342 342
 	}
343 343
 
344 344
 	public function get_single_action( $id ) {
345
-	    $action = get_post($id);
345
+		$action = get_post($id);
346 346
 		if ( $action ) {
347 347
 			$action = $this->prepare_action( $action );
348 348
 			$this->_set( $id );
349 349
 		}
350
-	    return $action;
350
+		return $action;
351 351
 	}
352 352
 
353 353
 	public function get_one( $form_id ) {
354
-	    return $this->get_all($form_id, 1);
354
+		return $this->get_all($form_id, 1);
355 355
 	}
356 356
 
357
-    public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
-        $action_controls = FrmFormActionsController::get_form_actions( $type );
359
-        if ( empty($action_controls) ) {
360
-            // don't continue if there are no available actions
361
-            return array();
362
-        }
357
+	public static function get_action_for_form( $form_id, $type = 'all', $limit = 99 ) {
358
+		$action_controls = FrmFormActionsController::get_form_actions( $type );
359
+		if ( empty($action_controls) ) {
360
+			// don't continue if there are no available actions
361
+			return array();
362
+		}
363 363
 
364 364
 		$limit = apply_filters( 'frm_form_action_limit', $limit, compact( 'type', 'form_id' ) );
365 365
 
366
-        if ( 'all' != $type ) {
367
-            return $action_controls->get_all( $form_id, $limit );
368
-        }
366
+		if ( 'all' != $type ) {
367
+			return $action_controls->get_all( $form_id, $limit );
368
+		}
369 369
 
370 370
 		$args = self::action_args( $form_id, $limit );
371 371
 		$actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
372 372
 
373
-        if ( ! $actions ) {
374
-            return array();
375
-        }
373
+		if ( ! $actions ) {
374
+			return array();
375
+		}
376 376
 
377
-        $settings = array();
378
-        foreach ( $actions as $action ) {
377
+		$settings = array();
378
+		foreach ( $actions as $action ) {
379 379
 			// some plugins/themes are formatting the post_excerpt
380 380
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
381 381
 
382 382
 			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
383
-                continue;
384
-            }
383
+				continue;
384
+			}
385 385
 
386
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
386
+			$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
387 387
 			$settings[ $action->ID ] = $action;
388 388
 
389 389
 			if ( count( $settings ) >= $limit ) {
390 390
 				break;
391 391
 			}
392
-        }
392
+		}
393 393
 
394
-        if ( 1 === $limit ) {
395
-            $settings = reset($settings);
396
-        }
394
+		if ( 1 === $limit ) {
395
+			$settings = reset($settings);
396
+		}
397 397
 
398
-        return $settings;
399
-    }
398
+		return $settings;
399
+	}
400 400
 
401 401
 	/**
402 402
 	 * @param int $action_id
@@ -416,45 +416,45 @@  discard block
 block discarded – undo
416 416
 	}
417 417
 
418 418
 	public function get_all( $form_id = false, $limit = 99 ) {
419
-	    if ( $form_id ) {
420
-	        $this->form_id = $form_id;
421
-	    }
419
+		if ( $form_id ) {
420
+			$this->form_id = $form_id;
421
+		}
422 422
 
423
-	    $type = $this->id_base;
423
+		$type = $this->id_base;
424 424
 
425
-	    global $frm_vars;
426
-	    $frm_vars['action_type'] = $type;
425
+		global $frm_vars;
426
+		$frm_vars['action_type'] = $type;
427 427
 
428
-	    add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
428
+		add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
429 429
 		$query = self::action_args( $form_id, $limit );
430
-        $query['post_status']      = 'any';
431
-        $query['suppress_filters'] = false;
430
+		$query['post_status']      = 'any';
431
+		$query['suppress_filters'] = false;
432 432
 
433 433
 		$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
434
-        unset($query);
434
+		unset($query);
435 435
 
436
-        remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
436
+		remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
437 437
 
438
-        if ( empty($actions) ) {
439
-            return array();
440
-        }
438
+		if ( empty($actions) ) {
439
+			return array();
440
+		}
441 441
 
442
-        $settings = array();
443
-        foreach ( $actions as $action ) {
444
-            if ( count($settings) >= $limit ) {
445
-                continue;
446
-            }
442
+		$settings = array();
443
+		foreach ( $actions as $action ) {
444
+			if ( count($settings) >= $limit ) {
445
+				continue;
446
+			}
447 447
 
448
-            $action = $this->prepare_action($action);
448
+			$action = $this->prepare_action($action);
449 449
 
450 450
 			$settings[ $action->ID ] = $action;
451
-        }
451
+		}
452 452
 
453
-        if ( 1 === $limit ) {
454
-            $settings = reset($settings);
455
-        }
453
+		if ( 1 === $limit ) {
454
+			$settings = reset($settings);
455
+		}
456 456
 
457
-        return $settings;
457
+		return $settings;
458 458
 	}
459 459
 
460 460
 	public static function action_args( $form_id = 0, $limit = 99 ) {
@@ -477,45 +477,45 @@  discard block
 block discarded – undo
477 477
 		$action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
478 478
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
479 479
 
480
-        $default_values = $this->get_global_defaults();
480
+		$default_values = $this->get_global_defaults();
481 481
 
482
-        // fill default values
483
-        $action->post_content += $default_values;
482
+		// fill default values
483
+		$action->post_content += $default_values;
484 484
 
485
-        foreach ( $default_values as $k => $vals ) {
486
-            if ( is_array($vals) && ! empty($vals) ) {
485
+		foreach ( $default_values as $k => $vals ) {
486
+			if ( is_array($vals) && ! empty($vals) ) {
487 487
 				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
488
-                    continue;
489
-                }
488
+					continue;
489
+				}
490 490
 				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
491
-            }
492
-        }
491
+			}
492
+		}
493 493
 
494
-        if ( ! is_array($action->post_content['event']) ) {
495
-            $action->post_content['event'] = explode(',', $action->post_content['event']);
496
-        }
494
+		if ( ! is_array($action->post_content['event']) ) {
495
+			$action->post_content['event'] = explode(',', $action->post_content['event']);
496
+		}
497 497
 
498
-        return $action;
498
+		return $action;
499 499
 	}
500 500
 
501 501
 	public function destroy( $form_id = false, $type = 'default' ) {
502
-	    global $wpdb;
502
+		global $wpdb;
503 503
 
504
-	    $this->form_id = $form_id;
504
+		$this->form_id = $form_id;
505 505
 
506
-	    $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
507
-	    if ( $form_id ) {
508
-	        $query['menu_order'] = $form_id;
509
-	    }
510
-	    if ( 'all' != $type ) {
511
-	        $query['post_excerpt'] = $this->id_base;
512
-	    }
506
+		$query = array( 'post_type' => FrmFormActionsController::$action_post_type );
507
+		if ( $form_id ) {
508
+			$query['menu_order'] = $form_id;
509
+		}
510
+		if ( 'all' != $type ) {
511
+			$query['post_excerpt'] = $this->id_base;
512
+		}
513 513
 
514
-        $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
514
+		$post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
515 515
 
516
-        foreach ( $post_ids as $id ) {
517
-            wp_delete_post($id);
518
-        }
516
+		foreach ( $post_ids as $id ) {
517
+			wp_delete_post($id);
518
+		}
519 519
 		self::clear_cache();
520 520
 	}
521 521
 
@@ -533,69 +533,69 @@  discard block
 block discarded – undo
533 533
 	}
534 534
 
535 535
 	public function get_global_defaults() {
536
-	    $defaults = $this->get_defaults();
536
+		$defaults = $this->get_defaults();
537 537
 
538
-	    if ( ! isset($defaults['event']) ) {
538
+		if ( ! isset($defaults['event']) ) {
539 539
 			$defaults['event'] = array( 'create' );
540
-	    }
540
+		}
541 541
 
542
-	    if ( ! isset($defaults['conditions']) ) {
543
-	        $defaults['conditions'] = array(
544
-                'send_stop' => '',
545
-                'any_all'   => '',
546
-            );
547
-        }
542
+		if ( ! isset($defaults['conditions']) ) {
543
+			$defaults['conditions'] = array(
544
+				'send_stop' => '',
545
+				'any_all'   => '',
546
+			);
547
+		}
548 548
 
549
-        return $defaults;
549
+		return $defaults;
550 550
 	}
551 551
 
552 552
 	public function get_global_switch_fields() {
553
-	    $switch = $this->get_switch_fields();
553
+		$switch = $this->get_switch_fields();
554 554
 		$switch['conditions'] = array( 'hide_field' );
555
-	    return $switch;
555
+		return $switch;
556 556
 	}
557 557
 
558 558
 	/**
559 559
 	 * Migrate settings from form->options into new action.
560 560
 	 */
561 561
 	public function migrate_to_2( $form, $update = 'update' ) {
562
-        $action = $this->prepare_new($form->id);
563
-        $form->options = maybe_unserialize($form->options);
562
+		$action = $this->prepare_new($form->id);
563
+		$form->options = maybe_unserialize($form->options);
564 564
 
565
-        // fill with existing options
566
-        foreach ( $action->post_content as $name => $val ) {
565
+		// fill with existing options
566
+		foreach ( $action->post_content as $name => $val ) {
567 567
 			if ( isset( $form->options[ $name ] ) ) {
568 568
 				$action->post_content[ $name ] = $form->options[ $name ];
569 569
 				unset( $form->options[ $name ] );
570
-            }
571
-        }
570
+			}
571
+		}
572 572
 
573
-        $action = $this->migrate_values($action, $form);
573
+		$action = $this->migrate_values($action, $form);
574 574
 
575
-        // check if action already exists
576
-        $post_id = get_posts( array(
577
-            'name'          => $action->post_name,
578
-            'post_type'     => FrmFormActionsController::$action_post_type,
579
-            'post_status'   => $action->post_status,
580
-            'numberposts'   => 1,
581
-        ) );
575
+		// check if action already exists
576
+		$post_id = get_posts( array(
577
+			'name'          => $action->post_name,
578
+			'post_type'     => FrmFormActionsController::$action_post_type,
579
+			'post_status'   => $action->post_status,
580
+			'numberposts'   => 1,
581
+		) );
582 582
 
583
-        if ( empty($post_id) ) {
584
-            // create action now
585
-            $post_id = $this->save_settings($action);
586
-        }
583
+		if ( empty($post_id) ) {
584
+			// create action now
585
+			$post_id = $this->save_settings($action);
586
+		}
587 587
 
588
-        if ( $post_id && 'update' == $update ) {
589
-            global $wpdb;
590
-            $form->options = maybe_serialize($form->options);
588
+		if ( $post_id && 'update' == $update ) {
589
+			global $wpdb;
590
+			$form->options = maybe_serialize($form->options);
591 591
 
592
-            // update form options
592
+			// update form options
593 593
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
594
-	        FrmForm::clear_form_cache();
595
-        }
594
+			FrmForm::clear_form_cache();
595
+		}
596 596
 
597
-        return $post_id;
598
-    }
597
+		return $post_id;
598
+	}
599 599
 
600 600
 	public static function action_conditions_met( $action, $entry ) {
601 601
 		$notification = $action->post_content;
Please login to merge, or discard this patch.