3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once('Widget.class.php');
22 require_once('common/frs/FRSPackageFactory.class.php');
24 * Widget_MyMonitoredFp
26 * Filemodules that are actively monitored
28 class Widget_MyMonitoredFp extends Widget {
29 function Widget_MyMonitoredFp() {
30 $this->Widget('mymonitoredfp');
33 return _("Monitored File Packages");
35 function getContent() {
36 $frsrf = new FRSReleaseFactory();
37 $html_my_monitored_fp = '';
38 $sql="SELECT groups.group_name,groups.group_id ".
39 "FROM groups,filemodule_monitor,frs_package ".
40 "WHERE groups.group_id=frs_package.group_id ".
41 "AND frs_package.status_id !=$1".
42 "AND frs_package.package_id=filemodule_monitor.filemodule_id ".
43 "AND filemodule_monitor.user_id=$2";
44 $um =& UserManager::instance();
45 $current_user =& $um->getCurrentUser();
46 if ($current_user->isRestricted()) {
47 $projects = $current_user->getProjects();
48 $sql .= "AND groups.group_id IN (". implode(',', $projects) .") ";
50 $sql .= "GROUP BY group_id ORDER BY group_id ASC LIMIT 100";
52 $result=db_query_params($sql,array($frsrf->STATUS_DELETED,user_getid()));
53 $rows=db_numrows($result);
54 if (!$result || $rows < 1) {
55 $html_my_monitored_fp .= '<p><b>' . _("You are not monitoring any files") . '</b></p><p>' . _("If you monitor files, you will be sent new release notices via email, with a link to the new file on our download server.") . '</p><p>' . _("You can monitor files by visiting a project's "Summary Page" and clicking on the appropriate icon in the files section.") . '</p>';
57 $html_my_monitored_fp .= '<table style="width:100%">';
58 $request =& HTTPRequest::instance();
59 for ($j=0; $j<$rows; $j++) {
60 $group_id = db_result($result,$j,'group_id');
62 $sql2="SELECT frs_package.name,filemodule_monitor.filemodule_id ".
63 "FROM groups,filemodule_monitor,frs_package ".
64 "WHERE groups.group_id=frs_package.group_id ".
65 "AND groups.group_id=$1 ".
66 "AND frs_package.status_id !=$2".
67 "AND frs_package.package_id=filemodule_monitor.filemodule_id ".
68 "AND filemodule_monitor.user_id=$3 LIMIT 100";
69 $result2 = db_query_params($sql2,array($group_id,$frsrf->STATUS_DELETED,user_getid()));
70 $rows2 = db_numrows($result2);
72 $vItemId = new Valid_UInt('hide_item_id');
74 if($request->valid($vItemId)) {
75 $hide_item_id = $request->get('hide_item_id');
80 $vFrs = new Valid_WhiteList('hide_frs', array(0, 1));
82 if($request->valid($vFrs)) {
83 $hide_frs = $request->get('hide_frs');
88 list($hide_now,$count_diff,$hide_url) = my_hide_url('frs',$group_id,$hide_item_id,$rows2,$hide_frs);
90 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="2">' : '').
91 $hide_url.'<A HREF="/project/?group_id='.$group_id.'">'.
92 db_result($result,$j,'group_name').'</A> ';
95 $count_new = max(0, $count_diff);
96 for ($i=0; $i<$rows2; $i++) {
99 <TR class="'. util_get_alt_row_color($i) .'">'.
100 '<TD WIDTH="99%"> - <A HREF="/file/showfiles.php?group_id='.$group_id.'">'.
101 db_result($result2,$i,'name').'</A></TD>'.
102 '<TD><A HREF="/file/filemodule_monitor.php?filemodule_id='.
103 db_result($result2,$i,'filemodule_id').
104 '" onClick="return confirm(\''._("Stop Monitoring this Package?").'\')">'.
105 '<IMG SRC="'.util_get_image_theme("ic/trash.png").'" HEIGHT="16" WIDTH="16" '.
106 'BORDER=0" ALT="'._("STOP MONITORING").'"></A></TD></TR>';
110 $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
111 $html_my_monitored_fp .= $html_hdr .$html;
113 $html_my_monitored_fp .= '</table>';
115 return $html_my_monitored_fp;
118 function getCategory() {
121 function getDescription() {
122 return _("List packages that you are currently monitoring, by project.<br />To cancel any of the monitored items just click on the trash icon next to the item label.");