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 include $gfcommon.'docman/DocumentFactory.class.php';
27 * Widget_MyProjectsLastDocuments
31 class Widget_MyProjectsLastDocuments extends Widget {
32 function Widget_MyProjectsLastDocuments() {
33 $this->Widget('myprojectslastdocuments');
37 return _("The 5 Last Documents in My Projects");
40 function getContent() {
41 $html_my_projects = '';
43 $user = session_get_user();
44 $groups = $user->getGroups();
46 if (count ($groups) < 1) {
47 $html_my_projects .= '<div class="warning">'. _("You're not a member of any project") .'</div>';
49 sortProjectList($groups);
50 $request =& HTTPRequest::instance();
51 $html_my_projects .= '<table style="width:100%">';
53 foreach ($groups as $g) {
55 $vItemId = new Valid_UInt('hide_item_id');
57 if($request->valid($vItemId)) {
58 $hide_item_id = $request->get('hide_item_id');
63 $vWhiteList = new Valid_WhiteList('hide_docmanproject', array(0, 1));
64 $vWhiteList->required();
65 if($request->valid($vWhiteList)) {
66 $hide_docmanproject = $request->get('hide_docmanproject');
68 $hide_docmanproject = null;
71 $df = new DocumentFactory($g);
73 $df->setOrder(array('updatedate','createdate'));
77 list($hide_now,$count_diff,$hide_url) = my_hide_url('docmanproject', $g->getID(), $hide_item_id, count($df->Documents), $hide_docmanproject);
78 $html_hdr = ($i ? '<tr class="boxitem"><td colspan="4">' : '').
79 $hide_url.'<a href="/docman/?group_id='.$g->getID().'">'.
80 $g->getPublicName().'</a> </td></tr>';
84 $keys = array_keys($df->Documents);
87 $html .= '<tr><td colspan="4"><div class="warning">'._('No documents').'</div></td></tr>';
89 foreach ($keys as $key) {
90 $dg = new DocumentGroup($g, $key);
91 $html .= '<tr><td colspan="4"><a href="'.util_make_url('/docman/?group_id='.$g->getID().'&view=listfile&dirid='.$key).'">'.$dg->getPath().'</a></td></tr>';
93 $count = count($df->Documents[$key]);
94 for ($i=0; $i < $count; $i++) {
95 $doc =& $df->Documents[$key][$i];
96 $html .= '<tr '. $HTML->boxGetAltRowStyle($j) .'>';
97 $html .= '<td>'.html_image($doc->getFileTypeImage(), '22', '22', array('alt'=>$doc->getFileType())).'</td>';
98 switch ($doc->getFileType()) {
100 $docurl = $doc->getFileName();
104 $docurl = util_make_url('/docman/view.php/'.$g->getID().'/'.$doc->getID().'/'.urlencode($doc->getFileName()));
107 $html .= '<td><a href="'.$docurl.'">'.$doc->getFilename().'</a></td>';
108 $html .= '<td>'.make_user_link($doc->getCreatorUserName(), $doc->getCreatorRealName()).'</td>';
109 if ( $doc->getUpdated() ) {
110 $html .= '<td>'.date(_('Y-m-d H:i'), $doc->getUpdated()).'</td>';
112 $html .= '<td>'.date(_('Y-m-d H:i'), $doc->getCreated()).'</td>';
121 $html_my_projects .= $html_hdr.$html;
123 $html_my_projects .= '</table>';
125 return $html_my_projects;
128 function getDescription() {
129 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");
132 function getCategory() {
133 return 'Documents-Manager';
139 // c-file-style: "bsd"