[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-admin/includes/install/ -> form.php (source)

   1  <?php
   2  
   3  /* Form install */
   4  
   5  global $wpdb;
   6  
   7  //////////////////////////////////
   8  //// Install                  ////
   9  //////////////////////////////////
  10  
  11  $charset_collate = '';
  12  if ( $wpdb->supports_collation() ) 
  13  {
  14      if ( ! empty($wpdb->charset) ) $charset_collate  = "DEFAULT CHARACTER SET $wpdb->charset";
  15      if ( ! empty($wpdb->collate) ) $charset_collate .= " COLLATE $wpdb->collate";
  16  }
  17  
  18  $queries = array();
  19  
  20  $queries[] =
  21  "CREATE TABLE $wpdb->mp_forms (
  22   id                bigint(20)      NOT NULL auto_increment,
  23   label             varchar(255)    NOT NULL default '',
  24   description       varchar(255)    NOT NULL default '',
  25   template          varchar(50)     NOT NULL default '',
  26   settings          longtext,
  27   PRIMARY KEY (id),
  28   UNIQUE KEY id (id)
  29  ) $charset_collate;";
  30  
  31  $queries[] =
  32  "CREATE TABLE $wpdb->mp_fields (
  33   id                bigint(20)      NOT NULL auto_increment,
  34   form_id           bigint(20)      NOT NULL,
  35   ordre             bigint(20)      UNSIGNED NOT NULL default 0,
  36   type              varchar(50)     NOT NULL default '',
  37   template          varchar(50)     NOT NULL default '',
  38   label             varchar(255)    NOT NULL default '',
  39   description       varchar(255)    NOT NULL default '',
  40   settings          longtext,
  41   PRIMARY KEY (id),
  42   UNIQUE KEY id (id)
  43  ) $charset_collate;";
  44  
  45  require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  46  dbDelta($queries);
  47  
  48  //////////////////////////////////
  49  //// Upgrade to MailPress 5.0 ////
  50  //////////////////////////////////
  51  
  52  foreach( array($wpdb->mp_forms, $wpdb->mp_fields) as $x)
  53  {
  54      $rows = $wpdb->get_results( "SELECT id, settings FROM $x;" );
  55      if ($rows)
  56      {
  57          foreach($rows as $row)
  58          {
  59              if (unserialize($row->settings)) continue;
  60              $settings = mysql_real_escape_string(stripslashes($row->settings));
  61              $wpdb->query( "UPDATE $x SET settings = '$settings' WHERE id = {$row->id};" );
  62          }
  63      }
  64  }


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1