Beispiel #1
0
/**
 * Cloudrexx
 *
 * @link      http://www.cloudrexx.com
 * @copyright Cloudrexx AG 2007-2015
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
function _marketUpdate()
{
    global $objDatabase, $_ARRAYLANG;
    $query = "SELECT id FROM " . DBPREFIX . "module_market_settings WHERE name='codeMode'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_market_settings` ( `id` , `name` , `value` , `description` , `type` )\n                        VALUES ( NULL , 'codeMode', '1', 'TXT_MARKET_SET_CODE_MODE', '2')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_market_mail');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_market_mail'));
        return false;
    }
    if (!isset($arrColumns['MAILTO'])) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_market_mail` ADD `mailto` VARCHAR( 10 ) NOT NULL AFTER `content`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /*****************************************************************
     * EXTENSION:    New attributes 'color' and 'sort_id' for entries *
     * ADDED:        Contrexx v2.1.0                                  *
     *****************************************************************/
    $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_market');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_market'));
        return false;
    }
    if (!isset($arrColumns['SORT_ID'])) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_market` ADD `sort_id` INT( 4 ) NOT NULL DEFAULT '0' AFTER `paypal`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!isset($arrColumns['COLOR'])) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_market` ADD `color` VARCHAR(50) NOT NULL DEFAULT '' AFTER `description`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    try {
        // delete obsolete table  contrexx_module_market_access
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_market_access');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_market_spez_fields', array('id' => array('type' => 'INT(5)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)'), 'value' => array('type' => 'VARCHAR(100)'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1'), 'lang_id' => array('type' => 'INT(2)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0')));
    } catch (\Cx\Lib\UpdateException $e) {
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Beispiel #2
0
/**
 * Cloudrexx
 *
 * @link      http://www.cloudrexx.com
 * @copyright Cloudrexx AG 2007-2015
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
function _auctionUpdate()
{
    try {
        // delete obsolete table  contrexx_module_auction_access
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_auction_access');
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
 /**
  * Fixes database errors.
  *
  * Also migrates settings from the old Shop settings table to \Cx\Core\Setting.
  * @return  boolean                 False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     global $_CONFIGURATION;
     // ShopSettings
     \Cx\Core\Setting\Controller\Setting::errorHandler();
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     $table_name = DBPREFIX . 'module_shop_config';
     $i = 0;
     if (\Cx\Lib\UpdateUtil::table_exist($table_name)) {
         // Migrate all entries using the \Cx\Core\Setting\Controller\Setting class
         $query = "\n                SELECT `name`, `value`, `status`\n                  FROM " . DBPREFIX . "module_shop_config\n                 ORDER BY `id` ASC";
         $objResult = \Cx\Lib\UpdateUtil::sql($query);
         if (!$objResult) {
             throw new \Cx\Lib\Update_DatabaseException('Failed to query old Shop settings', $query);
         }
         while (!$objResult->EOF) {
             $name = $objResult->fields['name'];
             $value = $objResult->fields['value'];
             $status = $objResult->fields['status'];
             $name_status = null;
             switch ($name) {
                 // OBSOLETE
                 case 'tax_default_id':
                 case 'tax_enabled':
                 case 'tax_included':
                 case 'tax_number':
                     // Ignore, do not migrate!
                     $name = null;
                     break;
                     // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\])
                 // VALUE ONLY (RE: arrConfig\[.*?\]\[.value.\])
                 case 'confirmation_emails':
                     $name = 'email_confirmation';
                     break;
                 case 'country_id':
                 case 'datatrans_merchant_id':
                 case 'datatrans_request_type':
                     break;
                 case 'datatrans_status':
                     $name = 'datatrans_active';
                     break;
                 case 'datatrans_use_testserver':
                 case 'email':
                 case 'fax':
                 case 'orderitems_amount_max':
                 case 'paypal_default_currency':
                 case 'postfinance_mobile_ijustwanttotest':
                 case 'postfinance_mobile_sign':
                 case 'postfinance_mobile_status':
                 case 'postfinance_mobile_webuser':
                 case 'product_sorting':
                 case 'saferpay_finalize_payment':
                 case 'saferpay_window_option':
                     break;
                 case 'shop_address':
                 case 'shop_company':
                 case 'shop_show_products_default':
                 case 'shop_thumbnail_max_height':
                 case 'shop_thumbnail_max_width':
                 case 'shop_thumbnail_quality':
                 case 'shop_weight_enable':
                     $name = preg_replace('/^shop_/', '', $name);
                     break;
                 case 'telephone':
                 case 'vat_default_id':
                 case 'vat_enabled_foreign_customer':
                 case 'vat_enabled_foreign_reseller':
                 case 'vat_enabled_home_customer':
                 case 'vat_enabled_home_reseller':
                 case 'vat_included_foreign_customer':
                 case 'vat_included_foreign_reseller':
                 case 'vat_included_home_customer':
                 case 'vat_included_home_reseller':
                 case 'vat_number':
                 case 'vat_other_id':
                     break;
                 case 'yellowpay_accepted_payment_methods':
                 case 'yellowpay_authorization_type':
                 case 'yellowpay_hash_seed':
                 case 'yellowpay_hash_signature_in':
                 case 'yellowpay_hash_signature_out':
                 case 'yellowpay_use_testserver':
                     $name = preg_replace('/^yellowpay(.*)$/', 'postfinance$1', $name);
                     break;
                 case 'yellowpay_id':
                     // Obsolete
                     $name = null;
                     break;
                     // VALUE & STATUS
                 // VALUE & STATUS
                 case 'paypal_account_email':
                     $name_status = 'paypal_active';
                     break;
                 case 'saferpay_id':
                     $name_status = 'saferpay_active';
                     break;
                 case 'yellowpay_shop_id':
                     $name = 'postfinance_shop_id';
                     $name_status = 'postfinance_active';
                     break;
                     // STATUS ONLY (RE: arrConfig\[.*?\]\[.status.\])
                 // STATUS ONLY (RE: arrConfig\[.*?\]\[.status.\])
                 case 'payment_lsv_status':
                     $name_status = 'payment_lsv_active';
                     $name = null;
                     break;
                 case 'saferpay_use_test_account':
                     $name_status = $name;
                     $name = null;
                     break;
             }
             if ($name) {
                 if (\Cx\Core\Setting\Controller\Setting::getValue($name, 'Shop') === NULL && !\Cx\Core\Setting\Controller\Setting::add($name, $value, ++$i)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to add \\Cx\\Core\\Setting entry for '{$name}'");
                 }
             }
             if ($name_status) {
                 if (\Cx\Core\Setting\Controller\Setting::getValue($name_status, 'Shop') === NULL && !\Cx\Core\Setting\Controller\Setting::add($name_status, $status, ++$i)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to add \\Cx\\Core\\Setting entry for status '{$name_status}'");
                 }
             }
             $objResult->MoveNext();
         }
     }
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     // Try adding any that just *might* be missing for *any* reason
     \Cx\Core\Setting\Controller\Setting::add('email', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('email_confirmation', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('company', 'Comvation AG', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('address', 'Burgstrasse 20', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('country_id', 204, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('telephone', '+4133 2266000', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('fax', '+4133 2266001', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_number', '12345678', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_foreign_customer', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_foreign_reseller', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_home_customer', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_enabled_home_reseller', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_foreign_customer', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_foreign_reseller', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_home_customer', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_included_home_reseller', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_default_id', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('vat_other_id', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('weight_enable', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('show_products_default', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('product_sorting', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, '0:TXT_SHOP_PRODUCT_SORTING_ALPHABETIC,' . '1:TXT_SHOP_PRODUCT_SORTING_INDIVIDUAL,' . '2:TXT_SHOP_PRODUCT_SORTING_PRODUCTCODE', 'config');
     \Cx\Core\Setting\Controller\Setting::add('thumbnail_max_width', 140, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('thumbnail_max_height', 140, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('thumbnail_quality', 90, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_id', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_use_test_account', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_finalize_payment', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('saferpay_window_option', 2, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('paypal_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('paypal_account_email', '*****@*****.**', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('paypal_default_currency', 'CHF', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // Also see Yellowpay.class
     \Cx\Core\Setting\Controller\Setting::add('payrexx_instance_name', 'Instanz Name', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('payrexx_api_secret', 'API Secret', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('payrexx_active', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_shop_id', 'Ihr Kontoname', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('postfinance_active', '0', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_authorization_type', 'SAL', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, 'RES:Reservation,SAL:Verkauf');
     // OBSOLETE
     // As it appears that in_array(0, $array) is true for each non-empty
     // $array, indices for the entries must be numbered starting at 1.
     //        $arrPayments = array();
     //        foreach (self::$arrKnownPaymentMethod as $index => $name) {
     //            $arrPayments[$index] = $name;
     //        }
     //        \Cx\Core\Setting\Controller\Setting::add('postfinance_accepted_payment_methods', '', ++$i,
     //                \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOXGROUP,
     //                \Cx\Core\Setting\Controller\Setting::joinValues($arrPayments));
     \Cx\Core\Setting\Controller\Setting::add('postfinance_hash_signature_in', 'Mindestens 16 Buchstaben, Ziffern und Zeichen', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('postfinance_hash_signature_out', 'Mindestens 16 Buchstaben, Ziffern und Zeichen', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT);
     \Cx\Core\Setting\Controller\Setting::add('postfinance_use_testserver', '1', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX, '1');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_webuser', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_sign', 'geheimer_schlüssel', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_ijustwanttotest', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('postfinance_mobile_status', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_merchant_id', '1234', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_active', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_request_type', 'CAA', ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('datatrans_use_testserver', 1, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('payment_lsv_active', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // New for V3.0
     // Disable jsCart by default.
     $useJsCart = '0';
     // Activate it in case it was activated in config/configuration.php
     if (isset($_CONFIGURATION['custom']['shopJsCart']) && $_CONFIGURATION['custom']['shopJsCart']) {
         $useJsCart = '1';
     }
     \Cx\Core\Setting\Controller\Setting::add('use_js_cart', $useJsCart, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX);
     // Disable shopnavbar on other pages by default.
     $shopnavbar = '0';
     // Activate it in case it was activated in config/configuration.php
     if (isset($_CONFIGURATION['custom']['shopnavbar']) && $_CONFIGURATION['custom']['shopnavbar']) {
         $shopnavbar = '1';
     }
     \Cx\Core\Setting\Controller\Setting::add('shopnavbar_on_all_pages', $shopnavbar, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_CHECKBOX);
     // New for v3.1.0
     \Cx\Core\Setting\Controller\Setting::add('orderitems_amount_min', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // New for v2.2(?)
     \Cx\Core\Setting\Controller\Setting::add('orderitems_amount_max', 0, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // New for v2.3
     \Cx\Core\Setting\Controller\Setting::add('register', ShopLibrary::REGISTER_MANDATORY, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN, \Cx\Core\Setting\Controller\Setting::joinValues(array(ShopLibrary::REGISTER_MANDATORY, ShopLibrary::REGISTER_OPTIONAL, ShopLibrary::REGISTER_NONE)), 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_products_per_page_frontend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('history_maximum_age_days', 730, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_orders_per_page_frontend', 10, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_orders_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_customers_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_manufacturers_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_mailtemplate_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('numof_coupon_per_page_backend', 25, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('usergroup_id_customer', 0, 341, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USERGROUP, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('usergroup_id_reseller', 0, 342, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USERGROUP, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('user_profile_attribute_customer_group_id', 0, 351, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('user_profile_attribute_notes', 0, 352, \Cx\Core\Setting\Controller\Setting::TYPE_DROPDOWN_USER_CUSTOM_ATTRIBUTE, null, 'config');
     \Cx\Core\Setting\Controller\Setting::add('num_categories_per_row', 4, ++$i, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'config');
     // Note that the Settings *MUST* be reinited after adding new entries!
     // Add more new/missing settings here
     \Cx\Lib\UpdateUtil::drop_table($table_name);
     // Always
     return false;
 }
 /**
  * Handles database errors
  *
  * Also migrates old ProductAttribute to new Attribute structures,
  * including Text records.
  * @return  boolean   false       Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Attribute
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_name';
     $table_name_new = DBPREFIX . 'module_shop_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'display_type'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'name')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_ATTRIBUTE_NAME);
                 $query = "\n                        SELECT `id`, `name`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query Attribute names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['name'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_ATTRIBUTE_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Attribute name '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         //DBG::activate(DBG_ADODB);
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Attribute table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes_value';
     $table_name_new = DBPREFIX . 'module_shop_option';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'renamefrom' => 'name_id'), 'price' => array('type' => 'DECIMAL(9,2)', 'default' => '0.00'));
         $table_index = array();
         if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
             if (\Cx\Lib\UpdateUtil::column_exist($table_name_old, 'value')) {
                 // Migrate all Product strings to the Text table first
                 \Text::deleteByKey('Shop', self::TEXT_OPTION_NAME);
                 $query = "\n                        SELECT `id`, `value`\n                          FROM `{$table_name_old}`";
                 $objResult = \Cx\Lib\UpdateUtil::sql($query);
                 if (!$objResult) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to query option names", $query);
                 }
                 while (!$objResult->EOF) {
                     $id = $objResult->fields['id'];
                     $name = $objResult->fields['value'];
                     if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_OPTION_NAME, $name)) {
                         throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate option Text '{$name}'");
                     }
                     $objResult->MoveNext();
                 }
             }
         }
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Option table");
         }
     }
     $table_name_old = DBPREFIX . 'module_shop_products_attributes';
     $table_name_new = DBPREFIX . 'module_shop_rel_product_attribute';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_new)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     } else {
         $table_structure = array('product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'option_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'attributes_value_id'), 'ord' => array('type' => 'INT(10)', 'default' => '0', 'renamefrom' => 'sort_id'));
         $table_index = array();
         \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index);
         if (!\Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new)) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to rename Product-Attribute relation table {$table_name_old} to {$table_name_new}");
         }
     }
     // Always
     return false;
 }
 /**
  * Handles all kinds of database errors
  *
  * Creates the processors' table, and creates default entries if necessary
  * @return  boolean                         False. Always.
  * @global  ADOConnection   $objDatabase
  */
 static function errorHandler()
 {
     // PaymentProcessing
     $table_name_old = DBPREFIX . 'module_shop_processors';
     $table_name_new = DBPREFIX . 'module_shop_payment_processors';
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name_new);
     }
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'ENUM("internal", "external")', 'default' => 'internal'), 'name' => array('type' => 'VARCHAR(255)', 'default' => ''), 'description' => array('type' => 'TEXT', 'default' => ''), 'company_url' => array('type' => 'VARCHAR(255)', 'default' => ''), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => 1), 'picture' => array('type' => 'VARCHAR(255)', 'default' => ''));
     \Cx\Lib\UpdateUtil::table($table_name_new, $table_structure);
     $arrPsp = array(array(1, 'external', 'saferpay', 'Saferpay is a comprehensive Internet payment platform, specially developed for commercial applications. It provides a guarantee of secure payment processes over the Internet for merchants as well as for cardholders. Merchants benefit from the easy integration of the payment method into their e-commerce platform, and from the modularity with which they can take account of current and future requirements. Cardholders benefit from the security of buying from any shop that uses Saferpay.', 'http://www.saferpay.com/', 1, 'logo_saferpay.gif'), array(2, 'external', 'paypal', 'With more than 40 million member accounts in over 45 countries worldwide, PayPal is the world\'s largest online payment service. PayPal makes sending money as easy as sending email! Any PayPal member can instantly and securely send money to anyone in the U.S. with an email address. PayPal can also be used on a web-enabled cell phone. In the future, PayPal will be available to use on web-enabled pagers and other handheld devices.', 'http://www.paypal.com/', 1, 'logo_paypal.gif'), array(3, 'external', 'yellowpay', 'PostFinance vereinfacht das Inkasso im Online-Shop.', 'http://www.postfinance.ch/', 1, 'logo_postfinance.gif'), array(4, 'internal', 'internal', 'Internal no forms', '', 1, ''), array(9, 'internal', 'internal_lsv', 'LSV with internal form', '', 1, ''), array(10, 'external', 'datatrans', 'Die professionelle und komplette Payment-Lösung', 'http://datatrans.biz/', 1, 'logo_datatrans.gif'), array(11, 'external', 'mobilesolutions', 'PostFinance Mobile', 'https://postfinance.mobilesolutions.ch/', 1, 'logo_postfinance_mobile.gif'));
     $query_template = "\n            REPLACE INTO `{$table_name_new}` (\n                `id`, `type`, `name`,\n                `description`,\n                `company_url`, `status`, `picture`\n            ) VALUES (\n                ?, ?, ?, ?, ?, ?, ?\n            )";
     foreach ($arrPsp as $psp) {
         \Cx\Lib\UpdateUtil::sql($query_template, $psp);
     }
     if (\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     }
     // Drop obsolete PSPs -- see Payment::errorHandler()
     \Cx\Lib\UpdateUtil::sql("\n            DELETE FROM `" . DBPREFIX . "module_shop_payment_processors`\n             WHERE `id` IN (5, 6, 7, 8)");
     // Always
     return false;
 }
Beispiel #6
0
 /**
  * Handles database errors
  *
  * Also migrates old Shop Customers to the User accounts and adds
  * all new settings
  * @return  boolean     false     Always!
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     // Customer
     $table_name_old = DBPREFIX . "module_shop_customers";
     // If the old Customer table is missing, the migration has completed
     // successfully already
     if (!\Cx\Lib\UpdateUtil::table_exist($table_name_old)) {
         return false;
     }
     // Ensure that the ShopSettings (including \Cx\Core\Setting) and Order tables
     // are ready first!
     //DBG::log("Customer::errorHandler(): Adding settings");
     ShopSettings::errorHandler();
     //        \Cx\Core\Country\Controller\Country::errorHandler(); // Called by Order::errorHandler();
     Order::errorHandler();
     Discount::errorHandler();
     \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
     $objUser = \FWUser::getFWUserObject()->objUser;
     // Create new User_Profile_Attributes
     $index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes', 'Shop');
     if (!$index_notes) {
         //DBG::log("Customer::errorHandler(): Adding notes attribute...");
         //            $objProfileAttribute = new \User_Profile_Attribute();
         $objProfileAttribute = $objUser->objAttribute->getById(0);
         //DBG::log("Customer::errorHandler(): NEW notes attribute: ".var_export($objProfileAttribute, true));
         $objProfileAttribute->setNames(array(1 => 'Notizen', 2 => 'Notes', 3 => 'Notes', 4 => 'Notes', 5 => 'Notes', 6 => 'Notes'));
         $objProfileAttribute->setType('text');
         $objProfileAttribute->setMultiline(true);
         $objProfileAttribute->setParent(0);
         $objProfileAttribute->setProtection(array(1));
         //DBG::log("Customer::errorHandler(): Made notes attribute: ".var_export($objProfileAttribute, true));
         if (!$objProfileAttribute->store()) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'");
         }
         //Re initialize shop setting
         \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
         //DBG::log("Customer::errorHandler(): Stored notes attribute, ID ".$objProfileAttribute->getId());
         if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_notes', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_notes'))) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'notes' setting");
         }
         //DBG::log("Customer::errorHandler(): Stored notes attribute ID setting");
     }
     $index_group = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_group_id', 'Shop');
     if (!$index_group) {
         //            $objProfileAttribute = new \User_Profile_Attribute();
         $objProfileAttribute = $objUser->objAttribute->getById(0);
         $objProfileAttribute->setNames(array(1 => 'Kundenrabattgruppe', 2 => 'Discount group', 3 => 'Kundenrabattgruppe', 4 => 'Kundenrabattgruppe', 5 => 'Kundenrabattgruppe', 6 => 'Kundenrabattgruppe'));
         $objProfileAttribute->setType('text');
         $objProfileAttribute->setParent(0);
         $objProfileAttribute->setProtection(array(1));
         if (!$objProfileAttribute->store()) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to create User_Profile_Attribute 'notes'");
         }
         //Re initialize shop setting
         \Cx\Core\Setting\Controller\Setting::init('Shop', 'config');
         if (!(\Cx\Core\Setting\Controller\Setting::set('user_profile_attribute_customer_group_id', $objProfileAttribute->getId()) && \Cx\Core\Setting\Controller\Setting::update('user_profile_attribute_customer_group_id'))) {
             throw new \Cx\Lib\Update_DatabaseException("Failed to update User_Profile_Attribute 'customer_group_id' setting");
         }
     }
     // For the migration, a temporary flag is needed in the orders table
     // in order to prevent mixing up old and new customer_id values.
     $table_order_name = DBPREFIX . "module_shop_orders";
     if (!\Cx\Lib\UpdateUtil::column_exist($table_order_name, 'migrated')) {
         $query = "\n                ALTER TABLE `{$table_order_name}`\n                  ADD `migrated` TINYINT(1) unsigned NOT NULL default 0";
         \Cx\Lib\UpdateUtil::sql($query);
     }
     // Create missing UserGroups for customers and resellers
     $objGroup = null;
     $group_id_customer = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_customer', 'Shop');
     if ($group_id_customer) {
         $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_customer);
     }
     if (!$objGroup || $objGroup->EOF) {
         $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Endkunden'));
     }
     if (!$objGroup || $objGroup->EOF) {
         $objGroup = new \UserGroup();
         $objGroup->setActiveStatus(true);
         $objGroup->setDescription('Online Shop Endkunden');
         $objGroup->setName('Shop Endkunden');
         $objGroup->setType('frontend');
     }
     //DBG::log("Group: ".var_export($objGroup, true));
     if (!$objGroup) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for customers");
     }
     //DBG::log("Customer::errorHandler(): Made customer usergroup: ".var_export($objGroup, true));
     if (!$objGroup->store() || !$objGroup->getId()) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for customers");
     }
     //DBG::log("Customer::errorHandler(): Stored customer usergroup, ID ".$objGroup->getId());
     \Cx\Core\Setting\Controller\Setting::set('usergroup_id_customer', $objGroup->getId());
     if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_customer')) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for customers");
     }
     $group_id_customer = $objGroup->getId();
     $objGroup = null;
     $group_id_reseller = \Cx\Core\Setting\Controller\Setting::getValue('usergroup_id_reseller', 'Shop');
     if ($group_id_reseller) {
         $objGroup = \FWUser::getFWUserObject()->objGroup->getGroup($group_id_reseller);
     }
     if (!$objGroup || $objGroup->EOF) {
         $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('group_name' => 'Shop Wiederverkäufer'));
     }
     if (!$objGroup || $objGroup->EOF) {
         $objGroup = new \UserGroup();
         $objGroup->setActiveStatus(true);
         $objGroup->setDescription('Online Shop Wiederverkäufer');
         $objGroup->setName('Shop Wiederverkäufer');
         $objGroup->setType('frontend');
     }
     if (!$objGroup) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to create UserGroup for resellers");
     }
     //DBG::log("Customer::errorHandler(): Made reseller usergroup: ".var_export($objGroup, true));
     if (!$objGroup->store() || !$objGroup->getId()) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup for resellers");
     }
     \Cx\Core\Setting\Controller\Setting::set('usergroup_id_reseller', $objGroup->getId());
     if (!\Cx\Core\Setting\Controller\Setting::update('usergroup_id_reseller')) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to store UserGroup ID for resellers");
     }
     $group_id_reseller = $objGroup->getId();
     $default_lang_id = \FWLanguage::getDefaultLangId();
     $query = "\n            SELECT `customer`.`customerid`,\n                   `customer`.`prefix`, `customer`.`firstname`,\n                   `customer`.`lastname`,\n                   `customer`.`company`, `customer`.`address`,\n                   `customer`.`city`, `customer`.`zip`,\n                   `customer`.`country_id`,\n                   `customer`.`phone`, `customer`.`fax`,\n                   `customer`.`email`,\n                   `customer`.`username`, `customer`.`password`,\n                   `customer`.`company_note`,\n                   `customer`.`is_reseller`,\n                   `customer`.`customer_status`, `customer`.`register_date`,\n                   `customer`.`group_id`\n              FROM `{$table_name_old}` AS `customer`\n             ORDER BY `customer`.`customerid` ASC";
     $objResult = \Cx\Lib\UpdateUtil::sql($query);
     while (!$objResult->EOF) {
         $old_customer_id = $objResult->fields['customerid'];
         if (empty($objResult->fields['email'])) {
             $objResult->fields['email'] = $objResult->fields['username'];
         }
         $email = $objResult->fields['email'];
         $objUser = \FWUser::getFWUserObject()->objUser->getUsers(array('email' => array(0 => $email)));
         // TODO: See whether a User with that username (but different e-mail address) exists!
         $objUser_name = \FWUser::getFWUserObject()->objUser->getUsers(array('username' => array(0 => $objResult->fields['username'])));
         if ($objUser && $objUser_name) {
             $objUser = $objUser_name;
         }
         $objCustomer = null;
         if ($objUser) {
             $objCustomer = self::getById($objUser->getId());
         }
         if (!$objCustomer) {
             $lang_id = Order::getLanguageIdByCustomerId($old_customer_id);
             $lang_id = \FWLanguage::getLangIdByIso639_1($lang_id);
             if (!$lang_id) {
                 $lang_id = $default_lang_id;
             }
             $objCustomer = new Customer();
             if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) {
                 $objCustomer->gender('gender_female');
             } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) {
                 $objCustomer->gender('gender_male');
                 //                } else {
                 // Other "genders", like "family", "thing", or "it" won't be matched
                 // and are left on "gender_unknown".
                 //DBG::log("*** Prefix {$objResult->fields['prefix']}, UNKNOWN GENDER!");
             }
             //DBG::log("Prefix {$objResult->fields['prefix']}, made gender ".$objCustomer->gender());
             $objCustomer->company($objResult->fields['company']);
             $objCustomer->firstname($objResult->fields['firstname']);
             $objCustomer->lastname($objResult->fields['lastname']);
             $objCustomer->address($objResult->fields['address']);
             $objCustomer->city($objResult->fields['city']);
             $objCustomer->zip($objResult->fields['zip']);
             $objCustomer->country_id($objResult->fields['country_id']);
             $objCustomer->phone($objResult->fields['phone']);
             $objCustomer->fax($objResult->fields['fax']);
             $objCustomer->email($objResult->fields['email']);
             $objCustomer->companynote($objResult->fields['company_note']);
             $objCustomer->active($objResult->fields['customer_status']);
             // Handled by a UserGroup now, see below
             //$objCustomer->setResellerStatus($objResult->fields['is_reseller']);
             $objCustomer->register_date($objResult->fields['register_date']);
             $objCustomer->group_id($objResult->fields['group_id']);
             // NOTE: Mind that the User class has been modified to accept e-mail addresses
             // as usernames!
             $objCustomer->username($objResult->fields['username']);
             // Copy the md5 hash of the password!
             $objCustomer->password = $objResult->fields['password'];
             $objCustomer->setFrontendLanguage($lang_id);
         }
         if ($objResult->fields['is_reseller']) {
             $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_reseller));
             //DBG::log("Customer::errorHandler(): Added reseller: ".$objCustomer->id());
         } else {
             $objCustomer->setGroups($objCustomer->getAssociatedGroupIds() + array($group_id_customer));
             //DBG::log("Customer::errorHandler(): Added customer: ".$objCustomer->id());
         }
         if (!$objCustomer->store()) {
             //DBG::log(var_export($objCustomer, true));
             throw new \Cx\Lib\Update_DatabaseException("Failed to migrate existing Customer ID " . $old_customer_id . " to Users (Messages: " . join(', ', $objCustomer->error_msg) . ")");
         }
         // Update the Orders table with the new Customer ID.
         // Note that we use the ambiguous old customer ID that may
         // coincide with a new User ID, so to prevent inconsistencies,
         // migrated Orders are marked as such.
         $query = "\n                UPDATE `{$table_order_name}`\n                   SET `customer_id`=" . $objCustomer->id() . ",\n                       `migrated`=1\n                 WHERE `customer_id`={$old_customer_id}\n                   AND `migrated`=0";
         \Cx\Lib\UpdateUtil::sql($query);
         // Drop migrated
         $query = "\n                DELETE FROM `{$table_name_old}`\n                 WHERE `customerid`={$old_customer_id}";
         \Cx\Lib\UpdateUtil::sql($query);
         $objResult->MoveNext();
         if (!checkMemoryLimit() || !checkTimeoutLimit()) {
             return false;
         }
     }
     // Remove the flag, it's no longer needed.
     // (You could also verify that all records have been migrated by
     // querying them with "[...] WHERE `migrated`=0", which *MUST* result
     // in an empty recordset.  This is left as an exercise for the reader.)
     $query = "\n            ALTER TABLE `{$table_order_name}`\n             DROP `migrated`";
     \Cx\Lib\UpdateUtil::sql($query);
     \Cx\Lib\UpdateUtil::drop_table($table_name_old);
     //DBG::log("Updated Customer table and related stuff");
     // Always
     return false;
 }
Beispiel #7
0
function _newsUpdate()
{
    global $objDatabase, $_CONFIG, $objUpdate, $_ARRAYLANG;
    /************************************************
     * EXTENSION:    Placeholder NEWS_LINK replaced    *
     *                by NEWS_LINK_TITLE                *
     * ADDED:        Contrexx v2.1.0                    *
     ************************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.1.0')) {
        try {
            \Cx\Lib\UpdateUtil::migrateContentPage('news', null, '{NEWS_LINK}', '{NEWS_LINK_TITLE}', '2.1.0');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /************************************************
     * EXTENSION:    Front- and backend permissions  *
     * ADDED:        Contrexx v2.1.0                    *
     ************************************************/
    $query = "SELECT 1 FROM `" . DBPREFIX . "module_news_settings` WHERE `name` = 'news_message_protection'";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult) {
        if ($objResult->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_news_settings` (`name`, `value`) VALUES ('news_message_protection', '1'),\n                                                                                              ('recent_news_message_limit', '5')\n            ";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "SELECT 1 FROM `" . DBPREFIX . "module_news_settings` WHERE `name` = 'news_message_protection_restricted'";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult) {
        if ($objResult->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_news_settings` (`name`, `value`) VALUES ('news_message_protection_restricted', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news'));
        return false;
    }
    if (!in_array('frontend_access_id', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_news` ADD `frontend_access_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `validated`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('backend_access_id', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_news` ADD `backend_access_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `frontend_access_id`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /************************************************
     * EXTENSION:    Thunbmail Image                 *
     * ADDED:        Contrexx v2.1.0                    *
     ************************************************/
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news'));
        return false;
    }
    if (!in_array('teaser_image_thumbnail_path', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_news` ADD `teaser_image_thumbnail_path` TEXT NOT NULL AFTER `teaser_image_path`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    try {
        // delete obsolete table  contrexx_module_news_access
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_news_access');
        # fix some ugly NOT NULL without defaults
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news', array('id' => array('type' => 'INT(6) UNSIGNED', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'date' => array('type' => 'INT(14)', 'notnull' => false, 'default_expr' => 'NULL'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'text' => array('type' => 'MEDIUMTEXT', 'notnull' => true), 'redirect' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'source' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'url1' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'url2' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => ''), 'catid' => array('type' => 'INT(2) UNSIGNED', 'notnull' => true, 'default' => 0), 'lang' => array('type' => 'INT(2) UNSIGNED', 'notnull' => true, 'default' => 0), 'userid' => array('type' => 'INT(6) UNSIGNED', 'notnull' => true, 'default' => 0), 'startdate' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'enddate' => array('type' => 'DATETIME', 'notnull' => true, 'default' => '0000-00-00 00:00:00'), 'status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => 1), 'validated' => array('type' => "ENUM('0','1')", 'notnull' => true, 'default' => 0), 'frontend_access_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'default' => 0), 'backend_access_id' => array('type' => 'INT(10) UNSIGNED', 'notnull' => true, 'default' => 0), 'teaser_only' => array('type' => "ENUM('0','1')", 'notnull' => true, 'default' => 0), 'teaser_frames' => array('type' => 'TEXT', 'notnull' => true), 'teaser_text' => array('type' => 'TEXT', 'notnull' => true), 'teaser_show_link' => array('type' => 'TINYINT(1) UNSIGNED', 'notnull' => true, 'default' => 1), 'teaser_image_path' => array('type' => 'TEXT', 'notnull' => true), 'teaser_image_thumbnail_path' => array('type' => 'TEXT', 'notnull' => true), 'changelog' => array('type' => 'INT(14)', 'notnull' => true, 'default' => 0)), array('newsindex' => array('type' => 'FULLTEXT', 'fields' => array('text', 'title', 'teaser_text'))));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    //encoding was a little messy in 2.1.4. convert titles and teasers to their raw representation
    if ($_CONFIG['coreCmsVersion'] == "2.1.4") {
        try {
            $res = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `title`, `teaser_text` FROM `' . DBPREFIX . 'module_news` WHERE `changelog` > ' . mktime(0, 0, 0, 12, 15, 2010));
            while ($res->MoveNext()) {
                $title = $res->fields['title'];
                $teaserText = $res->fields['teaser_text'];
                $id = $res->fields['id'];
                //title is html entity style
                $title = html_entity_decode($title, ENT_QUOTES, CONTREXX_CHARSET);
                //teaserText is html entity style, but no cloudrexx was specified on encoding
                $teaserText = html_entity_decode($teaserText);
                \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_news` SET `title`="' . addslashes($title) . '", `teaser_text`="' . addslashes($teaserText) . '" where `id`=' . $id);
            }
            $hfr = new HackyFeedRepublisher();
            $hfr->runRepublishing();
        } catch (\Cx\Lib\UpdateException $e) {
            DBG::trace();
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /****************************
     * ADDED:    Contrexx v3.0.0 *
     *****************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_locale', array('news_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'news_id'), 'is_active' => array('type' => 'INT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'lang_id'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'is_active'), 'text' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'title'), 'teaser_text' => array('type' => 'text', 'notnull' => true, 'after' => 'text')), array('newsindex' => array('fields' => array('text', 'title', 'teaser_text'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories_locale', array('category_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'category_id'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_types', array('typeid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_types_locale', array('lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'type_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'lang_id'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'type_id')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_settings_locale', array('name' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'primary' => true), 'lang_id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'name'), 'value' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array('name' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_comments', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'text' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'title'), 'newsid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'text'), 'date' => array('type' => 'INT(14)', 'notnull' => false, 'default' => NULL, 'after' => 'newsid'), 'poster_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'date'), 'userid' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'poster_name'), 'ip_address' => array('type' => 'VARCHAR(15)', 'notnull' => true, 'default' => '0.0.0.0', 'after' => 'userid'), 'is_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1', 'after' => 'ip_address')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_stats_view', array('user_sid' => array('type' => 'CHAR(32)', 'notnull' => true), 'news_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'after' => 'user_sid'), 'time' => array('type' => 'timestamp', 'notnull' => true, 'default_expr' => 'CURRENT_TIMESTAMP', 'on_update' => 'CURRENT_TIMESTAMP', 'after' => 'news_id')), array('idx_user_sid' => array('fields' => array('user_sid')), 'idx_news_id' => array('fields' => array('news_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news', array('id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'date' => array('type' => 'INT(14)', 'notnull' => false, 'default' => NULL, 'after' => 'id'), 'title' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'date'), 'text' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'title'), 'redirect' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'text'), 'source' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'redirect'), 'url1' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'source'), 'url2' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'url1'), 'catid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'url2'), 'lang' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'catid'), 'typeid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'lang'), 'publisher' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'typeid'), 'publisher_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'publisher'), 'author' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'publisher_id'), 'author_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'author'), 'userid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'author_id'), 'startdate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'userid'), 'enddate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate'), 'status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1', 'after' => 'enddate'), 'validated' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'status'), 'frontend_access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'validated'), 'backend_access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend_access_id'), 'teaser_only' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'backend_access_id'), 'teaser_frames' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_only'), 'teaser_text' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_frames'), 'teaser_show_link' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'after' => 'teaser_text'), 'teaser_image_path' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_show_link'), 'teaser_image_thumbnail_path' => array('type' => 'text', 'notnull' => true, 'after' => 'teaser_image_path'), 'changelog' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0', 'after' => 'teaser_image_thumbnail_path'), 'allow_comments' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'changelog')), array('newsindex' => array('fields' => array('text', 'title', 'teaser_text'), 'type' => 'FULLTEXT')));
        $arrColumnsNews = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news');
        if ($arrColumnsNews === false) {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news'));
            return false;
        }
        if (isset($arrColumnsNews['TITLE']) && isset($arrColumnsNews['TEXT']) && isset($arrColumnsNews['TEASER_TEXT']) && isset($arrColumnsNews['LANG'])) {
            \Cx\Lib\UpdateUtil::sql('
                INSERT INTO `' . DBPREFIX . 'module_news_locale` (`news_id`, `lang_id`, `title`, `text`, `teaser_text`)
                SELECT `id`, `lang`, `title`, `text`, `teaser_text` FROM `' . DBPREFIX . 'module_news`
                ON DUPLICATE KEY UPDATE `news_id` = `news_id`
            ');
        }
        if (isset($arrColumnsNews['TITLE'])) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `title`');
        }
        if (isset($arrColumnsNews['TEXT'])) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `text`');
        }
        if (isset($arrColumnsNews['TEASER_TEXT'])) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `teaser_text`');
        }
        if (isset($arrColumnsNews['LANG'])) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news` DROP `lang`');
        }
        $arrColumnsNewsCategories = $objDatabase->MetaColumnNames(DBPREFIX . 'module_news_categories');
        if ($arrColumnsNewsCategories === false) {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_news_categories'));
            return false;
        }
        if (isset($arrColumnsNewsCategories['NAME'])) {
            \Cx\Lib\UpdateUtil::sql('
                INSERT INTO ' . DBPREFIX . 'module_news_categories_locale (`category_id`, `lang_id`, `name`)
                SELECT c.catid, l.id, c.name
                FROM ' . DBPREFIX . 'module_news_categories AS c, ' . DBPREFIX . 'languages AS l
                ORDER BY c.catid, l.id
                ON DUPLICATE KEY UPDATE `category_id` = `category_id`
            ');
            \Cx\Lib\UpdateUtil::sql('
                INSERT INTO ' . DBPREFIX . 'module_news_categories_locale (`category_id`, `lang_id`, `name`)
                SELECT c.catid, l.id, c.name
                FROM ' . DBPREFIX . 'module_news_categories AS c, ' . DBPREFIX . 'languages AS l
                ORDER BY c.catid, l.id
                ON DUPLICATE KEY UPDATE `category_id` = `category_id`
            ');
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news_categories` DROP `name`');
        }
        if (isset($arrColumnsNewsCategories['LANG'])) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_news_categories` DROP `lang`');
        }
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'module_news_settings_locale` (`name`, `lang_id`, `value`)
            SELECT n.`name`, l.`id`, n.`value`
            FROM `' . DBPREFIX . 'module_news_settings` AS n, `' . DBPREFIX . 'languages` AS l
            WHERE n.`name` IN ("news_feed_description", "news_feed_title")
            ORDER BY n.`name`, l.`id`
            ON DUPLICATE KEY UPDATE `' . DBPREFIX . 'module_news_settings_locale`.`name` = `' . DBPREFIX . 'module_news_settings_locale`.`name`
        ');
        \Cx\Lib\UpdateUtil::sql('DELETE FROM `' . DBPREFIX . 'module_news_settings` WHERE `name` IN ("news_feed_title", "news_feed_description")');
        \Cx\Lib\UpdateUtil::sql('
            INSERT INTO `' . DBPREFIX . 'module_news_settings` (`name`, `value`)
            VALUES  ("news_comments_activated", "0"),
                    ("news_comments_anonymous", "0"),
                    ("news_comments_autoactivate", "0"),
                    ("news_comments_notification", "1"),
                    ("news_comments_timeout", "30"),
                    ("news_default_teasers", ""),
                    ("news_use_types","0"),
                    ("news_use_top","0"),
                    ("news_top_days","10"),
                    ("news_top_limit","10"),
                    ("news_assigned_author_groups", "0"),
                    ("news_assigned_publisher_groups", "0")
            ON DUPLICATE KEY UPDATE `name` = `name`
        ');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        \Cx\Lib\UpdateUtil::migrateContentPage('news', 'details', array('{NEWS_DATE}', '{NEWS_COMMENTS_DATE}'), array('{NEWS_LONG_DATE}', '{NEWS_COMMENTS_LONG_DATE}'), '3.0.1');
        // this adds the block news_redirect
        $search = array('/.*\\{NEWS_TEXT\\}.*/ms');
        $callback = function ($matches) {
            if (!preg_match('/<!--\\s+BEGIN\\s+news_redirect\\s+-->/ms', $matches[0])) {
                $newsContent = <<<NEWS
<!-- BEGIN news_text -->{NEWS_TEXT}<!-- END news_text -->
    <!-- BEGIN news_redirect -->{TXT_NEWS_REDIRECT_INSTRUCTION} <a href="{NEWS_REDIRECT_URL}" target="_blank">{NEWS_REDIRECT_URL}</a><!-- END news_redirect -->
NEWS;
                return str_replace('{NEWS_TEXT}', $newsContent, $matches[0]);
            } else {
                return $matches[0];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => 'details'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        // migrate content page to version 3.0.1
        $search = array('/(.*)/ms');
        $callback = function ($matches) {
            $content = $matches[1];
            if (empty($content)) {
                return $content;
            }
            // migrate to ckeditor
            $content = str_replace('FCKeditorAPI.GetInstance(\'newsText\').SetData(\'\')', 'CKEDITOR.instances[\'newsText\'].setData()', $content);
            if (!preg_match('/<!--\\s+BEGIN\\s+news_submit_form_captcha\\s+-->.*<!--\\s+END\\s+news_submit_form_captcha\\s+-->/ms', $content)) {
                // check if captcha code is already present
                if (preg_match('/\\{IMAGE_URL\\}/ms', $content)) {
                    // add missing template block news_submit_form_captcha
                    $content = preg_replace('/(.*)(<p[^>]*>.*?<label[^>]*>.*?\\{IMAGE_URL\\}.*?<\\/p>)/ms', '$1<!-- BEGIN news_submit_form_captcha -->$2<!-- END news_submit_form_captcha -->', $content);
                } else {
                    // add whole captcha code incl. template block
                    $content = preg_replace('/(.*)(<tr[^>]*>.*?<td([^>]*)>.*?\\{NEWS_TEXT\\}.*?(\\s*)<\\/tr>)/ms', '$1$2$4<!-- BEGIN news_submit_form_captcha -->$4<tr>$4    <td$3>{NEWS_CAPTCHA_CODE}</td>$4</tr>$4<!-- END news_submit_form_captcha -->', $content);
                }
            }
            // add text variable
            $content = str_replace('Captcha', '{TXT_NEWS_CAPTCHA}', $content);
            // replace image with {NEWS_CAPTCHA_CODE}
            $content = preg_replace('/<img[^>]+\\{IMAGE_URL\\}[^>]+>(?:<br\\s*\\/?>)?/ms', '{NEWS_CAPTCHA_CODE}', $content);
            // remove {TXT_CAPTCHA}
            $content = str_replace('{TXT_CAPTCHA}', '', $content);
            // remove <input type="text" name="captcha" id="captcha" />
            $content = preg_replace('/<input[^>]+name\\s*=\\s*[\'"]captcha[\'"][^>]*>/ms', '', $content);
            return $content;
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => 'submit'), $search, $callback, array('content'), '3.0.1');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'news'), '/(\\{NEWS_COUNT_COMMENTS\\})/', '<!-- BEGIN news_comments_count -->$1<!-- END news_comments_count -->', array('content'), '3.0.3');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'news', 'cmd' => 'details'), '/(\\{NEWS_COUNT_COMMENTS\\})/', '<!-- BEGIN news_comments_count -->$1<!-- END news_comments_count -->', array('content'), '3.0.3');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /************************************************
     * EXTENSION:    Categories as NestedSet         *
     * ADDED:        Contrexx v3.1.0                 *
     ************************************************/
    if (!isset($_SESSION['contrexx_update']['news'])) {
        $_SESSION['contrexx_update']['news'] = array();
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0') && !isset($_SESSION['contrexx_update']['news']['nestedSet'])) {
        try {
            $nestedSetRootId = null;
            $count = null;
            $leftAndRight = 2;
            $sorting = 1;
            $level = 2;
            // add nested set columns
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories', array('catid' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(11)', 'after' => 'catid'), 'left_id' => array('type' => 'INT(11)', 'after' => 'parent_id'), 'right_id' => array('type' => 'INT(11)', 'after' => 'left_id'), 'sorting' => array('type' => 'INT(11)', 'after' => 'right_id'), 'level' => array('type' => 'INT(11)', 'after' => 'sorting')));
            // add nested set root node and select its id
            $objResultRoot = \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_categories` (`catid`, `parent_id`, `left_id`, `right_id`, `sorting`, `level`) VALUES (0, 0, 0, 0, 0, 0)');
            if ($objResultRoot) {
                $nestedSetRootId = $objDatabase->Insert_ID();
            }
            // count categories
            $objResultCount = \Cx\Lib\UpdateUtil::sql('SELECT count(`catid`) AS count FROM `' . DBPREFIX . 'module_news_categories`');
            if ($objResultCount && !$objResultCount->EOF) {
                $count = $objResultCount->fields['count'];
            }
            // add nested set information to root node
            \Cx\Lib\UpdateUtil::sql('
                UPDATE `' . DBPREFIX . 'module_news_categories` SET
                `parent_id` = ' . $nestedSetRootId . ',
                `left_id` = 1,
                `right_id` = ' . $count * 2 . ',
                `sorting` = 1,
                `level` = 1
                WHERE `catid` = ' . $nestedSetRootId . '
            ');
            // add nested set information to all categories
            $objResultCatSelect = \Cx\Lib\UpdateUtil::sql('SELECT `catid` FROM `' . DBPREFIX . 'module_news_categories` ORDER BY `catid` ASC');
            if ($objResultCatSelect) {
                while (!$objResultCatSelect->EOF) {
                    $catId = $objResultCatSelect->fields['catid'];
                    if ($catId != $nestedSetRootId) {
                        \Cx\Lib\UpdateUtil::sql('
                            UPDATE `' . DBPREFIX . 'module_news_categories` SET
                            `parent_id` = ' . $nestedSetRootId . ',
                            `left_id` = ' . $leftAndRight++ . ',
                            `right_id` = ' . $leftAndRight++ . ',
                            `sorting` = ' . $sorting++ . ',
                            `level` = ' . $level . '
                            WHERE `catid` = ' . $catId . '
                        ');
                    }
                    $objResultCatSelect->MoveNext();
                }
            }
            // add new tables
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories_locks', array('lockId' => array('type' => 'VARCHAR(32)'), 'lockTable' => array('type' => 'VARCHAR(32)', 'after' => 'lockId'), 'lockStamp' => array('type' => 'BIGINT(11)', 'notnull' => true, 'after' => 'lockTable')));
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_news_categories_catid', array('id' => array('type' => 'INT(11)', 'notnull' => true)));
            // insert id of last added category
            \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_categories_catid` (`id`) VALUES (' . $nestedSetRootId . ')');
            $_SESSION['contrexx_update']['news']['nestedSet'] = true;
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /************************************
     * EXTENSION:    Module page changes *
     * ADDED:        Contrexx v3.1.0     *
     ************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql('SELECT `id` FROM `' . DBPREFIX . 'content_page` WHERE `module` = "news" AND `cmd` RLIKE "^[0-9]*$"');
            if ($result && $result->RecordCount() > 0) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('id' => $result->fields['id']), '/(.*)/ms', function ($matches) {
                        $page = $matches[0];
                        if (!empty($page) && !preg_match('/<!--\\s+BEGIN\\s+news_status_message\\s+-->.*<!--\\s+END\\s+news_status_message\\s+-->/ms', $page) && !preg_match('/<!--\\s+BEGIN\\s+news_menu\\s+-->.*<!--\\s+END\\s+news_menu\\s+-->/ms', $page) && !preg_match('/<!--\\s+BEGIN\\s+news_list\\s+-->.*<!--\\s+END\\s+news_list\\s+-->/ms', $page)) {
                            $page = preg_replace_callback('/<form[^>]*>[^<]*\\{NEWS_CAT_DROPDOWNMENU\\}[^>]*<\\/form>/ims', function ($matches) {
                                $menu = $matches[0];
                                $menu = preg_replace_callback('/(action\\s*=\\s*([\'"])[^\\2]+section=news)\\2/i', function ($matches) {
                                    return $matches[1] . '&cmd=[[NEWS_CMD]]' . $matches[2];
                                }, $menu);
                                return '
                                    <!-- BEGIN news_status_message -->
                                    {TXT_NEWS_NO_NEWS_FOUND}
                                    <!-- END news_status_message -->

                                    <!-- BEGIN news_menu -->
                                    ' . $menu . '
                                    <!-- END news_menu -->
                                ';
                            }, $page);
                            $page = preg_replace_callback('/<ul[^>]*>[^<]*<!--\\s+BEGIN\\s+newsrow\\s+-->.*<!--\\s+END\\s+newsrow\\s+-->[^>]*<\\/ul>/ims', function ($matches) {
                                return '
                                    <!-- BEGIN news_list -->
                                    ' . $matches[0] . '
                                    <!-- END news_list -->
                                ';
                            }, $page);
                            if (!preg_match('/<!--\\s+BEGIN\\s+news_status_message\\s+-->.*<!--\\s+END\\s+news_status_message\\s+-->/ms', $page)) {
                                $page = '
                                    <!-- BEGIN news_status_message -->
                                    {TXT_NEWS_NO_NEWS_FOUND}
                                    <!-- END news_status_message -->
                                ' . $page;
                            }
                        }
                        return $page;
                    }, array('content'), '3.1.0');
                    $result->MoveNext();
                }
            }
            $result = \Cx\Lib\UpdateUtil::sql('SELECT `id` FROM `' . DBPREFIX . 'content_page` WHERE `module` = "news" AND `cmd` RLIKE "^details[0-9]*$"');
            if ($result && $result->RecordCount() > 0) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('id' => $result->fields['id']), '/(.*)/ms', function ($matches) {
                        $page = $matches[0];
                        if (!empty($page) && !preg_match('/<!--\\s+BEGIN\\s+news_use_teaser_text\\s+-->.*<!--\\s+END\\s+news_use_teaser_text\\s+-->/ms', $page)) {
                            $page = preg_replace('/\\{NEWS_TEASER_TEXT\\}/', '<!-- BEGIN news_use_teaser_text -->\\0<!-- END news_use_teaser_text -->', $page);
                        }
                        return $page;
                    }, array('content'), '3.1.0');
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***********************************
     * EXTENSION:    new settings added *
     * ADDED:        Contrexx v3.1.0    *
     ***********************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql('SELECT `name` FROM `' . DBPREFIX . 'module_news_settings` WHERE `name` = "news_use_teaser_text"');
            if ($result && $result->RecordCount() == 0) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO `' . DBPREFIX . 'module_news_settings` (`name`, `value`) VALUES ("news_use_teaser_text", 1)');
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Beispiel #8
0
/**
 * Cloudrexx
 *
 * @link      http://www.cloudrexx.com
 * @copyright Cloudrexx AG 2007-2015
 *
 * According to our dual licensing model, this program can be used either
 * under the terms of the GNU Affero General Public License, version 3,
 * or under a proprietary license.
 *
 * The texts of the GNU Affero General Public License with an additional
 * permission and of our proprietary license can be found at and
 * in the LICENSE file you have received along with this program.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * "Cloudrexx" is a registered trademark of Cloudrexx AG.
 * The licensing of the program under the AGPLv3 does not imply a
 * trademark license. Therefore any rights, title and interest in
 * our trademarks remain entirely with us.
 */
function _accessUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG, $_ARRAYLANG, $_CORELANG;
    $arrTables = $objDatabase->MetaTables('TABLES');
    if (!$arrTables) {
        setUpdateMsg($_ARRAYLANG['TXT_UNABLE_DETERMINE_DATABASE_STRUCTURE']);
        return false;
    }
    /****************************
     *
     * ADD NOTIFICATION E-MAILS
     *
     ***************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_mail', array('type' => array('type' => 'ENUM(\'reg_confirm\',\'reset_pw\',\'user_activated\',\'user_deactivated\',\'new_user\')', 'notnull' => true, 'default' => 'reg_confirm'), 'lang_id' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'sender_mail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'sender_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'format' => array('type' => 'ENUM(\'text\',\'html\',\'multipart\')', 'notnull' => true, 'default' => 'text'), 'body_text' => array('type' => 'TEXT'), 'body_html' => array('type' => 'TEXT')), array('mail' => array('fields' => array('type', 'lang_id'), 'type' => 'UNIQUE')), 'InnoDB');
        $result = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'access_group_dynamic_ids`');
        if ($result->EOF) {
            \Cx\Lib\UpdateUtil::sql('ALTER IGNORE TABLE `' . DBPREFIX . 'access_group_dynamic_ids` ADD PRIMARY KEY ( `access_id` , `group_id` )');
        }
        $result = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'access_group_static_ids`');
        if ($result->EOF) {
            \Cx\Lib\UpdateUtil::sql('ALTER IGNORE TABLE `' . DBPREFIX . 'access_group_static_ids` ADD PRIMARY KEY ( `access_id` , `group_id` )');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    \DBG::msg('001');
    $arrMails = array(array('type' => 'reg_confirm', 'subject' => 'Benutzerregistrierung bestätigen', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nVielen Dank für Ihre Anmeldung bei [[HOST]].\\r\\nBitte klicken Sie auf den folgenden Link, um Ihre E-Mail-Adresse zu bestätigen:\\r\\n[[ACTIVATION_LINK]]\\r\\n\\r\\nUm sich später einzuloggen, geben Sie bitte Ihren Benutzernamen \\"[[USERNAME]]\\" und das Passwort ein, das Sie bei der Registrierung festgelegt haben.\\r\\n\\r\\n\\r\\n--\\r\\nIhr [[SENDER]]'), array('type' => 'reset_pw', 'subject' => 'Kennwort zurücksetzen', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nUm ein neues Passwort zu wählen, müssen Sie auf die unten aufgeführte URL gehen und dort Ihr neues Passwort eingeben.\\r\\n\\r\\nWICHTIG: Die Gültigkeit der URL wird nach 60 Minuten verfallen, nachdem diese E-Mail abgeschickt wurde.\\r\\nFalls Sie mehr Zeit benötigen, geben Sie Ihre E-Mail Adresse einfach ein weiteres Mal ein.\\r\\n\\r\\nIhre URL:\\r\\n[[URL]]\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'user_activated', 'subject' => 'Ihr Benutzerkonto wurde aktiviert', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nIhr Benutzerkonto auf [[HOST]] wurde soeben aktiviert und kann von nun an verwendet werden.\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'user_deactivated', 'subject' => 'Ihr Benutzerkonto wurde deaktiviert', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nIhr Benutzerkonto auf [[HOST]] wurde soeben deaktiviert.\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'new_user', 'subject' => 'Ein neuer Benutzer hat sich registriert', 'body_text' => 'Der Benutzer [[USERNAME]] hat sich soeben registriert und muss nun frei geschaltet werden.\\r\\n\\r\\nÜber die folgende Adresse kann das Benutzerkonto von [[USERNAME]] verwaltet werden:\\r\\n[[LINK]]\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'));
    foreach ($arrMails as $arrMail) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_mail` WHERE `type` = '" . $arrMail['type'] . "'";
        $objMail = $objDatabase->SelectLimit($query, 1);
        if ($objMail !== false) {
            if ($objMail->RecordCount() == 0) {
                $query = "INSERT INTO `" . DBPREFIX . "access_user_mail` (\n                    `type`,\n                    `lang_id`,\n                    `sender_mail`,\n                    `sender_name`,\n                    `subject`,\n                    `body_text`,\n                    `body_html`\n                ) VALUES (\n                    '" . $arrMail['type'] . "',\n                    0,\n                    '" . addslashes($_CONFIG['coreAdminEmail']) . "',\n                    '" . addslashes($_CONFIG['coreAdminName']) . "',\n                    '" . $arrMail['subject'] . "',\n                    '" . $arrMail['body_text'] . "',\n                    ''\n                )";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /****************
     *
     * ADD SETTINGS
     *
     ***************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_settings', array('key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'value' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'key'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'value')), array('key' => array('fields' => array('key'), 'type' => 'UNIQUE')), 'InnoDB');
        if (in_array(DBPREFIX . "communit_config", $arrTables)) {
            $objResult = \Cx\Lib\UpdateUtil::sql('SELECT `name`, `value`, `status` FROM `' . DBPREFIX . 'community_config`');
            while (!$objResult->EOF) {
                $arrCommunityConfig[$objResult->fields['name']] = array('value' => $objResult->fields['value'], 'status' => $objResult->fields['status']);
                $objResult->MoveNext();
            }
        }
        $arrSettings = array('user_activation' => array('value' => '', 'status' => isset($arrCommunityConfig['user_activation']['status']) ? $arrCommunityConfig['user_activation']['status'] : 0), 'user_activation_timeout' => array('value' => isset($arrCommunityConfig['user_activation_timeout']['value']) ? $arrCommunityConfig['user_activation_timeout']['value'] : 0, 'status' => isset($arrCommunityConfig['user_activation_timeout']['status']) ? $arrCommunityConfig['user_activation_timeout']['status'] : 0), 'assigne_to_groups' => array('value' => isset($arrCommunityConfig['community_groups']['value']) ? $arrCommunityConfig['community_groups']['value'] : '', 'status' => 1), 'max_profile_pic_width' => array('value' => '160', 'status' => 1), 'max_profile_pic_height' => array('value' => '160', 'status' => 1), 'profile_thumbnail_pic_width' => array('value' => '50', 'status' => 1), 'profile_thumbnail_pic_height' => array('value' => '50', 'status' => 1), 'max_profile_pic_size' => array('value' => '30000', 'status' => 1), 'max_pic_width' => array('value' => '600', 'status' => 1), 'max_pic_height' => array('value' => '600', 'status' => 1), 'max_thumbnail_pic_width' => array('value' => '130', 'status' => 1), 'max_thumbnail_pic_height' => array('value' => '130', 'status' => 1), 'max_pic_size' => array('value' => '200000', 'status' => 1), 'notification_address' => array('value' => addslashes($_CONFIG['coreAdminEmail']), 'status' => 1), 'user_config_email_access' => array('value' => '', 'status' => 1), 'user_config_profile_access' => array('value' => '', 'status' => 1), 'default_email_access' => array('value' => 'members_only', 'status' => 1), 'default_profile_access' => array('value' => 'members_only', 'status' => 1), 'user_delete_account' => array('value' => '', 'status' => 1), 'block_currently_online_users' => array('value' => '10', 'status' => 0), 'block_currently_online_users_pic' => array('value' => '', 'status' => 0), 'block_last_active_users' => array('value' => '10', 'status' => 0), 'block_last_active_users_pic' => array('value' => '', 'status' => 0), 'block_latest_reg_users' => array('value' => '10', 'status' => 0), 'block_latest_reg_users_pic' => array('value' => '', 'status' => 0), 'block_birthday_users' => array('value' => '10', 'status' => 0), 'block_birthday_users_pic' => array('value' => '', 'status' => 0), 'session_user_interval' => array('value' => '0', 'status' => 1), 'user_accept_tos_on_signup' => array('value' => '', 'status' => 0), 'user_captcha' => array('value' => '', 'status' => 0), 'profile_thumbnail_method' => array('value' => 'crop', 'status' => 1), 'profile_thumbnail_scale_color' => array('value' => '#FFFFFF', 'status' => 1));
        foreach ($arrSettings as $key => $arrSetting) {
            if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "access_settings` WHERE `key` = '" . $key . "'")->RecordCount()) {
                \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings`\n                    SET `key`       = '" . $key . "',\n                        `value`     = '" . $arrSetting['value'] . "',\n                        `status`    = '" . $arrSetting['status'] . "'\n                ");
            }
        }
        // delete obsolete table community_config
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'community_config');
        // delete obsolete table user_validity
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'user_validity');
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /********************
     *
     * ADD USER PROFILE
     *
     *******************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_profile', array('user_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'gender' => array('type' => 'ENUM(\'gender_undefined\',\'gender_female\',\'gender_male\')', 'notnull' => true, 'default' => 'gender_undefined', 'after' => 'user_id'), 'title' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'gender'), 'firstname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'lastname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'firstname'), 'company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lastname'), 'address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'company'), 'city' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'address'), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '', 'after' => 'city'), 'country' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'zip'), 'phone_office' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'country'), 'phone_private' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_office'), 'phone_mobile' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_private'), 'phone_fax' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_mobile'), 'birthday' => array('type' => 'VARCHAR(11)', 'notnull' => false, 'after' => 'phone_fax'), 'website' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'birthday'), 'profession' => array('type' => 'VARCHAR(150)', 'notnull' => true, 'default' => '', 'after' => 'website'), 'interests' => array('type' => 'text', 'after' => 'profession'), 'signature' => array('type' => 'text', 'after' => 'interests'), 'picture' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'signature')), array('profile' => array('fields' => array('firstname' => 100, 'lastname' => 100, 'company' => 50))), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /***************************
     *
     * MIGRATE GROUP RELATIONS
     *
     **************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_rel_user_group', array('user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'user_id')), array(), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'access_users');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
        return false;
    }
    if (in_array('groups', $arrColumns)) {
        $query = "SELECT `id`, `groups` FROM " . DBPREFIX . "access_users WHERE `groups` != ''";
        $objUser = $objDatabase->Execute($query);
        if ($objUser) {
            while (!$objUser->EOF) {
                $arrGroups = explode(',', $objUser->fields['groups']);
                foreach ($arrGroups as $groupId) {
                    $query = "SELECT 1 FROM " . DBPREFIX . "access_rel_user_group WHERE `user_id` = " . $objUser->fields['id'] . " AND `group_id` = " . intval($groupId);
                    $objRel = $objDatabase->SelectLimit($query, 1);
                    if ($objRel) {
                        if ($objRel->RecordCount() == 0) {
                            $query = "INSERT INTO " . DBPREFIX . "access_rel_user_group (`user_id`, `group_id`) VALUES (" . $objUser->fields['id'] . ", " . intval($groupId) . ")";
                            if ($objDatabase->Execute($query) === false) {
                                return _databaseError($query, $objDatabase->ErrorMsg());
                            }
                        }
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
                $objUser->MoveNext();
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` DROP `groups`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    \DBG::msg('002');
    /*********************
     *
     * ADD USER VALIDITY
     *
     ********************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_validity', array('validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)), array(), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_validity`";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult) {
        if ($objResult->RecordCount() == 0) {
            $query = "\n                INSERT INTO `" . DBPREFIX . "access_user_validity` (`validity`) VALUES\n                    ('0'), ('1'), ('15'), ('31'), ('62'),\n                    ('92'), ('123'), ('184'), ('366'), ('731')\n                ";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /********************
     *
     * MIGRATE PROFILES
     *
     *******************/
    if (in_array('firstname', $arrColumns)) {
        $query = "SELECT `id`, `firstname`, `lastname`, `residence`, `profession`, `interests`, `webpage`, `company`, `zip`, `phone`, `mobile`, `street` FROM `" . DBPREFIX . "access_users`";
        $objUser = $objDatabase->Execute($query);
        if ($objUser) {
            while (!$objUser->EOF) {
                $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_profile` WHERE `user_id` = " . $objUser->fields['id'];
                $objProfile = $objDatabase->SelectLimit($query, 1);
                if ($objProfile) {
                    if ($objProfile->RecordCount() == 0) {
                        $query = "INSERT INTO `" . DBPREFIX . "access_user_profile` (\n                            `user_id`,\n                            `gender`,\n                            `firstname`,\n                            `lastname`,\n                            `company`,\n                            `address`,\n                            `city`,\n                            `zip`,\n                            `country`,\n                            `phone_office`,\n                            `phone_private`,\n                            `phone_mobile`,\n                            `phone_fax`,\n                            `website`,\n                            `profession`,\n                            `interests`,\n                            `picture`\n                        ) VALUES (\n                            " . $objUser->fields['id'] . ",\n                            'gender_undefined',\n                            '" . addslashes($objUser->fields['firstname']) . "',\n                            '" . addslashes($objUser->fields['lastname']) . "',\n                            '" . addslashes($objUser->fields['company']) . "',\n                            '" . addslashes($objUser->fields['street']) . "',\n                            '" . addslashes($objUser->fields['residence']) . "',\n                            '" . addslashes($objUser->fields['zip']) . "',\n                            0,\n                            '',\n                            '" . addslashes($objUser->fields['phone']) . "',\n                            '" . addslashes($objUser->fields['mobile']) . "',\n                            '',\n                            '" . addslashes($objUser->fields['webpage']) . "',\n                            '" . addslashes($objUser->fields['profession']) . "',\n                            '" . addslashes($objUser->fields['interests']) . "',\n                            ''\n                        )";
                        if ($objDatabase->Execute($query) === false) {
                            return _databaseError($query, $objDatabase->ErrorMsg());
                        }
                    }
                } else {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
                $objUser->MoveNext();
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $arrRemoveColumns = array('firstname', 'lastname', 'residence', 'profession', 'interests', 'webpage', 'company', 'zip', 'phone', 'mobile', 'street', 'levelid');
    foreach ($arrRemoveColumns as $column) {
        if (in_array($column, $arrColumns)) {
            $query = "ALTER TABLE " . DBPREFIX . "access_users DROP `" . $column . "`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $arrColumnDetails = $objDatabase->MetaColumns(DBPREFIX . 'access_users');
    if ($arrColumnDetails === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
        return false;
    }
    if (in_array('regdate', $arrColumns)) {
        if ($arrColumnDetails['REGDATE']->type == 'date') {
            if (!in_array('regdate_new', $arrColumns)) {
                $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `regdate_new` INT( 14 ) UNSIGNED NULL DEFAULT '0' AFTER `regdate`";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
            $query = "UPDATE `" . DBPREFIX . "access_users` SET `regdate_new` = UNIX_TIMESTAMP(`regdate`), `regdate` = '0000-00-00' WHERE `regdate` != '0000-00-00'";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            $query = "ALTER TABLE `" . DBPREFIX . "access_users` DROP `regdate`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'access_users');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
        return false;
    }
    if (in_array('regdate_new', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `regdate_new` `regdate` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0'";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `is_admin` `is_admin` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    if (!in_array('email_access', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `email_access` ENUM( 'everyone', 'members_only', 'nobody' ) NOT NULL DEFAULT 'nobody' AFTER `email`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('profile_access', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `profile_access` ENUM( 'everyone', 'members_only', 'nobody' ) NOT NULL DEFAULT 'members_only' AFTER `active`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('frontend_lang_id', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `langId` `frontend_lang_id` INT( 2 ) UNSIGNED NOT NULL DEFAULT '0'";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('backend_lang_id', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `backend_lang_id` INT( 2 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `frontend_lang_id`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        } else {
            $query = "UPDATE `" . DBPREFIX . "access_users` SET `backend_lang_id` = `frontend_lang_id`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    if (!in_array('last_auth', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `last_auth` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `regdate`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('last_activity', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `last_activity` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `last_auth`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('expiration', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `expiration` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `regdate`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('validity', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `validity` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `expiration`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    } else {
        try {
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "access_users` SET `expiration` = `validity`*60*60*24+`regdate` WHERE `expiration` = 0 AND `validity` > 0");
        } catch (\Cx\Lib\UpdateException $e) {
            // we COULD do something else here..
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    \DBG::msg('003');
    /***********************************
     *
     * MIGRATE COMMUNITY CONTENT PAGES
     *
     **********************************/
    // only execute this part for versions < 2.0.0
    $pattern = array('/section=community&(amp;)?cmd=profile/', '/section=community&(amp;)?cmd=register/', '/section=community/');
    $replacement = array('section=access&$1cmd=settings', 'section=access&$1cmd=signup', 'section=access');
    try {
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array(), $pattern, $replacement, array('content', 'target'), '2.0.0');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'community'), array('/community/', '/profile/', '/register/'), array('access', 'settings', 'signup'), array('module', 'cmd'), '2.0.0');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /***********************************
     *
     * CREATE PROFILE ATTRIBUTE TABLES
     *
     **********************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'type' => array('type' => 'ENUM(\'text\',\'textarea\',\'mail\',\'uri\',\'date\',\'image\',\'checkbox\',\'menu\',\'menu_option\',\'group\',\'frame\',\'history\')', 'notnull' => true, 'default' => 'text', 'after' => 'parent_id'), 'mandatory' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'type'), 'sort_type' => array('type' => 'ENUM(\'asc\',\'desc\',\'custom\')', 'notnull' => true, 'default' => 'asc', 'after' => 'mandatory'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sort_type'), 'access_special' => array('type' => 'ENUM(\'\',\'menu_select_higher\',\'menu_select_lower\')', 'notnull' => true, 'default' => '', 'after' => 'order_id'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'access_special')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute_name', array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'attribute_id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute_value', array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'attribute_id'), 'history_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'user_id'), 'value' => array('type' => 'text', 'after' => 'history_id')), array('value' => array('fields' => array('value'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_core_attribute', array('id' => array('type' => 'VARCHAR(25)', 'primary' => true), 'mandatory' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'sort_type' => array('type' => 'ENUM(\'asc\',\'desc\',\'custom\')', 'notnull' => true, 'default' => 'asc', 'after' => 'mandatory'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sort_type'), 'access_special' => array('type' => 'ENUM(\'\',\'menu_select_higher\',\'menu_select_lower\')', 'notnull' => true, 'default' => '', 'after' => 'order_id'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'access_special')), array(), 'InnoDB');
        /************************
         *
         * ADD USER TITLE TABLE
         *
         ***********************/
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_title', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'title')), array('title' => array('fields' => array('title'), 'type' => 'UNIQUE')), 'InnoDB');
        $arrDefaultTitle = array('Sehr geehrte Frau', 'Sehr geehrter Herr', 'Dear Ms', 'Dear Mr', 'Madame', 'Monsieur');
        foreach ($arrDefaultTitle as $title) {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_user_title` SET `title` = '" . $title . "' ON DUPLICATE KEY UPDATE `id` = `id`");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /******************************
     *
     * REMOVE OBSOLETE ACCESS IDS
     *
     *****************************/
    $query = 'DELETE FROM `' . DBPREFIX . 'access_group_static_ids` WHERE `access_id` IN (28, 29, 30, 33, 34, 36)';
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /*******************
     *
     * MIGRATE SESSION
     *
     ******************/
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'sessions');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'sessions'));
        return false;
    }
    if (!in_array('user_id', $arrColumns)) {
        $query = "\n            ALTER TABLE `" . DBPREFIX . "sessions`\n             DROP `username`,\n              ADD `user_id` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `status`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /***************************************
     *
     * ADD CHECKBOX PROFILE ATTRIBUTE TYPE
     *
     **************************************/
    $query = "ALTER TABLE `" . DBPREFIX . "access_user_attribute` CHANGE `type` `type` enum('text','textarea','mail','uri','date','image','checkbox','menu','menu_option','group','frame','history') NOT NULL DEFAULT 'text'";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    // Currently, this is only here to create the u2u_active field.. but instead of adding
    // 10 lines for each new field in the future, why not just extend this block
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_users', array('id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'is_admin' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'is_admin'), 'password' => array('type' => 'VARCHAR(32)', 'notnull' => false, 'after' => 'username'), 'regdate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'password'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'regdate'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'expiration'), 'last_auth' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'validity'), 'last_auth_status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1', 'after' => 'last_auth'), 'last_activity' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'last_auth_status'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'last_activity'), 'email_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'nobody', 'after' => 'email'), 'frontend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'email_access'), 'backend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend_lang_id'), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'backend_lang_id'), 'primary_group' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'active'), 'profile_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'members_only', 'after' => 'primary_group'), 'restore_key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => '', 'after' => 'profile_access'), 'restore_key_time' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'restore_key'), 'u2u_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1', 'after' => 'restore_key_time')), array('username' => array('fields' => array('username'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_groups', array('group_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'group_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'group_id'), 'group_description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'group_name'), 'is_active' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1', 'after' => 'group_description'), 'type' => array('type' => 'ENUM(\'frontend\',\'backend\')', 'notnull' => true, 'default' => 'frontend', 'after' => 'is_active'), 'homepage' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'type')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    \DBG::msg('004');
    // only update if installed version is at least a version 2.0.0
    // older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled
    if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
        try {
            // migrate content page to version 3.0.1
            $search = array('/(.*)/ms');
            $callback = function ($matches) {
                $content = $matches[1];
                if (empty($content)) {
                    return $content;
                }
                // add missing access_captcha template block
                if (!preg_match('/<!--\\s+BEGIN\\s+access_captcha\\s+-->.*<!--\\s+END\\s+access_captcha\\s+-->/ms', $content)) {
                    $content = preg_replace('/(<\\/fieldset>|)(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$2<!-- BEGIN access_captcha -->$2$3<label>{TXT_ACCESS_CAPTCHA}</label>{ACCESS_CAPTCHA_CODE}$5$2<!-- END access_captcha -->$2$1$2$3$4$5', $content);
                }
                // add missing access_newsletter template block
                if (!preg_match('/<!--\\s+BEGIN\\s+access_newsletter\\s+-->.*<!--\\s+END\\s+access_newsletter\\s+-->/ms', $content)) {
                    $content = preg_replace('/(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$1<!-- BEGIN access_newsletter -->$1<fieldset><legend>Newsletter abonnieren</legend>$1    <!-- BEGIN access_newsletter_list -->$1    <p>$1        <label for="access_user_newsletters-{ACCESS_NEWSLETTER_ID}">&nbsp;{ACCESS_NEWSLETTER_NAME}</label>$1        <input type="checkbox" name="access_user_newsletters[]" id="access_user_newsletters-{ACCESS_NEWSLETTER_ID}" value="{ACCESS_NEWSLETTER_ID}"{ACCESS_NEWSLETTER_SELECTED} />$1    </p>$1    <!-- END access_newsletter_list -->$1</fieldset>$1<!-- END access_newsletter -->$1$2$3$4', $content);
                }
                return $content;
            };
            \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.1');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************
     *
     * ADD NETWORK TABLE FOR SOCIAL LOGIN
     *
     **************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_network', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'oauth_provider' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'oauth_id' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'oauth_provider'), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'oauth_id')), array(), 'InnoDB');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        /***************************************
         *
         * ADD NEW VALUES FOR SOCIAL LOGIN
         *
         **************************************/
        try {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin', '', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_show_signup', '', 0) ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('use_usernames', '0', '1') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_assign_to_groups', '3', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_active_automatically', '', '1') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ('access', 'providers', 'sociallogin', 'text', '{\"facebook\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"twitter\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"google\":{\"active\":\"0\",\"settings\":[\"\",\"\",\"\"]}}', '', '0') ON DUPLICATE KEY UPDATE `section` = `section`");
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        /**
         * Content page
         * access signup
         */
        try {
            // migrate content page to version 3.0.1
            $search = array('/(.*)/ms');
            $callback = function ($matches) {
                $content = $matches[1];
                if (empty($content)) {
                    return $content;
                }
                // fix duplicated social networks blocks
                if (preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+BEGIN\\s+access_social_networks\\s+-->/ms', $content)) {
                    $content = preg_replace('/<br\\s+\\/><br\\s+\\/><!--\\s+BEGIN\\s+access_social_networks\\s+-->.*?<!--\\s+END\\s+access_social_networks\\s+-->/ms', '', $content);
                }
                // add missing access_social_networks template block
                if (!preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+END\\s+access_social_networks\\s+-->/ms', $content)) {
                    $content = preg_replace('/(<!--\\s+BEGIN\\s+access_signup_form\\s+-->.*?)(<div[^>]*>|)(.*?\\{ACCESS_SIGNUP_MESSAGE\\}.*?)(<\\/div>|)/ms', '$1<br /><br /><!-- BEGIN access_social_networks --><fieldset><legend>oder Login mit Social Media</legend><!-- BEGIN access_social_networks_facebook -->        <a class="facebook loginbutton" href="{ACCESS_SOCIALLOGIN_FACEBOOK}">Facebook</a>        <!-- END access_social_networks_facebook -->        <!-- BEGIN access_social_networks_google -->        <a class="google loginbutton" href="{ACCESS_SOCIALLOGIN_GOOGLE}">Google</a>        <!-- END access_social_networks_google -->        <!-- BEGIN access_social_networks_twitter -->        <a class="twitter loginbutton" href="{ACCESS_SOCIALLOGIN_TWITTER}">Twitter</a>        <!-- END access_social_networks_twitter -->    </fieldset>    <!-- END access_social_networks -->$2$3$4', $content);
                }
                return $content;
            };
            \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.2');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************
     *
     * ADD SETTING FOR SOCIAL LOGIN
     *
     **************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
        try {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_activation_timeout', '10', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************
     *
     * STRICT_TRANS_TABLES ISSUE FIX FOR PROFILE TABLE
     *
     **************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            \Cx\Lib\UpdateUtil::sql("ALTER TABLE `" . DBPREFIX . "access_user_profile` CHANGE `interests` `interests` TEXT NULL");
            \Cx\Lib\UpdateUtil::sql("ALTER TABLE `" . DBPREFIX . "access_user_profile` CHANGE `signature` `signature` TEXT NULL");
            // add access to filesharing for existing groups
            try {
                $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 7 GROUP BY group_id");
                if ($result !== false) {
                    while (!$result->EOF) {
                        \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                    VALUES (8, " . intval($result->fields['group_id']) . ")");
                        $result->MoveNext();
                    }
                }
            } catch (\Cx\Lib\UpdateException $e) {
                return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /************************************************
     * BUGFIX:	Set write access to the upload dir  *
     ************************************************/
    // This is obsolete due to the new \Cx\Lib\FileSystem
    /*
    	require_once ASCMS_FRAMEWORK_PATH.'/File.class.php';
    	$objFile = new File();
    	if (is_writeable(ASCMS_ACCESS_PROFILE_IMG_PATH) || $objFile->setChmod(ASCMS_ACCESS_PROFILE_IMG_PATH, ASCMS_ACCESS_PROFILE_IMG_WEB_PATH, '')) {
        	if ($mediaDir = @opendir(ASCMS_ACCESS_PROFILE_IMG_PATH)) {
        		while($file = readdir($mediaDir)) {
        			if ($file != '.' && $file != '..') {
        				if (!is_writeable(ASCMS_ACCESS_PROFILE_IMG_PATH.'/'.$file) && !$objFile->setChmod(ASCMS_ACCESS_PROFILE_IMG_PATH.'/', ASCMS_ACCESS_PROFILE_IMG_WEB_PATH.'/', $file)) {
        					setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/'.$file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        					return false;
        				}
        			}
    			}
        	} else {
        		setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        		return false;
    		}
        } else {
        	setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        	return false;
        }
    
    	require_once ASCMS_FRAMEWORK_PATH.'/File.class.php';
    	$objFile = new File();
    	if (is_writeable(ASCMS_ACCESS_PHOTO_IMG_PATH) || $objFile->setChmod(ASCMS_ACCESS_PHOTO_IMG_PATH, ASCMS_ACCESS_PHOTO_IMG_WEB_PATH, '')) {
        	if ($mediaDir = @opendir(ASCMS_ACCESS_PHOTO_IMG_PATH)) {
        		while($file = readdir($mediaDir)) {
        			if ($file != '.' && $file != '..') {
        				if (!is_writeable(ASCMS_ACCESS_PHOTO_IMG_PATH.'/'.$file) && !$objFile->setChmod(ASCMS_ACCESS_PHOTO_IMG_PATH.'/', ASCMS_ACCESS_PHOTO_IMG_WEB_PATH.'/', $file)) {
        					setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/'.$file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        					return false;
        				}
        			}
    			}
        	} else {
        		setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        		return false;
    		}
        } else {
        	setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        	return false;
        }*/
    return true;
}
 public function dropOldTables()
 {
     // Drop old tables
     try {
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content_history');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content_logfile');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content_navigation');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'content_navigation_history');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_alias_source');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_alias_target');
         \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_block_rel_lang');
     } catch (\Cx\Lib\UpdateException $e) {
         \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
         return false;
     }
     return true;
 }
Beispiel #10
0
 /**
  * drop old tables
  * @return bool|void
  */
 protected function dropOldTables()
 {
     try {
         \Cx\Lib\UpdateUtil::drop_table(CALENDAR_OLD_EVENT_TABLE);
         \Cx\Lib\UpdateUtil::drop_table(CALENDAR_OLD_CATEGORY_TABLE);
         \Cx\Lib\UpdateUtil::drop_table(CALENDAR_OLD_FORM_DATA_TABLE);
         \Cx\Lib\UpdateUtil::drop_table(CALENDAR_OLD_FORM_FIELD_TABLE);
         \Cx\Lib\UpdateUtil::drop_table(CALENDAR_OLD_REGISTRATIONS_TABLE);
     } catch (\Cx\Lib\UpdateException $e) {
         return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
     }
     return true;
 }
Beispiel #11
0
 /**
  * Tries to recreate the database table(s) for the class
  *
  * Should be called whenever there's a problem with the database table.
  * @return  boolean             False.  Always.
  */
 static function errorHandler()
 {
     $table_name = DBPREFIX . 'core_country';
     $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'alpha2' => array('type' => 'CHAR(2)', 'notnull' => true, 'default' => ''), 'alpha3' => array('type' => 'CHAR(3)', 'notnull' => true, 'default' => ''), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'is_active'));
     \Cx\Lib\UpdateUtil::table($table_name, $table_structure);
     if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
         \Text::deleteByKey('core', self::TEXT_NAME);
         // Copy the Countries from the Shop module if possible
         if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . "module_shop_countries")) {
             $query = "\n                    SELECT `countries_id`, `countries_name`,\n                           `countries_iso_code_2`, `countries_iso_code_3`,\n                           `activation_status`\n                      FROM " . DBPREFIX . "module_shop_countries";
             $objResult = \Cx\Lib\UpdateUtil::sql($query);
             if (!$objResult) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to to query Country names", $query);
             }
             $default_lang_id = \FWLanguage::getDefaultLangId();
             while (!$objResult->EOF) {
                 $id = $objResult->fields['countries_id'];
                 $name = $objResult->fields['countries_name'];
                 $alpha2 = $objResult->fields['countries_iso_code_2'];
                 $alpha3 = $objResult->fields['countries_iso_code_3'];
                 $active = $objResult->fields['activation_status'];
                 $ord = 0;
                 if ($id == 14) {
                     // fixing missing name
                     $name = 'Österreich';
                 }
                 if (!self::store($alpha2, $alpha3, $default_lang_id, $name, $ord, $active, $id)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to migrate Country '{$name}'");
                 }
                 $objResult->MoveNext();
             }
             \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_countries');
         }
     }
     // USE FOR NEW INSTALLATIONS ONLY!
     // These records will lead to inconsistencies with Country references in
     // other tables otherwise.
     if (\Cx\Lib\UpdateUtil::table_empty($table_name)) {
         // Add new Country records if available
         if (file_exists(ASCMS_CORE_PATH . '/countries_iso_3166-2.php') && (include_once ASCMS_CORE_PATH . '/countries_iso_3166-2.php')) {
             //DBG::log("Country::errorHandler(): Included ISO file");
             $arrCountries = null;
             $ord = 0;
             foreach ($arrCountries as $country_id => $arrCountry) {
                 $name = $arrCountry[0];
                 $alpha2 = $arrCountry[1];
                 $alpha3 = $arrCountry[2];
                 // Not currently in use:
                 //                    $numeric = $arrCountry[3];
                 //                    $iso_full = $arrCountry[4];
                 // English (language ID 2) only!
                 if (!self::store($alpha2, $alpha3, 2, $name, ++$ord, true, $country_id)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to add Country '{$name}' from ISO file");
                 }
                 //DBG::log("Country::errorHandler(): Added Country ID $country_id: '$name'");
             }
         }
     }
     //DBG::activate(DBG_ADODB);
     // Add more languages from the countries_languages.php file,
     // if present
     $arrCountries = array();
     // $arrCountries is redefined in the file
     if (file_exists(ASCMS_CORE_PATH . '/countries_languages.php') && (include_once ASCMS_CORE_PATH . '/countries_languages.php')) {
         foreach ($arrCountries as $alpha2 => $arrLanguage) {
             //DBG::log("errorHandler: Looking for Alpha-2 $alpha2");
             $country_id = self::getIdByAlpha2($alpha2);
             if (!$country_id) {
                 // TODO: Fail or not?
                 continue;
             }
             foreach ($arrLanguage as $lang_id => $name) {
                 if (!\Text::replace($country_id, $lang_id, 'core', self::TEXT_NAME, $name)) {
                     throw new \Cx\Lib\Update_DatabaseException("Failed to to update Country '{$name}' from languages file");
                 }
                 //DBG::log("Country::errorHandler(): Added Country ID $country_id: language ID $lang_id");
             }
         }
     }
     \Cx\Core\Setting\Controller\Setting::init('core', 'country');
     \Cx\Core\Setting\Controller\Setting::add('numof_countries_per_page_backend', 30, 101);
     // More to come...
     // Always!
     return false;
 }
Beispiel #12
0
function _directoryUpdate()
{
    global $objDatabase, $_ARRAYLANG;
    /// 2.0
    $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_directory_dir');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_directory_dir'));
        return false;
    }
    $arrNewCols = array('LONGITUDE' => array('type' => 'DECIMAL( 18, 15 )', 'default' => '0', 'after' => 'premium'), 'LATITUDE' => array('type' => 'DECIMAL( 18, 15 )', 'default' => '0', 'after' => 'longitude'), 'ZOOM' => array('type' => 'DECIMAL( 18, 15 )', 'default' => '1', 'after' => 'latitude'), 'COUNTRY' => array('type' => 'VARCHAR( 255 )', 'default' => '', 'after' => 'city'));
    foreach ($arrNewCols as $col => $arrAttr) {
        if (!isset($arrColumns[$col])) {
            $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` ADD `" . strtolower($col) . "` " . $arrAttr['type'] . " NOT NULL DEFAULT '" . $arrAttr['default'] . "' AFTER `" . $arrAttr['after'] . "`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $inputColumns = '(`id`, `typ`, `name`, `title`, `active`, `active_backend`, `is_required`, `read_only`, `sort`, `exp_search`, `is_search`)';
    $arrInputs = array(69 => "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` " . $inputColumns . " VALUES (69, 13, 'googlemap', 'TXT_DIR_F_GOOGLEMAP', 1, 1, 0, 0, 6, 0, 0)", 70 => "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` " . $inputColumns . " VALUES (70, 3, 'country', 'TXT_DIR_F_COUNTRY', 1, 1, 1, 0, 1, 0, 0)");
    foreach ($arrInputs as $id => $queryInputs) {
        $query = "SELECT id FROM " . DBPREFIX . "module_directory_inputfields WHERE id=" . $id;
        $objCheck = $objDatabase->SelectLimit($query, 1);
        if ($objCheck !== false) {
            if ($objCheck->RecordCount() == 0) {
                if ($objDatabase->Execute($queryInputs) === false) {
                    return _databaseError($queryInputs, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='country'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` ,  `settyp` )\n                        VALUES (NULL, 'country', ',Schweiz,Deutschland,Österreich', 0)";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` CHANGE `spez_field_21` `spez_field_21` VARCHAR( 255 ) NOT NULL DEFAULT ''";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` CHANGE `spez_field_22` `spez_field_22` VARCHAR( 255 ) NOT NULL DEFAULT ''";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='pagingLimit'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` ,  `settyp` )\n                        VALUES (NULL, 'pagingLimit', '20', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='googlemap_start_location'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` ,  `settyp` )\n                        VALUES (NULL, 'googlemap_start_location', '46:8:1', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /// 2.1
    $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='youtubeWidth'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` ,  `settyp` )\n                         VALUES (NULL , 'youtubeWidth', '400', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "SELECT setid FROM " . DBPREFIX . "module_directory_settings WHERE setname='youtubeHeight'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_directory_settings` ( `setid` , `setname` , `setvalue` ,  `settyp` )\n                         VALUES (NULL , 'youtubeHeight', '300', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $query = "SELECT id FROM " . DBPREFIX . "module_directory_inputfields WHERE name='youtube'";
    $objCheck = $objDatabase->SelectLimit($query, 1);
    if ($objCheck !== false) {
        if ($objCheck->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_directory_inputfields` (`id` ,`typ` ,`name` ,`title` ,`active` ,`active_backend` ,`is_required` ,`read_only` ,`sort` ,`exp_search` ,`is_search`)\n                         VALUES (NULL , '1', 'youtube', 'TXT_DIRECTORY_YOUTUBE', '0', '0', '0', '0', '0', '0', '0')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    $arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_directory_dir');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_directory_dir'));
        return false;
    }
    if (!array_key_exists("YOUTUBE", $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir` ADD `youtube` MEDIUMTEXT NOT NULL;";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $query = "ALTER TABLE `" . DBPREFIX . "module_directory_dir`\n                CHANGE `logo` `logo` VARCHAR(50) NULL,\n                CHANGE `map` `map` VARCHAR(255) NULL,\n                CHANGE `lokal` `lokal` VARCHAR(255) NULL,\n                CHANGE `spez_field_11` `spez_field_11` VARCHAR(255) NULL,\n                CHANGE `spez_field_12` `spez_field_12` VARCHAR(255) NULL,\n                CHANGE `spez_field_13` `spez_field_13` VARCHAR(255) NULL,\n                CHANGE `spez_field_14` `spez_field_14` VARCHAR(255) NULL,\n                CHANGE `spez_field_15` `spez_field_15` VARCHAR(255) NULL,\n                CHANGE `spez_field_16` `spez_field_16` VARCHAR(255) NULL,\n                CHANGE `spez_field_17` `spez_field_17` VARCHAR(255) NULL,\n                CHANGE `spez_field_18` `spez_field_18` VARCHAR(255) NULL,\n                CHANGE `spez_field_19` `spez_field_19` VARCHAR(255) NULL,\n                CHANGE `spez_field_20` `spez_field_20` VARCHAR(255) NULL;";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    //delete obsolete table  contrexx_module_directory_access
    try {
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_directory_access');
    } catch (\Cx\Lib\UpdateException $e) {
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /********************************
     * EXTENSION:   Fulltext key    *
     * ADDED:       Contrexx v3.0.0 *
     ********************************/
    try {
        $objResult = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'module_directory_categories` WHERE  `Key_name` = "directoryindex" and (`Column_name`= "name" OR `Column_name` = "description")');
        if ($objResult && $objResult->RecordCount() == 0) {
            \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_directory_categories` ADD FULLTEXT KEY `directoryindex` (`name`, `description`)');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /**********************************
     * EXTENSION:   Content Migration *
     * ADDED:       Contrexx v3.0.0   *
     **********************************/
    try {
        // migrate content page to version 3.0.1
        $search = array('/(.*)/ms');
        $callback = function ($matches) {
            $content = $matches[1];
            if (empty($content)) {
                return $content;
            }
            // add missing placeholder {DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}
            if (strpos($content, '{DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}') === false) {
                $content .= "\n{DIRECTORY_GOOGLEMAP_JAVASCRIPT_BLOCK}";
            }
            // move placeholder {DIRECTORY_JAVASCRIPT} to the end of the content page
            $content = str_replace('{DIRECTORY_JAVASCRIPT}', '', $content);
            $content .= "\n{DIRECTORY_JAVASCRIPT}";
            return $content;
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'directory'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
Beispiel #13
0
 /**
  * Migrates existing old Shop mailtemplates to the new MailTemplate class
  * @return  boolean         False.  Always.
  * @throws  Cx\Lib\Update_DatabaseException
  */
 static function errorHandler()
 {
     if (!(include_once \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseFrameworkPath() . '/UpdateUtil')) {
         return false;
     }
     if (\Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'core_mail_template')) {
         // Make sure there are no bodies lying around
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_NAME);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_FROM);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SENDER);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_REPLY);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_TO);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_CC);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_BCC);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SUBJECT);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE_HTML);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_ATTACHMENTS);
         \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_INLINE);
     }
     // Migrate existing templates from the shop to the MailTemplate.
     // These are the keys replacing the IDs.
     // TODO: Migrate the old template using the original IDs, make them unprotected
     // TODO: Add the new default templates with the new keys
     // and have the user migrate changes herself!
     $arrKey = array(1 => 'order_confirmation', 2 => 'order_complete', 3 => 'customer_login', 4 => 'order_confirmation_login');
     $arrLanguageId = \FWLanguage::getIdArray();
     if (empty($arrLanguageId)) {
         throw new \Cx\Lib\Update_DatabaseException("Failed to get frontend language IDs");
     }
     foreach ($arrLanguageId as $lang_id) {
         // Mind that the template name is single language yet!
         $arrTemplates = self::getTemplateArray($lang_id);
         if (empty($arrTemplates)) {
             continue;
         }
         foreach ($arrTemplates as $id => $arrTemplate) {
             // TODO: utf8_encode() may not be necessary in all cases.
             // It worked without it for me earlier, but was necessary for verkehrstheorie.ch
             $arrTemplate = array_map("utf8_encode", $arrTemplate);
             if (isset($arrKey[$id])) {
                 // System templates get their default key
                 $arrTemplate['key'] = $arrKey[$id];
                 if ($id == 4) {
                     // Clear the protected flag, so the obsolete template
                     // #4 may be removed at will
                     $arrTemplate['protected'] = false;
                 }
             } else {
                 // Custom templates:
                 // Make the name lowercase and replace any non-letter
                 $new_key = preg_replace('/[^a-z]/', '_', strtolower($arrTemplate['name']));
                 // Keep it unique!  Use the ID if the key is taken
                 if (in_array($new_key, $arrKey)) {
                     $new_key = $id;
                 }
                 // Remember used keys, and replace the former ID
                 $arrKey[$id] = $new_key;
                 $arrTemplate['key'] = $new_key;
             }
             foreach ($arrTemplate as &$string) {
                 // Replace old <PLACEHOLDERS> with new [PLACEHOLDERS].
                 $string = preg_replace('/\\<([A-Z_]+)\\>/', '[$1]', $string);
                 // TODO: This is completely unreliable.
                 // Use the process as described above, not replacing the old templates,
                 // but adding the new ones instead.
                 //                    $string = str_replace('[ORDER_DATA]', $order_data, $string);
                 //                    $string = preg_replace('/[\\w\\s\\:]+\\[USERNAME\\](?:\\n|<br\\s?\\/?
                 //                          >)*[\\w\\s\\:]+\\[PASSWORD\\]/',
                 //                        $login_data, $string);
             }
             //                $arrTemplate['message_html'] = preg_replace(
             //                    '/(?:\r|\n|\r\n)/', "<br />\n", $arrTemplate['message']);
             $arrTemplate['lang_id'] = $lang_id;
             if (!\Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', $arrTemplate)) {
                 throw new \Cx\Lib\Update_DatabaseException("Failed to store Mailtemplate");
             }
         }
     }
     // Drop old Mail tables after successful migration
     \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail_content');
     \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail');
     // Always!
     return false;
 }
Beispiel #14
0
    /**
     * Migrates existing old Shop mailtemplates to the new MailTemplate class
     * @return  boolean         False.  Always.
     * @throws  Cx\Lib\Update_DatabaseException
     */
    static function errorHandler()
    {
        // Mail
        \Cx\Core\MailTemplate\Controller\MailTemplate::errorHandler();
        if (\Cx\Lib\UpdateUtil::table_empty(DBPREFIX . 'core_mail_template')) {
            // Make sure there are no bodies lying around
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_NAME);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_FROM);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SENDER);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_REPLY);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_TO);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_CC);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_BCC);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_SUBJECT);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_MESSAGE_HTML);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_ATTACHMENTS);
            \Text::deleteByKey('Shop', \Cx\Core\MailTemplate\Controller\MailTemplate::TEXT_INLINE);
        }
        $arrFrom = $arrSender = $arrSubject = array();
        $arrLanguageId = \FWLanguage::getIdArray();
        if (empty($arrLanguageId)) {
            throw new \Cx\Lib\Update_DatabaseException("Failed to get frontend language IDs");
        }
        if (\Cx\Lib\UpdateUtil::table_exist(DBPREFIX . 'module_shop_mail')) {
            // Migrate existing templates from the shop to the MailTemplate,
            // appending "_backup_by_update" to the respective keys.
            // Make them unprotected.
            // These are the keys replacing the IDs:
            $arrKey = array(1 => 'order_confirmation', 2 => 'order_complete', 3 => 'customer_login', 4 => 'order_confirmation_login');
            foreach ($arrLanguageId as $lang_id) {
                // Mind that the template name is single language yet!
                $arrTemplates = self::getTemplateArray($lang_id);
                if (empty($arrTemplates)) {
                    continue;
                }
                foreach ($arrTemplates as $id => $arrTemplate) {
                    // NOTE: utf8_encode() may be necessary in some cases.
                    // It usually works without it, but was necessary on a few installations.
                    //                    $arrTemplate = array_map("utf8_encode", $arrTemplate);
                    if (!empty($arrTemplate['from']) && empty($arrFrom[$id])) {
                        $arrFrom[$id] = $arrTemplate['from'];
                    }
                    if (!empty($arrTemplate['sender']) && empty($arrSender[$id])) {
                        $arrSender[$id] = $arrTemplate['sender'];
                    }
                    if (!empty($arrTemplate['subject']) && empty($arrSubject[$id])) {
                        $arrSubject[$id] = str_replace('<DATE>', '[ORDER_DATE]', $arrTemplate['subject']);
                    }
                    if (isset($arrKey[$id])) {
                        // System templates get their default key
                        $arrTemplate['key'] = $arrKey[$id] . '_backup_by_update';
                        // Clear the protected flag, so the old templates
                        // may be removed at will
                        $arrTemplate['protected'] = false;
                    } else {
                        // Custom templates:
                        // Make the name lowercase and replace any non-letter
                        $new_key = preg_replace('/[^a-z]/', '_', strtolower($arrTemplate['name']));
                        // Keep it unique!  Use the ID if the key is taken
                        if (in_array($new_key, $arrKey)) {
                            $new_key = $id;
                        }
                        // Remember used keys, and replace the former ID
                        $arrKey[$id] = $new_key;
                        $arrTemplate['key'] = $new_key;
                    }
                    // Some installations may contain corrupt templates
                    // causing empty (0 or "") keys.  Those would make
                    // MailTemplate::store() fail!
                    if (empty($arrTemplate['key'])) {
                        $arrTemplate['key'] = uniqid() . '_backup_by_update)';
                    }
                    foreach ($arrTemplate as &$string) {
                        // Replace old <PLACEHOLDERS> with new [PLACEHOLDERS].
                        $string = preg_replace('/\\<([A-Z_]+)\\>/', '[$1]', $string);
                        // This is completely unreliable.
                        // Use the process as described above, not replacing the old templates,
                        // but adding the new ones instead.
                        //                    $string = str_replace('[ORDER_DATA]', $order_data, $string);
                        //                    $string = preg_replace('/[\\w\\s\\:]+\\[USERNAME\\](?:\\n|<br\\s?\\/?
                        //                          >)*[\\w\\s\\:]+\\[PASSWORD\\]/',
                        //                        $login_data, $string);
                    }
                    //                $arrTemplate['message_html'] = preg_replace(
                    //                    '/(?:\r|\n|\r\n)/', "<br />\n", $arrTemplate['message']);
                    $arrTemplate['lang_id'] = $lang_id;
                    if (!\Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', $arrTemplate)) {
                        throw new \Cx\Lib\Update_DatabaseException("Failed to store Mailtemplate");
                    }
                }
            }
            // Drop old Mail tables after successful migration
            \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail_content');
            \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_shop_mail');
        }
        // Add the new default templates with the new keys
        // and have the user migrate changes herself!
        foreach ($arrLanguageId as $lang_id) {
            if (!\Cx\Core\MailTemplate\Controller\MailTemplate::get('Shop', 'order_confirmation', $lang_id)) {
                \Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', array('lang_id' => $lang_id, 'key' => 'order_confirmation', 'name' => 'Bestellungsbestätigung', 'from' => isset($arrFrom[1]) ? $arrFrom[1] : '', 'sender' => isset($arrSender[1]) ? $arrSender[1] : '', 'to' => '[CUSTOMER_EMAIL]', 'subject' => isset($arrSubject[1]) ? $arrSubject[1] : '', 'message' => <<<EOF
[CUSTOMER_SALUTATION],

Herzlichen Dank für Ihre Bestellung im [SHOP_COMPANY] Online Shop.

Ihre Auftrags-Nr. lautet: [ORDER_ID]
Ihre Kunden-Nr. lautet: [CUSTOMER_ID]
Bestellungszeit: [ORDER_DATE] [ORDER_TIME]

------------------------------------------------------------------------
Bestellinformationen
------------------------------------------------------------------------[[ORDER_ITEM]
ID:             [PRODUCT_ID]
Artikel Nr.:    [PRODUCT_CODE]
Menge:          [PRODUCT_QUANTITY]
Beschreibung:   [PRODUCT_TITLE][[PRODUCT_OPTIONS]
            [PRODUCT_OPTIONS][PRODUCT_OPTIONS]]
Stückpreis:      [PRODUCT_ITEM_PRICE] [CURRENCY]                       Total [PRODUCT_TOTAL_PRICE] [CURRENCY][[USER_DATA]
Benutzername:   [USER_NAME]
Passwort:       [USER_PASS][USER_DATA]][[COUPON_DATA]
Gutschein Code: [COUPON_CODE][COUPON_DATA]][ORDER_ITEM]]
------------------------------------------------------------------------
Zwischensumme:    [ORDER_ITEM_COUNT] Artikel                             [ORDER_ITEM_SUM] [CURRENCY][[DISCOUNT_COUPON]
Gutschein Code: [DISCOUNT_COUPON_CODE]   [DISCOUNT_COUPON_AMOUNT] [CURRENCY][DISCOUNT_COUPON]]
------------------------------------------------------------------------[[SHIPMENT]
Versandart:     [SHIPMENT_NAME]   [SHIPMENT_PRICE] [CURRENCY][SHIPMENT]][[PAYMENT]
Bezahlung:      [PAYMENT_NAME]   [PAYMENT_PRICE] [CURRENCY][PAYMENT]][[VAT]
[VAT_TEXT]                   [VAT_PRICE] [CURRENCY][VAT]]
------------------------------------------------------------------------
Gesamtsumme                                                [ORDER_SUM] [CURRENCY]
------------------------------------------------------------------------

Bemerkungen:
[REMARKS]


Ihre Kundenadresse:
[CUSTOMER_COMPANY]
[CUSTOMER_FIRSTNAME] [CUSTOMER_LASTNAME]
[CUSTOMER_ADDRESS]
[CUSTOMER_ZIP] [CUSTOMER_CITY]
[CUSTOMER_COUNTRY][[SHIPPING_ADDRESS]


Lieferadresse:
[SHIPPING_COMPANY]
[SHIPPING_FIRSTNAME] [SHIPPING_LASTNAME]
[SHIPPING_ADDRESS]
[SHIPPING_ZIP] [SHIPPING_CITY]
[SHIPPING_COUNTRY][SHIPPING_ADDRESS]]

Ihr Link zum Online Store: [SHOP_HOMEPAGE][[CUSTOMER_LOGIN]

Ihre Zugangsdaten zum Shop:
Benutzername:   [CUSTOMER_USERNAME]
Passwort:       [CUSTOMER_PASSWORD][CUSTOMER_LOGIN]]

Wir freuen uns auf Ihren nächsten Besuch im [SHOP_COMPANY] Online Store und wünschen Ihnen noch einen schönen Tag.

P.S. Diese Auftragsbestätigung wurde gesendet an: [CUSTOMER_EMAIL]

Mit freundlichen Grüssen
Ihr [SHOP_COMPANY] Online Shop Team

[SHOP_HOMEPAGE]
EOF
, 'message_html' => <<<EOF
[CUSTOMER_SALUTATION],<br />
<br />
Herzlichen Dank f&uuml;r Ihre Bestellung im [SHOP_COMPANY] Online Shop.<br />
<br />
Ihre Auftrags-Nr. lautet: [ORDER_ID]<br />
Ihre Kunden-Nr. lautet: [CUSTOMER_ID]<br />
Bestellungszeit: [ORDER_DATE] [ORDER_TIME]<br />
<br />
<br />
<table cellspacing="1" cellpadding="1" style="border: 0;">
<tbody>
<tr>
  <td colspan="6">Bestellinformationen</td>
</tr>
<tr>
  <td><div style="text-align: right;">ID</div></td>
  <td><div style="text-align: right;">Artikel Nr.</div></td>
  <td><div style="text-align: right;">Menge</div></td>
  <td>Beschreibung</td>
  <td><div style="text-align: right;">St&uuml;ckpreis</div></td>
  <td><div style="text-align: right;">Total</div></td>
</tr><!--[[ORDER_ITEM]-->
<tr>
  <td><div style="text-align: right;">[PRODUCT_ID]</div></td>
  <td><div style="text-align: right;">[PRODUCT_CODE]</div></td>
  <td><div style="text-align: right;">[PRODUCT_QUANTITY]</div></td>
  <td>[PRODUCT_TITLE]<!--[[PRODUCT_OPTIONS]--><br />
    [PRODUCT_OPTIONS]<!--[PRODUCT_OPTIONS]]--></td>
  <td><div style="text-align: right;">[PRODUCT_ITEM_PRICE] [CURRENCY]</div></td>
  <td><div style="text-align: right;">[PRODUCT_TOTAL_PRICE] [CURRENCY]</div></td>
</tr><!--[[USER_DATA]-->
<tr>
  <td colspan="3">&nbsp;</td>
  <td>Benutzername: [USER_NAME]<br />Passwort: [USER_PASS]</td>
  <td colspan="2">&nbsp;</td>
</tr><!--[USER_DATA]]--><!--[[COUPON_DATA]-->
<tr>
  <td colspan="3">&nbsp;</td>
  <td>Gutschein Code: [COUPON_CODE]</td>
  <td colspan="2">&nbsp;</td>
</tr><!--[COUPON_DATA]]--><!--[ORDER_ITEM]]-->
<tr style="border-top: 4px none;">
  <td colspan="2">Zwischensumme</td>
  <td><div style="text-align: right;">[ORDER_ITEM_COUNT]</div></td>
  <td colspan="2">Artikel</td>
  <td><div style="text-align: right;">[ORDER_ITEM_SUM] [CURRENCY]</div></td>
</tr><!--[[DISCOUNT_COUPON]-->
<tr style="border-top: 4px none;">
  <td colspan="3">Gutscheincode</td>
  <td colspan="2">[DISCOUNT_COUPON_CODE]</td>
  <td><div style="text-align: right;">[DISCOUNT_COUPON_AMOUNT] [CURRENCY]</div></td>
</tr><!--[DISCOUNT_COUPON]][[SHIPMENT]-->
<tr style="border-top: 2px none;">
  <td colspan="3">Versandart</td>
  <td colspan="2">[SHIPMENT_NAME]</td>
  <td><div style="text-align: right;">[SHIPMENT_PRICE] [CURRENCY]</div></td>
</tr><!--[SHIPMENT]][[PAYMENT]-->
<tr style="border-top: 2px none;">
  <td colspan="3">Bezahlung</td>
  <td colspan="2">[PAYMENT_NAME]</td>
  <td><div style="text-align: right;">[PAYMENT_PRICE] [CURRENCY]</div></td>
</tr><!--[PAYMENT]][[VAT]-->
<tr style="border-top: 2px none;">
  <td colspan="5">[VAT_TEXT]</td>
  <td><div style="text-align: right;">[VAT_PRICE] [CURRENCY]</div></td>
</tr><!--[VAT]]-->
<tr style="border-top: 4px none;">
  <td colspan="5">Gesamtsumme</td>
  <td><div style="text-align: right;">[ORDER_SUM] [CURRENCY]</div></td>
</tr>
</tbody>
</table>
<br />
Bemerkungen:<br />
[REMARKS]<br />
<br />
<br />
Ihre Kundenadresse:<br />
[CUSTOMER_COMPANY]<br />
[CUSTOMER_FIRSTNAME] [CUSTOMER_LASTNAME]<br />
[CUSTOMER_ADDRESS]<br />
[CUSTOMER_ZIP] [CUSTOMER_CITY]<br />
[CUSTOMER_COUNTRY]<br /><!--[[SHIPPING_ADDRESS]-->
<br />
<br />
Lieferadresse:<br />
[SHIPPING_COMPANY]<br />
[SHIPPING_FIRSTNAME] [SHIPPING_LASTNAME]<br />
[SHIPPING_ADDRESS]<br />
[SHIPPING_ZIP] [SHIPPING_CITY]<br />
[SHIPPING_COUNTRY]<br /><!--[SHIPPING_ADDRESS]]-->
<br />
<br />
Ihr Link zum Online Store: [SHOP_HOMEPAGE]<br /><!--[[CUSTOMER_LOGIN]-->
<br />
Ihre Zugangsdaten zum Shop:<br />
Benutzername:   [CUSTOMER_USERNAME]<br />
Passwort:       [CUSTOMER_PASSWORD]<br /><!--[CUSTOMER_LOGIN]]-->
<br />
Wir freuen uns auf Ihren n&auml;chsten Besuch im [SHOP_COMPANY] Online Store und w&uuml;nschen Ihnen noch einen sch&ouml;nen Tag.<br />
<br />
P.S. Diese Auftragsbest&auml;tigung wurde gesendet an: [CUSTOMER_EMAIL]<br />
<br />
Mit freundlichen Gr&uuml;ssen<br />
Ihr [SHOP_COMPANY] Online Shop Team<br />
<br />
[SHOP_HOMEPAGE]<br />
<br />
EOF
, 'protected' => true, 'html' => true));
            }
            if (!\Cx\Core\MailTemplate\Controller\MailTemplate::get('Shop', 'order_complete', $lang_id)) {
                \Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', array('lang_id' => $lang_id, 'key' => 'order_complete', 'name' => 'Auftrag abgeschlossen', 'from' => isset($arrFrom[2]) ? $arrFrom[2] : '', 'sender' => isset($arrSender[2]) ? $arrSender[2] : '', 'to' => '[CUSTOMER_EMAIL]', 'subject' => isset($arrSubject[2]) ? $arrSubject[2] : '', 'message' => <<<EOF
[CUSTOMER_SALUTATION]

Ihre Bestellung wurde ausgeführt. Sie werden in den nächsten Tagen ihre Lieferung erhalten.

Herzlichen Dank für das Vertrauen.
Wir würden uns freuen, wenn Sie uns weiterempfehlen und wünschen Ihnen noch einen schönen Tag.

Mit freundlichen Grüssen
Ihr [SHOP_COMPANY] Online Shop Team

[SHOP_HOMEPAGE]
EOF
, 'message_html' => <<<EOF
[CUSTOMER_SALUTATION]<br />
<br />
Ihre Bestellung wurde ausgeführt. Sie werden in den nächsten Tagen ihre Lieferung erhalten.<br />
<br />
Herzlichen Dank für das Vertrauen.<br />
Wir würden uns freuen, wenn Sie uns weiterempfehlen und wünschen Ihnen noch einen schönen Tag.<br />
<br />
Mit freundlichen Grüssen<br />
Ihr [SHOP_COMPANY] Online Shop Team<br />
<br />
[SHOP_HOMEPAGE]<br />
EOF
, 'protected' => true, 'html' => true));
            }
            if (!\Cx\Core\MailTemplate\Controller\MailTemplate::get('Shop', 'customer_login', $lang_id)) {
                \Cx\Core\MailTemplate\Controller\MailTemplate::store('Shop', array('lang_id' => $lang_id, 'key' => 'customer_login', 'name' => 'Logindaten', 'from' => isset($arrFrom[3]) ? $arrFrom[3] : '', 'sender' => isset($arrSender[3]) ? $arrSender[3] : '', 'to' => '[CUSTOMER_EMAIL]', 'subject' => isset($arrSubject[3]) ? $arrSubject[3] : '', 'message' => <<<EOF
[CUSTOMER_SALUTATION]

Hier Ihre Zugangsdaten zum Shop:[[CUSTOMER_LOGIN]
Benutzername: [CUSTOMER_USERNAME]
Passwort: [CUSTOMER_PASSWORD][CUSTOMER_LOGIN]]

Mit freundlichen Grüssen
Ihr [SHOP_COMPANY] Online Shop Team

[SHOP_HOMEPAGE]
EOF
, 'message_html' => <<<EOF
[CUSTOMER_SALUTATION]<br />
<br />
Hier Ihre Zugangsdaten zum Shop:<br /><!--[[CUSTOMER_LOGIN]-->
Benutzername: [CUSTOMER_USERNAME]<br />
Passwort: [CUSTOMER_PASSWORD]<br /><!--[CUSTOMER_LOGIN]]-->
<br />
Mit freundlichen Gr&uuml;ssen<br />
Ihr [SHOP_COMPANY] Online Shop Team<br />
<br />
[SHOP_HOMEPAGE]<br />
EOF
, 'protected' => true, 'html' => true));
            }
        }
        // Always!
        return false;
    }