4 * FusionForge Monitored Forums Track Page
6 * Portions Copyright 1999-2001 (c) VA Linux Systems
7 * The rest Copyright 2002-2004 (c) GForge Team
8 * Copyright 2005 (c) - Daniel Perez
9 * Copyright 2010 (c) Franck Villaume - Capgemini
10 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
11 * http://fusionforge.org/
13 * This file is part of FusionForge. FusionForge is free software;
14 * you can redistribute it and/or modify it under the terms of the
15 * GNU General Public License as published by the Free Software
16 * Foundation; either version 2 of the Licence, or (at your option)
19 * FusionForge 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 along
25 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 require_once('../env.inc.php');
30 require_once $gfcommon.'include/pre.php';
31 require_once $gfcommon.'forum/ForumHTML.class.php';
32 require_once $gfcommon.'forum/Forum.class.php';
33 require_once $gfcommon.'forum/ForumFactory.class.php';
34 require_once $gfcommon.'forum/ForumMessageFactory.class.php';
35 require_once $gfcommon.'forum/ForumMessage.class.php';
37 session_require_login();
39 $user_id = user_getid();
40 $group_id = getIntFromRequest("group_id");
42 // If the link comes from the project, display the project header. If it comes from the user page, display the normal site header
44 forum_header(array('title'=>_('My Monitored Forums')));
46 site_header(array('title'=>_('My Monitored Forums'), 'user_id' => $user_id));
49 //get the user monitored forums
50 $result = db_query_params ('SELECT mon.forum_id, fg.group_id FROM forum_monitored_forums mon,forum_group_list fg where mon.user_id=$1 and fg.group_forum_id=mon.forum_id',
53 echo '<p class="error">Database error :'.db_error().'</p>';
54 forum_footer(array());
57 if ( db_numrows($result) < 1) {
58 echo '<p class="information">'._('You have no monitored forums').'</p>';
59 forum_footer(array());
63 //now, i need to create a forum object per each forum that the user is monitoring
64 $monitored_forums = array();
65 for ($i=0;$i<db_numrows($result);$i++) {
66 $monitored_forums[$i] = db_fetch_array($result);
69 $tablearr=array(_('Project'),_('Forum'), _('Threads'),
70 _('Posts'), _('Last Post'), _('New Content?'));
71 echo $HTML->listTableTop($tablearr);
77 //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
78 for($i=0;$i<sizeof($monitored_forums);$i++) {
79 $g = group_get_object($monitored_forums[$i]["group_id"]);
80 if (!$g || !is_object($g) || $g->isError()) {
83 $f = new Forum($g,$monitored_forums[$i]["forum_id"]);
84 if (!$f || !is_object($f) || $f->isError()) {
85 exit_error($f->isError(),'forums');
88 //just skip it - this object should never have been placed here
89 } elseif ($f->isError()) {
90 echo $f->getErrorMessage();
92 //check if the forum has new content
94 $fh = new ForumHTML($f);
95 if (!$fh || !is_object($fh)) {
96 exit_error(_('Error getting new ForumHTML'),'forums');
97 } elseif ($fh->isError()) {
98 exit_error($fh->getErrorMessage(),'forums');
101 $fmf = new ForumMessageFactory($f);
102 if (!$fmf || !is_object($fmf)) {
103 exit_error(_('Error getting new ForumMessageFactory'),'forums');
104 } elseif ($fmf->isError()) {
105 exit_error($fmf->getErrorMessage(),'forums');
108 $fmf->setUp($offset,$style,$max_rows,$set);
109 $style=$fmf->getStyle();
110 $max_rows=$fmf->max_rows;
111 $offset=$fmf->offset;
112 $msg_arr = $fmf->nestArray($fmf->getNested());
113 if ($fmf->isError()) {
114 exit_error($fmf->getErrorMessage(),'forums');
116 $rows=count($msg_arr[0]);
117 $avail_rows=$fmf->fetched_rows;
118 if ($rows > $max_rows) {
122 $newcontent = ' ';
123 //this loops through every message AND followup, in search of new messages.
124 //anything that's new ( new thread or followup) is considered to be a "new thing" and the forum
125 //is considered to have new contents
126 if (!empty($msg_arr)) {
127 foreach ($msg_arr as $forum_msg_arr) {
128 foreach ($forum_msg_arr as $forum_msg) {
129 if ($f->getSavedDate() < $forum_msg->getPostDate()) {
130 //we've got ourselves a new message or followup for this forum. note that, exit the search
131 $newcontent = "<center>" . html_image('ic/new.png','', '', array('alt' => 'new')) . "</center>";
135 if ($newcontent != ' ') {
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','', '', array('alt' => 'new')) . "</center>";
151 $this_forum_group = $f->getGroup();
152 $date = $f->getMostRecentDate()? date(_('Y-m-d H:i'),$f->getMostRecentDate()) : '';
153 echo '<tr '. $HTML->boxGetAltRowStyle($j++) . '>
154 <td>' . $this_forum_group->getPublicName() . '</td>
155 <td><a href="forum.php?forum_id='. $f->getID() .'&group_id='.$this_forum_group->getID().'">'.
156 html_image('ic/forum20w.png') .
158 $f->getName() .'</a></td>
159 <td style="text-align:center">'.$f->getThreadCount().'</td>
160 <td style="text-align:center">'. $f->getMessageCount() .'</td>
161 <td style="text-align:center">'. $date .'</td>
162 <td>' . $newcontent . '</td></tr>';
166 echo $HTML->listTableBottom();
167 forum_footer(array());