3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2010, Franck Villaume - Capgemini
5 * Copyright 2011, Franck Villaume - TrivialDev
7 * This file is a part of FusionForge.
9 * FusionForge is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with FusionForge. If not, see <http://www.gnu.org/licenses/>.
23 require_once('Widget.class.php');
24 require_once 'www/my/my_utils.php';
27 * Widget_MyMonitoredDocuments
29 * Documents that are actively monitored
31 class Widget_MyMonitoredDocuments extends Widget {
32 function Widget_MyMonitoredDocuments() {
33 $this->Widget('mymonitoreddocuments');
36 return _("Monitored Documents");
38 function getContent() {
39 $html_my_monitored_documents = '';
40 $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()));
41 $rows=db_numrows($result);
42 if (!$result || $rows < 1) {
43 $html_my_monitored_documents .= '<p><b>' . _("You are not monitoring any documents.") . '</b></p><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>';
45 $request =& HTTPRequest::instance();
46 $html_my_monitored_documents .= '<table style="width:100%">';
47 for ($j=0; $j<$rows; $j++) {
48 $group_id = db_result($result,$j,'group_id');
50 $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";
51 $result2 = db_query_params($sql2,array($group_id,user_getid()));
52 $rows2 = db_numrows($result2);
54 $vItemId = new Valid_UInt('hide_item_id');
56 if($request->valid($vItemId)) {
57 $hide_item_id = $request->get('hide_item_id');
62 $vDocument = new Valid_WhiteList('hide_document', array(0, 1));
63 $vDocument->required();
64 if($request->valid($vDocument)) {
65 $hide_document = $request->get('hide_document');
67 $hide_document = null;
70 list($hide_now,$count_diff,$hide_url) = my_hide_url('document',$group_id,$hide_item_id,$rows,$hide_document);
72 $html_hdr = ($j ? '<tr class="boxitem"><td colspan="2">' : '').
73 $hide_url.'<A HREF="/docman/?group_id='.$group_id.'">'.
74 db_result($result,$j,'group_name').'</A> ';
77 $count_new = max(0, $count_diff);
78 for ($i=0; $i<$rows2; $i++) {
82 $class="bgcolor-white";
85 $class="bgcolor-grey";
90 $doc_group = db_result($result2,$i,'doc_group');
91 $docid = db_result($result2,$i,'docid');
94 <TR class="'. $class .'"><TD WIDTH="99%">'.
95 ' - <A HREF="/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'">'.
96 stripslashes(db_result($result2,$i,'filename')).'</A></TD>'.
97 '<TD ALIGN="center"><A HREF="/docman/?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$doc_group.'&fileid='.$docid.'">'.
98 '<IMG SRC="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" HEIGHT="16" WIDTH="16" '.
99 'BORDER=0 ALT="'._("STOP MONITORING").'"></A></TD></TR>';
103 $html_hdr .= '['.$rows2.($count_new ? ", <b>".sprintf(_('%s new'), array($count_new))."</b>]" : ']').'</td></tr>';
104 $html_my_monitored_documents .= $html_hdr.$html;
106 $html_my_monitored_documents .= '</table>';
108 return $html_my_monitored_documents;
111 function getCategory() {
114 function getDescription() {
115 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.");
120 function getAjaxUrl($owner_id, $owner_type) {
121 $request =& HTTPRequest::instance();
122 $ajax_url = parent::getAjaxUrl($owner_id, $owner_type);
123 if ($request->exist('hide_item_id') || $request->exist('hide_document')) {
124 $ajax_url .= '&hide_item_id=' . $request->get('hide_item_id') . '&hide_document=' . $request->get('hide_document');