11unset( $xoopsOption[
'nocommon'] );
13include
'../mainfile.php';
14include
'../class/xoopscomments.php';
15include
'../include/comment_constants.php';
17echo
'<h2>wizard/install_updateComments_go.inc</h2>';
19$module_handler =& xoops_gethandler(
'module' );
20$old_commentd_mods = [
'news' =>
'comments',
'xoopspoll' =>
'xoopspollcomments' ];
21$title = _INSTALL_L147;
24foreach ( $old_commentd_mods as $module => $com_table ) {
25 $moduleobj =& $module_handler->getByDirname( $module );
26 if ( is_object( $moduleobj ) ) {
27 $content .=
'<h5>' . $moduleobj->getVar(
'name' ) .
'</h5>';
28 $comment_handler =& xoops_gethandler(
'comment' );
30 $criteria->setOrder(
'DESC' );
31 $criteria->setSort(
'com_id' );
32 $criteria->setLimit( 1 );
33 $last_comment =& $comment_handler->getObjects( $criteria );
34 $offset = ( is_array( $last_comment ) && count( $last_comment ) > 0 ) ? $last_comment[0]->getVar(
'com_id' ) : 0;
37 $top_comments = $xc->getAllComments( [
'pid=0' ] );
39 foreach ( $top_comments as $tc ) {
40 $sql = sprintf(
"INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix(
'xoopscomments' ), $tc->getVar(
'comment_id' ) + $offset, 0, $moduleobj->getVar(
'mid' ),
'', addslashes( $tc->getVar(
'subject',
'n' ) ), addslashes( $tc->getVar(
'comment',
'n' ) ), $tc->getVar(
'date' ), $tc->getVar(
'date' ), $tc->getVar(
'user_id' ), $tc->getVar(
'ip' ), 0, $tc->getVar(
'item_id' ), $tc->getVar(
'comment_id' ) + $offset, XOOPS_COMMENT_ACTIVE, 0, 1, 1, 1, 1 );
42 if ( ! $xoopsDB->query( $sql ) ) {
43 $content .= _NGIMG . sprintf( _INSTALL_L146, $tc->getVar(
'comment_id' ) + $offset ) .
'<br>';
45 $content .= _OKIMG . sprintf( _INSTALL_L145, $tc->getVar(
'comment_id' ) + $offset ) .
'<br>';
46 $child_comments = $tc->getCommentTree();
47 foreach ( $child_comments as $cc ) {
48 $sql = sprintf(
"INSERT INTO %s (com_id, com_pid, com_modid, com_icon, com_title, com_text, com_created, com_modified, com_uid, com_ip, com_sig, com_itemid, com_rootid, com_status, dohtml, dosmiley, doxcode, doimage, dobr) VALUES (%u, %u, %u, '%s', '%s', '%s', %u, %u, %u, '%s', %u, %u, %u, %u, %u, %u, %u, %u, %u)", $xoopsDB->prefix(
'xoopscomments' ), $cc->getVar(
'comment_id' ) + $offset, $cc->getVar(
'pid' ) + $offset, $moduleobj->getVar(
'mid' ),
'', addslashes( $cc->getVar(
'subject',
'n' ) ), addslashes( $cc->getVar(
'comment',
'n' ) ), $cc->getVar(
'date' ), $cc->getVar(
'date' ), $cc->getVar(
'user_id' ), $cc->getVar(
'ip' ), 0, $cc->getVar(
'item_id' ), $tc->getVar(
'comment_id' ) + $offset, XOOPS_COMMENT_ACTIVE, 0, 1, 1, 1, 1 );
49 if ( ! $xoopsDB->query( $sql ) ) {
50 $content .= _NGIMG . sprintf( _INSTALL_L146, $cc->getVar(
'comment_id' ) + $offset ) .
'<br>';
52 $content .= _OKIMG . sprintf( _INSTALL_L145, $cc->getVar(
'comment_id' ) + $offset ) .
'<br>';
59$xoopsDB->query(
'ALTER TABLE ' . $xoopsDB->prefix(
'xoopscomments' ) .
' CHANGE com_id com_id mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY' );
61$b_next = [
'updateSmilies', _INSTALL_L14 ];
63include
'./install_tpl.php';