コード例 #1
0
ファイル: gallery.php プロジェクト: nahakiole/cloudrexx
function _galleryUpdate()
{
    global $objDatabase, $_ARRAYLANG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_gallery_categories', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'pid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'sorting' => array('type' => 'INT(6)', 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'comment' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'voting' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'backendProtected' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'backend_access_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'frontendProtected' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'frontend_access_id' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_gallery_pictures', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'catid' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'validated' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'status' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'catimg' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '0'), 'sorting' => array('type' => 'INT(6) UNSIGNED', 'notnull' => true, 'default' => '999'), 'size_show' => array('type' => 'SET(\'0\',\'1\')', 'notnull' => true, 'default' => '1'), 'path' => array('type' => 'TEXT', 'notnull' => true), 'link' => array('type' => 'TEXT', 'notnull' => true), 'lastedit' => array('type' => 'INT(14)', 'notnull' => true, 'default' => '0'), 'size_type' => array('type' => "SET('abs', 'proz')", 'notnull' => true, 'default' => 'proz'), 'size_proz' => array('type' => "INT(3)", 'notnull' => true, 'default' => '0'), 'size_abs_h' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'size_abs_w' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0'), 'quality' => array('type' => 'TINYINT(3)', 'notnull' => true, 'default' => '0')), array('galleryPicturesIndex' => array('type' => 'FULLTEXT', 'fields' => array('path'))));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrSettings = array('1' => array('name' => 'max_images_upload', 'value' => '10'), '2' => array('name' => 'standard_quality', 'value' => '95'), '3' => array('name' => 'standard_size_proz', 'value' => '25'), '4' => array('name' => 'standard_width_abs', 'value' => '140'), '6' => array('name' => 'standard_height_abs', 'value' => '0'), '7' => array('name' => 'standard_size_type', 'value' => 'abs'), '8' => array('name' => 'validation_show_limit', 'value' => '10'), '9' => array('name' => 'validation_standard_type', 'value' => 'all'), '11' => array('name' => 'show_names', 'value' => 'off'), '12' => array('name' => 'quality', 'value' => '95'), '13' => array('name' => 'show_comments', 'value' => 'off'), '14' => array('name' => 'show_voting', 'value' => 'off'), '15' => array('name' => 'enable_popups', 'value' => 'on'), '16' => array('name' => 'image_width', 'value' => '1200'), '17' => array('name' => 'paging', 'value' => '30'), '18' => array('name' => 'show_latest', 'value' => 'on'), '19' => array('name' => 'show_random', 'value' => 'on'), '20' => array('name' => 'header_type', 'value' => 'hierarchy'), '21' => array('name' => 'show_ext', 'value' => 'off'), '22' => array('name' => 'show_file_name', 'value' => 'on'), '23' => array('name' => 'slide_show', 'value' => 'slideshow'), '24' => array('name' => 'slide_show_seconds', 'value' => '3'));
    foreach ($arrSettings as $id => $arrSetting) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "module_gallery_settings` WHERE `name`= '" . $arrSetting['name'] . "'";
        if (($objRS = $objDatabase->Execute($query)) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        if ($objRS->RecordCount() == 0) {
            $query = "\n                INSERT INTO `" . DBPREFIX . "module_gallery_settings` (`id`, `name`, `value`)\n                VALUES (" . $id . ", '" . $arrSetting['name'] . "', '" . $arrSetting['value'] . "')\n                ON DUPLICATE KEY UPDATE `id` = `id`\n            ";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    /**************************************************************************
     * EXTENSION:   cleanup: delete translations, comments and                *
     *              votes of inexisting pictures                              *
     * ADDED:       Contrexx v3.0.1                                           *
     **************************************************************************/
    try {
        \Cx\Lib\UpdateUtil::sql('
            DELETE `language_pics`
            FROM `' . DBPREFIX . 'module_gallery_language_pics` as `language_pics` LEFT JOIN `' . DBPREFIX . 'module_gallery_pictures` as `pictures` ON `pictures`.`id` = `language_pics`.`picture_id`
            WHERE `pictures`.`id` IS NULL
        ');
        \Cx\Lib\UpdateUtil::sql('
            DELETE `comments`
            FROM `' . DBPREFIX . 'module_gallery_comments` as `comments` LEFT JOIN `' . DBPREFIX . 'module_gallery_pictures` as `pictures` ON `pictures`.`id` = `comments`.`picid`
            WHERE `pictures`.`id` IS NULL
        ');
        \Cx\Lib\UpdateUtil::sql('
            DELETE `votes`
            FROM `' . DBPREFIX . 'module_gallery_votes` as `votes` LEFT JOIN `' . DBPREFIX . 'module_gallery_pictures` as `pictures` ON `pictures`.`id` = `votes`.`picid`
            WHERE `pictures`.`id` IS NULL
        ');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // remove the script tag at the beginning of the gallery page
    \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'gallery'), '/^\\s*(<script[^>]+>.+?Shadowbox.+?<\\/script>)+/sm', '', array('content'), '3.0.3');
    return true;
}
コード例 #2
0
ファイル: newsletter.php プロジェクト: nahakiole/cloudrexx
function _newsletterUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG;
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_category', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'status'), 'notification_email' => array('type' => 'VARCHAR(250)', 'notnull' => true, 'default' => '', 'after' => 'name')), array('name' => array('fields' => array('name'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_confirm_mail', array('id' => array('type' => 'INT(1)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'content' => array('type' => 'longtext', 'after' => 'title'), 'recipients' => array('type' => 'text', 'after' => 'content')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'template' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'subject'), 'content' => array('type' => 'text', 'after' => 'template'), 'attachment' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'content'), 'priority' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'attachment'), 'sender_email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'priority'), 'sender_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'sender_email'), 'return_path' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'sender_name'), 'smtp_server' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'return_path'), 'status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'smtp_server'), 'count' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'status'), 'recipient_count' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'count'), 'date_create' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'recipient_count'), 'date_sent' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'date_create'), 'tmp_copy' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'date_sent')));
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    DBG::msg("Done checking tables.. going to check settings");
    //the two values notifyOnUnsubscribe and notificationUnsubscribe have been merged into the latter.
    $unsubscribeVal = 1;
    try {
        DBG::msg("Retrieving old unsubscribe value if set.");
        $res = \Cx\Lib\UpdateUtil::sql("SELECT setvalue FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notifyOnUnsubscribe'");
        if (!$res->EOF) {
            $unsubscribeVal = $res->fields['setvalue'];
        } else {
            DBG::msg("Not found. Retrieving new unsubscribe value if set.");
            $res = \Cx\Lib\UpdateUtil::sql("SELECT setvalue FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notificatonUnsubscribe'");
            if (!$res->EOF) {
                $unsubscribeVal = $res->fields['setvalue'];
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $settings = array('sender_mail' => array('setid' => 1, 'setname' => 'sender_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'sender_name' => array('setid' => 2, 'setname' => 'sender_name', 'setvalue' => 'admin', 'status' => 1), 'reply_mail' => array('setid' => 3, 'setname' => 'reply_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'mails_per_run' => array('setid' => 4, 'setname' => 'mails_per_run', 'setvalue' => '30', 'status' => 1), 'text_break_after' => array('setid' => 5, 'setname' => 'text_break_after', 'setvalue' => '100', 'status' => 1), 'test_mail' => array('setid' => 6, 'setname' => 'test_mail', 'setvalue' => '*****@*****.**', 'status' => 1), 'overview_entries_limit' => array('setid' => 7, 'setname' => 'overview_entries_limit', 'setvalue' => '10', 'status' => 1), 'rejected_mail_operation' => array('setid' => 8, 'setname' => 'rejected_mail_operation', 'setvalue' => 'delete', 'status' => 1), 'defUnsubscribe' => array('setid' => 9, 'setname' => 'defUnsubscribe', 'setvalue' => '0', 'status' => 1), 'notificationSubscribe' => array('setid' => 11, 'setname' => 'notificationSubscribe', 'setvalue' => '1', 'status' => 1), 'notificationUnsubscribe' => array('setid' => 10, 'setname' => 'notificationUnsubscribe', 'setvalue' => $unsubscribeVal, 'status' => 1), 'recipient_attribute_status' => array('setid' => 12, 'setname' => 'recipient_attribute_status', 'setvalue' => '{"recipient_sex":{"active":true,"required":false},"recipient_salutation":{"active":true,"required":false},"recipient_title":{"active":false,"required":false},"recipient_firstname":{"active":true,"required":false},"recipient_lastname":{"active":true,"required":false},"recipient_position":{"active":false,"required":false},"recipient_company":{"active":true,"required":false},"recipient_industry":{"active":false,"required":false},"recipient_address":{"active":true,"required":false},"recipient_city":{"active":true,"required":false},"recipient_zip":{"active":true,"required":false},"recipient_country":{"active":true,"required":false},"recipient_phone":{"active":true,"required":false},"recipient_private":{"active":false,"required":false},"recipient_mobile":{"active":false,"required":false},"recipient_fax":{"active":false,"required":false},"recipient_birthday":{"active":true,"required":false},"recipient_website":{"active":false,"required":false}}', 'status' => 1), 'reject_info_mail_text' => array('setid' => 13, 'setname' => 'reject_info_mail_text', 'setvalue' => 'Der Newsletter konnte an folgende E-Mail-Adresse nicht versendet werden:\\r\\n[[EMAIL]]\\r\\n\\r\\nUm die E-Mail Adresse zu bearbeiten, klicken Sie bitte auf den folgenden Link:\\r\\n[[LINK]]', 'status' => 1));
    try {
        DBG::msg("Reading current settings");
        $res = \Cx\Lib\UpdateUtil::sql("SELECT * FROM " . DBPREFIX . "module_newsletter_settings");
        while (!$res->EOF) {
            $field = $res->fields['setname'];
            DBG::msg("...merging {$field} with default settings");
            if (isset($settings[$field])) {
                //do we have another value for this?
                $settings[$field]['setvalue'] = $res->fields['setvalue'];
            }
            $res->MoveNext();
        }
        DBG::msg("Updating settings");
        foreach ($settings as $entry) {
            $setid = intval($entry['setid']);
            $field = addslashes($entry['setname']);
            $value = addslashes($entry['setvalue']);
            $status = intval($entry['status']);
            DBG::msg("...deleting field {$field}");
            \Cx\Lib\UpdateUtil::sql("DELETE FROM " . DBPREFIX . "module_newsletter_settings WHERE setid = '{$setid}' OR setname = '{$field}'");
            DBG::msg("...rewriting field {$field}");
            \Cx\Lib\UpdateUtil::sql("\n                INSERT INTO " . DBPREFIX . "module_newsletter_settings\n                    (setid, setname, setvalue, status)\n                VALUES (\n                    '{$setid}', '{$field}', '{$value}', '{$status}'\n                );\n            ");
        }
        DBG::msg("Deleting old unsubscribe key if set");
        \Cx\Lib\UpdateUtil::sql("DELETE FROM " . DBPREFIX . "module_newsletter_settings WHERE setname='notifyOnUnsubscribe'");
        DBG::msg("Done with newsletter update");
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        DBG::msg("Setting recipient count");
        $objResult = \Cx\Lib\UpdateUtil::sql("SELECT `newsletter`, COUNT(1) AS recipient_count FROM `" . DBPREFIX . "module_newsletter_tmp_sending` GROUP BY `newsletter`");
        if ($objResult->RecordCount()) {
            while (!$objResult->EOF) {
                \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter` SET `recipient_count` = " . $objResult->fields['recipient_count'] . " WHERE `id`=" . $objResult->fields['newsletter']);
                $objResult->MoveNext();
            }
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    // Add notification recipients to confirm_mail table
    try {
        $objResult = \Cx\Lib\UpdateUtil::sql("SELECT id FROM `" . DBPREFIX . "module_newsletter_confirm_mail` WHERE id='3'");
        if ($objResult->RecordCount() == 0) {
            DBG::msg("inserting standard confirm mails");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_newsletter_confirm_mail` (`id` ,`title` ,`content` ,`recipients`) VALUES ('3', '[[url]] - Neue Newsletter Empfänger [[action]]', 'Hallo Admin Eine neue Empfänger [[action]] in ihrem Newsletter System. Automatisch generierte Nachricht [[date]]', '');");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_access_user', array('accessUserID' => array('type' => 'INT(5)', 'unsigned' => true), 'newsletterCategoryID' => array('type' => 'INT(11)', 'after' => 'accessUserID'), 'code' => array('type' => 'VARCHAR(255)', 'after' => 'newsletterCategoryID', 'notnull' => true, 'default' => '')), array('rel' => array('fields' => array('accessUserID', 'newsletterCategoryID'), 'type' => 'UNIQUE'), 'accessUserID' => array('fields' => array('accessUserID'))));
        // set random newsletter code for access recipients
        \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_newsletter_access_user SET `code` = SUBSTR(MD5(RAND()),1,12) WHERE `code` = \'\'');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_rel_usergroup_newsletter', array('userGroup' => array('type' => 'INT(10)', 'unsigned' => true), 'newsletter' => array('type' => 'INT(10)', 'unsigned' => true, 'after' => 'userGroup')), array('uniq' => array('fields' => array('userGroup', 'newsletter'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_settings', array('setid' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'setname' => array('type' => 'VARCHAR(250)', 'after' => 'setid', 'notnull' => true, 'default' => ''), 'setvalue' => array('type' => 'text', 'after' => 'setname'), 'status' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'setvalue')), array('setname' => array('fields' => array('setname'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_tmp_sending', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'newsletter' => array('type' => 'INT(11)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'email' => array('type' => 'VARCHAR(255)', 'after' => 'newsletter', 'notnull' => true, 'default' => ''), 'sendt' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'email'), 'type' => array('type' => 'ENUM(\'access\',\'newsletter\',\'core\')', 'notnull' => true, 'default' => 'newsletter', 'after' => 'sendt'), 'code' => array('type' => 'VARCHAR(10)', 'after' => 'type')), array('unique_email' => array('fields' => array('newsletter', 'email'), 'type' => 'UNIQUE'), 'email' => array('fields' => array('email'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_email_link', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'email_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'id'), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'email_id'), 'url' => array('type' => 'VARCHAR(255)', 'after' => 'title')), array('email_id' => array('fields' => array('email_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_email_link_feedback', array('id' => array('type' => 'INT(11)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'link_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'id'), 'email_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'link_id'), 'recipient_id' => array('type' => 'INT(11)', 'unsigned' => true, 'after' => 'email_id'), 'recipient_type' => array('type' => 'ENUM(\'access\',\'newsletter\')', 'after' => 'recipient_id')), array('link_id' => array('fields' => array('link_id', 'email_id', 'recipient_id', 'recipient_type'), 'type' => 'UNIQUE'), 'email_id' => array('fields' => array('email_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_template', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'name'), 'html' => array('type' => 'text', 'after' => 'description'), 'required' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'html'), 'type' => array('type' => 'ENUM(\'e-mail\',\'news\')', 'notnull' => true, 'default' => 'e-mail', 'after' => 'required')));
        // migrate country field
        if (newsletter_migrate_country_field() == 'timeout') {
            return 'timeout';
        }
        // IMPORTANT: the table definition statement of module_newsletter_user must be AFTER newsletter_migrate_country_field() has been called!
        // fix missing columns & rename old columns if required
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_newsletter_user', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'code' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'code'), 'uri' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'email'), 'sex' => array('type' => 'ENUM(\'m\',\'f\')', 'notnull' => false, 'after' => 'uri'), 'salutation' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sex', 'renamefrom' => 'title'), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'salutation'), 'lastname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'firstname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lastname'), 'position' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'firstname'), 'company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'position'), 'industry_sector' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'company'), 'address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'industry_sector', 'renamefrom' => 'street'), 'zip' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'address'), 'city' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'zip'), 'country_id' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'city'), 'phone_office' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'country_id', 'renamefrom' => 'phone'), 'phone_private' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_office'), 'phone_mobile' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_private'), 'fax' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'phone_mobile'), 'notes' => array('type' => 'text', 'after' => 'fax'), 'birthday' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '00-00-0000', 'after' => 'notes'), 'status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'birthday'), 'emaildate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'status'), 'language' => array('type' => 'INT(3)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'emaildate')), array('email' => array('fields' => array('email'), 'type' => 'UNIQUE'), 'status' => array('fields' => array('status'))));
        // fix user's SALUTATION of previews updates
        if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0') && $objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
            // set user's SALUTATION based of previews updates
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `salutation` = `title`, `title` = '' WHERE `salutation` = '0' AND `title` REGEXP '^[0-9]+\$'");
            // clear all user's TITLE attribute that consist only of a number (it is most likely not the case that a user's TITLE is a number,
            // so we assume that it is a left over of the preview update bug, which did not migrate the user's TITLE attribute to the user's SALUTATION attribute
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "module_newsletter_user` SET `title` = '' WHERE `title` REGEXP '^[0-9]+\$'");
        }
        // switch to source mode for all newsletter content pages
        \Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'newsletter'), '3.0.1');
        // replace several placeholders that have changed
        $search = array('/TXT_NEWSLETTER_URI/', '/NEWSLETTER_URI/', '/TXT_NEWSLETTER_STREET/', '/NEWSLETTER_STREET/');
        $replace = array('TXT_NEWSLETTER_WEBSITE', 'NEWSLETTER_WEBSITE', 'TXT_NEWSLETTER_ADDRESS', 'NEWSLETTER_ADDRESS');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'newsletter'), $search, $replace, array('content'), '3.0.1');
        // sorry, brainfuck coming up...
        // this adds the missing template block newsletter_list as well as the placeholder [[NEWSLETTER_LIST_SELECTED]]
        $search = array('/(<!--\\s+BEGIN\\s+newsletter_lists\\s+-->)(.*)(<!--\\s+END\\s+newsletter_lists\\s+-->)/ms');
        $callback = function ($matches) {
            if (preg_match('/^(.*)(<[^>]+[\'"]list\\[\\{NEWSLETTER_LIST_ID\\}\\][\'"])([^>]*>)(.*)$/ms', $matches[2], $listMatches)) {
                if (strpos($listMatches[2] . $listMatches[3], '{NEWSLETTER_LIST_SELECTED}') === false) {
                    $matches[2] = $listMatches[1] . $listMatches[2] . ' {NEWSLETTER_LIST_SELECTED} ' . $listMatches[3] . $listMatches[4];
                } else {
                    $matches[2] = $listMatches[1] . $listMatches[2] . $listMatches[3] . $listMatches[4];
                }
            }
            if (!preg_match('/<!--\\s+BEGIN\\s+newsletter_list\\s+-->.*<!--\\s+END\\s+newsletter_list\\s+-->/ms', $matches[2])) {
                return $matches[1] . '<!-- BEGIN newsletter_list -->' . $matches[2] . '<!-- END newsletter_list -->' . $matches[3];
            } else {
                return $matches[1] . $matches[2] . $matches[3];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
        // this adds the missing placeholders [[SELECTED_DAY]], [[SELECTED_MONTH]], [[SELECTED_YEAR]]
        $search = array('/(<option[^>]+\\{USERS_BIRTHDAY_(DAY|MONTH|YEAR)\\}[\'"])([^>]*>)/ms');
        $callback = function ($matches) {
            if (strpos($matches[1] . $matches[3], '{SELECTED_' . $matches[2] . '}') === false) {
                return $matches[1] . ' {SELECTED_' . $matches[2] . '} ' . $matches[3];
            } else {
                return $matches[1] . $matches[3];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
        // replace [[TXT_NEWSLETTER_TITLE]] to [[TXT_NEWSLETTER_SALUTATION]]
        // replace [[NEWSLETTER_TITLE]] to [[NEWSLETTER_SALUTATION]]
        $search = array('/.*\\{NEWSLETTER_TITLE\\}.*/ms');
        $callback = function ($matches) {
            if (!preg_match('/<!--\\s+BEGIN\\s+recipient_title\\s+-->.*\\{NEWSLETTER_TITLE\\}.*<!--\\s+END\\s+recipient_title\\s+-->/ms', $matches[0]) && !preg_match('/<!--\\s+BEGIN\\s+recipient_salutation\\s+-->/ms', $matches[0]) && !preg_match('/\\{NEWSLETTER_SALUTATION\\}/ms', $matches[0])) {
                return str_replace(array('TXT_NEWSLETTER_TITLE', '{NEWSLETTER_TITLE}'), array('TXT_NEWSLETTER_SALUTATION', '{NEWSLETTER_SALUTATION}'), $matches[0]);
            } else {
                return $matches[0];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'newsletter'), $search, $callback, array('content'), '3.0.1');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3') && empty($_SESSION['contrexx_update']['newsletter_links_decoded'])) {
        try {
            $objResult = \Cx\Lib\UpdateUtil::sql('SELECT `id`, `url` FROM `' . DBPREFIX . 'module_newsletter_email_link`');
            if ($objResult !== false && $objResult->RecordCount() > 0) {
                while (!$objResult->EOF) {
                    \Cx\Lib\UpdateUtil::sql('UPDATE `' . DBPREFIX . 'module_newsletter_email_link` SET `url` = ? WHERE `id` = ?', array(html_entity_decode($objResult->fields['url'], ENT_QUOTES, CONTREXX_CHARSET), $objResult->fields['id']));
                    $objResult->MoveNext();
                }
            }
            $_SESSION['contrexx_update']['newsletter_links_decoded'] = true;
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.0')) {
        // add access to access ids 152/171/172/174/175/176 for user groups which had access to access id 25
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 25 GROUP BY group_id");
            if ($result !== false) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                VALUES\n                                                (152, " . intval($result->fields['group_id']) . "),\n                                                (171, " . intval($result->fields['group_id']) . "),\n                                                (172, " . intval($result->fields['group_id']) . "),\n                                                (174, " . intval($result->fields['group_id']) . "),\n                                                (175, " . intval($result->fields['group_id']) . "),\n                                                (176, " . intval($result->fields['group_id']) . ")\n                                                ");
                    $result->MoveNext();
                }
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    // add access id 176 for user groups which had access to 172 if version is older than 3.1.0
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 172 GROUP BY `group_id`");
            if ($result !== false) {
                while (!$result->EOF) {
                    \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                VALUES (176, " . intval($result->fields['group_id']) . ")");
                    $result->MoveNext();
                }
            }
        } 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
ファイル: access.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 _accessUpdate()
{
    global $objDatabase, $objUpdate, $_CONFIG, $_ARRAYLANG, $_CORELANG;
    $arrTables = $objDatabase->MetaTables('TABLES');
    if (!$arrTables) {
        setUpdateMsg($_ARRAYLANG['TXT_UNABLE_DETERMINE_DATABASE_STRUCTURE']);
        return false;
    }
    /****************************
     *
     * ADD NOTIFICATION E-MAILS
     *
     ***************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_mail', array('type' => array('type' => 'ENUM(\'reg_confirm\',\'reset_pw\',\'user_activated\',\'user_deactivated\',\'new_user\')', 'notnull' => true, 'default' => 'reg_confirm'), 'lang_id' => array('type' => 'TINYINT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'sender_mail' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'sender_name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'subject' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => ''), 'format' => array('type' => 'ENUM(\'text\',\'html\',\'multipart\')', 'notnull' => true, 'default' => 'text'), 'body_text' => array('type' => 'TEXT'), 'body_html' => array('type' => 'TEXT')), array('mail' => array('fields' => array('type', 'lang_id'), 'type' => 'UNIQUE')), 'InnoDB');
        $result = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'access_group_dynamic_ids`');
        if ($result->EOF) {
            \Cx\Lib\UpdateUtil::sql('ALTER IGNORE TABLE `' . DBPREFIX . 'access_group_dynamic_ids` ADD PRIMARY KEY ( `access_id` , `group_id` )');
        }
        $result = \Cx\Lib\UpdateUtil::sql('SHOW KEYS FROM `' . DBPREFIX . 'access_group_static_ids`');
        if ($result->EOF) {
            \Cx\Lib\UpdateUtil::sql('ALTER IGNORE TABLE `' . DBPREFIX . 'access_group_static_ids` ADD PRIMARY KEY ( `access_id` , `group_id` )');
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    \DBG::msg('001');
    $arrMails = array(array('type' => 'reg_confirm', 'subject' => 'Benutzerregistrierung bestätigen', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nVielen Dank für Ihre Anmeldung bei [[HOST]].\\r\\nBitte klicken Sie auf den folgenden Link, um Ihre E-Mail-Adresse zu bestätigen:\\r\\n[[ACTIVATION_LINK]]\\r\\n\\r\\nUm sich später einzuloggen, geben Sie bitte Ihren Benutzernamen \\"[[USERNAME]]\\" und das Passwort ein, das Sie bei der Registrierung festgelegt haben.\\r\\n\\r\\n\\r\\n--\\r\\nIhr [[SENDER]]'), array('type' => 'reset_pw', 'subject' => 'Kennwort zurücksetzen', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nUm ein neues Passwort zu wählen, müssen Sie auf die unten aufgeführte URL gehen und dort Ihr neues Passwort eingeben.\\r\\n\\r\\nWICHTIG: Die Gültigkeit der URL wird nach 60 Minuten verfallen, nachdem diese E-Mail abgeschickt wurde.\\r\\nFalls Sie mehr Zeit benötigen, geben Sie Ihre E-Mail Adresse einfach ein weiteres Mal ein.\\r\\n\\r\\nIhre URL:\\r\\n[[URL]]\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'user_activated', 'subject' => 'Ihr Benutzerkonto wurde aktiviert', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nIhr Benutzerkonto auf [[HOST]] wurde soeben aktiviert und kann von nun an verwendet werden.\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'user_deactivated', 'subject' => 'Ihr Benutzerkonto wurde deaktiviert', 'body_text' => 'Hallo [[USERNAME]],\\r\\n\\r\\nIhr Benutzerkonto auf [[HOST]] wurde soeben deaktiviert.\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'), array('type' => 'new_user', 'subject' => 'Ein neuer Benutzer hat sich registriert', 'body_text' => 'Der Benutzer [[USERNAME]] hat sich soeben registriert und muss nun frei geschaltet werden.\\r\\n\\r\\nÜber die folgende Adresse kann das Benutzerkonto von [[USERNAME]] verwaltet werden:\\r\\n[[LINK]]\\r\\n\\r\\n\\r\\n--\\r\\n[[SENDER]]'));
    foreach ($arrMails as $arrMail) {
        $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_mail` WHERE `type` = '" . $arrMail['type'] . "'";
        $objMail = $objDatabase->SelectLimit($query, 1);
        if ($objMail !== false) {
            if ($objMail->RecordCount() == 0) {
                $query = "INSERT INTO `" . DBPREFIX . "access_user_mail` (\n                    `type`,\n                    `lang_id`,\n                    `sender_mail`,\n                    `sender_name`,\n                    `subject`,\n                    `body_text`,\n                    `body_html`\n                ) VALUES (\n                    '" . $arrMail['type'] . "',\n                    0,\n                    '" . addslashes($_CONFIG['coreAdminEmail']) . "',\n                    '" . addslashes($_CONFIG['coreAdminName']) . "',\n                    '" . $arrMail['subject'] . "',\n                    '" . $arrMail['body_text'] . "',\n                    ''\n                )";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /****************
     *
     * ADD SETTINGS
     *
     ***************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_settings', array('key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => ''), 'value' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'key'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'value')), array('key' => array('fields' => array('key'), 'type' => 'UNIQUE')), 'InnoDB');
        if (in_array(DBPREFIX . "communit_config", $arrTables)) {
            $objResult = \Cx\Lib\UpdateUtil::sql('SELECT `name`, `value`, `status` FROM `' . DBPREFIX . 'community_config`');
            while (!$objResult->EOF) {
                $arrCommunityConfig[$objResult->fields['name']] = array('value' => $objResult->fields['value'], 'status' => $objResult->fields['status']);
                $objResult->MoveNext();
            }
        }
        $arrSettings = array('user_activation' => array('value' => '', 'status' => isset($arrCommunityConfig['user_activation']['status']) ? $arrCommunityConfig['user_activation']['status'] : 0), 'user_activation_timeout' => array('value' => isset($arrCommunityConfig['user_activation_timeout']['value']) ? $arrCommunityConfig['user_activation_timeout']['value'] : 0, 'status' => isset($arrCommunityConfig['user_activation_timeout']['status']) ? $arrCommunityConfig['user_activation_timeout']['status'] : 0), 'assigne_to_groups' => array('value' => isset($arrCommunityConfig['community_groups']['value']) ? $arrCommunityConfig['community_groups']['value'] : '', 'status' => 1), 'max_profile_pic_width' => array('value' => '160', 'status' => 1), 'max_profile_pic_height' => array('value' => '160', 'status' => 1), 'profile_thumbnail_pic_width' => array('value' => '50', 'status' => 1), 'profile_thumbnail_pic_height' => array('value' => '50', 'status' => 1), 'max_profile_pic_size' => array('value' => '30000', 'status' => 1), 'max_pic_width' => array('value' => '600', 'status' => 1), 'max_pic_height' => array('value' => '600', 'status' => 1), 'max_thumbnail_pic_width' => array('value' => '130', 'status' => 1), 'max_thumbnail_pic_height' => array('value' => '130', 'status' => 1), 'max_pic_size' => array('value' => '200000', 'status' => 1), 'notification_address' => array('value' => addslashes($_CONFIG['coreAdminEmail']), 'status' => 1), 'user_config_email_access' => array('value' => '', 'status' => 1), 'user_config_profile_access' => array('value' => '', 'status' => 1), 'default_email_access' => array('value' => 'members_only', 'status' => 1), 'default_profile_access' => array('value' => 'members_only', 'status' => 1), 'user_delete_account' => array('value' => '', 'status' => 1), 'block_currently_online_users' => array('value' => '10', 'status' => 0), 'block_currently_online_users_pic' => array('value' => '', 'status' => 0), 'block_last_active_users' => array('value' => '10', 'status' => 0), 'block_last_active_users_pic' => array('value' => '', 'status' => 0), 'block_latest_reg_users' => array('value' => '10', 'status' => 0), 'block_latest_reg_users_pic' => array('value' => '', 'status' => 0), 'block_birthday_users' => array('value' => '10', 'status' => 0), 'block_birthday_users_pic' => array('value' => '', 'status' => 0), 'session_user_interval' => array('value' => '0', 'status' => 1), 'user_accept_tos_on_signup' => array('value' => '', 'status' => 0), 'user_captcha' => array('value' => '', 'status' => 0), 'profile_thumbnail_method' => array('value' => 'crop', 'status' => 1), 'profile_thumbnail_scale_color' => array('value' => '#FFFFFF', 'status' => 1));
        foreach ($arrSettings as $key => $arrSetting) {
            if (!\Cx\Lib\UpdateUtil::sql("SELECT 1 FROM `" . DBPREFIX . "access_settings` WHERE `key` = '" . $key . "'")->RecordCount()) {
                \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings`\n                    SET `key`       = '" . $key . "',\n                        `value`     = '" . $arrSetting['value'] . "',\n                        `status`    = '" . $arrSetting['status'] . "'\n                ");
            }
        }
        // delete obsolete table community_config
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'community_config');
        // delete obsolete table user_validity
        \Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'user_validity');
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /********************
     *
     * ADD USER PROFILE
     *
     *******************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_profile', array('user_id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'gender' => array('type' => 'ENUM(\'gender_undefined\',\'gender_female\',\'gender_male\')', 'notnull' => true, 'default' => 'gender_undefined', 'after' => 'user_id'), 'title' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'gender'), 'firstname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'title'), 'lastname' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'firstname'), 'company' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lastname'), 'address' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'company'), 'city' => array('type' => 'VARCHAR(50)', 'notnull' => true, 'default' => '', 'after' => 'address'), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => '', 'after' => 'city'), 'country' => array('type' => 'SMALLINT(5)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'zip'), 'phone_office' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'country'), 'phone_private' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_office'), 'phone_mobile' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_private'), 'phone_fax' => array('type' => 'VARCHAR(20)', 'notnull' => true, 'default' => '', 'after' => 'phone_mobile'), 'birthday' => array('type' => 'VARCHAR(11)', 'notnull' => false, 'after' => 'phone_fax'), 'website' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'birthday'), 'profession' => array('type' => 'VARCHAR(150)', 'notnull' => true, 'default' => '', 'after' => 'website'), 'interests' => array('type' => 'text', 'after' => 'profession'), 'signature' => array('type' => 'text', 'after' => 'interests'), 'picture' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'signature')), array('profile' => array('fields' => array('firstname' => 100, 'lastname' => 100, 'company' => 50))), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /***************************
     *
     * MIGRATE GROUP RELATIONS
     *
     **************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_rel_user_group', array('user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'group_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'user_id')), array(), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'access_users');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
        return false;
    }
    if (in_array('groups', $arrColumns)) {
        $query = "SELECT `id`, `groups` FROM " . DBPREFIX . "access_users WHERE `groups` != ''";
        $objUser = $objDatabase->Execute($query);
        if ($objUser) {
            while (!$objUser->EOF) {
                $arrGroups = explode(',', $objUser->fields['groups']);
                foreach ($arrGroups as $groupId) {
                    $query = "SELECT 1 FROM " . DBPREFIX . "access_rel_user_group WHERE `user_id` = " . $objUser->fields['id'] . " AND `group_id` = " . intval($groupId);
                    $objRel = $objDatabase->SelectLimit($query, 1);
                    if ($objRel) {
                        if ($objRel->RecordCount() == 0) {
                            $query = "INSERT INTO " . DBPREFIX . "access_rel_user_group (`user_id`, `group_id`) VALUES (" . $objUser->fields['id'] . ", " . intval($groupId) . ")";
                            if ($objDatabase->Execute($query) === false) {
                                return _databaseError($query, $objDatabase->ErrorMsg());
                            }
                        }
                    } else {
                        return _databaseError($query, $objDatabase->ErrorMsg());
                    }
                }
                $objUser->MoveNext();
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` DROP `groups`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    \DBG::msg('002');
    /*********************
     *
     * ADD USER VALIDITY
     *
     ********************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_validity', array('validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true)), array(), 'InnoDB');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_validity`";
    $objResult = $objDatabase->SelectLimit($query, 1);
    if ($objResult) {
        if ($objResult->RecordCount() == 0) {
            $query = "\n                INSERT INTO `" . DBPREFIX . "access_user_validity` (`validity`) VALUES\n                    ('0'), ('1'), ('15'), ('31'), ('62'),\n                    ('92'), ('123'), ('184'), ('366'), ('731')\n                ";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    } else {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /********************
     *
     * MIGRATE PROFILES
     *
     *******************/
    if (in_array('firstname', $arrColumns)) {
        $query = "SELECT `id`, `firstname`, `lastname`, `residence`, `profession`, `interests`, `webpage`, `company`, `zip`, `phone`, `mobile`, `street` FROM `" . DBPREFIX . "access_users`";
        $objUser = $objDatabase->Execute($query);
        if ($objUser) {
            while (!$objUser->EOF) {
                $query = "SELECT 1 FROM `" . DBPREFIX . "access_user_profile` WHERE `user_id` = " . $objUser->fields['id'];
                $objProfile = $objDatabase->SelectLimit($query, 1);
                if ($objProfile) {
                    if ($objProfile->RecordCount() == 0) {
                        $query = "INSERT INTO `" . DBPREFIX . "access_user_profile` (\n                            `user_id`,\n                            `gender`,\n                            `firstname`,\n                            `lastname`,\n                            `company`,\n                            `address`,\n                            `city`,\n                            `zip`,\n                            `country`,\n                            `phone_office`,\n                            `phone_private`,\n                            `phone_mobile`,\n                            `phone_fax`,\n                            `website`,\n                            `profession`,\n                            `interests`,\n                            `picture`\n                        ) VALUES (\n                            " . $objUser->fields['id'] . ",\n                            'gender_undefined',\n                            '" . addslashes($objUser->fields['firstname']) . "',\n                            '" . addslashes($objUser->fields['lastname']) . "',\n                            '" . addslashes($objUser->fields['company']) . "',\n                            '" . addslashes($objUser->fields['street']) . "',\n                            '" . addslashes($objUser->fields['residence']) . "',\n                            '" . addslashes($objUser->fields['zip']) . "',\n                            0,\n                            '',\n                            '" . addslashes($objUser->fields['phone']) . "',\n                            '" . addslashes($objUser->fields['mobile']) . "',\n                            '',\n                            '" . addslashes($objUser->fields['webpage']) . "',\n                            '" . addslashes($objUser->fields['profession']) . "',\n                            '" . addslashes($objUser->fields['interests']) . "',\n                            ''\n                        )";
                        if ($objDatabase->Execute($query) === false) {
                            return _databaseError($query, $objDatabase->ErrorMsg());
                        }
                    }
                } else {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
                $objUser->MoveNext();
            }
        } else {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $arrRemoveColumns = array('firstname', 'lastname', 'residence', 'profession', 'interests', 'webpage', 'company', 'zip', 'phone', 'mobile', 'street', 'levelid');
    foreach ($arrRemoveColumns as $column) {
        if (in_array($column, $arrColumns)) {
            $query = "ALTER TABLE " . DBPREFIX . "access_users DROP `" . $column . "`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $arrColumnDetails = $objDatabase->MetaColumns(DBPREFIX . 'access_users');
    if ($arrColumnDetails === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
        return false;
    }
    if (in_array('regdate', $arrColumns)) {
        if ($arrColumnDetails['REGDATE']->type == 'date') {
            if (!in_array('regdate_new', $arrColumns)) {
                $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `regdate_new` INT( 14 ) UNSIGNED NULL DEFAULT '0' AFTER `regdate`";
                if ($objDatabase->Execute($query) === false) {
                    return _databaseError($query, $objDatabase->ErrorMsg());
                }
            }
            $query = "UPDATE `" . DBPREFIX . "access_users` SET `regdate_new` = UNIX_TIMESTAMP(`regdate`), `regdate` = '0000-00-00' WHERE `regdate` != '0000-00-00'";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
            $query = "ALTER TABLE `" . DBPREFIX . "access_users` DROP `regdate`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'access_users');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'access_users'));
        return false;
    }
    if (in_array('regdate_new', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `regdate_new` `regdate` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0'";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `is_admin` `is_admin` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    if (!in_array('email_access', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `email_access` ENUM( 'everyone', 'members_only', 'nobody' ) NOT NULL DEFAULT 'nobody' AFTER `email`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('profile_access', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `profile_access` ENUM( 'everyone', 'members_only', 'nobody' ) NOT NULL DEFAULT 'members_only' AFTER `active`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('frontend_lang_id', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` CHANGE `langId` `frontend_lang_id` INT( 2 ) UNSIGNED NOT NULL DEFAULT '0'";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('backend_lang_id', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `backend_lang_id` INT( 2 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `frontend_lang_id`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        } else {
            $query = "UPDATE `" . DBPREFIX . "access_users` SET `backend_lang_id` = `frontend_lang_id`";
            if ($objDatabase->Execute($query) === false) {
                return _databaseError($query, $objDatabase->ErrorMsg());
            }
        }
    }
    if (!in_array('last_auth', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `last_auth` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `regdate`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('last_activity', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `last_activity` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `last_auth`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('expiration', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `expiration` INT( 14 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `regdate`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    if (!in_array('validity', $arrColumns)) {
        $query = "ALTER TABLE `" . DBPREFIX . "access_users` ADD `validity` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `expiration`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    } else {
        try {
            \Cx\Lib\UpdateUtil::sql("UPDATE `" . DBPREFIX . "access_users` SET `expiration` = `validity`*60*60*24+`regdate` WHERE `expiration` = 0 AND `validity` > 0");
        } catch (\Cx\Lib\UpdateException $e) {
            // we COULD do something else here..
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    \DBG::msg('003');
    /***********************************
     *
     * MIGRATE COMMUNITY CONTENT PAGES
     *
     **********************************/
    // only execute this part for versions < 2.0.0
    $pattern = array('/section=community&(amp;)?cmd=profile/', '/section=community&(amp;)?cmd=register/', '/section=community/');
    $replacement = array('section=access&$1cmd=settings', 'section=access&$1cmd=signup', 'section=access');
    try {
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array(), $pattern, $replacement, array('content', 'target'), '2.0.0');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'community'), array('/community/', '/profile/', '/register/'), array('access', 'settings', 'signup'), array('module', 'cmd'), '2.0.0');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /***********************************
     *
     * CREATE PROFILE ATTRIBUTE TABLES
     *
     **********************************/
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'type' => array('type' => 'ENUM(\'text\',\'textarea\',\'mail\',\'uri\',\'date\',\'image\',\'checkbox\',\'menu\',\'menu_option\',\'group\',\'frame\',\'history\')', 'notnull' => true, 'default' => 'text', 'after' => 'parent_id'), 'mandatory' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'type'), 'sort_type' => array('type' => 'ENUM(\'asc\',\'desc\',\'custom\')', 'notnull' => true, 'default' => 'asc', 'after' => 'mandatory'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sort_type'), 'access_special' => array('type' => 'ENUM(\'\',\'menu_select_higher\',\'menu_select_lower\')', 'notnull' => true, 'default' => '', 'after' => 'order_id'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'access_special')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute_name', array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'attribute_id'), 'name' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'lang_id')), array(), 'InnoDB');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_attribute_value', array('attribute_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'attribute_id'), 'history_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'primary' => true, 'after' => 'user_id'), 'value' => array('type' => 'text', 'after' => 'history_id')), array('value' => array('fields' => array('value'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_core_attribute', array('id' => array('type' => 'VARCHAR(25)', 'primary' => true), 'mandatory' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'sort_type' => array('type' => 'ENUM(\'asc\',\'desc\',\'custom\')', 'notnull' => true, 'default' => 'asc', 'after' => 'mandatory'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'sort_type'), 'access_special' => array('type' => 'ENUM(\'\',\'menu_select_higher\',\'menu_select_lower\')', 'notnull' => true, 'default' => '', 'after' => 'order_id'), 'access_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'access_special')), array(), 'InnoDB');
        /************************
         *
         * ADD USER TITLE TABLE
         *
         ***********************/
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_title', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'title')), array('title' => array('fields' => array('title'), 'type' => 'UNIQUE')), 'InnoDB');
        $arrDefaultTitle = array('Sehr geehrte Frau', 'Sehr geehrter Herr', 'Dear Ms', 'Dear Mr', 'Madame', 'Monsieur');
        foreach ($arrDefaultTitle as $title) {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_user_title` SET `title` = '" . $title . "' ON DUPLICATE KEY UPDATE `id` = `id`");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    /******************************
     *
     * REMOVE OBSOLETE ACCESS IDS
     *
     *****************************/
    $query = 'DELETE FROM `' . DBPREFIX . 'access_group_static_ids` WHERE `access_id` IN (28, 29, 30, 33, 34, 36)';
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    /*******************
     *
     * MIGRATE SESSION
     *
     ******************/
    $arrColumns = $objDatabase->MetaColumnNames(DBPREFIX . 'sessions');
    if ($arrColumns === false) {
        setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'sessions'));
        return false;
    }
    if (!in_array('user_id', $arrColumns)) {
        $query = "\n            ALTER TABLE `" . DBPREFIX . "sessions`\n             DROP `username`,\n              ADD `user_id` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `status`";
        if ($objDatabase->Execute($query) === false) {
            return _databaseError($query, $objDatabase->ErrorMsg());
        }
    }
    /***************************************
     *
     * ADD CHECKBOX PROFILE ATTRIBUTE TYPE
     *
     **************************************/
    $query = "ALTER TABLE `" . DBPREFIX . "access_user_attribute` CHANGE `type` `type` enum('text','textarea','mail','uri','date','image','checkbox','menu','menu_option','group','frame','history') NOT NULL DEFAULT 'text'";
    if ($objDatabase->Execute($query) === false) {
        return _databaseError($query, $objDatabase->ErrorMsg());
    }
    // Currently, this is only here to create the u2u_active field.. but instead of adding
    // 10 lines for each new field in the future, why not just extend this block
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_users', array('id' => array('type' => 'INT(5)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'is_admin' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'id'), 'username' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'is_admin'), 'password' => array('type' => 'VARCHAR(32)', 'notnull' => false, 'after' => 'username'), 'regdate' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'password'), 'expiration' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'regdate'), 'validity' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'expiration'), 'last_auth' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'validity'), 'last_auth_status' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1', 'after' => 'last_auth'), 'last_activity' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'last_auth_status'), 'email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'after' => 'last_activity'), 'email_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'nobody', 'after' => 'email'), 'frontend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'email_access'), 'backend_lang_id' => array('type' => 'INT(2)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'frontend_lang_id'), 'active' => array('type' => 'TINYINT(1)', 'notnull' => true, 'default' => '0', 'after' => 'backend_lang_id'), 'primary_group' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'active'), 'profile_access' => array('type' => 'ENUM(\'everyone\',\'members_only\',\'nobody\')', 'notnull' => true, 'default' => 'members_only', 'after' => 'primary_group'), 'restore_key' => array('type' => 'VARCHAR(32)', 'notnull' => true, 'default' => '', 'after' => 'profile_access'), 'restore_key_time' => array('type' => 'INT(14)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'restore_key'), 'u2u_active' => array('type' => 'ENUM(\'0\',\'1\')', 'notnull' => true, 'default' => '1', 'after' => 'restore_key_time')), array('username' => array('fields' => array('username'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_groups', array('group_id' => array('type' => 'INT(6)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'group_name' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'group_id'), 'group_description' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'group_name'), 'is_active' => array('type' => 'TINYINT(4)', 'notnull' => true, 'default' => '1', 'after' => 'group_description'), 'type' => array('type' => 'ENUM(\'frontend\',\'backend\')', 'notnull' => true, 'default' => 'frontend', 'after' => 'is_active'), 'homepage' => array('type' => 'VARCHAR(255)', 'notnull' => true, 'default' => '', 'after' => 'type')));
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    \DBG::msg('004');
    // only update if installed version is at least a version 2.0.0
    // older versions < 2.0 have a complete other structure of the content page and must therefore completely be reinstalled
    if (!$objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.0.0')) {
        try {
            // migrate content page to version 3.0.1
            $search = array('/(.*)/ms');
            $callback = function ($matches) {
                $content = $matches[1];
                if (empty($content)) {
                    return $content;
                }
                // add missing access_captcha template block
                if (!preg_match('/<!--\\s+BEGIN\\s+access_captcha\\s+-->.*<!--\\s+END\\s+access_captcha\\s+-->/ms', $content)) {
                    $content = preg_replace('/(<\\/fieldset>|)(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$2<!-- BEGIN access_captcha -->$2$3<label>{TXT_ACCESS_CAPTCHA}</label>{ACCESS_CAPTCHA_CODE}$5$2<!-- END access_captcha -->$2$1$2$3$4$5', $content);
                }
                // add missing access_newsletter template block
                if (!preg_match('/<!--\\s+BEGIN\\s+access_newsletter\\s+-->.*<!--\\s+END\\s+access_newsletter\\s+-->/ms', $content)) {
                    $content = preg_replace('/(\\s*)(<p[^>]*>|)(\\{ACCESS_SIGNUP_BUTTON\\})(<\\/p>|)/ms', '$1<!-- BEGIN access_newsletter -->$1<fieldset><legend>Newsletter abonnieren</legend>$1    <!-- BEGIN access_newsletter_list -->$1    <p>$1        <label for="access_user_newsletters-{ACCESS_NEWSLETTER_ID}">&nbsp;{ACCESS_NEWSLETTER_NAME}</label>$1        <input type="checkbox" name="access_user_newsletters[]" id="access_user_newsletters-{ACCESS_NEWSLETTER_ID}" value="{ACCESS_NEWSLETTER_ID}"{ACCESS_NEWSLETTER_SELECTED} />$1    </p>$1    <!-- END access_newsletter_list -->$1</fieldset>$1<!-- END access_newsletter -->$1$2$3$4', $content);
                }
                return $content;
            };
            \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.1');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************
     *
     * ADD NETWORK TABLE FOR SOCIAL LOGIN
     *
     **************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
        try {
            \Cx\Lib\UpdateUtil::table(DBPREFIX . 'access_user_network', array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'oauth_provider' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'id'), 'oauth_id' => array('type' => 'VARCHAR(100)', 'notnull' => true, 'default' => '', 'after' => 'oauth_provider'), 'user_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0', 'after' => 'oauth_id')), array(), 'InnoDB');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        /***************************************
         *
         * ADD NEW VALUES FOR SOCIAL LOGIN
         *
         **************************************/
        try {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin', '', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_show_signup', '', 0) ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('use_usernames', '0', '1') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_assign_to_groups', '3', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_active_automatically', '', '1') ON DUPLICATE KEY UPDATE `key` = `key`");
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "core_setting` (`section`, `name`, `group`, `type`, `value`, `values`, `ord`) VALUES ('access', 'providers', 'sociallogin', 'text', '{\"facebook\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"twitter\":{\"active\":\"0\",\"settings\":[\"\",\"\"]},\"google\":{\"active\":\"0\",\"settings\":[\"\",\"\",\"\"]}}', '', '0') ON DUPLICATE KEY UPDATE `section` = `section`");
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
        /**
         * Content page
         * access signup
         */
        try {
            // migrate content page to version 3.0.1
            $search = array('/(.*)/ms');
            $callback = function ($matches) {
                $content = $matches[1];
                if (empty($content)) {
                    return $content;
                }
                // fix duplicated social networks blocks
                if (preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+BEGIN\\s+access_social_networks\\s+-->/ms', $content)) {
                    $content = preg_replace('/<br\\s+\\/><br\\s+\\/><!--\\s+BEGIN\\s+access_social_networks\\s+-->.*?<!--\\s+END\\s+access_social_networks\\s+-->/ms', '', $content);
                }
                // add missing access_social_networks template block
                if (!preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+END\\s+access_social_networks\\s+-->/ms', $content)) {
                    $content = preg_replace('/(<!--\\s+BEGIN\\s+access_signup_form\\s+-->.*?)(<div[^>]*>|)(.*?\\{ACCESS_SIGNUP_MESSAGE\\}.*?)(<\\/div>|)/ms', '$1<br /><br /><!-- BEGIN access_social_networks --><fieldset><legend>oder Login mit Social Media</legend><!-- BEGIN access_social_networks_facebook -->        <a class="facebook loginbutton" href="{ACCESS_SOCIALLOGIN_FACEBOOK}">Facebook</a>        <!-- END access_social_networks_facebook -->        <!-- BEGIN access_social_networks_google -->        <a class="google loginbutton" href="{ACCESS_SOCIALLOGIN_GOOGLE}">Google</a>        <!-- END access_social_networks_google -->        <!-- BEGIN access_social_networks_twitter -->        <a class="twitter loginbutton" href="{ACCESS_SOCIALLOGIN_TWITTER}">Twitter</a>        <!-- END access_social_networks_twitter -->    </fieldset>    <!-- END access_social_networks -->$2$3$4', $content);
                }
                return $content;
            };
            \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'access', 'cmd' => 'signup'), $search, $callback, array('content'), '3.0.2');
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************
     *
     * ADD SETTING FOR SOCIAL LOGIN
     *
     **************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.0.3')) {
        try {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "access_settings` (`key`, `value`, `status`) VALUES ('sociallogin_activation_timeout', '10', '0') ON DUPLICATE KEY UPDATE `key` = `key`");
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /***************************************
     *
     * STRICT_TRANS_TABLES ISSUE FIX FOR PROFILE TABLE
     *
     **************************************/
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '3.1.0')) {
        try {
            \Cx\Lib\UpdateUtil::sql("ALTER TABLE `" . DBPREFIX . "access_user_profile` CHANGE `interests` `interests` TEXT NULL");
            \Cx\Lib\UpdateUtil::sql("ALTER TABLE `" . DBPREFIX . "access_user_profile` CHANGE `signature` `signature` TEXT NULL");
            // add access to filesharing for existing groups
            try {
                $result = \Cx\Lib\UpdateUtil::sql("SELECT `group_id` FROM `" . DBPREFIX . "access_group_static_ids` WHERE access_id = 7 GROUP BY group_id");
                if ($result !== false) {
                    while (!$result->EOF) {
                        \Cx\Lib\UpdateUtil::sql("INSERT IGNORE INTO `" . DBPREFIX . "access_group_static_ids` (`access_id`, `group_id`)\n                                                    VALUES (8, " . intval($result->fields['group_id']) . ")");
                        $result->MoveNext();
                    }
                }
            } catch (\Cx\Lib\UpdateException $e) {
                return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
            }
        } catch (\Cx\Lib\UpdateException $e) {
            return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
        }
    }
    /************************************************
     * BUGFIX:	Set write access to the upload dir  *
     ************************************************/
    // This is obsolete due to the new \Cx\Lib\FileSystem
    /*
    	require_once ASCMS_FRAMEWORK_PATH.'/File.class.php';
    	$objFile = new File();
    	if (is_writeable(ASCMS_ACCESS_PROFILE_IMG_PATH) || $objFile->setChmod(ASCMS_ACCESS_PROFILE_IMG_PATH, ASCMS_ACCESS_PROFILE_IMG_WEB_PATH, '')) {
        	if ($mediaDir = @opendir(ASCMS_ACCESS_PROFILE_IMG_PATH)) {
        		while($file = readdir($mediaDir)) {
        			if ($file != '.' && $file != '..') {
        				if (!is_writeable(ASCMS_ACCESS_PROFILE_IMG_PATH.'/'.$file) && !$objFile->setChmod(ASCMS_ACCESS_PROFILE_IMG_PATH.'/', ASCMS_ACCESS_PROFILE_IMG_WEB_PATH.'/', $file)) {
        					setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/'.$file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        					return false;
        				}
        			}
    			}
        	} else {
        		setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        		return false;
    		}
        } else {
        	setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PROFILE_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        	return false;
        }
    
    	require_once ASCMS_FRAMEWORK_PATH.'/File.class.php';
    	$objFile = new File();
    	if (is_writeable(ASCMS_ACCESS_PHOTO_IMG_PATH) || $objFile->setChmod(ASCMS_ACCESS_PHOTO_IMG_PATH, ASCMS_ACCESS_PHOTO_IMG_WEB_PATH, '')) {
        	if ($mediaDir = @opendir(ASCMS_ACCESS_PHOTO_IMG_PATH)) {
        		while($file = readdir($mediaDir)) {
        			if ($file != '.' && $file != '..') {
        				if (!is_writeable(ASCMS_ACCESS_PHOTO_IMG_PATH.'/'.$file) && !$objFile->setChmod(ASCMS_ACCESS_PHOTO_IMG_PATH.'/', ASCMS_ACCESS_PHOTO_IMG_WEB_PATH.'/', $file)) {
        					setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_FILE'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/'.$file, $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        					return false;
        				}
        			}
    			}
        	} else {
        		setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        		return false;
    		}
        } else {
        	setUpdateMsg(sprintf($_ARRAYLANG['TXT_SET_WRITE_PERMISSON_TO_DIR_AND_CONTENT'], ASCMS_ACCESS_PHOTO_IMG_PATH.'/', $_CORELANG['TXT_UPDATE_TRY_AGAIN']), 'msg');
        	return false;
        }*/
    return true;
}
コード例 #5
0
ファイル: mediadir.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 _mediadirUpdate()
{
    global $_ARRAYLANG, $_CORELANG, $objUpdate, $_CONFIG;
    //create / update tables
    try {
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_categories', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(7)', 'after' => 'id'), 'order' => array('type' => 'INT(7)', 'after' => 'parent_id'), 'show_subcategories' => array('type' => 'INT(11)', 'after' => 'order'), 'show_entries' => array('type' => 'INT(1)', 'after' => 'show_subcategories'), 'picture' => array('type' => 'mediumtext', 'after' => 'show_entries'), 'active' => array('type' => 'INT(1)', 'after' => 'picture')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_categories_names', array('lang_id' => array('type' => 'INT(1)'), 'category_id' => array('type' => 'INT(7)', 'after' => 'lang_id'), 'category_name' => array('type' => 'VARCHAR(255)', 'after' => 'category_id'), 'category_description' => array('type' => 'mediumtext', 'after' => 'category_name')), array('lang_id' => array('fields' => array('lang_id')), 'category_id' => array('fields' => array('category_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_comments', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'entry_id' => array('type' => 'INT(7)', 'after' => 'id'), 'added_by' => array('type' => 'VARCHAR(255)', 'after' => 'entry_id'), 'date' => array('type' => 'VARCHAR(100)', 'after' => 'added_by'), 'ip' => array('type' => 'VARCHAR(100)', 'after' => 'date'), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'ip'), 'mail' => array('type' => 'VARCHAR(255)', 'after' => 'name'), 'url' => array('type' => 'VARCHAR(255)', 'after' => 'mail'), 'notification' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'url'), 'comment' => array('type' => 'mediumtext', 'after' => 'notification')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_entries', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'order' => array('type' => 'INT(7)', 'notnull' => true, 'default' => '0', 'after' => 'id'), 'form_id' => array('type' => 'INT(7)', 'after' => 'order'), 'create_date' => array('type' => 'INT(50)', 'after' => 'form_id'), 'update_date' => array('type' => 'INT(50)', 'after' => 'create_date'), 'validate_date' => array('type' => 'INT(50)', 'after' => 'update_date'), 'added_by' => array('type' => 'INT(10)', 'after' => 'validate_date'), 'updated_by' => array('type' => 'INT(10)', 'after' => 'added_by'), 'lang_id' => array('type' => 'INT(1)', 'after' => 'updated_by'), 'hits' => array('type' => 'INT(10)', 'after' => 'lang_id'), 'popular_hits' => array('type' => 'INT(10)', 'after' => 'hits'), 'popular_date' => array('type' => 'VARCHAR(20)', 'after' => 'popular_hits'), 'last_ip' => array('type' => 'VARCHAR(50)', 'after' => 'popular_date'), 'ready_to_confirm' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0', 'after' => 'last_ip'), 'confirmed' => array('type' => 'INT(1)', 'after' => 'ready_to_confirm'), 'active' => array('type' => 'INT(1)', 'after' => 'confirmed'), 'duration_type' => array('type' => 'INT(1)', 'after' => 'active'), 'duration_start' => array('type' => 'INT(50)', 'after' => 'duration_type'), 'duration_end' => array('type' => 'INT(50)', 'after' => 'duration_start'), 'duration_notification' => array('type' => 'INT(1)', 'after' => 'duration_end'), 'translation_status' => array('type' => 'VARCHAR(255)', 'after' => 'duration_notification')), array('lang_id' => array('fields' => array('lang_id')), 'active' => array('fields' => array('active'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_form_names', array('lang_id' => array('type' => 'INT(1)'), 'form_id' => array('type' => 'INT(7)', 'after' => 'lang_id'), 'form_name' => array('type' => 'VARCHAR(255)', 'after' => 'form_id'), 'form_description' => array('type' => 'mediumtext', 'notnull' => true, 'after' => 'form_name')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_forms', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'order' => array('type' => 'INT(7)', 'after' => 'id'), 'picture' => array('type' => 'mediumtext', 'after' => 'order'), 'active' => array('type' => 'INT(1)', 'after' => 'picture'), 'use_level' => array('type' => 'INT(1)', 'after' => 'active'), 'use_category' => array('type' => 'INT(1)', 'after' => 'use_level'), 'use_ready_to_confirm' => array('type' => 'INT(1)', 'after' => 'use_category'), 'cmd' => array('type' => 'VARCHAR(50)', 'after' => 'use_ready_to_confirm')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_inputfield_names', array('lang_id' => array('type' => 'INT(10)'), 'form_id' => array('type' => 'INT(7)', 'after' => 'lang_id'), 'field_id' => array('type' => 'INT(10)', 'after' => 'form_id'), 'field_name' => array('type' => 'VARCHAR(255)', 'after' => 'field_id'), 'field_default_value' => array('type' => 'mediumtext', 'after' => 'field_name'), 'field_info' => array('type' => 'mediumtext', 'after' => 'field_default_value')), array('field_id' => array('fields' => array('field_id')), 'lang_id' => array('fields' => array('lang_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_inputfield_types', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'id'), 'active' => array('type' => 'INT(1)', 'after' => 'name'), 'multi_lang' => array('type' => 'INT(1)', 'after' => 'active'), 'exp_search' => array('type' => 'INT(7)', 'after' => 'multi_lang'), 'dynamic' => array('type' => 'INT(1)', 'after' => 'exp_search'), 'comment' => array('type' => 'VARCHAR(255)', 'after' => 'dynamic')), array('name' => array('fields' => array('name'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_inputfield_verifications', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'id'), 'regex' => array('type' => 'VARCHAR(255)', 'after' => 'name')), array('name' => array('fields' => array('name'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_inputfields', array('id' => array('type' => 'INT(10)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'form' => array('type' => 'INT(7)', 'after' => 'id'), 'type' => array('type' => 'INT(10)', 'after' => 'form'), 'verification' => array('type' => 'INT(10)', 'after' => 'type'), 'search' => array('type' => 'INT(10)', 'after' => 'verification'), 'required' => array('type' => 'INT(10)', 'after' => 'search'), 'order' => array('type' => 'INT(10)', 'after' => 'required'), 'show_in' => array('type' => 'INT(10)', 'after' => 'order'), 'context_type' => array('type' => 'ENUM(\'none\',\'title\',\'address\',\'zip\',\'city\',\'country\')', 'after' => 'show_in')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_level_names', array('lang_id' => array('type' => 'INT(1)'), 'level_id' => array('type' => 'INT(7)', 'after' => 'lang_id'), 'level_name' => array('type' => 'VARCHAR(255)', 'after' => 'level_id'), 'level_description' => array('type' => 'mediumtext', 'after' => 'level_name')), array('lang_id' => array('fields' => array('lang_id')), 'category_id' => array('fields' => array('level_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_levels', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'parent_id' => array('type' => 'INT(7)', 'after' => 'id'), 'order' => array('type' => 'INT(7)', 'after' => 'parent_id'), 'show_sublevels' => array('type' => 'INT(11)', 'after' => 'order'), 'show_categories' => array('type' => 'INT(1)', 'after' => 'show_sublevels'), 'show_entries' => array('type' => 'INT(1)', 'after' => 'show_categories'), 'picture' => array('type' => 'mediumtext', 'after' => 'show_entries'), 'active' => array('type' => 'INT(1)', 'after' => 'picture')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_mail_actions', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(255)', 'after' => 'id'), 'default_recipient' => array('type' => 'ENUM(\'admin\',\'author\')', 'after' => 'name'), 'need_auth' => array('type' => 'INT(11)', 'after' => 'default_recipient')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_mails', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'id'), 'content' => array('type' => 'longtext', 'after' => 'title'), 'recipients' => array('type' => 'mediumtext', 'after' => 'content'), 'lang_id' => array('type' => 'INT(1)', 'after' => 'recipients'), 'action_id' => array('type' => 'INT(1)', 'after' => 'lang_id'), 'is_default' => array('type' => 'INT(1)', 'after' => 'action_id'), 'active' => array('type' => 'INT(1)', 'after' => 'is_default')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_masks', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'title' => array('type' => 'VARCHAR(255)', 'after' => 'id'), 'fields' => array('type' => 'mediumtext', 'after' => 'title'), 'active' => array('type' => 'INT(11)', 'after' => 'fields'), 'form_id' => array('type' => 'INT(11)', 'after' => 'active')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_order_rel_forms_selectors', array('selector_id' => array('type' => 'INT(7)'), 'form_id' => array('type' => 'INT(7)', 'after' => 'selector_id'), 'selector_order' => array('type' => 'INT(7)', 'after' => 'form_id'), 'exp_search' => array('type' => 'INT(1)', 'notnull' => true, 'after' => 'selector_order')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_rel_entry_categories', array('entry_id' => array('type' => 'INT(10)'), 'category_id' => array('type' => 'INT(10)', 'after' => 'entry_id')), array('entry_id' => array('fields' => array('entry_id')), 'category_id' => array('fields' => array('category_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_rel_entry_inputfields_clean', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'entry_id' => array('type' => 'INT(7)', 'after' => 'id'), 'lang_id' => array('type' => 'INT(7)', 'after' => 'entry_id'), 'form_id' => array('type' => 'INT(7)', 'after' => 'lang_id'), 'field_id' => array('type' => 'INT(7)', 'after' => 'form_id'), 'value' => array('type' => 'longtext', 'after' => 'field_id')), array('value' => array('fields' => array('value'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::sql('
          INSERT INTO `' . DBPREFIX . 'module_mediadir_rel_entry_inputfields_clean`
          SELECT NULL, `entry_id`, `lang_id`, `form_id`, `field_id`, `value`
          FROM `' . DBPREFIX . 'module_mediadir_rel_entry_inputfields`
          GROUP BY `entry_id`, `form_id`, `field_id`, `lang_id`, `value`
      ');
        \Cx\Lib\UpdateUtil::sql('
          TRUNCATE `' . DBPREFIX . 'module_mediadir_rel_entry_inputfields`
      ');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_rel_entry_inputfields', array('entry_id' => array('type' => 'INT(7)'), 'lang_id' => array('type' => 'INT(7)', 'after' => 'entry_id'), 'form_id' => array('type' => 'INT(7)', 'after' => 'lang_id'), 'field_id' => array('type' => 'INT(7)', 'after' => 'form_id'), 'value' => array('type' => 'longtext', 'after' => 'field_id')), array('entry_id' => array('fields' => array('entry_id', 'lang_id', 'form_id', 'field_id'), 'type' => 'UNIQUE'), 'value' => array('fields' => array('value'), 'type' => 'FULLTEXT')));
        \Cx\Lib\UpdateUtil::sql('
          INSERT IGNORE INTO `' . DBPREFIX . 'module_mediadir_rel_entry_inputfields`
          SELECT `entry_id`, `lang_id`, `form_id`, `field_id`, `value`
          FROM `' . DBPREFIX . 'module_mediadir_rel_entry_inputfields_clean`
          ORDER BY `id` DESC
      ');
        \Cx\Lib\UpdateUtil::sql('
          DROP TABLE `' . DBPREFIX . 'module_mediadir_rel_entry_inputfields_clean`
      ');
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_rel_entry_levels', array('entry_id' => array('type' => 'INT(10)'), 'level_id' => array('type' => 'INT(10)', 'after' => 'entry_id')), array('entry_id' => array('fields' => array('entry_id')), 'category_id' => array('fields' => array('level_id'))));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_settings', array('id' => array('type' => 'INT(11)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)', 'after' => 'id'), 'value' => array('type' => 'VARCHAR(255)', 'after' => 'name')), array('name' => array('fields' => array('name'), 'type' => 'UNIQUE')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_settings_num_categories', array('group_id' => array('type' => 'INT(1)'), 'num_categories' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'after' => 'group_id')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_settings_num_entries', array('group_id' => array('type' => 'INT(1)'), 'num_entries' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'default' => 'n', 'after' => 'group_id')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_settings_num_levels', array('group_id' => array('type' => 'INT(1)'), 'num_levels' => array('type' => 'VARCHAR(10)', 'notnull' => true, 'after' => 'group_id')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_settings_perm_group_forms', array('group_id' => array('type' => 'INT(7)'), 'form_id' => array('type' => 'INT(1)', 'after' => 'group_id'), 'status_group' => array('type' => 'INT(1)', 'notnull' => true, 'after' => 'form_id')));
        \Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_mediadir_votes', array('id' => array('type' => 'INT(7)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'entry_id' => array('type' => 'INT(7)', 'after' => 'id'), 'added_by' => array('type' => 'VARCHAR(255)', 'after' => 'entry_id'), 'date' => array('type' => 'VARCHAR(100)', 'after' => 'added_by'), 'ip' => array('type' => 'VARCHAR(100)', 'after' => 'date'), 'vote' => array('type' => 'INT(11)', 'after' => 'ip')));
        // remove the script tag at the beginning of the mediadir pages
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'mediadir'), '/^\\s*(<script[^>]+>.+?Shadowbox.+?<\\/script>)+/sm', '', array('content'), '3.0.4');
    } catch (\Cx\Lib\UpdateException $e) {
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    //insert default settings
    try {
        //mediadir_settings
        $arrValues = array(array(1, 'settingsShowCategoryDescription', '1'), array(2, 'settingsShowCategoryImage', '1'), array(3, 'settingsCategoryOrder', '1'), array(4, 'settingsShowLevels', '1'), array(5, 'settingsShowLevelDescription', '0'), array(6, 'settingsShowLevelImage', '0'), array(7, 'settingsLevelOrder', '1'), array(8, 'settingsConfirmNewEntries', '1'), array(9, 'categorySelectorOrder', '9'), array(10, 'levelSelectorOrder', '10'), array(11, 'settingsConfirmUpdatedEntries', '0'), array(12, 'settingsCountEntries', '0'), array(13, 'settingsThumbSize', '120'), array(14, 'settingsNumGalleryPics', '10'), array(15, 'settingsEncryptFilenames', '1'), array(16, 'settingsAllowAddEntries', '1'), array(17, 'settingsAllowDelEntries', '1'), array(18, 'settingsAllowEditEntries', '1'), array(19, 'settingsAddEntriesOnlyCommunity', '1'), array(20, 'settingsLatestNumXML', '10'), array(21, 'settingsLatestNumOverview', '5'), array(22, 'settingsLatestNumBackend', '5'), array(23, 'settingsLatestNumFrontend', '10'), array(24, 'settingsPopularNumFrontend', '10'), array(25, 'settingsPopularNumRestore', '30'), array(26, 'settingsLatestNumHeadlines', '6'), array(27, 'settingsGoogleMapStartposition', '46.749647513758326,7.6300048828125,8'), array(28, 'settingsAllowVotes', '1'), array(29, 'settingsVoteOnlyCommunity', '0'), array(30, 'settingsAllowComments', '1'), array(31, 'settingsCommentOnlyCommunity', '0'), array(32, 'settingsGoogleMapAllowKml', '0'), array(33, 'settingsShowEntriesInAllLang', '1'), array(34, 'settingsPagingNumEntries', '10'), array(35, 'settingsGoogleMapType', '0'), array(36, 'settingsClassificationPoints', '5'), array(37, 'settingsClassificationSearch', '1'), array(38, 'settingsEntryDisplaydurationType', '1'), array(39, 'settingsEntryDisplaydurationValue', '0'), array(40, 'settingsEntryDisplaydurationValueType', '1'), array(41, 'settingsEntryDisplaydurationNotification', '0'), array(42, 'categorySelectorExpSearch', '9'), array(43, 'levelSelectorExpSearch', '10'), array(44, 'settingsTranslationStatus', '0'), array(45, 'settingsReadyToConfirm', '0'), array(46, 'settingsImageFilesize', '300'), array(47, 'settingsActiveLanguages', '1,2,3'), array(48, 'settingsFrontendUseMultilang', '0'), array(49, 'settingsIndividualEntryOrder', '0'));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_settings WHERE name="' . $arrValue[1] . '"')->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_settings VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '","' . $arrValue[2] . '")');
            }
        }
        //mediadir_settings_num_categories
        $arrValues = array(array(3, 'n'), array(4, 'n'), array(5, 'n'));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_settings_num_categories WHERE group_id=' . $arrValue[0])->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_settings_num_categories VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '")');
            }
        }
        //mediadir_settings_num_entries
        $arrValues = array(array(3, 'n'), array(4, 'n'), array(5, 'n'));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_settings_num_entries WHERE group_id=' . $arrValue[0])->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_settings_num_entries VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '")');
            }
        }
        //mediadir_settings_num_levels
        $arrValues = array(array(3, 'n'), array(4, 'n'), array(5, 'n'));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_settings_num_levels WHERE group_id=' . $arrValue[0])->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_settings_num_levels VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '")');
            }
        }
        //mediadir_inputfield_verifications
        $arrValues = array(array(1, 'normal', '.*'), array(2, 'e-mail', "^[a-zäàáâöôüûñéè0-9!\\#\\\$\\%\\&\\''\\*\\+\\/\\=\\?\\^_\\`\\{\\|\\}\\~-]+(?:\\.[a-zäàáâöôüûñéè0-9!\\#\\\$\\%\\&\\" . '"' . "'\\*\\+\\/\\=\\?\\^_\\`\\{\\|\\}\\~-]+)*@(?:[a-zäàáâöôüûñéè0-9](?:[a-zäàáâöôüûñéè0-9-]*[a-zäàáâöôüûñéè0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\$"), array(3, 'url', '^(?:(?:ht|f)tps?\\:\\/\\/)?((([\\wÄÀÁÂÖÔÜÛÑÉÈäàáâöôüûñéè\\d-]{1,}\\.)+[a-z]{2,})|((?:(?:25[0-5]|2[0-4]\\d|[01]\\d\\d|\\d?\\d)(?:(\\.?\\d)\\.)) {4}))(?:[\\w\\d]+)?(\\/[\\w\\d\\-\\.\\?\\,\'\\/\\\\+\\&\\%\\$\\#\\=\\~]*)?$'), array(4, 'letters', '^[A-Za-zÄÀÁÂÖÔÜÛÑÉÈäàáâöôüûñéè\\ ]*[A-Za-zÄÀÁÂÖÔÜÛÑÉÈäàáâöôüûñéè]+[A-Za-zÄÀÁÂÖÔÜÛÑÉÈäàáâöôüûñéè\\ ]*$'), array(5, 'numbers', '^[0-9]*$'));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_inputfield_verifications WHERE name="' . $arrValue[1] . '"')->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_inputfield_verifications VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '","' . $arrValue[2] . '")');
            } else {
                \Cx\Lib\UpdateUtil::sql('UPDATE ' . DBPREFIX . 'module_mediadir_inputfield_verifications SET `regex`="' . $arrValue[2] . '" WHERE `name`="' . $arrValue[1] . '"');
            }
        }
        //mediadir_inputfield_types
        $arrValues = array(array(1, 'text', 1, 1, 1, 0, ''), array(2, 'textarea', 1, 1, 1, 0, ''), array(3, 'dropdown', 1, 0, 1, 0, ''), array(4, 'radio', 1, 0, 1, 0, ''), array(5, 'checkbox', 1, 0, 0, 0, ''), array(7, 'file', 1, 0, 0, 0, ''), array(8, 'image', 1, 0, 0, 0, ''), array(9, 'gallery', 0, 0, 0, 0, 'not yet developed'), array(10, 'podcast', 0, 0, 0, 0, 'not yet developed'), array(11, 'classification', 1, 0, 1, 0, ''), array(12, 'link', 1, 0, 0, 0, ''), array(13, 'link_group', 1, 0, 0, 0, ''), array(14, 'rss', 0, 0, 0, 0, 'not yet developed'), array(15, 'google_map', 1, 0, 0, 0, ''), array(16, 'add_step', 0, 0, 0, 0, ''), array(17, 'field_group', 0, 0, 0, 0, 'not yet developed'), array(18, 'label', 0, 0, 0, 0, 'not yet developed'), array(19, 'wysiwyg', 0, 1, 0, 0, 'developed for OSEC (unstable)'), array(20, 'mail', 1, 0, 0, 0, ''), array(21, 'google_weather', 1, 0, 0, 0, ''), array(22, 'relation', 0, 0, 0, 0, 'developed for OSEC (unstable)'), array(23, 'relation_group', 0, 0, 0, 0, 'developed for OSEC (unstable)'), array(24, 'accounts', 0, 0, 0, 0, 'developed for OSEC (unstable)'), array(25, 'country', 1, 0, 0, 0, ''), array(26, 'product_attributes', 0, 0, 1, 0, ''), array(27, 'downloads', 0, 1, 0, 1, 'developed for CADexchange.ch (unstable)'), array(28, 'responsibles', 0, 1, 0, 1, 'developed for CADexchange.ch (unstable)'), array(29, 'references', 0, 1, 0, 1, 'developed for CADexchange.ch (unstable)'), array(30, 'title', 0, 0, 0, 0, 'developed for CADexchange.ch (unstable)'));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_inputfield_types WHERE name="' . $arrValue[1] . '"')->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_inputfield_types VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '",' . $arrValue[2] . ',' . $arrValue[3] . ',' . $arrValue[4] . ',' . $arrValue[5] . ',"' . $arrValue[6] . '")');
            }
        }
        //mediadir_mail_actions
        $arrValues = array(array(1, 'newEntry', 'admin', 0), array(2, 'entryAdded', 'author', 1), array(3, 'entryConfirmed', 'author', 1), array(4, 'entryVoted', 'author', 1), array(5, 'entryDeleted', 'author', 1), array(6, 'entryEdited', 'author', 1), array(8, 'newComment', 'author', 1), array(9, 'notificationDisplayduration', 'admin', 0));
        foreach ($arrValues as $arrValue) {
            if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_mail_actions WHERE name="' . $arrValue[1] . '"')->EOF) {
                \Cx\Lib\UpdateUtil::sql('INSERT INTO ' . DBPREFIX . 'module_mediadir_mail_actions VALUES(' . $arrValue[0] . ',"' . $arrValue[1] . '","' . $arrValue[2] . '",' . $arrValue[3] . ')');
            }
        }
        //only insert mails if the table is empty
        if (\Cx\Lib\UpdateUtil::sql('SELECT 1 FROM ' . DBPREFIX . 'module_mediadir_mails')->EOF) {
            \Cx\Lib\UpdateUtil::sql("INSERT INTO `" . DBPREFIX . "module_mediadir_mails` (`id`, `title`, `content`, `recipients`, `lang_id`, `action_id`, `is_default`, `active`) VALUES\n('23', '[[URL]] - Eintrag erfolgreich bearbeitet', 'Hallo [[FIRSTNAME]] [[LASTNAME]] ([[USERNAME]])\n\nIhr Eintrag mit dem Titel \"[[TITLE]]\" auf [[URL]] wurde erfolgreich bearbeitet.\n\nBenutzen Sie folgenden Link um direkt zu Ihrem Eintrag zu gelangen:\n[[LINK]]\n\nFreundliche Grüsse\n[[URL]]-Team\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '6', '1', '0'),\n('22', '[[URL]] - Eintrag erfolgreich gelöscht', 'Hallo [[FIRSTNAME]] [[LASTNAME]] ([[USERNAME]])\n\nIhr Eintrag mit dem Titel \"[[TITLE]]\" auf [[URL]] wurde erfolgreich gelöscht.\n\nFreundliche Grüsse\nIhr [[URL]]-Team\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '5', '1', '0'),\n('21', '[[URL]] - Eintrag wurde bewertet', 'Hallo [[FIRSTNAME]] [[LASTNAME]] ([[USERNAME]])\n\nZu Ihrem Eintrag mit dem Titel \"[[TITLE]]\" auf [[URL]] wurde eine Bewertung abgegeben.\n\nBenutzen Sie folgenden Link um direkt zu Ihrem Eintrag zu gelangen:\n[[LINK]]\n\nFreundliche Grüsse\nIhr [[URL]]-Team\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '4', '1', '0'),\n('20', '[[URL]] - Ihr Eintrag wurde aufgeschaltet', 'Guten Tag,\n\nIhr Eintrag \"[[TITLE]]\" wurde geprüft und ist ab sofort einsehbar.\n\nBenutzen Sie folgenden Link um direkt zu ihrem Eintrag zu gelangen:\n[[LINK]]\n\n\nFreundliche Grüsse\nIhr [[URL]]-Team\n\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '3', '1', '0'),\n('19', '[[URL]] - Eintrag erfolgteich eingetragen', 'Hallo [[FIRSTNAME]] [[LASTNAME]] ([[USERNAME]])\n\nIhr Eintrag mit dem Titel \"[[TITLE]]\" wurde auf [[URL]] erfolgreich eingetragen.\n\n\nFreundliche Grüsse\nIhr [[URL]]-Team\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '2', '1', '0'),\n('24', '[[URL]] - Neuer Kommentar hinzugefügt', 'Hallo [[FIRSTNAME]] [[LASTNAME]] ([[USERNAME]])\n\nZu Ihrem Eintrag mit dem Titel \"[[TITLE]]\" auf [[URL]] wurde ein neuer Kommentar hinzugefügt.\n\nBenutzen Sie folgenden Link um direkt zu Ihrem Eintrag zu gelangen:\n[[LINK]]\n\nFreundliche Grüsse\nIhr [[URL]]-Team\n\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '8', '1', '0'),\n('32', '[[URL]] - Neuer Eintrag zur Prüfung freigegeben', 'Guten Tag,\n\nAuf http://[[URL]] wurde ein neuer Eintrag mit dem Titel \"[[TITLE]]\" erfasst. Bitte prüfen Sie diesen und geben Sie ihn gegebenenfalls frei.\n\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '1', '1', '0'),\n('33', '[[URL]] - Die Anzeigedauer eines Eintrages läuft ab', 'Hallo Admin\n\nAuf [[URL]] läuft in Kürze die Anzeigedauer des Eintrages \"[[TITLE]]\" ab.\n\nFreundliche Grüsse\nIhr [[URL]]-Team\n\n--\nDiese Nachricht wurde am [[DATE]] automatisch von Contrexx auf http://[[URL]] generiert.', '', '1', '9', '1', '0');");
        }
    } catch (\Cx\Lib\UpdateException $e) {
        // we COULD do something else here..
        return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
    }
    if ($objUpdate->_isNewerVersion($_CONFIG['coreCmsVersion'], '2.2.0')) {
        //insert demo values
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_categories` VALUES (167,0,0,1,1,'',1),(168,0,0,1,1,'',1),(169,0,0,0,1,'',1),(166,0,0,1,1,'',1),(165,0,0,1,1,'',1),(164,0,0,1,1,'',1);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_categories_names` VALUES (2,169,'Audio, Video ','test'),(2,165,'Foto',''),(3,165,'Foto',''),(1,166,'Telekommunikation',''),(2,166,'Telekommunikation',''),(3,166,'Telekommunikation',''),(1,167,'Internet',''),(2,167,'Internet',''),(3,167,'Internet',''),(1,168,'Elektronik   ',''),(2,168,'Elektronik   ',''),(3,168,'Elektronik   ',''),(1,169,'Audio, Video ','test'),(1,165,'Foto',''),(1,164,'Computer & Software',''),(2,164,'Computer & Software',''),(3,164,'Computer & Software',''),(3,169,'Audio, Video ','test');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_entries` VALUES (367,0,18,1300357796,0,1300357796,1,0,1,0,0,'','::1',1,1,1,1,1300316400,1308261600,0,'2'),(368,0,18,1300358208,1301485252,1300358208,1,1,1,2,2,'1301436000','192.168.99.160',1,1,1,1,1301436000,1301436000,0,'2');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_form_names` VALUES (3,18,'Unternehmen',''),(2,18,'Unternehmen',''),(1,18,'Unternehmen','');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_forms` VALUES (18,0,'',1,1,1,0,'');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_inputfield_names` VALUES (2,18,138,'Logo','',''),(1,18,138,'Logo','',''),(3,18,137,'Standort','',''),(2,18,137,'Standort','',''),(1,18,137,'Standort','',''),(3,18,136,'E-Mail','',''),(2,18,136,'E-Mail','',''),(1,18,136,'E-Mail','',''),(3,18,135,'Webseite','',''),(2,18,135,'Webseite','',''),(1,18,135,'Webseite','',''),(3,18,134,'Ort','',''),(2,18,134,'Ort','',''),(1,18,134,'Ort','',''),(3,18,133,'PLZ','',''),(2,18,133,'PLZ','',''),(1,18,133,'PLZ','',''),(3,18,132,'Strasse / Nr.','',''),(2,18,132,'Strasse / Nr.','',''),(1,18,132,'Strasse / Nr.','',''),(3,18,131,'Beschreibung','',''),(2,18,131,'Beschreibung','',''),(1,18,131,'Beschreibung','',''),(3,18,130,'Firmenname','',''),(1,18,130,'Firmenname','',''),(2,18,130,'Firmenname','',''),(3,18,138,'Logo','','');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_inputfields` VALUES (138,18,8,1,1,0,10,1),(137,18,15,1,0,0,9,1),(136,18,20,1,0,0,8,1),(135,18,12,1,0,0,7,1),(134,18,1,1,0,0,6,1),(133,18,1,1,1,0,5,1),(132,18,1,1,0,0,4,1),(131,18,2,1,0,1,3,1),(130,18,1,1,1,1,2,1);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_level_names` VALUES (3,18,'Bern',''),(3,26,'[[Neue Ebene]]',''),(3,21,'Graub',''),(1,20,'Wallis',''),(2,20,'Wallis',''),(3,20,'Wallis',''),(2,18,'Bern',''),(1,18,'Bern',''),(2,21,'Graub',''),(1,21,'Graubünden',''),(1,22,'Basel','baaasler ebeni'),(1,23,'Zug',''),(2,23,'Zug',''),(3,23,'Zug',''),(2,26,'[[Neue Ebene]]',''),(2,22,'Basel','baaasler ebeni'),(3,22,'Basel','baaasler ebeni'),(1,26,'Zürich','');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_levels` VALUES (18,0,0,0,1,0,'',1),(26,0,0,0,1,0,'',1),(20,0,0,1,1,0,'',1),(21,0,0,0,1,0,'',1),(22,0,0,0,1,0,'',1),(23,0,0,1,1,0,'',1);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_masks` VALUES (4,'Janik\\'s 1. Exportmaske','79,78,80,83,118,1',1,15),(5,'2','',1,15);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_order_rel_forms_selectors` VALUES (10,18,1,1),(9,18,0,1);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_rel_entry_categories` VALUES (368,167),(368,164);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_rel_entry_inputfields` VALUES (368,1,18,138,'/mediadir_merge/images/downloads/no_picture.gif'),(368,1,18,137,'46.75759950155461,7.6165080070495605,16,'),(368,1,18,136,'*****@*****.**'),(368,1,18,135,'www.comvation.com'),(368,3,18,134,'Thun'),(368,2,18,134,'Thun'),(368,1,18,134,'Thun'),(368,3,18,133,'3600'),(368,2,18,133,'3600'),(368,1,18,133,'3600'),(368,2,18,132,'Milit'),(368,3,18,132,'Milit'),(368,1,18,132,'Militärstrasse 6'),(368,3,18,131,'Die Comvation AG, Hersteller des globalen Web Content Management System Contrexx'),(368,2,18,131,'Die Comvation AG, Hersteller des globalen Web Content Management System Contrexx'),(368,1,18,131,'Die Comvation AG, Hersteller des globalen Web Content Management System Contrexx'),(368,3,18,130,'Comvation AG'),(368,2,18,130,'Comvation AG'),(368,1,18,130,'Comvation AG');");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_rel_entry_levels` VALUES (368,18);");
        tryButDontWorry("INSERT INTO `" . DBPREFIX . "module_mediadir_settings_perm_group_forms` VALUES (5,18,1),(4,18,1),(3,18,1);");
    }
    return true;
}
コード例 #6
0
ファイル: update3.php プロジェクト: Niggu/cloudrexx
        \Cx\Lib\UpdateUtil::setSourceModeOnContentPage(array('module' => 'shop', 'cmd' => 'payment'), '3.0.3');
        // replace comments placeholder with a sigma block , news module
        $search = array('/.*\\{NEWS_COUNT_COMMENTS\\}.*/ms');
        $callback = function ($matches) {
            $placeholder = '{NEWS_COUNT_COMMENTS}';
            $htmlCode = '<!-- BEGIN news_comments_count -->' . $placeholder . '<!-- END news_comments_count -->';
            if (!preg_match('/<!--\\s+BEGIN\\s+news_comments_count\\s+-->.*<!--\\s+END\\s+news_comments_count\\s+-->/ms', $matches[0])) {
                return str_replace($placeholder, $htmlCode, $matches[0]);
            } else {
                return $matches[0];
            }
        };
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => ''), $search, $callback, array('content'), '3.0.3');
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegexCallback(array('module' => 'news', 'cmd' => 'details'), $search, $callback, array('content'), '3.0.3');
        // remove the script tag at the beginning of the gallery page
        \Cx\Lib\UpdateUtil::migrateContentPageUsingRegex(array('module' => 'gallery'), '/^\\s*(<script[^>]+>.+?Shadowbox.+?<\\/script>)+/sm', '', array('content'), '3.0.3');
    } 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;
        }
        // fix duplicated social networks blocks
        if (preg_match('/<!--\\s+BEGIN\\s+access_social_networks\\s+-->.*<!--\\s+BEGIN\\s+access_social_networks\\s+-->/ms', $content)) {
            $content = preg_replace('/<br\\s+\\/><br\\s+\\/><!--\\s+BEGIN\\s+access_social_networks\\s+-->.*?<!--\\s+END\\s+access_social_networks\\s+-->/ms', '', $content);