示例#1
0
    foreach ($users as $user) {
        $comments = count(ItemComment::newInstance()->findByAuthorID($user['pk_i_id']));
        $items = count(Item::newInstance()->findByUserIDEnabled($user['pk_i_id']));
        User::newInstance()->update(array('i_items' => $items, 'i_comments' => $comments), array('pk_i_id' => $user['pk_i_id']));
        // CHANGE FROM b_enabled to b_active
        User::newInstance()->update(array('b_active' => $user['b_enabled'], 'b_enabled' => 1), array('pk_i_id' => $user['pk_i_id']));
    }
    unset($users);
    // Drop e_status column in t_item and t_item_comment
    $comm->query(sprintf("ALTER TABLE %st_item DROP e_status", DB_TABLE_PREFIX));
    $comm->query(sprintf("ALTER TABLE %st_item_comment DROP e_status", DB_TABLE_PREFIX));
    // Delete enabled_item_validation in t_preference
    $comm->query(sprintf("DELETE FROM %st_preference WHERE s_name = 'enabled_item_validation'", DB_TABLE_PREFIX));
    // insert two new e-mail notifications
    $comm->query(sprintf("INSERT INTO %st_pages (s_internal_name, b_indelible, dt_pub_date) VALUES ('email_alert_validation', 1, '%s' )", DB_TABLE_PREFIX, date('Y-m-d H:i:s')));
    $comm->query(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', 'Please validate your alert', '<p>Hi {USER_NAME},</p>\n<p>Please validate your alert registration by clicking on the following link: {VALIDATION_LINK}</p>\n<p>Thank you!</p>\n<p>Regards,</p>\n<p>{WEB_TITLE}</p>')", DB_TABLE_PREFIX, $comm->insertedId()));
    $comm->query(sprintf("INSERT INTO %st_pages (s_internal_name, b_indelible, dt_pub_date) VALUES ('email_comment_validated', 1, '%s' )", DB_TABLE_PREFIX, date('Y-m-d H:i:s')));
    $comm->query(sprintf("INSERT INTO %st_pages_description (fk_i_pages_id, fk_c_locale_code, s_title, s_text) VALUES (%d, 'en_US', '{WEB_TITLE} - Your comment has been approved', '<p>Hi {COMMENT_AUTHOR},</p>\n<p>Your comment has been approved on the following item: {ITEM_URL}</p>\n<p>Regards,</p>\n<p>{WEB_TITLE}</p>')", DB_TABLE_PREFIX, $comm->insertedId()));
}
if (osc_version() < 220) {
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_text', '', 'STRING')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_text_color', '', 'STRING')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_image','', 'STRING')", DB_TABLE_PREFIX));
    $comm->query(sprintf("INSERT INTO %st_preference VALUES ('osclass', 'watermark_place', 'centre', 'STRING')", DB_TABLE_PREFIX));
}
if (osc_version() < 230) {
    $comm->query(sprintf("\nCREATE TABLE %st_item_description_tmp (\n    fk_i_item_id INT UNSIGNED NOT NULL,\n    fk_c_locale_code CHAR(5) NOT NULL,\n    s_title VARCHAR(100) NOT NULL,\n    s_description MEDIUMTEXT NOT NULL,\n    s_what LONGTEXT NULL,\n\n        PRIMARY KEY (fk_i_item_id, fk_c_locale_code),\n        INDEX (fk_i_item_id),\n        FOREIGN KEY (fk_i_item_id) REFERENCES %st_item (pk_i_id),\n        FOREIGN KEY (fk_c_locale_code) REFERENCES %st_locale (pk_c_code)\n) ENGINE=MyISAM DEFAULT CHARACTER SET 'UTF8' COLLATE 'UTF8_GENERAL_CI';", DB_TABLE_PREFIX, DB_TABLE_PREFIX, DB_TABLE_PREFIX));
    $result = $comm->query(sprintf("SELECT * FROM %st_item_description", DB_TABLE_PREFIX));
    $descriptions = $result->result();
    foreach ($descriptions as $d) {
        $sql = sprintf("INSERT INTO %st_item_description_tmp (`fk_i_item_id` ,`fk_c_locale_code` ,`s_title` ,`s_description` ,`s_what`) VALUES ('%d',  '%s',  '%s',  '%s',  '%s')", DB_TABLE_PREFIX, $d['fk_i_item_id'], $d['fk_c_locale_code'], $comm->connId->real_escape_string($d['s_title']), $comm->connId->real_escape_string($d['s_description']), $comm->connId->real_escape_string($d['s_what']));