XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
install_updateComments_go.inc.php
1<?php
10
11unset( $xoopsOption['nocommon'] );
12
13include '../mainfile.php';
14include '../class/xoopscomments.php';
15include '../include/comment_constants.php';
16
17echo '<h2>wizard/install_updateComments_go.inc</h2>';
18
19$module_handler =& xoops_gethandler( 'module' );
20$old_commentd_mods = [ 'news' => 'comments', 'xoopspoll' => 'xoopspollcomments' ];
21$title = _INSTALL_L147;
22$content = '';
23
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' );
29 $criteria = new CriteriaCompo();
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;
35 $xc = new XoopsComments( $xoopsDB->prefix( $com_table ) );
36 // @todo ref $top_comments =& $xc->getAllComments( [ 'pid=0' ] );
37 $top_comments = $xc->getAllComments( [ 'pid=0' ] );
38
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 );
41
42 if ( ! $xoopsDB->query( $sql ) ) {
43 $content .= _NGIMG . sprintf( _INSTALL_L146, $tc->getVar( 'comment_id' ) + $offset ) . '<br>';
44 } else {
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>';
51 } else {
52 $content .= _OKIMG . sprintf( _INSTALL_L145, $cc->getVar( 'comment_id' ) + $offset ) . '<br>';
53 }
54 }
55 }
56 }
57 }
58}
59$xoopsDB->query( 'ALTER TABLE ' . $xoopsDB->prefix( 'xoopscomments' ) . ' CHANGE com_id com_id mediumint(8) unsigned NOT NULL auto_increment PRIMARY KEY' );
60
61$b_next = [ 'updateSmilies', _INSTALL_L14 ];
62
63include './install_tpl.php';