fix comments

5180 and nid < 5210'); $vid = variable_get('forum_nav_vocabulary', ''); while ($row = db_fetch_object($result)) { $node = node_load($row->nid); $node->taxonomy[200]->tid=200; $node->taxonomy[200]->vid=$vid; node_save($node); } /* db_set_active('ttsb'); $sql = 'SELECT c.cid,c.pid, c.uid as cuid, c.subject, c.hostname, c.timestamp, c.status, c.format, c.thread, c.name, c.mail, c.homepage, n.nid, n.title, n.type, n.uid,n.created,n.changed,n.comment, r.body,r.teaser FROM `comments` c LEFT JOIN node n ON n.nid = c.nid left join forum f on f.nid = n.nid left join node_revisions r on r.vid = n.vid AND r.nid=n.nid WHERE n.status =1 AND f.tid=116'; $result = db_query($sql); db_set_active(); $nid=0; while ($row=db_fetch_object($result)) { db_set_active('ttsb'); $longtext = db_result(db_query('select comment from comments where cid=%d',$row->cid)); db_set_active(); //echo $longtext.'
'; if ($row->nid != $nid) { echo $row->title.'
'; $node = new STDClass(); $node->title = $row->title; $node->type = $row->type; $node->format = 5; $node->uid = $row->uid; $node->created = $row->created; $node->changed = $row->changed; $node->comment = $row->comment; $node->body = $row->body; $node->teaser = $row->teaser; $node->tid = 200; $node->og_groups = array('3218'=>'3218'); node_save($node); $nid = $row->nid; } $newNID = $node->nid; $newVID = $node->vid; $newPID = 0; if ($row->pid > 0) { db_set_active('ttsb'); $result2 = db_query("select * from comments where cid = %d",$row->pid); db_set_active(); while ($parentrow = db_fetch_object($result2)) { $result3 = db_query("select cid from comments where nid=%d AND subject='%s'",$newNID,$parentrow->subject); while ($cidrow = db_fetch_object($result3)) { $newPID = $cidrow->cid; } } } $edit = array('nid'=>$newNID,'pid'=>$newPID,'uid'=>$row->cuid,'subject'=>$row->subject,'comment'=>$longtext,'format'=>$row->format,'timestamp'=>$row->timestamp,'status'=>1,'name'=>$row->name,'mail'=>$row->mail,'homepage'=>$row->homepage); comment_save($edit); }*/ /* db_set_active('ttsb'); $sql = 'SELECT c.cid, c.pid, c.uid, c.subject, c.comment, c.hostname, c.timestamp, c.status, c.format, c.thread, c.name, c.mail, c.homepage, n.nid, n.title, n.type FROM `comments` c LEFT JOIN node n ON n.nid = c.nid WHERE n.status =1 AND c.timestamp > 1293840000'; $result = db_query($sql); db_set_active(); while ($row=db_fetch_object($result)) { $sql = "SELECT c.cid, c.pid, c.uid, c.subject, c.comment, c.hostname, c.timestamp, c.status, c.format, c.thread, c.name, c.mail, c.homepage, n.nid, n.title, n.type FROM `comments` c LEFT JOIN node n ON n.nid = c.nid WHERE n.status =1 AND c.cid=%d AND c.uid=%d AND c.subject='%s'"; $result2 = db_query($sql,$row->cid,$row->uid,$row->subject); while ($row2 = db_fetch_object($result2)) { if (strcasecmp($row2->title,$row->title) <> 0) { print $row2->cid.' might have wrong nid ('.$row2->nid.')
old nid is '.$row->title.' new nid is '.$row2->title.'
'; $result3=db_query("select * from node n where n.type='%s' and n.title='%s'",$row->type,$row->title); if ($row3 = db_fetch_object($result3)) { //print 'Replacement node found->'.$row3->nid.'
'; //db_query('update comments set nid=%d where cid=%d',$row3->nid,$row2->cid); } else { print 'No replacement node found
'; print $row->nid.'
'; print $row->type.'
'; print $row->title.'
'; if ($row->type == 'forum') { print 'fix forum
'; db_set_active('ttsb'); $oldnode = db_fetch_object(db_query("SELECT node.vid, node.type, node.title, node.uid, node.status, node.created, node.changed, node.comment, node.promote, node.moderate, node.sticky, node.language, node.tnid, node.translate FROM `node` WHERE nid =%d",$row->nid)); print "old node is ".$oldnode->title."
"; $oldrev = db_fetch_object(db_query("SELECT uid, title, body, teaser, log, timestamp, format FROM node_revisions where vid=%d",$oldnode->vid)); print "old rev is ".$oldrev->title."
"; $tid = db_fetch_object(db_query("SELECT * FROM `term_data` t LEFT JOIN forum f ON f.tid = t.tid WHERE f.nid =%d",$row->nid)); print "old tid is ".$tid->name."
"; db_set_active(); if ($row4 = db_fetch_object(db_query("select * from term_data where name='%s'",$tid->name)) ) { print "found a matching tid ".$row4->tid."
"; print "Would be creating ".$node->title." for ".$row2->subject."
"; /*drupal_write_record('node',$oldnode); $oldrev->nid = $oldnode->nid; drupal_write_record('node_revisions',$oldrev); $formrecord = array('nid'=>$oldnode->nid,'vid'=>$oldrev->vid,'tid'=>$row4->tid); drupal_write_record('forum',$forumrecord); db_query('update comments set nid=%d where cid=%d',$oldnode->nid,$row2->cid);*//* } } } } } }*/ ?>