public function install()
 {
     foreach ($this->available_languages as $language) {
         Configuration::updateValue('TS_TAB0_ID_' . (int) Language::getIdByIso($language), '');
         Configuration::updateValue('TS_TAB0_ID_ACTIVE_' . (int) Language::getIdByIso($language), '');
     }
     Configuration::updateValue('TS_TAB0_DISPLAY_IN_SHOP', '');
     Configuration::updateValue('TS_TAB0_DISPLAY_RATING_FRONT_END', '');
     Configuration::updateValue('TS_TAB0_DISPLAY_RATING_OC', '');
     Configuration::updateValue('TS_TAB0_SEND_RATING', '');
     Configuration::updateValue('TS_TAB0_SEND_SEPERATE_MAIL', '');
     Configuration::updateValue('TS_TAB0_SEND_SEPERATE_MAIL_DELAY', '');
     return RatingAlert::createTable() and Configuration::updateValue('PS_TS_TAB0_SECURE_KEY', strtoupper(Tools::passwdGen(16)));
 }
Example #2
0
    public function install()
    {
        if (!method_exists('Tools', 'jsonDecode') || !method_exists('Tools', 'jsonEncode')) {
            return false;
        }
        foreach (array_keys(self::$available_languages) as $iso) {
            Configuration::updateValue(TSCommon::PREFIX_TABLE . 'CERTIFICATE_' . Tools::strtoupper($iso), Tools::htmlentitiesUTF8(Tools::jsonEncode(array('stateEnum' => '', 'typeEnum' => '', 'url' => '', 'tsID' => '', 'user' => '', 'password' => ''))));
        }
        Configuration::updateValue(TSCommon::PREFIX_TABLE . 'SHOPSW', '');
        Configuration::updateValue(TSCommon::PREFIX_TABLE . 'ET_CID', '');
        Configuration::updateValue(TSCommon::PREFIX_TABLE . 'ET_LID', '');
        Configuration::updateValue(TSCommon::PREFIX_TABLE . 'ENV_API', TSCommon::ENV_MOD);
        $query = '
		CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . TSCommon::DB_ITEMS . '` (
			`id_item` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
			`id_product` INT NOT NULL,
			`ts_id` VARCHAR( 33 ) NOT NULL,
			`id` INT NOT NULL,
			`currency` VARCHAR( 3 ) NOT NULL,
			`gross_fee` DECIMAL( 20, 6 ) NOT NULL,
			`net_fee` DECIMAL( 20, 6 ) NOT NULL,
			`protected_amount_decimal` INT NOT NULL,
			`protection_duration_int` INT NOT NULL,
			`ts_product_id` TEXT NOT NULL,
			`creation_date` VARCHAR( 25 ) NOT NULL
		);';
        Db::getInstance()->Execute($query);
        $query = '
		CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . TSCommon::DB_APPLI . '` (
			`id_application` INT NOT NULL PRIMARY KEY,
			`ts_id` VARCHAR( 33 ) NOT NULL,
			`id_order` INT NOT NULL,
			`statut_number` INT NOT NULL DEFAULT \'0\',
			`creation_date` DATETIME NOT NULL,
			`last_update` DATETIME NOT NULL
		);';
        Db::getInstance()->Execute($query);
        //add hidden category
        $category = new Category();
        foreach (self::$available_languages as $iso => $lang) {
            $language = Language::getIdByIso(Tools::strtolower($iso));
            $category->name[$language] = 'Trustedshops';
            $category->link_rewrite[$language] = 'trustedshops';
        }
        // If the default lang is different than available languages :
        // (Bug occurred otherwise)
        if (!array_key_exists(Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT')), self::$available_languages)) {
            $language = (int) Configuration::get('PS_LANG_DEFAULT');
            $category->name[$language] = 'Trustedshops';
            $category->link_rewrite[$language] = 'trustedshops';
        }
        // $category->id_parent = Configuration::get('PS_HOME_CATEGORY');
        $category->id_parent = 0;
        $category->level_depth = 0;
        $category->active = 0;
        $category->add();
        Configuration::updateValue(TSCommon::PREFIX_TABLE . 'CAT_ID', (int) $category->id);
        Configuration::updateValue(TSCommon::PREFIX_TABLE . 'SECURE_KEY', Tools::strtoupper(Tools::passwdGen(16)));
        return RatingAlert::createTable();
    }