4 * GForge Monitored Forums Track Page
6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2002-2004 (c) GForge Team
12 * This file is part of GForge.
14 * GForge is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * GForge is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with GForge; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 /* my monitored forums
30 by Daniel Perez - 2005
33 require_once('../env.inc.php');
34 require_once $gfwww.'include/pre.php';
35 require_once $gfwww.'forum/include/ForumHTML.class.php';
36 require_once $gfcommon.'forum/Forum.class.php';
37 require_once $gfcommon.'forum/ForumFactory.class.php';
38 require_once $gfcommon.'forum/ForumMessageFactory.class.php';
39 require_once $gfcommon.'forum/ForumMessage.class.php';
43 if (!session_loggedin()) {
44 exit_permission_denied();
47 $user_id = user_getid();
48 $group_id = getIntFromRequest("group_id");
49 //get the user monitored forums
50 $sql = "SELECT mon.forum_id, fg.group_id FROM forum_monitored_forums mon,forum_group_list fg where mon.user_id='$user_id' and fg.group_forum_id=mon.forum_id";
51 $result = db_query($sql);
52 if (!$result || db_numrows($result) < 1) {
53 exit_error(_('You have no monitored forums'),_('You are not monitoring any forums.').' '.db_error(), 'forums');
56 //now, i need to create a forum object per each forum that the user is monitoring
58 $monitored_forums = array();
59 for ($i=0;$i<db_numrows($result);$i++) {
60 $monitored_forums[$i] = db_fetch_array($result);
63 //if the link comes from the project, display the project header. If it comes from the user page, display the normal site header
65 forum_header(array('title'=>_('My Monitored Forums')));
67 site_header(array('title'=>_('My Monitored Forums'), 'user_id' => $user_id));
70 echo "<h4>" . _('My Monitored Forums') . "</h4></p>";
71 $tablearr=array(_('Project'),_('Forum'),
72 _('Description'),_('Threads'),
73 _('Posts'), _('Last Post'), _('New Content?'));
74 echo $HTML->listTableTop($tablearr);
80 //CHECK : if we won�t ever be needing to store each forum/fmf, etc for each pass, don�t use an array and use the same variable like $fmf instead of $fmf[$i], etc
81 for($i=0;$i<sizeof($monitored_forums);$i++) {
82 $g =& group_get_object($monitored_forums[$i]["group_id"]);
83 if (!$g || !is_object($g) || $g->isError()) {
86 $f = new Forum($g,$monitored_forums[$i]["forum_id"]);
87 if (!$f || !is_object($f) || $f->isError()) {
88 exit_error(_('Error'));
91 //just skip it - this object should never have been placed here
92 } elseif ($f->isError()) {
93 echo $f->getErrorMessage();
95 //check if the forum has new content
97 $fh = new ForumHTML($f);
98 if (!$fh || !is_object($fh)) {
99 exit_error(_('Error'), "Error getting new ForumHTML");
100 } elseif ($fh->isError()) {
101 exit_error(_('Error'),$fh->getErrorMessage());
104 $fmf = new ForumMessageFactory($f);
105 if (!$fmf || !is_object($fmf)) {
106 exit_error(_('Error'), "Error getting new ForumMessageFactory");
107 } elseif ($fmf->isError()) {
108 exit_error(_('Error'),$fmf->getErrorMessage());
110 $fmf->setUp($offset,$style,$max_rows,$set);
111 $style=$fmf->getStyle();
112 $max_rows=$fmf->max_rows;
113 $offset=$fmf->offset;
114 $msg_arr =& $fmf->nestArray($fmf->getNested());
115 if ($fmf->isError()) {
116 echo $fmf->getErrorMessage();
118 $rows=count($msg_arr[0]);
119 $avail_rows=$fmf->fetched_rows;
120 if ($rows > $max_rows) {
124 $newcontent = "<center>---</center>";
125 //this loops through every message AND followup, in search of new messages.
126 //anything that�s new ( new thread or followup) is considered to be a "new thing" and the forum
127 //is considered to have new contents
128 foreach ($msg_arr as $forum_msg_arr) {
129 foreach ($forum_msg_arr as $forum_msg) {
130 if ($f->getSavedDate() < $forum_msg->getPostDate()) {
131 //we�ve got ourselves a new message or followup for this forum. note that, exit the search
132 $newcontent = "<center>" . html_image("ic/new.png","25","11",array("border"=>"0")) . "</center>";
136 if ($newcontent!="<center>---</center>") {
140 /*while (($j < $rows) && ($total_rows < $max_rows)) {
141 $msg =& $msg_arr["0"][$j];
143 if ($f->getSavedDate() < $msg->getPostDate()) {
144 //we�ve got ourselves a new message for this forum. note that, exit the search
145 $newcontent = "<center>" . html_image("ic/new.png","25","11",array("border"=>"0")) . "</center>";
151 $this_forum_group = $f->getGroup();
152 echo '<tr '. $HTML->boxGetAltRowStyle($j) . '>
153 <td>' . $this_forum_group->getPublicName() . '</td>
154 <td><a href="forum.php?forum_id='. $f->getID() .'">'.
155 html_image("ic/forum20w.png","20","20",array("border"=>"0")) .
157 $f->getName() .'</a></td>
158 <td>'.$f->getDescription().'</td>
159 <td style="text-align:center">'.$f->getThreadCount().'</td>
160 <td style="text-align:center">'. $f->getMessageCount() .'</td>
161 <td>'. date(_('Y-m-d H:i'),$f->getMostRecentDate()) .'</td>
162 <td>' . $newcontent . '</td></tr>';
166 echo $HTML->listTableBottom();
167 forum_footer(array());