$dbKITregister = new dbKITregister();
if (!$dbKITregister->sqlTableExists()) {
    if (!$dbKITregister->sqlCreateTable()) {
        $error .= sprintf('<p>[Upgrade] %s </p>', $dbKITregister->getError());
    }
}
$dbKITprovider = new dbKITprovider();
if (!$dbKITprovider->sqlFieldExists(dbKITprovider::field_identifier)) {
    if (!$dbKITprovider->sqlAlterTableAddField(dbKITprovider::field_identifier, "VARCHAR (50) NOT NULL DEFAULT ''", dbKITprovider::field_name)) {
        $error .= sprintf('<p>[Upgrade] %s </p>', $dbKITprovider->getError());
    }
}
$dbKITcontact = new dbKITcontact();
if (!$dbKITcontact->sqlFieldExists(dbKITcontact::field_newsletter)) {
    if (!$dbKITcontact->sqlAlterTableAddField(dbKITcontact::field_newsletter, "VARCHAR (255) NOT NULL DEFAULT ''", dbKITcontact::field_category)) {
        $error .= sprintf('<p>[Upgrade] %s </p>', $dbKITcontact->getError());
    }
}
// check field_distribution --> #0.29
if (!$dbKITcontact->sqlFieldExists(dbKITcontact::field_distribution)) {
    if (!$dbKITcontact->sqlAlterTableAddField(dbKITcontact::field_distribution, "VARCHAR(255) NOT NULL DEFAULT ''", dbKITcontact::field_newsletter)) {
        $error .= sprintf('<p>[Upgrade] %s </p>', $dbKITcontact->getError());
    }
}
// install tables for newsletter module
$dbKITnewsletterTemplates = new dbKITnewsletterTemplates();
if (!$dbKITnewsletterTemplates->sqlTableExists()) {
    if (!$dbKITnewsletterTemplates->sqlCreateTable()) {
        $error .= sprintf('<p>[Upgrade] %s</p>', $dbKITnewsletterTemplates->getError());
    }
}
define('KIT_INSTALL_RUNNING', true);
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/initialize.php';
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/class.mail.php';
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/class.newsletter.php';
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/class.cronjob.php';
global $admin;
global $database;
$error = '';
// first install configuration table!
$dbConfig = new dbKITcfg(true);
if ($dbConfig->isError()) {
    $error .= sprintf('<p>[Installation] %s</p>', $dbConfig->getError());
}
$dbKITcontact = new dbKITcontact(true);
if ($dbKITcontact->isError()) {
    $error .= sprintf('<p>[Installation] %s</p>', $dbKITcontact->getError());
}
$dbKITcontactAddress = new dbKITcontactAddress(true);
if ($dbKITcontactAddress->isError()) {
    $error .= sprintf('<p>[Installation] %s</p>', $dbKITcontactAddress->getError());
}
$dbKITprovider = new dbKITprovider(true);
if ($dbKITprovider->isError()) {
    $error .= sprintf('<p>[Installation] %s</p>', $dbKITprovider->getError());
}
$dbKITmail = new dbKITmail(true);
if ($dbKITmail->isError()) {
    $error .= sprintf('<p>[Installation] %s</p>', $dbKITmail->getError());
}
$dbKITregister = new dbKITregister(true);
if ($dbKITregister->isError()) {
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/initialize.php';
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/class.mail.php';
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/class.newsletter.php';
require_once WB_PATH . '/modules/' . basename(dirname(__FILE__)) . '/class.cronjob.php';
global $admin;
$error = '';
$dbConfig = new dbKITcfg();
if ($dbConfig->sqlTableExists()) {
    if (!$dbConfig->sqlDeleteTable()) {
        $error .= sprintf('<p>[Delete Table] %s</p>', $dbConfig->getError());
    }
}
$dbContact = new dbKITcontact();
if ($dbContact->sqlTableExists()) {
    if (!$dbContact->sqlDeleteTable()) {
        $error .= sprintf('<p>[Delete Table] %s</p>', $dbContact->getError());
    }
}
$dbContactArray = new dbKITcontactArrayCfg();
if ($dbContactArray->sqlTableExists()) {
    if (!$dbContactArray->sqlDeleteTable()) {
        $error .= sprintf('<p>[Delete Table] %s</p>', $dbContactArray->getError());
    }
}
$dbContactAddress = new dbKITcontactAddress();
if ($dbContactAddress->sqlTableExists()) {
    if (!$dbContactAddress->sqlDeleteTable()) {
        $error .= sprintf('<p>[Delete Table] %s</p>', $dbContactAddress->getError());
    }
}
$dbCountries = new dbKITcountries();