Beispiel #1
0
$db = db::getInstance();
include_once "./include/sql_queries.php";
$smarty->register_modifier("siLocal_number", array("siLocal", "number"));
$smarty->register_modifier("siLocal_number_clean", array("siLocal", "number_clean"));
$smarty->register_modifier("siLocal_number_trim", array("siLocal", "number_trim"));
$smarty->register_modifier("siLocal_number_formatted", array("siLocal", "number_formatted"));
$smarty->register_modifier("siLocal_date", array("siLocal", "date"));
$smarty->register_modifier('htmlsafe', 'htmlsafe');
$smarty->register_modifier('urlsafe', 'urlsafe');
$smarty->register_modifier('urlencode', 'urlencode');
$smarty->register_modifier('outhtml', 'outhtml');
$smarty->register_modifier('htmlout', 'outhtml');
//common typo
$smarty->register_modifier('urlescape', 'urlencode');
//common typo
$install_tables_exists = checkTableExists(TB_PREFIX . "biller");
if ($install_tables_exists == true) {
    $install_data_exists = checkDataExists();
}
//TODO - add this as a function in sql_queries.php or a class file
//if ( ($install_tables_exists != false) AND ($install_data_exists != false) )
if ($install_tables_exists != false) {
    if (getNumberOfDoneSQLPatches() > "196") {
        $sql = "SELECT * from " . TB_PREFIX . "extensions WHERE (domain_id = :id OR domain_id =  0 ) ORDER BY domain_id ASC";
        $sth = dbQuery($sql, ':id', $auth_session->domain_id) or die(htmlsafe(end($dbh->errorInfo())));
        while ($this_extension = $sth->fetch()) {
            $DB_extensions[$this_extension['name']] = $this_extension;
        }
        $config->extension = $DB_extensions;
    }
}
        $patch['128']['patch'] = "ALTER TABLE `" . TB_PREFIX . "users` ADD `user_domain` VARCHAR( 255 ) NOT NULL AFTER `user_group` ;";
    }
}
if (checkTableExists(TB_PREFIX . 'users') == false) {
    $patch['128']['patch'] = "CREATE TABLE IF NOT EXISTS `" . TB_PREFIX . "users` (\n`user_id` int(11) NOT NULL auto_increment,\n`user_email` varchar(255) NOT NULL,\n`user_name` varchar(255) NOT NULL,\n`user_group` varchar(255) NOT NULL,\n`user_domain` varchar(255) NOT NULL,\n`user_password` varchar(255) NOT NULL,\nPRIMARY KEY  (`user_id`)) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n";
}
$patch['128']['date'] = "200709";
$patch['129']['name'] = "Fill user table with default values";
$patch['129']['patch'] = "INSERT INTO `" . TB_PREFIX . "users` (`user_id`, `user_email`, `user_name`, `user_group`, `user_domain`, `user_password`) VALUES (NULL, '*****@*****.**', 'demo', '1', '1', MD5('demo'))";
$patch['129']['date'] = "200709";
$patch['130']['name'] = "Create auth_challenges table";
if (checkTableExists(TB_PREFIX . 'auth_challenges') == true) {
    //a do nothing patch cause the table already exists
    $patch['130']['patch'] = "select * from " . TB_PREFIX . "auth_challenges";
}
if (checkTableExists(TB_PREFIX . 'auth_challenges') == false) {
    $patch['130']['patch'] = "CREATE TABLE IF NOT EXISTS `" . TB_PREFIX . "auth_challenges` (\n`challenges_key` int(11) NOT NULL,\n`challenges_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP);\n";
}
$patch['130']['date'] = "200709";
$patch['131']['name'] = "Make tax field 3 decimal places";
$patch['131']['patch'] = "ALTER TABLE `" . TB_PREFIX . "tax` CHANGE `tax_percentage` `tax_percentage` DECIMAL (10,3)  NULL";
$patch['131']['date'] = "200709";
//2008 09 26 - Beta release patches start
$patch['132']['name'] = "Correct Foreign Key Tax ID Field Type in Invoice Items Table";
$patch['132']['patch'] = "ALTER TABLE  `" . TB_PREFIX . "invoice_items` CHANGE `tax_id` `tax_id` int  DEFAULT '0' NOT NULL ;";
$patch['132']['date'] = "20071126";
$patch['133']['name'] = "Correct Foreign Key Invoice ID Field Type in Ac Payments Table";
$patch['133']['patch'] = "ALTER TABLE  `" . TB_PREFIX . "account_payments` CHANGE `ac_inv_id` `ac_inv_id` int  NOT NULL ;";
$patch['133']['date'] = "20071126";
$patch['134']['name'] = "Drop non-int compatible default from si_sql_patchmanager";
switch ($config->database->adapter) {
function getSystemDefaults($domain_id = '')
{
    $domain_id = domain_id::get($domain_id);
    $db = new db();
    #get sql patch level - if less than 198 do sql with no exntesion table
    if (checkTableExists(TB_PREFIX . "system_defaults") == false) {
        return null;
    }
    if (getNumberOfDoneSQLPatches() < "198") {
        $sql_default = "SELECT \n                                def.name,\n                                def.value\n                         FROM \n                            " . TB_PREFIX . "system_defaults def";
        $sth = $db->query($sql_default);
    }
    if (getNumberOfDoneSQLPatches() >= "198") {
        $sql_default = "SELECT \n                                def.name,\n                                def.value\n                         FROM \n                            " . TB_PREFIX . "system_defaults def\n                         INNER JOIN\n                             " . TB_PREFIX . "extensions ext ON (def.domain_id = ext.domain_id)";
        $sql_default .= " WHERE enabled=1";
        $sql_default .= " AND ext.name = 'core'";
        $sql_default .= " AND def.domain_id = :domain_id";
        $sql_default .= " ORDER BY extension_id ASC";
        // order is important for overriding settings
        // get all settings from default domain (0)
        //$sth = dbQuery($sql.$current_settings.$order, 'domain_id', 0) or die(htmlsafe(end($dbh->errorInfo())));
        $sth = $db->query($sql_default, ':domain_id', 0);
    }
    $defaults = null;
    $default = null;
    while ($default = $sth->fetch()) {
        $defaults["{$default['name']}"] = $default['value'];
    }
    if (getNumberOfDoneSQLPatches() > "198") {
        $sql = "SELECT def.name,def.value FROM " . TB_PREFIX . "system_defaults def ";
        $sql .= " INNER JOIN " . TB_PREFIX . "extensions ext ON (def.extension_id = ext.id)";
        $sql .= " WHERE enabled=1";
        $sql .= " AND def.domain_id = :domain_id";
        $sql .= " ORDER BY extension_id ASC";
        // order is important for overriding settings
        // add all settings from current domain
        //$sth = dbQuery($sql.$current_settings.$order, 'domain_id', $auth_session->domain_id) or die(htmlsafe(end($dbh->errorInfo())));
        $sth = $db->query($sql, 'domain_id', $domain_id);
        $default = null;
        while ($default = $sth->fetch()) {
            $defaults["{$default['name']}"] = $default['value'];
            // if setting is redefined, overwrite the previous value
        }
    }
    return $defaults;
}
Beispiel #4
0
<?php

$menu = false;
$import = new import();
$domain_id = domain_id::get();
if (checkTableExists('expense') == false) {
    $import->file = "./extensions/expense/install/db.sql";
    $import->pattern_find = array('si_', 'DOMAIN-ID', 'LOCALE', 'LANGUAGE');
    $import->pattern_replace = array(TB_PREFIX, $domain_id, 'en_GB', 'en_GB');
    //	$db->query($import->collate());
    $import->execute();
    $import->file = "./extensions/expense/install/db2.sql";
    $import->execute();
    //	$import->file = "./extensions/expense/install/db3.sql";
    //	$import->execute();
}
Beispiel #5
0
<?php

$menu = false;
if (checkTableExists(TB_PREFIX . "customers") == true and $install_data_exists == false) {
    //	echo "ESSENTIAL";
    //JSON import
    $importjson = new importjson();
    $importjson->file = "./databases/json/essential_data.json";
    //$importjson->debug = true;
    $importjson->pattern_find = array('si_', 'DOMAIN-ID', 'LOCALE', 'LANGUAGE');
    $importjson->pattern_replace = array(TB_PREFIX, '1', 'en_GB', 'en_GB');
    //dbQuery($importjson->collate());
    $db->query($importjson->collate());
}
Beispiel #6
0
<?php

$menu = false;
if (checkTableExists() == false) {
    //	echo "SCHEME";
    //SQL import
    $import = new import();
    $import->file = "./databases/mysql/structure.sql";
    $import->pattern_find = array('si_', 'DOMAIN-ID', 'LOCALE', 'LANGUAGE');
    $import->pattern_replace = array(TB_PREFIX, '1', 'en_GB', 'en_GB');
    //dbQuery($import->collate());
    $db->query($import->collate());
}