merged master

This commit is contained in:
Jonathan Labreuille
2015-10-16 14:40:32 +02:00
57 changed files with 1923 additions and 648 deletions

View File

@@ -8,7 +8,7 @@ if(!defined('ABSPATH')) exit;
class Initializer {
function __construct($params = array(
'file' => '',
'file' => '',
'version' => '1.0.0'
)) {
Env::init($params['file'], $params['version']);
@@ -41,6 +41,8 @@ class Initializer {
$segments = Env::$db_prefix . 'segments';
$subscriber_segment = Env::$db_prefix . 'subscriber_segment';
$newsletter_segment = Env::$db_prefix . 'newsletter_segment';
$custom_fields = Env::$db_prefix . 'custom_fields';
$subscriber_custom_field = Env::$db_prefix . 'subscriber_custom_field';
define('MP_SUBSCRIBERS_TABLE', $subscribers);
define('MP_SETTINGS_TABLE', $settings);
@@ -49,6 +51,8 @@ class Initializer {
define('MP_SUBSCRIBER_SEGMENT_TABLE', $subscriber_segment);
define('MP_NEWSLETTER_TEMPLATES_TABLE', $newsletter_templates);
define('MP_NEWSLETTER_SEGMENT_TABLE', $newsletter_segment);
define('MP_CUSTOM_FIELDS_TABLE', $custom_fields);
define('MP_SUBSCRIBER_CUSTOM_FIELD_TABLE', $subscriber_custom_field);
}
function setupActivator() {
@@ -88,4 +92,4 @@ class Initializer {
$permissions = new Permissions();
$permissions->init();
}
}
}

View File

@@ -16,7 +16,9 @@ class Migrator {
'newsletter_templates',
'segments',
'subscriber_segment',
'newsletter_segment'
'newsletter_segment',
'custom_fields',
'subscriber_custom_field'
);
}
@@ -133,6 +135,31 @@ class Migrator {
return $this->sqlify(__FUNCTION__, $attributes);
}
function custom_fields() {
$attributes = array(
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
'name varchar(90) NOT NULL,',
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
'PRIMARY KEY (id),',
'UNIQUE KEY name (name)'
);
return $this->sqlify(__FUNCTION__, $attributes);
}
function subscriber_custom_field() {
$attributes = array(
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
'subscriber_id mediumint(9) NOT NULL,',
'custom_field_id mediumint(9) NOT NULL,',
'value varchar(255) NOT NULL,',
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
'PRIMARY KEY (id)'
);
return $this->sqlify(__FUNCTION__, $attributes);
}
private function sqlify($model, $attributes) {
$table = $this->prefix . $model;