![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: view_topics.php 144 2008-04-06 19:54:09Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/forums/view_topics.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $AppUI->savePlace(); 7 8 // retrieve any state parameters 9 if (isset($_GET['orderby'])) { 10 $orderdir = $AppUI->getState('ForumVwOrderDir') ? ($AppUI->getState('ForumVwOrderDir') == 'asc' ? 'desc' : 'asc') : 'desc'; 11 $AppUI->setState('ForumVwOrderBy', w2PgetParam($_GET, 'orderby', null)); 12 $AppUI->setState('ForumVwOrderDir', $orderdir); 13 } 14 $orderby = $AppUI->getState('ForumVwOrderBy') ? $AppUI->getState('ForumVwOrderBy') : 'latest_reply'; 15 $orderdir = $AppUI->getState('ForumVwOrderDir') ? $AppUI->getState('ForumVwOrderDir') : 'desc'; 16 17 //Pull All Messages 18 $q = new DBQuery; 19 $q->addTable('forum_messages', 'fm1'); 20 $q->addQuery('fm1.*'); 21 $q->addQuery('COUNT(distinct fm2.message_id) AS replies'); 22 $q->addQuery('MAX(fm2.message_date) AS latest_reply'); 23 $q->addQuery('user_username, contact_first_name, contact_last_name, watch_user'); 24 $q->addQuery('count(distinct v1.visit_message) as reply_visits'); 25 $q->addQuery('v1.visit_user'); 26 $q->leftJoin('users', 'u', 'fm1.message_author = u.user_id'); 27 $q->leftJoin('contacts', 'con', 'contact_id = user_contact'); 28 $q->leftJoin('forum_messages', 'fm2', 'fm1.message_id = fm2.message_parent'); 29 $q->leftJoin('forum_watch', 'fw', 'watch_user = ' . (int)$AppUI->user_id . ' AND watch_topic = fm1.message_id'); 30 $q->leftJoin('forum_visits', 'v1', 'v1.visit_user = ' . (int)$AppUI->user_id . ' AND v1.visit_message = fm1.message_id'); 31 $q->addWhere('fm1.message_forum = ' . (int)$forum_id); 32 33 switch ($f) { 34 case 1: 35 $q->addWhere('watch_user IS NOT NULL'); 36 break; 37 case 2: 38 $q->addWhere('(NOW() < DATE_ADD(fm2.message_date, INTERVAL 30 DAY) OR NOW() < DATE_ADD(fm1.message_date, INTERVAL 30 DAY))'); 39 break; 40 } 41 $q->addGroup('fm1.message_id, fm1.message_parent'); 42 $q->addOrder($orderby . ' ' . $orderdir); 43 $topics = $q->loadList(); 44 45 $crumbs = array(); 46 $crumbs['?m=forums'] = 'forums list'; 47 ?> 48 <br /> 49 <?php 50 if (function_exists('styleRenderBoxTop')) { 51 echo styleRenderBoxTop(); 52 } 53 ?> 54 <table width="100%" cellspacing="1" cellpadding="2" border="0" class="tbl"> 55 <form name="watcher" action="?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&f=<?php echo $f; ?>" method="post"> 56 <tr><td colspan="5"> 57 <table width="100%" cellspacing="1" cellpadding="2" border="0"> 58 <tr> 59 <td align="left" nowrap="nowrap"><?php echo breadCrumbs($crumbs); ?></td> 60 <td width="100%" align="right"> 61 <?php if ($canAuthor) { ?> 62 <input type="button" class="button" style="width:120;" value="<?php echo $AppUI->_('start a new topic'); ?>" onclick="javascript:window.location='./index.php?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&post_message=1';"> 63 <?php } ?> 64 </td> 65 </tr> 66 </table> 67 </td></tr> 68 <tr> 69 <th><a href="?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&orderby=watch_user" class="hdr"><?php echo $AppUI->_('Watch'); ?></a></th> 70 <th><a href="?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&orderby=message_title" class="hdr"><?php echo $AppUI->_('Topics'); ?></a></th> 71 <th><a href="?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&orderby=user_username" class="hdr"><?php echo $AppUI->_('Author'); ?></a></th> 72 <th><a href="?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&orderby=replies" class="hdr"><?php echo $AppUI->_('Replies'); ?></a></th> 73 <th><a href="?m=forums&a=viewer&forum_id=<?php echo $forum_id; ?>&orderby=latest_reply" class="hdr"><?php echo $AppUI->_('Last Post'); ?></a></th> 74 </tr> 75 <?php 76 77 $now = new CDate(); 78 79 foreach ($topics as $row) { 80 $last = intval($row['latest_reply']) ? new CDate($row['latest_reply']) : null; 81 82 //JBF limit displayed messages to first-in-thread 83 if ($row["message_parent"] < 0) { ?> 84 <tr> 85 <td nowrap="nowrap" align="center" width="1%"> 86 <input type="checkbox" name="forum_<?php echo $row['message_id']; ?>" <?php echo $row['watch_user'] ? 'checked="checked"' : ''; ?> /> 87 </td> 88 <td> 89 <?php 90 if ($row['visit_user'] != $AppUI->user_id || $row['reply_visits'] != $row['replies']) { 91 echo w2PshowImage('icons/stock_new_small.png', false, false, 'You have unread posts in this topic'); 92 } 93 ?> 94 <span style="font-size:10pt;"> 95 <a href="?m=forums&a=viewer&forum_id=<?php echo $forum_id . '&message_id=' . $row["message_id"]; ?>"><?php echo $row['message_title']; ?></a> 96 </span> 97 </td> 98 <td bgcolor="#dddddd" width="10%"><?php echo $row['contact_first_name'] . ' ' . $row['contact_last_name']; ?></td> 99 <td align="center" width="10%"><?php echo $row['replies']; ?></td> 100 <td bgcolor="#dddddd" width="150" nowrap="nowrap"> 101 <?php if ($row['latest_reply']) { 102 echo $last->format($df . ' ' . $tf) . '<br /><font color="#999966">('; 103 104 $span = new Date_Span(); 105 $span->setFromDateDiff($now, $last); 106 107 printf('%.1f', $span->format('%d')); 108 echo ' ' . $AppUI->_('days ago'); 109 110 echo ')</font>'; 111 } else { 112 echo $AppUI->_('No replies'); 113 } 114 ?> 115 </td> 116 </tr> 117 <?php 118 } 119 } ?> 120 </table> 121 122 <table width="100%" border="0" cellpadding="0" cellspacing="1" class="std"> 123 <input type="hidden" name="dosql" value="do_watch_forum" /> 124 <input type="hidden" name="watch" value="topic" /> 125 <tr> 126 <td align="left"> 127 <input type="submit" class="button" value="<?php echo $AppUI->_('update watches'); ?>" /> 128 </td> 129 </tr> 130 </form> 131 </table>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |