1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
<?php
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
* Copyright 2010, Franck Villaume - Capgemini
* Copyright 2011-2013, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is a part of FusionForge.
*
* FusionForge is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* FusionForge is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FusionForge. If not, see <http://www.gnu.org/licenses/>.
*/
require_once 'Widget.class.php';
require_once $gfwww.'include/my_utils.php';
/**
* Widget_MyMonitoredDocuments
*
* Documents that are actively monitored
*/
class Widget_MyMonitoredDocuments extends Widget {
function __construct() {
$this->Widget('mymonitoreddocuments');
}
function getTitle() {
return _("Monitored Documents");
}
function getContent() {
$html_my_monitored_documents = '';
$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()));
$rows=db_numrows($result);
if (!$result || $rows < 1) {
$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>';
} else {
$request =& HTTPRequest::instance();
$html_my_monitored_documents .= '<table style="width:100%">';
$vItemId = new Valid_UInt('hide_item_id');
$vItemId->required();
if($request->valid($vItemId)) {
$hide_item_id = $request->get('hide_item_id');
} else {
$hide_item_id = null;
}
for ($j=0; $j<$rows; $j++) {
$group_id = db_result($result,$j,'group_id');
$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";
$result2 = db_query_params($sql2,array($group_id,user_getid()));
$rows2 = db_numrows($result2);
$vDocument = new Valid_WhiteList('hide_document', array(0, 1));
$vDocument->required();
if($request->valid($vDocument)) {
$hide_document = $request->get('hide_document');
} else {
$hide_document = null;
}
list($hide_now,$count_diff,$hide_url) = my_hide_url('document',$group_id,$hide_item_id,$rows2,$hide_document);
$html_hdr = '<tr class="boxitem"><td colspan="2">'.
$hide_url.'<a href="/docman/?group_id='.$group_id.'">'.
db_result($result,$j,'group_name').'</a> ';
$html = '';
$count_new = max(0, $count_diff);
for ($i = 0; $i < $rows2; $i++) {
if (!$hide_now) {
$doc_group = db_result($result2,$i,'doc_group');
$docid = db_result($result2,$i,'docid');
$html .= '
<tr '. $GLOBALS['HTML']->boxGetAltRowStyle($i) .'><td style="width:99%">'.
' - <a href="/docman/?group_id='.$group_id.'&view=listfile&dirid='.$doc_group.'">'.
stripslashes(db_result($result2,$i,'filename')).'</a></td>'.
'<td class="align-center"><a href="/docman/?group_id='.$group_id.'&action=monitorfile&option=remove&view=listfile&dirid='.$doc_group.'&fileid='.$docid.'">'.
'<img src="'.$GLOBALS['HTML']->imgroot.'ic/trash.png" height="16" width="16" '.
'alt="'._("Stop Monitoring").'" /></a></td></tr>';
}
}
$html_hdr .= '['.$rows2.($count_new ? ", <b>".sprintf(_('%s new'), $count_new)."</b>]" : ']').'</td></tr>';
$html_my_monitored_documents .= $html_hdr.$html;
}
$html_my_monitored_documents .= '</table>';
}
return $html_my_monitored_documents;
}
function getCategory() {
return _('Documents Manager');
}
function getDescription() {
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.");
}
function isAvailable() {
if (!forge_get_config('use_docman')) {
return false;
}
foreach (UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
if ($p->usesDocman()) {
return true;
}
}
return false;
}
}
|