3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2010, Franck Villaume - Capgemini
5 * Copyright 2012, 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');
26 * Widget_ProjectLatestDocuments
29 class Widget_ProjectLatestDocuments extends Widget {
31 function Widget_ProjectLatestDocuments() {
32 $this->Widget('projectlatestdocuments');
33 $request =& HTTPRequest::instance();
34 $pm = ProjectManager::instance();
35 $project = $pm->getProject($request->get('group_id'));
36 if ($project && $this->canBeUsedByProject($project)) {
37 $this->content['title'] = _('5 Latest Published Documents');
42 return $this->content['title'];
45 function getContent() {
47 $request =& HTTPRequest::instance();
48 $group_id = $request->get('group_id');
50 $qpa = db_construct_qpa();
51 $qpa = db_construct_qpa($qpa, 'SELECT filename, title, updatedate, createdate, realname, user_name, state_name, filetype, docid
55 array($group_id, '1'));
57 if (session_loggedin() && (user_ismember($group_id) ||
58 forge_check_global_perm('forge_admin'))) {
59 $qpa = db_construct_qpa($qpa, ' OR stateid=$1 OR stateid=$2 OR stateid=$3', array('3','4','5'));
62 $qpa = db_construct_qpa($qpa, ' ORDER BY updatedate,createdate DESC LIMIT 5',array());
63 $res_files = db_query_qpa($qpa);
65 $rows_files = db_numrows($res_files);
66 if (!$res_files || $rows_files < 1) {
69 echo '<div class="warning">'._('This Project Has Not Published Any Documents').'</div>';
71 $tabletop = array(_('Date'), _('Filename'), _('Title'), _('Author'));
72 if (session_loggedin() && (user_ismember($group_id) ||
73 forge_check_global_perm('forge_admin'))) {
74 $tabletop[] = _('Status');
76 echo $HTML->listTableTop($tabletop, false, 'sortable_widget_docman_listfile', 'sortable');
77 for ($f=0; $f<$rows_files; $f++) {
78 $updatedate = db_result($res_files, $f, 'updatedate');
79 $createdate = db_result($res_files, $f, 'createdate');
80 $realdate = ($updatedate >= $createdate) ? $updatedate : $createdate;
81 $displaydate = getdate($realdate);
82 $filename = db_result($res_files,$f,'filename');
83 $title = db_result($res_files,$f,'title');
84 $realname = db_result($res_files,$f,'realname');
85 $user_name = db_result($res_files,$f,'user_name');
86 $statename = db_result($res_files,$f,'state_name');
87 $filetype = db_result($res_files,$f,'filetype');
88 $docid = db_result($res_files,$f,'docid');
95 $docurl = util_make_url('/docman/view.php/'.$group_id.'/'.$docid.'/'.urlencode($filename));
99 <tr '. $HTML->boxGetAltRowStyle($f+1) .'>
101 . $displaydate["month"] . ' ' . $displaydate["mday"] . ', ' . $displaydate["year"] .
104 <a href="'.$docurl.'" ><strong>' . $filename . '</strong></a>
110 . make_user_link($user_name, $realname) .
112 if (session_loggedin() && (user_ismember($group_id) ||
113 forge_check_global_perm('forge_admin'))) {
120 echo $HTML->listTableBottom();
122 echo '<div class="underline-link">' . util_make_link('/docman/?group_id='.$group_id, _('Browse Documents Manager')) . '</div>';
125 function isAvailable() {
126 return isset($this->content['title']);
129 function canBeUsedByProject(&$project) {
130 return $project->usesDocman();
133 function getCategory() {
134 return 'Documents-Manager';
137 function getDescription() {
138 return _(' List the 5 most recent documents published by team project.');