3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2010, Franck Villaume - Capgemini
5 * Copyright 2011-2012, Franck Villaume - TrivialDev
6 * http://fusionforge.org
8 * This file is a part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge. If not, see <http://www.gnu.org/licenses/>.
24 require_once 'Widget.class.php';
25 require_once $gfwww.'include/my_utils.php';
28 * Widget_MyMonitoredDocuments
30 * Documents that are actively monitored
33 class Widget_MyMonitoredDocuments extends Widget {
34 function __construct() {
35 $this->Widget('mymonitoreddocuments');
39 return _("Monitored Documents");
42 function getContent() {
43 $html_my_monitored_documents = '';
44 $result=db_query_params('select DISTINCT groups.group_name, docdata_vw.group_id from groups, docdata_vw, docdata_monitored_docman where docdata_monitored_docman.doc_id = docdata_vw.docid and groups.group_id = docdata_vw.group_id and docdata_monitored_docman.user_id = $1',array(user_getid()));
45 $rows=db_numrows($result);
46 if (!$result || $rows < 1) {
47 $html_my_monitored_documents .= '<div class="warning">' . _("You are not monitoring any documents.") . '</div><p>' . _("If you monitor documents, you will be sent new update in the form of an email.") . '</p><p>' . _("You can monitor documents by clicking on the appropriate icon action in the directory itself.") . '</p>';
49 $request =& HTTPRequest::instance();
50 $html_my_monitored_documents .= '<table style="width:100%">';
51 $vItemId = new Valid_UInt('hide_item_id');
53 if($request->valid($vItemId)) {
54 $hide_item_id = $request->get('hide_item_id');
58 for ($j=0; $j<$rows; $j++) {
59 $group_id = db_result($result,$j,'group_id');
60 $sql2 = "select docdata_vw.docid, docdata_vw.doc_group, docdata_vw.filename, docdata_vw.filetype, docdata_vw.description from docdata_vw,docdata_monitored_docman where docdata_vw.docid = docdata_monitored_docman.doc_id and docdata_vw.group_id = $1 and docdata_monitored_docman.user_id = $2 limit 100";
61 $result2 = db_query_params($sql2,array($group_id,user_getid()));
62 $rows2 = db_numrows($result2);
64 $vDocument = new Valid_WhiteList('hide_document', array(0, 1));
65 $vDocument->required();
66 if($request->valid($vDocument)) {
67 $hide_document = $request->get('hide_document');
69 $hide_document = null;
72 list($hide_now,$count_diff,$hide_url) = my_hide_url('document',$group_id,$hide_item_id,$rows,$hide_document);
74 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="2">' : '').
75 $hide_url.'<a href="/docman/?group_id='.$group_id.'">'.
76 db_result($result,$j,'group_name').'</a> ';
79 $count_new = max(0, $count_diff);
80 for ($i = 0; $i < $rows2; $i++) {
82 $doc_group = db_result($result2,$i,'doc_group');
83 $docid = db_result($result2,$i,'docid');
85 <tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td width="99%">'.
86 ' - <a href="/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'">'.
87 stripslashes(db_result($result2,$i,'filename')).'</a></td>'.
88 '<td align="center"><a href="/docman/?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$doc_group.'&fileid='.$docid.'">'.
89 '<img src="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" height="16" width="16" '.
90 'border="0" alt="'._("STOP MONITORING").'" /></a></td></tr>';
94 $html_hdr .= '['.$rows2.($count_new ? ", <b>".sprintf(_('%s new'), array($count_new))."</b>]" : ']').'</td></tr>';
95 $html_my_monitored_documents .= $html_hdr.$html;
97 $html_my_monitored_documents .= '</table>';
99 return $html_my_monitored_documents;
102 function getCategory() {
103 return 'Documents-Manager';
106 function getDescription() {
107 return _("List documents 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.");