Ejemplo n.º 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;
}
Ejemplo n.º 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;
}
Ejemplo n.º 3
0
function _crmUpdate()
{
    global $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_contacts', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'customer_id' => array('type' => 'VARCHAR(256)', 'notnull' => false, 'after' => 'id'), 'customer_type' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'customer_id'), 'customer_name' => array('type' => 'VARCHAR(256)', 'notnull' => false, 'after' => 'customer_type'), 'customer_website' => array('type' => 'VARCHAR(256)', 'notnull' => false, 'after' => 'customer_name'), 'customer_addedby' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'customer_website'), 'customer_currency' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'customer_addedby'), 'contact_familyname' => array('type' => 'VARCHAR(256)', 'notnull' => false, 'after' => 'customer_currency'), 'contact_role' => array('type' => 'VARCHAR(256)', 'notnull' => false, 'after' => 'contact_familyname'), 'contact_customer' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'contact_role'), 'contact_language' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'contact_customer'), 'gender' => array('type' => 'TINYINT(2)', 'after' => 'contact_language'), 'notes' => array('type' => 'text', 'notnull' => false, 'after' => 'gender'), 'industry_type' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'notes'), 'contact_type' => array('type' => 'TINYINT(2)', 'notnull' => false, 'after' => 'industry_type'), 'user_account' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'contact_type'), 'datasource' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'user_account'), 'profile_picture' => array('type' => 'VARCHAR(256)', 'after' => 'datasource'), 'status' => array('type' => 'TINYINT(2)', 'notnull' => true, 'default' => '1', 'after' => 'profile_picture'), 'added_date' => array('type' => 'date', 'after' => 'status')), array('contact_customer' => array('fields' => array('contact_customer')), 'customer_id' => array('fields' => array('customer_id')), 'customer_name' => array('fields' => array('customer_name')), 'contact_familyname' => array('fields' => array('contact_familyname')), 'contact_role' => array('fields' => array('contact_role')), 'customer_id_2' => array('fields' => array('customer_id', 'customer_name', 'contact_familyname', 'contact_role', 'notes'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_currency', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(400)', 'after' => 'id'), 'active' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1', 'after' => 'name'), 'pos' => array('type' => 'INT(5)', 'notnull' => true, 'default' => '0', 'after' => 'active'), 'hourly_rate' => array('type' => 'text', 'after' => 'pos'), 'default_currency' => array('type' => 'TINYINT(1)', 'after' => 'hourly_rate')), array('name' => array('fields' => array('name' => 333)), 'name_2' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_comment', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'customer_id' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'id'), 'notes_type_id' => array('type' => 'INT(1)', 'after' => 'customer_id'), 'user_id' => array('type' => 'INT(11)', 'after' => 'notes_type_id'), 'date' => array('type' => 'date', 'after' => 'user_id'), 'comment' => array('type' => 'text', 'notnull' => false, 'after' => 'date'), 'added_date' => array('type' => 'datetime', 'notnull' => false, 'after' => 'comment'), 'updated_by' => array('type' => 'INT(11)', 'notnull' => false, 'after' => 'added_date'), 'updated_on' => array('type' => 'datetime', 'notnull' => false, 'after' => 'updated_by')), array('customer_id' => array('fields' => array('customer_id')), 'comment' => array('fields' => array('comment'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_contact_address', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'address' => array('type' => 'VARCHAR(256)', 'after' => 'id'), 'city' => array('type' => 'VARCHAR(256)', 'after' => 'address'), 'state' => array('type' => 'VARCHAR(256)', 'after' => 'city'), 'zip' => array('type' => 'VARCHAR(256)', 'after' => 'state'), 'country' => array('type' => 'VARCHAR(256)', 'after' => 'zip'), 'Address_Type' => array('type' => 'TINYINT(4)', 'after' => 'country'), 'is_primary' => array('type' => 'ENUM(\'0\',\'1\')', 'after' => 'Address_Type'), 'contact_id' => array('type' => 'INT(11)', 'after' => 'is_primary')), array('contact_id' => array('fields' => array('contact_id')), 'address' => array('fields' => array('address')), 'city' => array('fields' => array('city')), 'state' => array('fields' => array('state')), 'zip' => array('fields' => array('zip')), 'country' => array('fields' => array('country')), 'address_2' => array('fields' => array('address', 'city', 'state', 'zip', 'country'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_contact_emails', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'email' => array('type' => 'VARCHAR(256)', 'after' => 'id'), 'email_type' => array('type' => 'TINYINT(4)', 'after' => 'email'), 'is_primary' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => false, 'default' => '0', 'after' => 'email_type'), 'contact_id' => array('type' => 'INT(11)', 'after' => 'is_primary')), array('contact_id' => array('fields' => array('contact_id')), 'email' => array('fields' => array('email')), 'email_2' => array('fields' => array('email'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_contact_phone', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'phone' => array('type' => 'VARCHAR(256)', 'after' => 'id'), 'phone_type' => array('type' => 'TINYINT(4)', 'after' => 'phone'), 'is_primary' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => false, 'default' => '0', 'after' => 'phone_type'), 'contact_id' => array('type' => 'INT(11)', 'after' => 'is_primary')), array('contact_id' => array('fields' => array('contact_id')), 'phone' => array('fields' => array('phone')), 'phone_2' => array('fields' => array('phone'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_contact_social_network', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'url' => array('type' => 'VARCHAR(256)', 'after' => 'id'), 'url_profile' => array('type' => 'TINYINT(4)', 'after' => 'url'), 'is_primary' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => false, 'default' => '0', 'after' => 'url_profile'), 'contact_id' => array('type' => 'INT(11)', 'after' => 'is_primary')), array('contact_id' => array('fields' => array('contact_id')), 'url' => array('fields' => array('url')), 'url_2' => array('fields' => array('url'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_contact_websites', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'url' => array('type' => 'VARCHAR(256)', 'after' => 'id'), 'url_type' => array('type' => 'TINYINT(4)', 'after' => 'url'), 'url_profile' => array('type' => 'TINYINT(4)', 'after' => 'url_type'), 'is_primary' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => false, 'default' => '0', 'after' => 'url_profile'), 'contact_id' => array('type' => 'INT(11)', 'after' => 'is_primary')), array('contact_id' => array('fields' => array('contact_id')), 'url' => array('fields' => array('url')), 'url_2' => array('fields' => array('url'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_customer_types', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'label' => array('type' => 'VARCHAR(250)', 'after' => 'id'), 'hourly_rate' => array('type' => 'VARCHAR(256)', 'after' => 'label'), 'active' => array('type' => 'INT(1)', 'after' => 'hourly_rate'), 'pos' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0', 'after' => 'active'), 'default' => array('type' => 'TINYINT(2)', 'notnull' => true, 'default' => '0', 'after' => 'pos')), array('label' => array('fields' => array('label')), 'label_2' => array('fields' => array('label'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_industry_type_local', array('entry_id' => array('type' => 'INT(11)'), 'lang_id' => array('type' => 'INT(11)', 'after' => 'entry_id'), 'value' => array('type' => 'VARCHAR(256)', 'after' => 'lang_id')), array('entry_id' => array('fields' => array('entry_id')), 'value' => array('fields' => array('value')), 'value_2' => array('fields' => array('value'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_membership_local', array('entry_id' => array('type' => 'INT(11)'), 'lang_id' => array('type' => 'INT(11)', 'after' => 'entry_id'), 'value' => array('type' => 'VARCHAR(256)', 'after' => 'lang_id')), array('entry_id' => array('fields' => array('entry_id')), 'value' => array('fields' => array('value')), 'value_2' => array('fields' => array('value'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_notes', array('id' => array('type' => 'INT(1)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'id'), 'status' => array('type' => 'TINYINT(1)', 'after' => 'name'), 'icon' => array('type' => 'VARCHAR(255)', 'after' => 'status'), 'pos' => array('type' => 'INT(1)', 'after' => 'icon'), 'system_defined' => array('type' => 'TINYINT(2)', 'notnull' => true, 'default' => '0', 'after' => 'pos')), array('name' => array('fields' => array('name')), 'name_2' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_crm_task_types', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(256)', 'after' => 'id'), 'status' => array('type' => 'TINYINT(1)', 'after' => 'name'), 'sorting' => array('type' => 'INT(11)', 'after' => 'status'), 'description' => array('type' => 'text', 'after' => 'sorting'), 'icon' => array('type' => 'VARCHAR(255)', 'after' => 'description'), 'system_defined' => array('type' => 'TINYINT(4)', 'after' => 'icon')), array('name' => array('fields' => array('name')), 'name_2' => array('fields' => array('name'), 'type' => 'FULLTEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.2.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql('SELECT `id` FROM `' . DBPREFIX . 'core_text` WHERE `section` = \'crm\'');
            if ($result && $result->RecordCount() > 0) {
                // emails have been already migrated, stop
                return true;
            }
            // migrate mail templates
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_bcc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_cc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_from\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_message\', \'Guten Tag,\\r\\n\\r\\nNachfolgend erhalten Sie Ihre persönlichen Zugangsdaten zur Website http://www.example.com/\\r\\n\\r\\nBenutzername: [CRM_CONTACT_USERNAME]\\r\\nKennwort: [CRM_CONTACT_PASSWORD]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_message_html\', \'<div>Guten Tag,<br />\\r\\n<br />\\r\\nNachfolgend erhalten Sie Ihre pers&ouml;nlichen Zugangsdaten zur Website <a href="http://www.example.com/">http://www.example.com/</a><br />\\r\\n<br />\\r\\nBenutzername: [CRM_CONTACT_USERNAME]<br />\\r\\nKennwort: [CRM_CONTACT_PASSWORD]</div>\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_name\', \'Benachrichtigung über Benutzerkonto\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_reply\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_sender\', \'Ihr Firmenname\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_subject\', \'Ihr persönlischer Zugang\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(12, 1, \'crm\', \'core_mail_template_to\', \'[CRM_CONTACT_EMAIL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_bcc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_cc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_from\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_message\', \'Der Mitarbeiter [CRM_TASK_CREATED_USER] hat eine neue Aufgabe erstellt und Ihnen zugewiesen: [CRM_TASK_URL]\\r\\n\\r\\nBeschreibung: [CRM_TASK_DESCRIPTION_TEXT_VERSION]\\r\\n\\r\\nFällig am: [CRM_TASK_DUE_DATE]\\r\\n\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_message_html\', \'<div style="padding:0px; margin:0px; font-family:Tahoma, sans-serif; font-size:14px; width:620px; color: #333;">\\r\\n<div style="padding: 0px 20px; border:1px solid #e0e0e0; margin-bottom: 10px; width:618px;">\\r\\n<h1 style="background-color: #e0e0e0;color: #3d4a6b;font-size: 18px;font-weight: normal;padding: 15px 20px;margin-top: 0 !important;margin-bottom: 0 !important;margin-left: -20px !important;margin-right: -20px !important;-webkit-margin-before: 0 !important;-webkit-margin-after: 0 !important;-webkit-margin-start: -20px !important;-webkit-margin-end: -20px !important;">Neue Aufgabe wurde Ihnen zugewiesen</h1>\\r\\n\\r\\n<p style="margin-top: 20px;word-wrap: break-word !important;">Der Mitarbeiter [CRM_TASK_CREATED_USER] hat eine neue Aufgabe erstellt und Ihnen zugewiesen: [CRM_TASK_LINK]</p>\\r\\n\\r\\n<p style="margin-top: 20px;word-wrap: break-word !important;">Beschreibung: [CRM_TASK_DESCRIPTION_HTML_VERSION]<br />\\r\\nF&auml;llig am: [CRM_TASK_DUE_DATE]</p>\\r\\n</div>\\r\\n</div>\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_name\', \'Neue Aufgabe\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_reply\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_sender\', \'Ihr Firmenname\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_subject\', \'Neue Aufgabe : [CRM_TASK_NAME]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(13, 1, \'crm\', \'core_mail_template_to\', \'[CRM_ASSIGNED_USER_EMAIL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_bcc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_cc\', \'\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_from\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_message\', \'Im CRM wurde ein neuer Kontakt erfasst: [CRM_CONTACT_DETAILS_URL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_message_html\', \'<div style="padding:0px; margin:0px; font-family:Tahoma, sans-serif; font-size:14px; width:620px; color: #333;">\\r\\n<div style="padding: 0px 20px; border:1px solid #e0e0e0; margin-bottom: 10px; width:618px;">\\r\\n<h1 style="background-color: #e0e0e0;color: #3d4a6b;font-size: 18px;font-weight: normal;padding: 15px 20px;margin-top: 0 !important;margin-bottom: 0 !important;margin-left: -20px !important;margin-right: -20px !important;-webkit-margin-before: 0 !important;-webkit-margin-after: 0 !important;-webkit-margin-start: -20px !important;-webkit-margin-end: -20px !important;">Neuer Kontakt im CRM</h1>\\r\\n\\r\\n<p style="margin-top: 20px;word-wrap: break-word !important;">Neuer Kontakt: [CRM_CONTACT_DETAILS_LINK].</p>\\r\\n</div>\\r\\n</div>\\r\\n\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_name\', \'Benachrichtigung an Mitarbeiter über neue Kontakte\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_reply\', \'info@example.com\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_sender\', \'Ihr Firmenname\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_subject\', \'Neuer Kontakt erfasst\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_text` (`id`, `lang_id`, `section`, `key`, `text`) VALUES(14, 1, \'crm\', \'core_mail_template_to\', \'[CRM_ASSIGNED_USER_EMAIL]\')');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_mail_template` (`key`, `section`, `text_id`, `html`, `protected`) VALUES(\'crm_user_account_created\', \'crm\', 12, 1, 1)');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_mail_template` (`key`, `section`, `text_id`, `html`, `protected`) VALUES(\'crm_notify_staff_on_contact_added\', \'crm\', 14, 1, 1)');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_mail_template` (`key`, `section`, `text_id`, `html`, `protected`) VALUES(\'crm_task_assigned\', \'crm\', 13, 1, 1)');
            \Cx\Lib\UpdateUtil::sql('INSERT IGNORE INTO `' . DBPREFIX . 'core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES (\'crm\',\'numof_mailtemplate_per_page_backend\',\'config\',\'text\',\'25\',\'\',1001)');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
function _calendarUpdate()
{
    global $objDatabase;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'primary' => true, 'auto_increment' => true), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'id'), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'active'), 'startdate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'catid'), 'enddate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'startdate'), 'priority' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '3', 'after' => 'enddate'), 'access' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'priority'), 'name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'access'), 'comment' => array('type' => 'text', 'after' => 'name'), 'placeName' => array('type' => 'VARCHAR(255)', 'after' => 'comment'), 'link' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => 'http://', 'after' => 'placeName'), 'pic' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'link'), 'attachment' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'pic'), 'placeStreet' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'attachment'), 'placeZip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeStreet'), 'placeCity' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeZip'), 'placeLink' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeCity'), 'placeMap' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeLink'), 'organizerName' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'placeMap'), 'organizerStreet' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerName'), 'organizerZip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerStreet'), 'organizerPlace' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerZip'), 'organizerMail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerPlace'), 'organizerLink' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerMail'), 'key' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'organizerLink'), 'num' => array('type' => 'INT(5)', 'notnull' => true, 'default' => '0', 'after' => 'key'), 'mailTitle' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'num'), 'mailContent' => array('type' => 'text', 'after' => 'mailTitle'), 'registration' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'mailContent'), 'groups' => array('type' => 'text', 'after' => 'registration'), 'all_groups' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'groups'), 'public' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'all_groups'), 'notification' => array('type' => 'INT(1)', 'after' => 'public'), 'notification_address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'notification'), 'series_status' => array('type' => 'TINYINT(4)', 'after' => 'notification_address'), 'series_type' => array('type' => 'INT(11)', 'after' => 'series_status'), 'series_pattern_count' => array('type' => 'INT(11)', 'after' => 'series_type'), 'series_pattern_weekday' => array('type' => 'VARCHAR(7)', 'after' => 'series_pattern_count'), 'series_pattern_day' => array('type' => 'INT(11)', 'after' => 'series_pattern_weekday'), 'series_pattern_week' => array('type' => 'INT(11)', 'after' => 'series_pattern_day'), 'series_pattern_month' => array('type' => 'INT(11)', 'after' => 'series_pattern_week'), 'series_pattern_type' => array('type' => 'INT(11)', 'after' => 'series_pattern_month'), 'series_pattern_dourance_type' => array('type' => 'INT(11)', 'after' => 'series_pattern_type'), 'series_pattern_end' => array('type' => 'INT(11)', 'after' => 'series_pattern_dourance_type'), 'series_pattern_begin' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_end'), 'series_pattern_exceptions' => array('type' => 'longtext', 'after' => 'series_pattern_begin')), array('name' => array('fields' => array('name', 'comment', 'placeName'), 'type' => 'FULLTEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    //2.1.1
    $query = "SELECT status FROM " . DBPREFIX . "modules WHERE id='21'";
    $objResultCheck = $objDatabase->SelectLimit($query, 1);
    if ($objResultCheck !== false) {
        if ($objResultCheck->fields['status'] == 'y') {
            $calendarStatus = true;
        } else {
            $calendarStatus = false;
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    if ($calendarStatus) {
        $arrContentSites = array();
        $arrContentSites[0]['module'] = 'calendar';
        $arrContentSites[0]['cmd'] = '';
        $arrContentSites[1]['module'] = 'calendar';
        $arrContentSites[1]['cmd'] = 'eventlist';
        $arrContentSites[2]['module'] = 'calendar';
        $arrContentSites[2]['cmd'] = 'boxes';
        //insert new link placeholder in content, if module is active
        foreach ($arrContentSites as $key => $siteArray) {
            $module = $siteArray['module'];
            $cmd = $siteArray['cmd'];
            try {
                \Cx\Lib\UpdateUtil::migrateContentPage($module, $cmd, '<a href="index.php?section=calendar&amp;cmd=event&amp;id={CALENDAR_ID}">{CALENDAR_TITLE}</a>', '{CALENDAR_DETAIL_LINK}', '3.0.0');
            } catch (\Cx\Lib\UpdateException $e) {
                return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
            }
        }
        try {
            \Cx\Lib\UpdateUtil::migrateContentPage('calendar', 'sign', '<input type="hidden" name="id" value="{CALENDAR_NOTE_ID}" />', '<input type="hidden" name="id" value="{CALENDAR_NOTE_ID}" /><input type="hidden" name="date" value="{CALENDAR_NOTE_DATE}" />', '3.0.0');
            \Cx\Lib\UpdateUtil::migrateContentPage('calendar', 'sign', '<a href="index.php?section=calendar&amp;id={CALENDAR_NOTE_ID}">{TXT_CALENDAR_BACK}</a>', '{CALENDAR_LINK_BACK}', '3.0.0');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    try {
        // delete obsolete table  contrexx_module_calendar_access
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_calendar_access');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_form_data', array('reg_id' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0'), 'field_id' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0'), 'data' => array('type' => 'TEXT', 'notnull' => true)));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_form_fields', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'note_id' => array('type' => 'INT(10)', 'notnull' => true, 'default' => '0'), 'name' => array('type' => 'TEXT'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0'), 'required' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0'), 'order' => array('type' => 'INT(3)', 'notnull' => true, 'default' => '0'), 'key' => array('type' => 'INT(7)', 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_registrations', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'note_id' => array('type' => 'INT(7)', 'notnull' => true, 'default' => '0'), 'note_date' => array('type' => 'INT(11)', 'notnull' => true, 'after' => 'note_id'), 'time' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'host' => array('type' => 'VARCHAR(255)'), 'ip_address' => array('type' => 'VARCHAR(15)'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    global $objUpdate;
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        $CalendarUpdate31 = new CalendarUpdate31();
        $calendarUpdateFeedback = $CalendarUpdate31->run();
        if ($calendarUpdateFeedback !== true) {
            return $calendarUpdateFeedback;
        }
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.2.0')) {
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_event', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'startdate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'type'), 'enddate' => array('type' => 'INT(14)', 'notnull' => false, 'after' => 'startdate'), 'startdate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'enddate'), 'enddate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate_timestamp'), 'use_custom_date_display' => array('type' => 'TINYINT(1)', 'after' => 'enddate_timestamp'), 'showStartDateList' => array('type' => 'INT(1)', 'after' => 'use_custom_date_display'), 'showEndDateList' => array('type' => 'INT(1)', 'after' => 'showStartDateList'), 'showStartTimeList' => array('type' => 'INT(1)', 'after' => 'showEndDateList'), 'showEndTimeList' => array('type' => 'INT(1)', 'after' => 'showStartTimeList'), 'showTimeTypeList' => array('type' => 'INT(1)', 'after' => 'showEndTimeList'), 'showStartDateDetail' => array('type' => 'INT(1)', 'after' => 'showTimeTypeList'), 'showEndDateDetail' => array('type' => 'INT(1)', 'after' => 'showStartDateDetail'), 'showStartTimeDetail' => array('type' => 'INT(1)', 'after' => 'showEndDateDetail'), 'showEndTimeDetail' => array('type' => 'INT(1)', 'after' => 'showStartTimeDetail'), 'showTimeTypeDetail' => array('type' => 'INT(1)', 'after' => 'showEndTimeDetail'), 'google' => array('type' => 'INT(11)', 'after' => 'showTimeTypeDetail'), 'access' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'google'), 'priority' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '3', 'after' => 'access'), 'price' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'priority'), 'link' => array('type' => 'VARCHAR(255)', 'after' => 'price'), 'pic' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'link'), 'attach' => array('type' => 'VARCHAR(255)', 'after' => 'pic'), 'place_mediadir_id' => array('type' => 'INT(11)', 'after' => 'attach'), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'place_mediadir_id'), 'show_in' => array('type' => 'VARCHAR(255)', 'after' => 'catid'), 'invited_groups' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'show_in'), 'invited_mails' => array('type' => 'mediumtext', 'notnull' => false, 'after' => 'invited_groups'), 'invitation_sent' => array('type' => 'INT(1)', 'after' => 'invited_mails'), 'invitation_email_template' => array('type' => 'VARCHAR(255)', 'after' => 'invitation_sent'), 'registration' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'invitation_email_template'), 'registration_form' => array('type' => 'INT(11)', 'after' => 'registration'), 'registration_num' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'registration_form'), 'registration_notification' => array('type' => 'VARCHAR(1024)', 'notnull' => false, 'after' => 'registration_num'), 'email_template' => array('type' => 'VARCHAR(255)', 'after' => 'registration_notification'), 'ticket_sales' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email_template'), 'num_seating' => array('type' => 'text', 'after' => 'ticket_sales'), 'series_status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0', 'after' => 'num_seating'), 'series_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_status'), 'series_pattern_count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_type'), 'series_pattern_weekday' => array('type' => 'VARCHAR(7)', 'after' => 'series_pattern_count'), 'series_pattern_day' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_weekday'), 'series_pattern_week' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_day'), 'series_pattern_month' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_week'), 'series_pattern_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_month'), 'series_pattern_dourance_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_type'), 'series_pattern_end' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_dourance_type'), 'series_pattern_end_date' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'series_pattern_end'), 'series_pattern_begin' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_end_date'), 'series_pattern_exceptions' => array('type' => 'longtext', 'after' => 'series_pattern_begin'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'series_pattern_exceptions'), 'confirmed' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'status'), 'author' => array('type' => 'VARCHAR(255)', 'after' => 'confirmed'), 'all_day' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'author'), 'location_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'all_day'), 'place' => array('type' => 'VARCHAR(255)', 'after' => 'location_type'), 'place_id' => array('type' => 'INT(11)', 'after' => 'place'), 'place_street' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_id'), 'place_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'after' => 'place_street'), 'place_city' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_zip'), 'place_country' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_city'), 'place_link' => array('type' => 'VARCHAR(255)', 'after' => 'place_country'), 'place_map' => array('type' => 'VARCHAR(255)', 'after' => 'place_link'), 'host_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'place_map'), 'org_name' => array('type' => 'VARCHAR(255)', 'after' => 'host_type'), 'org_street' => array('type' => 'VARCHAR(255)', 'after' => 'org_name'), 'org_zip' => array('type' => 'VARCHAR(10)', 'after' => 'org_street'), 'org_city' => array('type' => 'VARCHAR(255)', 'after' => 'org_zip'), 'org_country' => array('type' => 'VARCHAR(255)', 'after' => 'org_city'), 'org_link' => array('type' => 'VARCHAR(255)', 'after' => 'org_country'), 'org_email' => array('type' => 'VARCHAR(255)', 'after' => 'org_link'), 'host_mediadir_id' => array('type' => 'INT(11)', 'after' => 'org_email')), array('fk_contrexx_module_calendar_notes_contrexx_module_calendar_ca1' => array('fields' => array('catid'))));
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        try {
            \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET `startdate_timestamp` = FROM_UNIXTIME(`startdate`), `enddate_timestamp` = FROM_UNIXTIME(`enddate`)');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_calendar_event', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'startdate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'type'), 'enddate' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate'), 'startdate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'enddate'), 'enddate_timestamp' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'startdate_timestamp'), 'use_custom_date_display' => array('type' => 'TINYINT(1)', 'after' => 'enddate_timestamp'), 'showStartDateList' => array('type' => 'INT(1)', 'after' => 'use_custom_date_display'), 'showEndDateList' => array('type' => 'INT(1)', 'after' => 'showStartDateList'), 'showStartTimeList' => array('type' => 'INT(1)', 'after' => 'showEndDateList'), 'showEndTimeList' => array('type' => 'INT(1)', 'after' => 'showStartTimeList'), 'showTimeTypeList' => array('type' => 'INT(1)', 'after' => 'showEndTimeList'), 'showStartDateDetail' => array('type' => 'INT(1)', 'after' => 'showTimeTypeList'), 'showEndDateDetail' => array('type' => 'INT(1)', 'after' => 'showStartDateDetail'), 'showStartTimeDetail' => array('type' => 'INT(1)', 'after' => 'showEndDateDetail'), 'showEndTimeDetail' => array('type' => 'INT(1)', 'after' => 'showStartTimeDetail'), 'showTimeTypeDetail' => array('type' => 'INT(1)', 'after' => 'showEndTimeDetail'), 'google' => array('type' => 'INT(11)', 'after' => 'showTimeTypeDetail'), 'access' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'google'), 'priority' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '3', 'after' => 'access'), 'price' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'priority'), 'link' => array('type' => 'VARCHAR(255)', 'after' => 'price'), 'pic' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'link'), 'attach' => array('type' => 'VARCHAR(255)', 'after' => 'pic'), 'place_mediadir_id' => array('type' => 'INT(11)', 'after' => 'attach'), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'place_mediadir_id'), 'show_in' => array('type' => 'VARCHAR(255)', 'after' => 'catid'), 'invited_groups' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'show_in'), 'invited_mails' => array('type' => 'mediumtext', 'notnull' => false, 'after' => 'invited_groups'), 'invitation_sent' => array('type' => 'INT(1)', 'after' => 'invited_mails'), 'invitation_email_template' => array('type' => 'VARCHAR(255)', 'after' => 'invitation_sent'), 'registration' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'invitation_email_template'), 'registration_form' => array('type' => 'INT(11)', 'after' => 'registration'), 'registration_num' => array('type' => 'VARCHAR(45)', 'notnull' => false, 'after' => 'registration_form'), 'registration_notification' => array('type' => 'VARCHAR(1024)', 'notnull' => false, 'after' => 'registration_num'), 'email_template' => array('type' => 'VARCHAR(255)', 'after' => 'registration_notification'), 'ticket_sales' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email_template'), 'num_seating' => array('type' => 'text', 'after' => 'ticket_sales'), 'series_status' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '0', 'after' => 'num_seating'), 'series_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_status'), 'series_pattern_count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_type'), 'series_pattern_weekday' => array('type' => 'VARCHAR(7)', 'after' => 'series_pattern_count'), 'series_pattern_day' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_weekday'), 'series_pattern_week' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_day'), 'series_pattern_month' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_week'), 'series_pattern_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_month'), 'series_pattern_dourance_type' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_type'), 'series_pattern_end' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_dourance_type'), 'series_pattern_end_date' => array('type' => 'timestamp', 'notnull' => true, 'default' => '0000-00-00 00:00:00', 'after' => 'series_pattern_end'), 'series_pattern_begin' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'series_pattern_end_date'), 'series_pattern_exceptions' => array('type' => 'longtext', 'after' => 'series_pattern_begin'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'series_pattern_exceptions'), 'confirmed' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'status'), 'author' => array('type' => 'VARCHAR(255)', 'after' => 'confirmed'), 'all_day' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'author'), 'location_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'all_day'), 'place' => array('type' => 'VARCHAR(255)', 'after' => 'location_type'), 'place_id' => array('type' => 'INT(11)', 'after' => 'place'), 'place_street' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_id'), 'place_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'after' => 'place_street'), 'place_city' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_zip'), 'place_country' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'place_city'), 'place_link' => array('type' => 'VARCHAR(255)', 'after' => 'place_country'), 'place_map' => array('type' => 'VARCHAR(255)', 'after' => 'place_link'), 'host_type' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '1', 'after' => 'place_map'), 'org_name' => array('type' => 'VARCHAR(255)', 'after' => 'host_type'), 'org_street' => array('type' => 'VARCHAR(255)', 'after' => 'org_name'), 'org_zip' => array('type' => 'VARCHAR(10)', 'after' => 'org_street'), 'org_city' => array('type' => 'VARCHAR(255)', 'after' => 'org_zip'), 'org_country' => array('type' => 'VARCHAR(255)', 'after' => 'org_city'), 'org_link' => array('type' => 'VARCHAR(255)', 'after' => 'org_country'), 'org_email' => array('type' => 'VARCHAR(255)', 'after' => 'org_link'), 'host_mediadir_id' => array('type' => 'INT(11)', 'after' => 'org_email')), array('fk_contrexx_module_calendar_notes_contrexx_module_calendar_ca1' => array('fields' => array('catid'))));
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        try {
            \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET `startdate` = `startdate_timestamp`, `enddate` = `enddate_timestamp`');
            if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_calendar_event', 'startdate_timestamp')) {
                \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_calendar_event` DROP COLUMN `startdate_timestamp`');
            }
            if (\Cx\Lib\UpdateUtil::column_exist(DBPREFIX . 'module_calendar_event', 'enddate_timestamp')) {
                \Cx\Lib\UpdateUtil::sql('ALTER TABLE `' . DBPREFIX . 'module_calendar_event` DROP COLUMN `enddate_timestamp`');
            }
            \Cx\LIb\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET `series_pattern_end_date` = FROM_UNIXTIME(`series_pattern_end`)');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    // update calendar data to version 3.2.0
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.2.0')) {
        $languages = FWLanguage::getLanguageArray();
        try {
            $result = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `invitation_email_template`, `email_template` FROM `' . DBPREFIX . 'module_calendar_event`');
            if ($result && $result->RecordCount() > 0) {
                while (!$result->EOF) {
                    // if the event has been already migrated, continue
                    if (intval($result->fields['invitation_email_template']) != $result->fields['invitation_email_template']) {
                        $result->MoveNext();
                        continue;
                    }
                    $invitationEmailTemplate = array();
                    $emailTemplate = array();
                    foreach ($languages as $langId => $langData) {
                        $invitationEmailTemplate[$langId] = $result->fields['invitation_email_template'];
                        $emailTemplate[$langId] = $result->fields['email_template'];
                    }
                    $invitationEmailTemplate = json_encode($invitationEmailTemplate);
                    $emailTemplate = json_encode($emailTemplate);
                    \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_calendar_event` SET
                                            `invitation_email_template`=\'' . contrexx_raw2db($invitationEmailTemplate) . '\',
                                            `email_template`=\'' . contrexx_raw2db($emailTemplate) . '\' WHERE `id`=' . intval($result->fields['id']));
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Ejemplo n.º 6
0
function _updateSettings()
{
    global $objUpdate, $objDatabase, $_ARRAYLANG, $_CORELANG, $_CONFIG, $arrSettings, $arrSettingsByName;
    // TODO: Unused
    //    $setVars = false;
    $arrSettings = array(3 => array('setname' => 'dnsServer', 'setvalue' => 'ns1.contrexxdns.net', 'setmodule' => 1), 4 => array('setname' => 'bannerStatus', 'setvalue' => '0', 'setmodule' => 28), 5 => array('setname' => 'spamKeywords', 'setvalue' => 'sex, viagra', 'setmodule' => 1), 11 => array('setname' => 'coreAdminName', 'setvalue' => 'Webmaster', 'setmodule' => 1), 18 => array('setname' => 'corePagingLimit', 'setvalue' => '30', 'setmodule' => 1), 19 => array('setname' => 'searchDescriptionLength', 'setvalue' => '150', 'setmodule' => 5), 23 => array('setname' => 'coreIdsStatus', 'setvalue' => 'off', 'setmodule' => 1), 24 => array('setname' => 'coreAdminEmail', 'setvalue' => '*****@*****.**', 'setmodule' => 1), 29 => array('setname' => 'contactFormEmail', 'setvalue' => '*****@*****.**', 'setmodule' => 6), 34 => array('setname' => 'sessionLifeTime', 'setvalue' => '3600', 'setmodule' => 1), 35 => array('setname' => 'lastAccessId', 'setvalue' => '1', 'setmodule' => 1), 37 => array('setname' => 'newsTeasersStatus', 'setvalue' => '0', 'setmodule' => 8), 39 => array('setname' => 'feedNewsMLStatus', 'setvalue' => '0', 'setmodule' => 22), 40 => array('setname' => 'calendarheadlines', 'setvalue' => '1', 'setmodule' => 21), 41 => array('setname' => 'calendarheadlinescount', 'setvalue' => '5', 'setmodule' => 21), 42 => array('setname' => 'blockStatus', 'setvalue' => '1', 'setmodule' => 7), 44 => array('setname' => 'calendarheadlinescat', 'setvalue' => '0', 'setmodule' => 21), 45 => array('setname' => 'calendardefaultcount', 'setvalue' => '16', 'setmodule' => 21), 48 => array('setname' => 'blockRandom', 'setvalue' => '1', 'setmodule' => 7), 49 => array('setname' => 'directoryHomeContent', 'setvalue' => '0', 'setmodule' => 12), 50 => array('setname' => 'cacheEnabled', 'setvalue' => 'off', 'setmodule' => 1), 51 => array('setname' => 'coreGlobalPageTitle', 'setvalue' => 'Contrexx Example Page', 'setmodule' => 1), 52 => array('setname' => 'cacheExpiration', 'setvalue' => '86400', 'setmodule' => 1), 53 => array('setname' => 'domainUrl', 'setvalue' => 'localhost', 'setmodule' => 1), 54 => array('setname' => 'xmlSitemapStatus', 'setvalue' => 'off', 'setmodule' => 1), 55 => array('setname' => 'systemStatus', 'setvalue' => 'on', 'setmodule' => 1), 56 => array('setname' => 'searchVisibleContentOnly', 'setvalue' => 'on', 'setmodule' => 1), 57 => array('setname' => 'protocolHttpsFrontend', 'setvalue' => 'off', 'setmodule' => 1), 58 => array('setname' => 'protocolHttpsBackend', 'setvalue' => 'off', 'setmodule' => 1), 59 => array('setname' => 'forceDomainUrl', 'setvalue' => 'off', 'setmodule' => 1), 60 => array('setname' => 'forumHomeContent', 'setvalue' => '0', 'setmodule' => 20), 62 => array('setname' => 'coreSmtpServer', 'setvalue' => '0', 'setmodule' => 1), 63 => array('setname' => 'languageDetection', 'setvalue' => 'on', 'setmodule' => 1), 64 => array('setname' => 'podcastHomeContent', 'setvalue' => '0', 'setmodule' => 35), 65 => array('setname' => 'googleMapsAPIKey', 'setvalue' => '', 'setmodule' => 1), 66 => array('setname' => 'forumTagContent', 'setvalue' => '0', 'setmodule' => 20), 68 => array('setname' => 'dataUseModule', 'setvalue' => '0', 'setmodule' => 48), 69 => array('setname' => 'frontendEditingStatus', 'setvalue' => 'off', 'setmodule' => 1), 71 => array('setname' => 'coreListProtectedPages', 'setvalue' => 'on', 'setmodule' => 1), 72 => array('setname' => 'useKnowledgePlaceholders', 'setvalue' => '0', 'setmodule' => 56), 73 => array('setname' => 'advancedUploadFrontend', 'setvalue' => 'off', 'setmodule' => 52), 74 => array('setname' => 'advancedUploadBackend', 'setvalue' => 'on', 'setmodule' => 52), 75 => array('setname' => 'installationId', 'setvalue' => '', 'setmodule' => 1), 76 => array('setname' => 'licenseKey', 'setvalue' => '', 'setmodule' => 1), 77 => array('setname' => 'contactCompany', 'setvalue' => 'Ihr Firmenname', 'setmodule' => 1), 78 => array('setname' => 'contactAddress', 'setvalue' => 'Musterstrasse 12', 'setmodule' => 1), 79 => array('setname' => 'contactZip', 'setvalue' => '3600', 'setmodule' => 1), 80 => array('setname' => 'contactPlace', 'setvalue' => 'Musterhausen', 'setmodule' => 1), 81 => array('setname' => 'contactCountry', 'setvalue' => 'Musterland', 'setmodule' => 1), 82 => array('setname' => 'contactPhone', 'setvalue' => '033 123 45 67', 'setmodule' => 1), 83 => array('setname' => 'contactFax', 'setvalue' => '033 123 45 68', 'setmodule' => 1), 84 => array('setname' => 'sessionLifeTimeRememberMe', 'setvalue' => '1209600', 'setmodule' => 1), 85 => array('setname' => 'dashboardNews', 'setvalue' => 'on', 'setmodule' => 1), 86 => array('setname' => 'dashboardStatistics', 'setvalue' => 'on', 'setmodule' => 1), 87 => array('setname' => 'timezone', 'setvalue' => 'Europe/Zurich', 'setmodule' => 1), 88 => array('setname' => 'googleAnalyticsTrackingId', 'setvalue' => '', 'setmodule' => 1), 89 => array('setname' => 'passwordComplexity', 'setvalue' => 'off', 'setmodule' => 1), 90 => array('setname' => 'licenseState', 'setvalue' => 'OK', 'setmodule' => 66), 91 => array('setname' => 'licenseValidTo', 'setvalue' => '', 'setmodule' => 66), 92 => array('setname' => 'coreCmsEdition', 'setvalue' => 'Trial', 'setmodule' => 66), 93 => array('setname' => 'licenseMessage', 'setvalue' => '', 'setmodule' => 66), 94 => array('setname' => 'licenseCreatedAt', 'setvalue' => '', 'setmodule' => 66), 95 => array('setname' => 'licenseDomains', 'setvalue' => '', 'setmodule' => 66), 96 => array('setname' => 'licenseGrayzoneMessages', 'setvalue' => '', 'setmodule' => 66), 97 => array('setname' => 'coreCmsVersion', 'setvalue' => '3.0.4', 'setmodule' => 66), 98 => array('setname' => 'coreCmsCodeName', 'setvalue' => 'Nikola Tesla', 'setmodule' => 66), 99 => array('setname' => 'coreCmsStatus', 'setvalue' => 'Stable', 'setmodule' => 66), 100 => array('setname' => 'coreCmsReleaseDate', 'setvalue' => '12.04.2013', 'setmodule' => 66), 101 => array('setname' => 'licensePartner', 'setvalue' => '', 'setmodule' => 66), 102 => array('setname' => 'licenseCustomer', 'setvalue' => '', 'setmodule' => 66), 103 => array('setname' => 'availableComponents', 'setvalue' => '', 'setmodule' => 66), 104 => array('setname' => 'upgradeUrl', 'setvalue' => 'http://license.contrexx.com/', 'setmodule' => 66), 105 => array('setname' => 'isUpgradable', 'setvalue' => 'off', 'setmodule' => 66), 106 => array('setname' => 'dashboardMessages', 'setvalue' => 'YToxOntzOjI6ImRlIjtPOjMxOiJDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlIjo2OntzOjQxOiIAQ3hcQ29yZV9Nb2R1bGVzXExpY2Vuc2VcTWVzc2FnZQBsYW5nQ29kZSI7czoyOiJkZSI7czozNzoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAdGV4dCI7czo5MjoiU2llIGJlbnV0emVuIGRlbiBSZWxlYXNlIENhbmRpZGF0ZSB2b24gQ29udHJleHggMy4gS2xpY2tlbiBTaWUgaGllciB1bSBOZXVpZ2tlaXRlbiB6dSBzZWhlbiEiO3M6Mzc6IgBDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlAHR5cGUiO3M6MTA6Indhcm5pbmdib3giO3M6Mzc6IgBDeFxDb3JlX01vZHVsZXNcTGljZW5zZVxNZXNzYWdlAGxpbmsiO3M6MjE6ImluZGV4LnBocD9jbWQ9bGljZW5zZSI7czo0MzoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAbGlua1RhcmdldCI7czo1OiJfc2VsZiI7czo0ODoiAEN4XENvcmVfTW9kdWxlc1xMaWNlbnNlXE1lc3NhZ2UAc2hvd0luRGFzaGJvYXJkIjtiOjE7fX0=', 'setmodule' => 66), 112 => array('setname' => 'coreCmsName', 'setvalue' => 'Contrexx', 'setmodule' => 66), 113 => array('setname' => 'useCustomizings', 'setvalue' => 'off', 'setmodule' => 1), 114 => array('setname' => 'licenseGrayzoneTime', 'setvalue' => '14', 'setmodule' => 66), 115 => array('setname' => 'licenseLockTime', 'setvalue' => '10', 'setmodule' => 66), 116 => array('setname' => 'licenseUpdateInterval', 'setvalue' => '24', 'setmodule' => 66), 117 => array('setname' => 'licenseFailedUpdate', 'setvalue' => '0', 'setmodule' => 66), 118 => array('setname' => 'licenseSuccessfulUpdate', 'setvalue' => '0', 'setmodule' => 66), 119 => array('setname' => 'cacheUserCache', 'setvalue' => 'off', 'setmodule' => 1), 120 => array('setname' => 'cacheOPCache', 'setvalue' => 'off', 'setmodule' => 1), 121 => array('setname' => 'cacheUserCacheMemcacheConfig', 'setvalue' => '{\\"ip":\\"127.0.0.1\\",\\"port\\":11211}', 'setmodule' => 1), 122 => array('setname' => 'cacheProxyCacheVarnishConfig', 'setvalue' => '{\\"ip":\\"127.0.0.1\\",\\"port\\":8080}', 'setmodule' => 1));
    $arrSettingsByName = array();
    foreach ($arrSettings as $setid => $data) {
        $arrSettingsByName[$data['setname']] = $setid;
    }
    // change googleSitemapStatus to xmlSitemapStatus
    $query = "SELECT 1 FROM `" . DBPREFIX . "settings` WHERE `setname`='googleSitemapStatus'";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult) {
        if ($objResult->RecordCount() == 1) {
            $query = "UPDATE `" . DBPREFIX . "settings` SET `setname` = 'xmlSitemapStatus' WHERE `setname` = 'googleSitemapStatus'";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    try {
        //remove fileuploader setting
        \Cx\Lib\UpdateUtil::sql('DELETE FROM ' . DBPREFIX . 'settings WHERE setid=70 AND setname="fileUploaderStatus"');
    } catch (\Cx\Lib\UpdateException $e) {
        DBG::trace();
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    foreach ($arrSettings as $setId => $arrSetting) {
        if (!_updateSettingsTable($setId, $arrSetting)) {
            return false;
        }
    }
    $query = "UPDATE `" . DBPREFIX . "settings` SET `setmodule`=1 WHERE `setmodule`=0";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    //timezone (Contrexx 3.0.1)
    $arrTimezoneIdentifiers = timezone_identifiers_list();
    if (isset($_POST['timezone']) && array_key_exists($_POST['timezone'], $arrTimezoneIdentifiers)) {
        $_SESSION['contrexx_update']['update']['timezone'] = $_POST['timezone'];
    }
    if (isset($_SESSION['contrexx_update']['update']['timezone']) && array_key_exists(ContrexxUpdate::_getSessionArray($_SESSION['contrexx_update']['update']['timezone']), $arrTimezoneIdentifiers)) {
        try {
            \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'settings` SET `setvalue` = "' . $arrTimezoneIdentifiers[$_SESSION['contrexx_update']['update']['timezone']] . '" WHERE `setname` = "timezone"');
            // add timezone to $_CONFIG array so it will be written in configuration.php in components/core/core.php
            $_CONFIG['timezone'] = $arrTimezoneIdentifiers[$_SESSION['contrexx_update']['update']['timezone']];
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    } else {
        $selected = -1;
        if (($defaultTimezoneId = array_search(@date_default_timezone_get(), $arrTimezoneIdentifiers)) && !empty($defaultTimezoneId)) {
            $selected = $defaultTimezoneId;
        }
        $options = '<option value="-1"' . ($selected == -1 ? ' selected="selected"' : '') . '>' . $_CORELANG['TXT_PLEASE_SELECT'] . '</option>';
        foreach ($arrTimezoneIdentifiers as $id => $name) {
            $dateTimeZone = new DateTimeZone($name);
            $dateTime = new DateTime('now', $dateTimeZone);
            $timeOffset = $dateTimeZone->getOffset($dateTime);
            $sign = $timeOffset < 0 ? '-' : '+';
            $gmt = 'GMT ' . $sign . gmdate('g:i', $timeOffset);
            $options .= '<option value="' . $id . '"' . ($selected == $id ? ' selected="selected"' : '') . '>' . $name . ' (' . $gmt . ')' . '</option>';
        }
        setUpdateMsg($_CORELANG['TXT_TIMEZONE'], 'title');
        setUpdateMsg($_CORELANG['TXT_TIMEZONE_INTRODUCTION'] . ' <select name="timezone">' . $options . '</select>', 'msg');
        setUpdateMsg('<input type="submit" value="' . $_CORELANG['TXT_UPDATE_NEXT'] . '" name="updateNext" /><input type="hidden" name="processUpdate" id="processUpdate" />', 'button');
        return false;
    }
    // write settings
    $strFooter = '';
    $arrModules = '';
    \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/config/');
    if (!file_exists(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) {
        if (!touch(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) {
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_CREATE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php'));
            setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR'], ASCMS_DOCUMENT_ROOT . '/config/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
            return false;
        }
    }
    \Cx\Lib\FileSystem\FileSystem::makeWritable(ASCMS_DOCUMENT_ROOT . '/config/settings.php');
    if (is_writable(ASCMS_DOCUMENT_ROOT . '/config/settings.php')) {
        try {
            $objFile = new \Cx\Lib\FileSystem\File(ASCMS_DOCUMENT_ROOT . '/config/settings.php');
            //Header & Footer
            $strHeader = "<?php\n";
            $strHeader .= "/**\n";
            $strHeader .= "* This file is generated by the \"settings\"-menu in your CMS.\n";
            $strHeader .= "* Do not try to edit it manually!\n";
            $strHeader .= "*/\n\n";
            $strFooter .= "?>";
            //Get module-names
            $objResult = $objDatabase->Execute('SELECT    id, name FROM ' . DBPREFIX . 'modules');
            if ($objResult->RecordCount() > 0) {
                while (!$objResult->EOF) {
                    $arrModules[$objResult->fields['id']] = $objResult->fields['name'];
                    $objResult->MoveNext();
                }
            }
            //Get values
            $objResult = $objDatabase->Execute('SELECT        setname,
                                                            setmodule,
                                                            setvalue
                                                FROM        ' . DBPREFIX . 'settings
                                                ORDER BY    setmodule ASC,
                                                            setname ASC
                                            ');
            $intMaxLen = 0;
            $arrValues = array();
            while ($objResult && !$objResult->EOF) {
                $intMaxLen = strlen($objResult->fields['setname']) > $intMaxLen ? strlen($objResult->fields['setname']) : $intMaxLen;
                $arrValues[$objResult->fields['setmodule']][$objResult->fields['setname']] = $objResult->fields['setvalue'];
                $objResult->MoveNext();
            }
            $intMaxLen += strlen('$_CONFIG[\'\']') + 1;
            //needed for formatted output
            $fileContent = $strHeader;
            foreach ($arrValues as $intModule => $arrInner) {
                $fileContent .= "/**\n";
                $fileContent .= "* -------------------------------------------------------------------------\n";
                if (isset($arrModules[$intModule])) {
                    $fileContent .= "* " . ucfirst($arrModules[$intModule]) . "\n";
                } else {
                    $fileContent .= "* " . $intModule . "\n";
                }
                $fileContent .= "* -------------------------------------------------------------------------\n";
                $fileContent .= "*/\n";
                foreach ($arrInner as $strName => $strValue) {
                    $fileContent .= sprintf("%-" . $intMaxLen . "s", '$_CONFIG[\'' . $strName . '\']');
                    $fileContent .= "= ";
                    $fileContent .= (is_numeric($strValue) ? $strValue : '"' . $strValue . '"') . ";\n";
                }
                $fileContent .= "\n";
            }
            $fileContent .= $strFooter;
            $objFile->write($fileContent);
        } catch (\Cx\Lib\FileSystem\FileSystemException $e) {
        }
    } else {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_WRITE_SETTINGS_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php'));
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_DOCUMENT_ROOT . '/config/settings.php', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        return false;
    }
    $query = "\n    ALTER TABLE " . DBPREFIX . "settings\n    CHANGE COLUMN setid setid integer(6) UNSIGNED NOT NULL auto_increment;\n    ";
    if (!$objDatabase->Execute($query)) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'settings_image', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(50)', 'after' => 'id'), 'value' => array('type' => 'text', 'after' => 'name')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
        try {
            \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_cut_width', '500'));
            \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_cut_height', '500'));
            \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_scale_width', '800'));
            \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_scale_height', '800'));
            \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "settings_image` (`name`, `value`) VALUES (?, ?)", array('image_compression', '100'));
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
Ejemplo n.º 7
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;
}