0 ? $setconfig['perpage_pc'] : 10; $this->setconfig = $setconfig; } function forumdisplay_variables(&$variables) { global $_G; $setconfig = $this->setconfig; if($setconfig['allow_forums'] && !in_array($variables['fid'], $setconfig['allow_forums'])){ return; } if($setconfig['add_replies']){ $tids = array(); foreach ($variables['forum_threadlist'] as &$thread) { $tids[] = $thread['tid']; } if(empty($tids)){ return; } $wherearr = array(); $wherearr[] = 'tid in ('.dimplode($tids).')'; $wherearr[] = "status = '0'"; $recordlist = DB::fetch_all('SELECT tid,count(*) as count FROM '.DB::table('plugin_replyfloor_message').($wherearr ? ' WHERE '.implode(' AND ', $wherearr) : '').' group by tid'); $count = array(); foreach ($recordlist as $value) { $count[$value['tid']] = $value['count']; } foreach ($variables['forum_threadlist'] as &$thread) { if($count[$thread['tid']]){ $thread['replies'] += $count[$thread['tid']]; } } } } function viewthread_variables(&$variables) { global $_G; $setconfig = $this->setconfig; if($setconfig['allow_forums'] && !in_array($variables['fid'], $setconfig['allow_forums'])){ return; } if(empty($_GET['viewpid'])) { $pids = array(); foreach($variables['postlist'] as $post) { if(!$post['first']){ $pids[] = $post['pid']; } } if($pids) { if(!$setconfig['order_type']){ $setconfig['order_type'] = empty($_GET['ordertype']) && getstatus($_G['forum_thread']['status'], 4) ? 1 : intval($_GET['ordertype']); } $orderby = 'order by createtime desc'; if($setconfig['order_type'] == 2){ $orderby = 'order by createtime asc'; } $messageinfo = C::t('#'.self::$identifier.'#replyfloor_message')->fetch_message_by_pid($pids, $setconfig['perpage_pc'], $orderby, $setconfig); foreach($variables['postlist'] as &$post) { if(!$post['first']){ $count = $messageinfo[$post['pid']]['count'] ? $messageinfo[$post['pid']]['count'] : 0; $list = $messageinfo[$post['pid']]['list'] ? $messageinfo[$post['pid']]['list'] : array(); $post['replyfloor'] = array('count' => $count, 'list' => $list); } } } } else { } $variables['allowreplyfloor'] = 1; } }