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 include $gfcommon.'docman/DocumentFactory.class.php';
28 * Widget_MyProjectsLastDocuments
32 class Widget_MyProjectsLastDocuments extends Widget {
33 function Widget_MyProjectsLastDocuments() {
34 $this->Widget('myprojectslastdocuments');
38 return _("The 5 Last Documents in My Projects");
41 function getContent() {
42 $html_my_projects = '';
44 $user = session_get_user();
45 $groups = $user->getGroups();
47 if (count ($groups) < 1) {
48 $html_my_projects .= '<div class="warning">'. _("You're not a member of any project") .'</div>';
50 sortProjectList($groups);
51 $request = HTTPRequest::instance();
52 $vItemId = new Valid_UInt('hide_item_id');
54 if($request->valid($vItemId)) {
55 $hide_item_id = $request->get('hide_item_id');
59 $html_my_projects .= '<table style="width:100%">';
61 foreach ($groups as $g) {
62 if ($g->usesDocman()) {
65 $vWhiteList = new Valid_WhiteList('hide_dmproj', array(0, 1));
66 $vWhiteList->required();
67 if($request->valid($vWhiteList)) {
68 $hide_docmanproject = $request->get('hide_dmproj');
70 $hide_docmanproject = null;
73 $df = new DocumentFactory($g);
75 $df->setOrder(array('updatedate','createdate'));
79 list($hide_now,$count_diff,$hide_url) = my_hide_url('dmproj', $g->getID(), $hide_item_id, count($df->Documents), $hide_docmanproject);
80 $html_hdr = ($i ? '<tr class="boxitem"><td colspan="4">' : '').
81 $hide_url.'<a href="/docman/?group_id='.$g->getID().'">'.
82 $g->getPublicName().'</a> </td></tr>';
86 $keys = array_keys($df->Documents);
89 $html .= '<tr><td colspan="4"><div class="warning">'._('No documents').'</div></td></tr>';
91 foreach ($keys as $key) {
92 $dg = new DocumentGroup($g, $key);
93 $view = ($dg->getState() != 2) ? 'listfile' : 'listtrashfile';
94 $html .= '<tr><td colspan="4"><a href="'.util_make_url('/docman/?group_id='.$g->getID().'&view='.$view.'&dirid='.$key).'">'.$dg->getPath().'</a></td></tr>';
96 $count = count($df->Documents[$key]);
97 for ($i=0; $i < $count; $i++) {
98 $doc =& $df->Documents[$key][$i];
99 $html .= '<tr '. $HTML->boxGetAltRowStyle($j) .'>';
100 switch ($doc->getFileType()) {
102 $docurl = $doc->getFileName();
106 $docurl = util_make_url('/docman/view.php/'.$g->getID().'/'.$doc->getID().'/'.urlencode($doc->getFileName()));
109 $html .= '<td><a href="'.$docurl.'">'.html_image($doc->getFileTypeImage(), '22', '22', array('alt'=>$doc->getFileType())).'</a></td>';
110 $html .= '<td>'.$doc->getFilename().'</td>';
111 $html .= '<td>'.make_user_link($doc->getCreatorUserName(), $doc->getCreatorRealName()).'</td>';
112 if ( $doc->getUpdated() ) {
113 $html .= '<td>'.date(_('Y-m-d H:i'), $doc->getUpdated()).'</td>';
115 $html .= '<td>'.date(_('Y-m-d H:i'), $doc->getCreated()).'</td>';
124 $html_my_projects .= $html_hdr.$html;
127 $html_my_projects .= '</table>';
129 return $html_my_projects;
132 function getDescription() {
133 return _("List the last 5 documents (with filename, author and last modification time) published in projects you belong to. Selecting any of these projects brings you to the corresponding Project Document Manager page. The documents will be per directory ordered. Selecting any of directory links will brings you to the corresponding Project Document Manager Listing Directory page");
136 function getCategory() {
137 return 'Documents-Manager';
143 // c-file-style: "bsd"