コード例 #1
0
ファイル: search.php プロジェクト: Niggu/cloudrexx
/**
 * 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 _searchUpdate()
{
    /*********************************************************
     * EXTENSION:   Change name of HTML_Template_Sigma block *
     * ADDED:       Contrexx v3.0.0                          *
     *********************************************************/
    try {
        \Cx\Lib\UpdateUtil::migrateContentPage('search', null, 'searchrow', 'search_result', '3.0.0');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
}
コード例 #2
0
ファイル: media1.php プロジェクト: Cloudrexx/cloudrexx
/**
 * 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 _media1Update()
{
    global $_ARRAYLANG, $_CORELANG;
    /*    require_once ASCMS_FRAMEWORK_PATH.'/File.class.php';
        $objFile = new File();
    
        $paths = glob(ASCMS_DOCUMENT_ROOT.'/media/archive*');
        foreach ($paths as $path) {
            $path = "$path/";
            $web_path = preg_replace("#".ASCMS_DOCUMENT_ROOT."/media/#", ASCMS_PATH_OFFSET . '/media/', $path);
            $status = $objFile->delFile($path, $web_path, '.htaccess');
    
            if ($status == 'error') {
                setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], "<pre>$web_path</pre>", $_CORELANG['TXT_UPDATE_TRY_AGAIN']));
                return false;
            }
            }*/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_media_settings', array('name' => array('type' => 'VARCHAR(50)'), 'value' => array('type' => 'VARCHAR(250)', 'after' => 'name')), array('name' => array('fields' => array('name'))), 'InnoDB');
        $arrValues = array(array("media1_frontend_changable", "off"), array("media2_frontend_changable", "off"), array("media3_frontend_changable", "off"), array("media4_frontend_changable", "off"), array("media1_frontend_managable", "off"), array("media2_frontend_managable", "off"), array("media3_frontend_managable", "off"), array("media4_frontend_managable", "off"));
        for ($i = 0; $i < count($arrValues); $i++) {
            $rs = \Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_media_settings WHERE name="' . $arrValues[$i][0] . '";');
            if ($rs->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_media_settings VALUES ("' . $arrValues[$i][0] . '","' . $arrValues[$i][1] . '")');
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrContentSites = array('media1', 'media2', 'media3', 'media4');
    // replace source url to image
    foreach ($arrContentSites as $module) {
        try {
            \Cx\Lib\UpdateUtil::migrateContentPage($module, '', 'images/modules/media/_base.gif', 'core_modules/media/View/Media/_base.gif', '3.1.2');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    return true;
}
コード例 #3
0
ファイル: news.php プロジェクト: Cloudrexx/cloudrexx
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;
}
コード例 #4
0
ファイル: calendar.php プロジェクト: nahakiole/cloudrexx
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;
}
コード例 #5
0
ファイル: livecam.php プロジェクト: Niggu/cloudrexx
/**
 * 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 _livecamUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_livecam', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'primary' => true), 'currentImagePath' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '/webcam/cam1/current.jpg'), 'archivePath' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '/webcam/cam1/archive/'), 'thumbnailPath' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '/webcam/cam1/thumbs/'), 'maxImageWidth' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '400'), 'thumbMaxSize' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '200'), 'shadowboxActivate' => array('type' => 'SET(\'1\',\'0\')', 'notnull' => true, 'default' => '1', 'renamefrom' => 'lightboxActivate'), 'showFrom' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'showTill' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_livecam_settings', array('setid' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'TEXT')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $query = "SELECT 1 FROM `" . DBPREFIX . "module_livecam_settings` WHERE `setname` = 'amount_of_cams'";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult !== false) {
        if ($objResult->RecordCount() == 0) {
            $query = "INSERT INTO `" . DBPREFIX . "module_livecam_settings` (`setname`, `setvalue`) VALUES ('amount_of_cams', '1')";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /************************************************
     * BUGFIX:   Migrate settings                    *
     * ADDED:    2.1.2                               *
     ************************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
        $arrFormerSettings = array('currentImageUrl' => '', 'archivePath' => '', 'thumbnailPath' => '');
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_livecam` WHERE `id` = 1";
        $objResult = $objDatabase->SelectLimit($query, 1);
        if ($objResult !== false) {
            if ($objResult->RecordCount() == 0) {
                $query = "SELECT `setname`, `setvalue` FROM `" . DBPREFIX . "module_livecam_settings` WHERE `setname` IN ('" . implode("','", array_keys($arrFormerSettings)) . "')";
                $objResult = $objDatabase->Execute($query);
                if ($objResult !== false) {
                    while (!$objResult->EOF) {
                        $arrFormerSettings[$objResult->fields['setname']] = $objResult->fields['setvalue'];
                        $objResult->MoveNext();
                    }
                    $query = "INSERT INTO `" . DBPREFIX . "module_livecam` (`id`, `currentImagePath`, `archivePath`, `thumbnailPath`, `maxImageWidth`, `thumbMaxSize`, `shadowboxActivate`) VALUES\n                            ('1', '" . addslashes($arrFormerSettings['currentImageUrl']) . "', '" . addslashes($arrFormerSettings['archivePath']) . "', '" . addslashes($arrFormerSettings['thumbnailPath']) . "', '400', '120', '0')";
                    if ($objDatabase->Execute($query) === false) {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                } else {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        foreach (array_keys($arrFormerSettings) as $setting) {
            $query = "DELETE FROM `" . DBPREFIX . "module_livecam_settings` WHERE `setname` = '" . $setting . "'";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $defaultFrom = mktime(0, 0);
    $defaultTill = mktime(23, 59);
    //set new default settings
    $query = "UPDATE `" . DBPREFIX . "module_livecam` SET `showFrom`={$defaultFrom}, `showTill`={$defaultTill} WHERE `showFrom` = '0'";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /************************************************
     * BUGFIX:   Update content page                 *
     * ADDED:    2.1.3                               *
     ************************************************/
    // both spaces in the search and replace pattern are required in that case
    try {
        \Cx\Lib\UpdateUtil::migrateContentPage('livecam', null, ' {LIVECAM_IMAGE_SHADOWBOX}', ' rel="{LIVECAM_IMAGE_SHADOWBOX}"', '2.1.3');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    return true;
}
コード例 #6
0
ファイル: update3.php プロジェクト: Niggu/cloudrexx
    }
}
$arrContentSites = array('media1', 'media2', 'media3', 'media4');
// replace source url to image
foreach ($arrContentSites as $module) {
    try {
        \Cx\Lib\UpdateUtil::migrateContentPage($module, '', 'images/modules/media/_base.gif', 'core_modules/media/View/Media/_base.gif', '3.1.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
}
$arrContentSites = array('media1', 'media2', 'media3', 'media4');
// replace source url to image
foreach ($arrContentSites as $module) {
    try {
        \Cx\Lib\UpdateUtil::migrateContentPage($module, '', 'images/modules/media/_base.gif', 'core_modules/media/View/Media/_base.gif', '3.1.2');
    } 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;