Completed
Push — master ( efe739...717945 )
by Stephanie
03:35
created
classes/models/FrmMigrate.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 		return $charset_collate;
83 83
 	}
84 84
 
85
-    private function create_tables() {
86
-        $charset_collate = $this->collation();
87
-        $sql = array();
85
+	private function create_tables() {
86
+		$charset_collate = $this->collation();
87
+		$sql = array();
88 88
 
89
-        /* Create/Upgrade Fields Table */
89
+		/* Create/Upgrade Fields Table */
90 90
 		$sql[] = 'CREATE TABLE ' . $this->fields . ' (
91 91
 				id BIGINT(20) NOT NULL auto_increment,
92 92
 				field_key varchar(100) default NULL,
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 UNIQUE KEY field_key (field_key)
106 106
         )';
107 107
 
108
-        /* Create/Upgrade Forms Table */
108
+		/* Create/Upgrade Forms Table */
109 109
 		$sql[] = 'CREATE TABLE ' . $this->forms . ' (
110 110
                 id int(11) NOT NULL auto_increment,
111 111
 				form_key varchar(100) default NULL,
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 UNIQUE KEY form_key (form_key)
124 124
         )';
125 125
 
126
-        /* Create/Upgrade Items Table */
126
+		/* Create/Upgrade Items Table */
127 127
 		$sql[] = 'CREATE TABLE ' . $this->entries . ' (
128 128
 				id BIGINT(20) NOT NULL auto_increment,
129 129
 				item_key varchar(100) default NULL,
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
                 UNIQUE KEY item_key (item_key)
147 147
         )';
148 148
 
149
-        /* Create/Upgrade Meta Table */
149
+		/* Create/Upgrade Meta Table */
150 150
 		$sql[] = 'CREATE TABLE ' . $this->entry_metas . ' (
151 151
 				id BIGINT(20) NOT NULL auto_increment,
152 152
 				meta_value longtext default NULL,
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
                 KEY item_id (item_id)
159 159
         )';
160 160
 
161
-        foreach ( $sql as $q ) {
161
+		foreach ( $sql as $q ) {
162 162
 			if ( function_exists( 'dbDelta' ) ) {
163 163
 				dbDelta( $q . $charset_collate . ';' );
164 164
 			} else {
165 165
 				global $wpdb;
166 166
 				$wpdb->query( $q . $charset_collate );
167 167
 			}
168
-            unset($q);
169
-        }
170
-    }
168
+			unset($q);
169
+		}
170
+	}
171 171
 
172 172
 	private function maybe_create_contact_form() {
173 173
 		$template_id = FrmForm::get_id_by_key( 'contact' );
@@ -209,31 +209,31 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 	}
211 211
 
212
-    public function uninstall() {
212
+	public function uninstall() {
213 213
 		if ( ! current_user_can( 'administrator' ) ) {
214
-            $frm_settings = FrmAppHelper::get_settings();
215
-            wp_die($frm_settings->admin_permission);
216
-        }
214
+			$frm_settings = FrmAppHelper::get_settings();
215
+			wp_die($frm_settings->admin_permission);
216
+		}
217 217
 
218
-        global $wpdb, $wp_roles;
218
+		global $wpdb, $wp_roles;
219 219
 
220 220
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields );
221 221
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms );
222 222
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
223 223
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
224 224
 
225
-        delete_option('frm_options');
226
-        delete_option('frm_db_version');
227
-
228
-        //delete roles
229
-        $frm_roles = FrmAppHelper::frm_capabilities();
230
-        $roles = get_editable_roles();
231
-        foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232
-            foreach ( $roles as $role => $details ) {
233
-                $wp_roles->remove_cap( $role, $frm_role );
234
-                unset($role, $details);
235
-    		}
236
-    		unset($frm_role, $frm_role_description);
225
+		delete_option('frm_options');
226
+		delete_option('frm_db_version');
227
+
228
+		//delete roles
229
+		$frm_roles = FrmAppHelper::frm_capabilities();
230
+		$roles = get_editable_roles();
231
+		foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232
+			foreach ( $roles as $role => $details ) {
233
+				$wp_roles->remove_cap( $role, $frm_role );
234
+				unset($role, $details);
235
+			}
236
+			unset($frm_role, $frm_role_description);
237 237
 		}
238 238
 		unset($roles, $frm_roles);
239 239
 
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
259 259
 
260
-        do_action('frm_after_uninstall');
261
-        return true;
262
-    }
260
+		do_action('frm_after_uninstall');
261
+		return true;
262
+	}
263 263
 
264 264
 	/**
265 265
 	 * Reverse migration 17 -- Divide by 9
@@ -426,99 +426,99 @@  discard block
 block discarded – undo
426 426
 		$size .= 'px';
427 427
 	}
428 428
 
429
-    /**
430
-     * Migrate post and email notification settings into actions
431
-     */
432
-    private function migrate_to_16() {
433
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
434
-
435
-        /**
436
-        * Old email settings format:
437
-        * email_to: Email or field id
438
-        * also_email_to: array of fields ids
439
-        * reply_to: Email, field id, 'custom'
440
-        * cust_reply_to: string
441
-        * reply_to_name: field id, 'custom'
442
-        * cust_reply_to_name: string
443
-        * plain_text: 0|1
444
-        * email_message: string or ''
445
-        * email_subject: string or ''
446
-        * inc_user_info: 0|1
447
-        * update_email: 0, 1, 2
448
-        *
449
-        * Old autoresponder settings format:
450
-        * auto_responder: 0|1
451
-        * ar_email_message: string or ''
452
-        * ar_email_to: field id
453
-        * ar_plain_text: 0|1
454
-        * ar_reply_to_name: string
455
-        * ar_reply_to: string
456
-        * ar_email_subject: string
457
-        * ar_update_email: 0, 1, 2
458
-        *
459
-        * New email settings:
460
-        * post_content: json settings
461
-        * post_title: form id
462
-        * post_excerpt: message
463
-        *
464
-        */
465
-
466
-        foreach ( $forms as $form ) {
429
+	/**
430
+	 * Migrate post and email notification settings into actions
431
+	 */
432
+	private function migrate_to_16() {
433
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' );
434
+
435
+		/**
436
+		 * Old email settings format:
437
+		 * email_to: Email or field id
438
+		 * also_email_to: array of fields ids
439
+		 * reply_to: Email, field id, 'custom'
440
+		 * cust_reply_to: string
441
+		 * reply_to_name: field id, 'custom'
442
+		 * cust_reply_to_name: string
443
+		 * plain_text: 0|1
444
+		 * email_message: string or ''
445
+		 * email_subject: string or ''
446
+		 * inc_user_info: 0|1
447
+		 * update_email: 0, 1, 2
448
+		 *
449
+		 * Old autoresponder settings format:
450
+		 * auto_responder: 0|1
451
+		 * ar_email_message: string or ''
452
+		 * ar_email_to: field id
453
+		 * ar_plain_text: 0|1
454
+		 * ar_reply_to_name: string
455
+		 * ar_reply_to: string
456
+		 * ar_email_subject: string
457
+		 * ar_update_email: 0, 1, 2
458
+		 *
459
+		 * New email settings:
460
+		 * post_content: json settings
461
+		 * post_title: form id
462
+		 * post_excerpt: message
463
+		 *
464
+		 */
465
+
466
+		foreach ( $forms as $form ) {
467 467
 			if ( $form->is_template && $form->default_template ) {
468 468
 				// don't migrate the default templates since the email will be added anyway
469 469
 				continue;
470 470
 			}
471 471
 
472
-            // Format form options
473
-            $form_options = maybe_unserialize($form->options);
472
+			// Format form options
473
+			$form_options = maybe_unserialize($form->options);
474 474
 
475
-            // Migrate settings to actions
476
-            FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
477
-        }
478
-    }
475
+			// Migrate settings to actions
476
+			FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
477
+		}
478
+	}
479 479
 
480
-    private function migrate_to_11() {
481
-        global $wpdb;
480
+	private function migrate_to_11() {
481
+		global $wpdb;
482 482
 
483
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
483
+		$forms = FrmDb::get_results( $this->forms, array(), 'id, options');
484 484
 
485
-        $sending = __( 'Sending', 'formidable' );
485
+		$sending = __( 'Sending', 'formidable' );
486 486
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
487
-        $old_default_html = <<<DEFAULT_HTML
487
+		$old_default_html = <<<DEFAULT_HTML
488 488
 <div class="frm_submit">
489 489
 [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button]
490 490
 <input type="submit" value="[button_label]" [button_action] />
491 491
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
492 492
 </div>
493 493
 DEFAULT_HTML;
494
-        unset($sending, $img);
494
+		unset($sending, $img);
495 495
 
496
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
497
-        $draft_link = FrmFormsHelper::get_draft_link();
496
+		$new_default_html = FrmFormsHelper::get_default_html('submit');
497
+		$draft_link = FrmFormsHelper::get_draft_link();
498 498
 		foreach ( $forms as $form ) {
499
-            $form->options = maybe_unserialize($form->options);
500
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
501
-                continue;
502
-            }
499
+			$form->options = maybe_unserialize($form->options);
500
+			if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
501
+				continue;
502
+			}
503 503
 
504
-            if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
505
-                $form->options['submit_html'] = $new_default_html;
504
+			if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) {
505
+				$form->options['submit_html'] = $new_default_html;
506 506
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
507 507
 			} else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) {
508 508
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
509 509
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
510
-            }
511
-            unset($form);
512
-        }
513
-    }
510
+			}
511
+			unset($form);
512
+		}
513
+	}
514 514
 
515
-    private function migrate_to_6() {
516
-        global $wpdb;
515
+	private function migrate_to_6() {
516
+		global $wpdb;
517 517
 
518 518
 		$no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) );
519 519
 		$fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' );
520 520
 
521
-        $default_html = <<<DEFAULT_HTML
521
+		$default_html = <<<DEFAULT_HTML
522 522
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
523 523
     <label class="frm_pos_[label_position]">[field_name]
524 524
         <span class="frm_required">[required_label]</span>
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 </div>
529 529
 DEFAULT_HTML;
530 530
 
531
-        $old_default_html = <<<DEFAULT_HTML
531
+		$old_default_html = <<<DEFAULT_HTML
532 532
 <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
533 533
     <label class="frm_pos_[label_position]">[field_name]
534 534
         <span class="frm_required">[required_label]</span>
@@ -538,16 +538,16 @@  discard block
 block discarded – undo
538 538
 </div>
539 539
 DEFAULT_HTML;
540 540
 
541
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
542
-        foreach ( $fields as $field ) {
543
-            $field->field_options = maybe_unserialize($field->field_options);
541
+		$new_default_html = FrmFieldsHelper::get_default_html('text');
542
+		foreach ( $fields as $field ) {
543
+			$field->field_options = maybe_unserialize($field->field_options);
544 544
 			$html = FrmField::get_option( $field, 'custom_html' );
545 545
 			if ( $html == $default_html || $html == $old_default_html ) {
546
-                $field->field_options['custom_html'] = $new_default_html;
546
+				$field->field_options['custom_html'] = $new_default_html;
547 547
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
548
-            }
549
-            unset($field);
550
-        }
551
-        unset($default_html, $old_default_html, $fields);
552
-    }
548
+			}
549
+			unset($field);
550
+		}
551
+		unset($default_html, $old_default_html, $fields);
552
+	}
553 553
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 	public $entry_metas;
8 8
 
9 9
 	public function __construct() {
10
-		if ( ! defined('ABSPATH') ) {
11
-			die('You are not allowed to call this page directly.');
10
+		if ( ! defined( 'ABSPATH' ) ) {
11
+			die( 'You are not allowed to call this page directly.' );
12 12
 		}
13 13
 
14 14
 		global $wpdb;
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			}
52 52
 		}
53 53
 
54
-		do_action('frm_after_install');
54
+		do_action( 'frm_after_install' );
55 55
 
56 56
 		$frm_vars['doing_upgrade'] = false;
57 57
 
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 				global $wpdb;
166 166
 				$wpdb->query( $q . $charset_collate );
167 167
 			}
168
-            unset($q);
168
+            unset( $q );
169 169
         }
170 170
     }
171 171
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
     public function uninstall() {
213 213
 		if ( ! current_user_can( 'administrator' ) ) {
214 214
             $frm_settings = FrmAppHelper::get_settings();
215
-            wp_die($frm_settings->admin_permission);
215
+            wp_die( $frm_settings->admin_permission );
216 216
         }
217 217
 
218 218
         global $wpdb, $wp_roles;
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries );
223 223
 		$wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas );
224 224
 
225
-        delete_option('frm_options');
226
-        delete_option('frm_db_version');
225
+        delete_option( 'frm_options' );
226
+        delete_option( 'frm_db_version' );
227 227
 
228 228
         //delete roles
229 229
         $frm_roles = FrmAppHelper::frm_capabilities();
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
         foreach ( $frm_roles as $frm_role => $frm_role_description ) {
232 232
             foreach ( $roles as $role => $details ) {
233 233
                 $wp_roles->remove_cap( $role, $frm_role );
234
-                unset($role, $details);
234
+                unset( $role, $details );
235 235
     		}
236
-    		unset($frm_role, $frm_role_description);
236
+    		unset( $frm_role, $frm_role_description );
237 237
 		}
238
-		unset($roles, $frm_roles);
238
+		unset( $roles, $frm_roles );
239 239
 
240 240
 		// delete actions, views, and styles
241 241
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) );
259 259
 
260
-        do_action('frm_after_uninstall');
260
+        do_action( 'frm_after_uninstall' );
261 261
         return true;
262 262
     }
263 263
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 				continue;
320 320
 			}
321 321
 
322
-			$this->maybe_convert_migrated_size( $widgets[ $k ]['size'] );
322
+			$this->maybe_convert_migrated_size( $widgets[$k]['size'] );
323 323
 		}
324 324
 		update_option( 'widget_frm_show_form', $widgets );
325 325
 	}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 			if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) {
416 416
 				continue;
417 417
 			}
418
-			$this->convert_character_to_px( $widgets[ $k ]['size'] );
418
+			$this->convert_character_to_px( $widgets[$k]['size'] );
419 419
 		}
420 420
 		update_option( 'widget_frm_show_form', $widgets );
421 421
 	}
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 			}
471 471
 
472 472
             // Format form options
473
-            $form_options = maybe_unserialize($form->options);
473
+            $form_options = maybe_unserialize( $form->options );
474 474
 
475 475
             // Migrate settings to actions
476 476
             FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id );
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
     private function migrate_to_11() {
481 481
         global $wpdb;
482 482
 
483
-        $forms = FrmDb::get_results( $this->forms, array(), 'id, options');
483
+        $forms = FrmDb::get_results( $this->forms, array(), 'id, options' );
484 484
 
485 485
         $sending = __( 'Sending', 'formidable' );
486 486
 		$img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif';
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" />
492 492
 </div>
493 493
 DEFAULT_HTML;
494
-        unset($sending, $img);
494
+        unset( $sending, $img );
495 495
 
496
-        $new_default_html = FrmFormsHelper::get_default_html('submit');
496
+        $new_default_html = FrmFormsHelper::get_default_html( 'submit' );
497 497
         $draft_link = FrmFormsHelper::get_draft_link();
498 498
 		foreach ( $forms as $form ) {
499
-            $form->options = maybe_unserialize($form->options);
500
-            if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) {
499
+            $form->options = maybe_unserialize( $form->options );
500
+            if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) {
501 501
                 continue;
502 502
             }
503 503
 
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 				$form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] );
509 509
 				$wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) );
510 510
             }
511
-            unset($form);
511
+            unset( $form );
512 512
         }
513 513
     }
514 514
 
@@ -538,16 +538,16 @@  discard block
 block discarded – undo
538 538
 </div>
539 539
 DEFAULT_HTML;
540 540
 
541
-        $new_default_html = FrmFieldsHelper::get_default_html('text');
541
+        $new_default_html = FrmFieldsHelper::get_default_html( 'text' );
542 542
         foreach ( $fields as $field ) {
543
-            $field->field_options = maybe_unserialize($field->field_options);
543
+            $field->field_options = maybe_unserialize( $field->field_options );
544 544
 			$html = FrmField::get_option( $field, 'custom_html' );
545 545
 			if ( $html == $default_html || $html == $old_default_html ) {
546 546
                 $field->field_options['custom_html'] = $new_default_html;
547 547
 				$wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) );
548 548
             }
549
-            unset($field);
549
+            unset( $field );
550 550
         }
551
-        unset($default_html, $old_default_html, $fields);
551
+        unset( $default_html, $old_default_html, $fields );
552 552
     }
553 553
 }
Please login to merge, or discard this patch.