![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: index.php 113 2008-03-21 16:11:42Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/forums/index.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('ForumIdxOrderDir') ? ($AppUI->getState('ForumIdxOrderDir') == 'asc' ? 'desc' : 'asc') : 'desc'; 11 $AppUI->setState('ForumIdxOrderBy', w2PgetParam($_GET, 'orderby', null)); 12 $AppUI->setState('ForumIdxOrderDir', $orderdir); 13 } 14 $orderby = $AppUI->getState('ForumIdxOrderBy') ? $AppUI->getState('ForumIdxOrderBy') : 'forum_name'; 15 $orderdir = $AppUI->getState('ForumIdxOrderDir') ? $AppUI->getState('ForumIdxOrderDir') : 'asc'; 16 17 $perms = &$AppUI->acl(); 18 19 $df = $AppUI->getPref('SHDATEFORMAT'); 20 $tf = $AppUI->getPref('TIMEFORMAT'); 21 22 $f = w2PgetParam($_POST, 'f', 0); 23 24 $forum = &new CForum; 25 require_once $AppUI->getModuleClass('projects'); 26 $project = &new CProject; 27 28 $max_msg_length = 30; 29 30 /* Query modified by Fergus McDonald 2005/08/12 to address slow join issue */ 31 32 $q = new DBQuery; 33 $q->addTable('forums'); 34 $q->addTable('projects', 'pr'); 35 $q->addTable('users', 'u'); 36 $q->addQuery('forum_id, forum_project, forum_description, forum_owner, forum_name'); 37 $q->addQuery('forum_moderated, forum_create_date, forum_last_date'); 38 $q->addQuery('sum(if(c.message_parent=-1,1,0)) as forum_topics, sum(if(c.message_parent>0,1,0)) as forum_replies'); 39 $q->addQuery('user_username, project_name, project_color_identifier, CONCAT(contact_first_name,\' \',contact_last_name) owner_name'); 40 $q->addQuery('SUBSTRING(l.message_body,1,' . $max_msg_length . ') message_body'); 41 $q->addQuery('LENGTH(l.message_body) message_length, watch_user, l.message_parent, l.message_id'); 42 $q->addQuery('count(distinct v.visit_message) as visit_count, count(distinct c.message_id) as message_count'); 43 $q->addJoin('forum_messages', 'l', 'l.message_id = forum_last_id'); 44 $q->addJoin('forum_messages', 'c', 'c.message_forum = forum_id'); 45 $q->addJoin('forum_watch', 'w', 'watch_user = ' . (int)$AppUI->user_id . ' AND watch_forum = forum_id'); 46 $q->addJoin('forum_visits', 'v', 'visit_user = ' . (int)$AppUI->user_id . ' AND visit_forum = forum_id and visit_message = c.message_id'); 47 $q->addJoin('contacts', 'cts', 'contact_id = u.user_contact'); 48 49 $project->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); 50 $forum->setAllowedSQL($AppUI->user_id, $q); 51 52 $q->addWhere('user_id = forum_owner AND pr.project_id = forum_project'); 53 54 switch ($f) { 55 case 1: 56 $q->addWhere('project_active = 1 AND forum_owner = ' . (int)$AppUI->user_id); 57 break; 58 case 2: 59 $q->addWhere('project_active = 1 AND watch_user IS NOT NULL'); 60 break; 61 case 3: 62 $q->addWhere('project_active = 1 AND project_owner = ' . (int)$AppUI->user_id); 63 break; 64 case 4: 65 $q->addWhere('project_active = 1 AND project_company = ' . (int)$AppUI->user_company); 66 break; 67 case 5: 68 $q->addWhere('project_active = 0'); 69 break; 70 default: 71 $q->addWhere('project_active = 1'); 72 break; 73 } 74 75 $q->addGroup('forum_id'); 76 $q->addOrder($orderby . ' ' . $orderdir); 77 $forums = $q->loadList(); 78 79 // setup the title block 80 $titleBlock = new CTitleBlock('Forums', 'support.png', $m, $m . '.' . $a); 81 $titleBlock->addCell(arraySelect($filters, 'f', 'size="1" class="text" onChange="document.forum_filter.submit();"', $f, true), '', '<form name="forum_filter" action="?m=forums" method="post">', '</form>'); 82 83 $canAdd = $perms->checkModule($m, 'add'); 84 if ($canAdd) { 85 $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new forum') . '">', '', '<form action="?m=forums&a=addedit" method="post">', '</form>'); 86 } 87 $titleBlock->show(); 88 ?> 89 90 <table width="100%" cellspacing="1" cellpadding="2" border="0" class="tbl"> 91 <form name="watcher" action="./index.php?m=forums&f=<?php echo $f; ?>" method="post"> 92 <tr> 93 <th nowrap="nowrap"> </th> 94 <th nowrap="nowrap" width="25"><a href="?m=forums&orderby=watch_user" class="hdr"><?php echo $AppUI->_('Watch'); ?></a></th> 95 <th nowrap="nowrap"><a href="?m=forums&orderby=forum_name" class="hdr"><?php echo $AppUI->_('Forum Name'); ?></a></th> 96 <th nowrap="nowrap" width="50" align="center"><a href="?m=forums&orderby=forum_topics" class="hdr"><?php echo $AppUI->_('Topics'); ?></a></th> 97 <th nowrap="nowrap" width="50" align="center"><a href="?m=forums&orderby=forum_replies" class="hdr"><?php echo $AppUI->_('Replies'); ?></a></th> 98 <th nowrap="nowrap" width="200"><a href="?m=forums&orderby=forum_last_date" class="hdr"><?php echo $AppUI->_('Last Post Info'); ?></a></th> 99 </tr> 100 <?php 101 $p = ''; 102 $now = new CDate(); 103 foreach ($forums as $row) { 104 $message_date = intval($row['forum_last_date']) ? new CDate($row['forum_last_date']) : null; 105 106 if ($p != $row['forum_project']) { 107 $create_date = intval($row['forum_create_date']) ? new CDate($row['forum_create_date']) : null; 108 ?> 109 <tr> 110 <td colspan="6" style="background-color:#<?php echo $row['project_color_identifier']; ?>"> 111 <a href="?m=projects&a=view&project_id=<?php echo $row['forum_project']; ?>"> 112 <font color="<?php echo bestColor($row['project_color_identifier']); ?>"> 113 <strong><?php echo $row['project_name']; ?></strong> 114 </font> 115 </a> 116 </td> 117 </tr> 118 <?php 119 $p = $row['forum_project']; 120 } ?> 121 <tr> 122 <td nowrap="nowrap" align="center"> 123 <?php if ($row["forum_owner"] == $AppUI->user_id || $perms->checkModule('forums', 'add')) { ?> 124 <a href="?m=forums&a=addedit&forum_id=<?php echo $row['forum_id']; ?>" title="<?php echo $AppUI->_('edit'); ?>"> 125 <?php echo w2PshowImage('icons/stock_edit-16.png', 16, 16, ''); ?> 126 </a> 127 <?php } 128 if ($row['visit_count'] != $row['message_count']) { 129 echo ' ' . w2PshowImage('icons/stock_new_small.png', false, false, 'You have unread messages in this forum'); 130 } 131 ?> 132 </td> 133 134 <td nowrap="nowrap" align="center"> 135 <input type="checkbox" name="forum_<?php echo $row['forum_id']; ?>" <?php echo $row['watch_user'] ? 'checked="checked"' : ''; ?> /> 136 </td> 137 138 <td> 139 <span style="font-size:10pt;font-weight:bold"> 140 <a href="?m=forums&a=viewer&forum_id=<?php echo $row['forum_id']; ?>"><?php echo $row['forum_name']; ?></a> 141 </span> 142 <br /><?php echo $row['forum_description']; ?> 143 <br /><font color="#777777"><?php echo $AppUI->_('Owner') . ' ' . $row['owner_name']; ?>, 144 <?php echo $AppUI->_('Started') . ' ' . $create_date->format($df); ?> 145 </font> 146 </td> 147 <td nowrap="nowrap" align="center"><?php echo $row['forum_topics']; ?></td> 148 <td nowrap="nowrap" align="center"><?php echo $row['forum_replies']; ?></td> 149 <td width="225"> 150 <?php 151 if ($message_date !== null) { 152 echo $message_date->format($df . ' ' . $tf); 153 154 $last = new Date_Span(); 155 $last->setFromDateDiff($now, $message_date); 156 157 echo '<br /><font color=#999966>(' . $AppUI->_('Last post') . ' '; 158 printf('%.1f', $last->format('%d')); 159 echo ' ' . $AppUI->_('days ago') . ') </font>'; 160 161 $id = $row['message_parent'] < 0 ? $row['message_id'] : $row['message_parent']; 162 163 echo '<br />> <a href="?m=forums&a=viewer&forum_id=' . $row['forum_id'] . '&message_id=' . $id . '">'; 164 echo '<font color=#777777>' . $row['message_body']; 165 echo $row['message_length'] > $max_msg_length ? '...' : ''; 166 echo '</font></a>'; 167 } else { 168 echo $AppUI->_('No posts'); 169 } 170 ?> 171 </td> 172 </tr> 173 174 <?php } ?> 175 </table> 176 177 <table width="100%" cellspacing="0" cellpadding="0" border="0" class="std"> 178 <input type="hidden" name="dosql" value="do_watch_forum" /> 179 <input type="hidden" name="watch" value="forum" /> 180 <tr> 181 <td align="left"> 182 <input type="submit" class="button" value="<?php echo $AppUI->_('update watches'); ?>" /> 183 </td> 184 </tr> 185 </form> 186 </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 |