--- showthread.php.old 2006-08-20 11:54:10.000000000 +0200 +++ showthread.php 2006-08-20 11:53:51.000000000 +0200 @@ -379,7 +379,10 @@ } // Build the threaded tree - $query = $db->query("SELECT u.*, u.username AS userusername, p.*, i.path as iconpath, i.name as iconname FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=p.icon) WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline"); + // KK: poprawki z watku: + // http://community.mybboard.net/showthread.php?tid=11399 + /* + $query = $db->query("SELECT u.*, u.username AS userusername, p.*, i.path as iconpath, i.name as iconname FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=p.icon) WHERE p.tid='$tid' AND p.visible='1' ORDER BY p.dateline"); // KK: oryginalne SQL while($post = $db->fetch_array($query)) { if(!$postsdone[$post['pid']]) { $tree[$post['replyto']][$post['pid']] = $post; @@ -389,6 +392,21 @@ $postsdone[$post['pid']] = 1; } } + */ + $query = $db->query("SELECT u.*, u.username AS userusername, p.pid, p.replyto, p.subject, p.dateline, p.message as message, i.path as iconpath, i.name as iconname FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=p.icon) WHERE p.tid='$tid' AND p.visible='1' AND p.pid = " . intval($mybb->input['pid']) . " ORDER BY p.dateline") ; + if($post = $db->fetch_array($query)) { + $tree[$post['replyto']][$post['pid']] = $post; + $isfirst = 0; + $postsdone[$post['pid']] = 1; + } + $query = $db->query("SELECT u.username AS userusername, u.username, p.pid, p.replyto, p.subject, p.dateline, i.path as iconpath, i.name as iconname FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid=p.icon) WHERE p.tid='$tid' AND p.visible='1' AND p.pid != " . intval($mybb->input['pid']) . " ORDER BY p.dateline") ; + while($post = $db->fetch_array($query)) { + if(!$postsdone[$post['pid']]) { + $tree[$post['replyto']][$post['pid']] = $post; + $tree[$post['replyto']][$post['pid']]['message'] = ''; + $postsdone[$post['pid']] = 1; + } + } $threadedbits = buildtree(); // KK: $query = $db->query("SELECT MAX(pid) as lastpostpid FROM ".TABLE_PREFIX."posts WHERE tid='$tid'") ;