Completed
Push — master ( 96a26a...ed722f )
by Jamie
03:45
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,59 +342,59 @@  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
-        if ( 'all' != $type ) {
365
-            return $action_controls->get_all( $form_id, $limit );
366
-        }
364
+		if ( 'all' != $type ) {
365
+			return $action_controls->get_all( $form_id, $limit );
366
+		}
367 367
 
368 368
 		$args = self::action_args( $form_id, $limit );
369 369
 		$actions = FrmAppHelper::check_cache( serialize( $args ), 'frm_actions', $args, 'get_posts' );
370 370
 
371
-        if ( ! $actions ) {
372
-            return array();
373
-        }
371
+		if ( ! $actions ) {
372
+			return array();
373
+		}
374 374
 
375
-        $settings = array();
376
-        foreach ( $actions as $action ) {
375
+		$settings = array();
376
+		foreach ( $actions as $action ) {
377 377
 			// some plugins/themes are formatting the post_excerpt
378 378
 			$action->post_excerpt = sanitize_title( $action->post_excerpt );
379 379
 
380 380
 			if ( ! isset( $action_controls[ $action->post_excerpt ] ) ) {
381
-                continue;
382
-            }
381
+				continue;
382
+			}
383 383
 
384
-            $action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
384
+			$action = $action_controls[ $action->post_excerpt ]->prepare_action( $action );
385 385
 			$settings[ $action->ID ] = $action;
386 386
 
387 387
 			if ( count( $settings ) >= $limit ) {
388 388
 				break;
389 389
 			}
390
-        }
390
+		}
391 391
 
392
-        if ( 1 === $limit ) {
393
-            $settings = reset($settings);
394
-        }
392
+		if ( 1 === $limit ) {
393
+			$settings = reset($settings);
394
+		}
395 395
 
396
-        return $settings;
397
-    }
396
+		return $settings;
397
+	}
398 398
 
399 399
 	/**
400 400
 	 * @param int $action_id
@@ -414,45 +414,45 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 
416 416
 	public function get_all( $form_id = false, $limit = 99 ) {
417
-	    if ( $form_id ) {
418
-	        $this->form_id = $form_id;
419
-	    }
417
+		if ( $form_id ) {
418
+			$this->form_id = $form_id;
419
+		}
420 420
 
421
-	    $type = $this->id_base;
421
+		$type = $this->id_base;
422 422
 
423
-	    global $frm_vars;
424
-	    $frm_vars['action_type'] = $type;
423
+		global $frm_vars;
424
+		$frm_vars['action_type'] = $type;
425 425
 
426
-	    add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
426
+		add_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
427 427
 		$query = self::action_args( $form_id, $limit );
428
-        $query['post_status']      = 'any';
429
-        $query['suppress_filters'] = false;
428
+		$query['post_status']      = 'any';
429
+		$query['suppress_filters'] = false;
430 430
 
431 431
 		$actions = FrmAppHelper::check_cache( serialize( $query ) . '_type_' . $type, 'frm_actions', $query, 'get_posts' );
432
-        unset($query);
432
+		unset($query);
433 433
 
434
-        remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
434
+		remove_filter( 'posts_where' , 'FrmFormActionsController::limit_by_type' );
435 435
 
436
-        if ( empty($actions) ) {
437
-            return array();
438
-        }
436
+		if ( empty($actions) ) {
437
+			return array();
438
+		}
439 439
 
440
-        $settings = array();
441
-        foreach ( $actions as $action ) {
442
-            if ( count($settings) >= $limit ) {
443
-                continue;
444
-            }
440
+		$settings = array();
441
+		foreach ( $actions as $action ) {
442
+			if ( count($settings) >= $limit ) {
443
+				continue;
444
+			}
445 445
 
446
-            $action = $this->prepare_action($action);
446
+			$action = $this->prepare_action($action);
447 447
 
448 448
 			$settings[ $action->ID ] = $action;
449
-        }
449
+		}
450 450
 
451
-        if ( 1 === $limit ) {
452
-            $settings = reset($settings);
453
-        }
451
+		if ( 1 === $limit ) {
452
+			$settings = reset($settings);
453
+		}
454 454
 
455
-        return $settings;
455
+		return $settings;
456 456
 	}
457 457
 
458 458
 	public static function action_args( $form_id = 0, $limit = 99 ) {
@@ -475,45 +475,45 @@  discard block
 block discarded – undo
475 475
 		$action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
476 476
 		$action->post_excerpt = sanitize_title( $action->post_excerpt );
477 477
 
478
-        $default_values = $this->get_global_defaults();
478
+		$default_values = $this->get_global_defaults();
479 479
 
480
-        // fill default values
481
-        $action->post_content += $default_values;
480
+		// fill default values
481
+		$action->post_content += $default_values;
482 482
 
483
-        foreach ( $default_values as $k => $vals ) {
484
-            if ( is_array($vals) && ! empty($vals) ) {
483
+		foreach ( $default_values as $k => $vals ) {
484
+			if ( is_array($vals) && ! empty($vals) ) {
485 485
 				if ( 'event' == $k && ! $this->action_options['force_event'] && ! empty( $action->post_content[ $k ] ) ) {
486
-                    continue;
487
-                }
486
+					continue;
487
+				}
488 488
 				$action->post_content[ $k ] = wp_parse_args( $action->post_content[ $k ], $vals );
489
-            }
490
-        }
489
+			}
490
+		}
491 491
 
492
-        if ( ! is_array($action->post_content['event']) ) {
493
-            $action->post_content['event'] = explode(',', $action->post_content['event']);
494
-        }
492
+		if ( ! is_array($action->post_content['event']) ) {
493
+			$action->post_content['event'] = explode(',', $action->post_content['event']);
494
+		}
495 495
 
496
-        return $action;
496
+		return $action;
497 497
 	}
498 498
 
499 499
 	public function destroy( $form_id = false, $type = 'default' ) {
500
-	    global $wpdb;
500
+		global $wpdb;
501 501
 
502
-	    $this->form_id = $form_id;
502
+		$this->form_id = $form_id;
503 503
 
504
-	    $query = array( 'post_type' => FrmFormActionsController::$action_post_type );
505
-	    if ( $form_id ) {
506
-	        $query['menu_order'] = $form_id;
507
-	    }
508
-	    if ( 'all' != $type ) {
509
-	        $query['post_excerpt'] = $this->id_base;
510
-	    }
504
+		$query = array( 'post_type' => FrmFormActionsController::$action_post_type );
505
+		if ( $form_id ) {
506
+			$query['menu_order'] = $form_id;
507
+		}
508
+		if ( 'all' != $type ) {
509
+			$query['post_excerpt'] = $this->id_base;
510
+		}
511 511
 
512
-        $post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
512
+		$post_ids = FrmDb::get_col( $wpdb->posts, $query, 'ID' );
513 513
 
514
-        foreach ( $post_ids as $id ) {
515
-            wp_delete_post($id);
516
-        }
514
+		foreach ( $post_ids as $id ) {
515
+			wp_delete_post($id);
516
+		}
517 517
 		self::clear_cache();
518 518
 	}
519 519
 
@@ -531,69 +531,69 @@  discard block
 block discarded – undo
531 531
 	}
532 532
 
533 533
 	public function get_global_defaults() {
534
-	    $defaults = $this->get_defaults();
534
+		$defaults = $this->get_defaults();
535 535
 
536
-	    if ( ! isset($defaults['event']) ) {
536
+		if ( ! isset($defaults['event']) ) {
537 537
 			$defaults['event'] = array( 'create' );
538
-	    }
538
+		}
539 539
 
540
-	    if ( ! isset($defaults['conditions']) ) {
541
-	        $defaults['conditions'] = array(
542
-                'send_stop' => '',
543
-                'any_all'   => '',
544
-            );
545
-        }
540
+		if ( ! isset($defaults['conditions']) ) {
541
+			$defaults['conditions'] = array(
542
+				'send_stop' => '',
543
+				'any_all'   => '',
544
+			);
545
+		}
546 546
 
547
-        return $defaults;
547
+		return $defaults;
548 548
 	}
549 549
 
550 550
 	public function get_global_switch_fields() {
551
-	    $switch = $this->get_switch_fields();
551
+		$switch = $this->get_switch_fields();
552 552
 		$switch['conditions'] = array( 'hide_field' );
553
-	    return $switch;
553
+		return $switch;
554 554
 	}
555 555
 
556 556
 	/**
557 557
 	 * Migrate settings from form->options into new action.
558 558
 	 */
559 559
 	public function migrate_to_2( $form, $update = 'update' ) {
560
-        $action = $this->prepare_new($form->id);
561
-        $form->options = maybe_unserialize($form->options);
560
+		$action = $this->prepare_new($form->id);
561
+		$form->options = maybe_unserialize($form->options);
562 562
 
563
-        // fill with existing options
564
-        foreach ( $action->post_content as $name => $val ) {
563
+		// fill with existing options
564
+		foreach ( $action->post_content as $name => $val ) {
565 565
 			if ( isset( $form->options[ $name ] ) ) {
566 566
 				$action->post_content[ $name ] = $form->options[ $name ];
567 567
 				unset( $form->options[ $name ] );
568
-            }
569
-        }
568
+			}
569
+		}
570 570
 
571
-        $action = $this->migrate_values($action, $form);
571
+		$action = $this->migrate_values($action, $form);
572 572
 
573
-        // check if action already exists
574
-        $post_id = get_posts( array(
575
-            'name'          => $action->post_name,
576
-            'post_type'     => FrmFormActionsController::$action_post_type,
577
-            'post_status'   => $action->post_status,
578
-            'numberposts'   => 1,
579
-        ) );
573
+		// check if action already exists
574
+		$post_id = get_posts( array(
575
+			'name'          => $action->post_name,
576
+			'post_type'     => FrmFormActionsController::$action_post_type,
577
+			'post_status'   => $action->post_status,
578
+			'numberposts'   => 1,
579
+		) );
580 580
 
581
-        if ( empty($post_id) ) {
582
-            // create action now
583
-            $post_id = $this->save_settings($action);
584
-        }
581
+		if ( empty($post_id) ) {
582
+			// create action now
583
+			$post_id = $this->save_settings($action);
584
+		}
585 585
 
586
-        if ( $post_id && 'update' == $update ) {
587
-            global $wpdb;
588
-            $form->options = maybe_serialize($form->options);
586
+		if ( $post_id && 'update' == $update ) {
587
+			global $wpdb;
588
+			$form->options = maybe_serialize($form->options);
589 589
 
590
-            // update form options
590
+			// update form options
591 591
 			$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => $form->options ), array( 'id' => $form->id ) );
592
-	        FrmForm::clear_form_cache();
593
-        }
592
+			FrmForm::clear_form_cache();
593
+		}
594 594
 
595
-        return $post_id;
596
-    }
595
+		return $post_id;
596
+	}
597 597
 
598 598
 	public static function action_conditions_met( $action, $entry ) {
599 599
 		$notification = $action->post_content;
Please login to merge, or discard this patch.