3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
4 * Copyright 2012, Franck Villaume - TrivialDev
6 * This file is a part of Fusionforge.
8 * Fusionforge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Fusionforge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
22 require_once 'Widget.class.php';
25 * Widget_ProjectLatestFileReleases
28 class Widget_ProjectLatestFileReleases extends Widget {
30 function __construct() {
31 $this->Widget('projectlatestfilereleases');
32 $request =& HTTPRequest::instance();
33 $pm = ProjectManager::instance();
34 $project = $pm->getProject($request->get('group_id'));
35 if ($project && $this->canBeUsedByProject($project)) {
36 $this->content['title'] = _('Latest File Releases');
41 return $this->content['title'];
44 function getContent() {
45 $request =& HTTPRequest::instance();
46 $pm = ProjectManager::instance();
47 $group_id=$request->get('group_id');
48 $project = $pm->getProject($group_id);
49 $unix_group_name = $project->getUnixName();
50 $HTML=$GLOBALS['HTML'];
53 // Members of projects can see all packages
54 // Non-members can only see public packages
57 if (session_loggedin() &&
58 (user_ismember($group_id) || forge_check_global_perm('forge_admin'))) {
59 $public_required = 0 ;
62 $res_files = db_query_params ('SELECT frs_package.package_id,frs_package.name AS package_name,frs_release.name AS release_name,frs_release.release_id AS release_id,frs_release.release_date AS release_date
63 FROM frs_package,frs_release
64 WHERE frs_package.package_id=frs_release.package_id
65 AND frs_package.group_id=$1
66 AND frs_release.status_id=1
67 AND (frs_package.is_public=1 OR 1 != $2)
68 ORDER BY frs_package.package_id,frs_release.release_date DESC',
71 $rows_files=db_numrows($res_files);
72 if (!$res_files || $rows_files < 1) {
75 echo '<div class="warning">'._('This Project Has Not Released Any Files').'</div>';
79 <table summary="Latest file releases" class="width-100p100">
80 <tr class="table-header">
81 <th class="align-left" scope="col">
101 This query actually contains ALL releases of all packages
102 We will test each row and make sure the package has changed before printing the row
104 for ($f=0; $f<$rows_files; $f++) {
105 if (db_result($res_files,$f,'package_id')==db_result($res_files,($f-1),'package_id')) {
106 //same package as last iteration - don't show this release
108 $rel_date = getdate (db_result ($res_files, $f, 'release_date'));
109 $package_name = db_result($res_files, $f, 'package_name');
110 $package_release = db_result($res_files,$f,'release_name');
112 <tr class="align-center">
113 <td class="align-left">
114 <strong>' . $package_name . '</strong>
116 // Releases to display
117 //print '<div about="" xmlns:sioc="http://rdfs.org/sioc/ns#" rel="container_of" resource="'.util_make_link ('/frs/?group_id=' . $group_id . '&release_id=' . db_result($res_files,$f,'release_id').'">';
123 . $rel_date["month"] . ' ' . $rel_date["mday"] . ', ' . $rel_date["year"] .
125 <td class="align-center">';
129 // accessibility: image is a link, so alt must be unique in page => construct a unique alt
130 $tmp_alt = $package_name . " - " . _('Release Notes');
131 $link = '/frs/shownotes.php?group_id=' . $group_id . '&release_id=' . db_result($res_files, $f, 'release_id');
132 $link_content = $HTML->getReleaseNotesPic($tmp_alt, $tmp_alt);
133 echo util_make_link ($link, $link_content);
135 <td class="align-center">';
138 $tmp_alt = $package_name . " - " . _('Monitor this package');
139 $link = '/frs/monitor.php?filemodule_id=' . db_result($res_files,$f,'package_id') . '&group_id='.$group_id.'&start=1';
140 $link_content = $HTML->getMonitorPic($tmp_alt, $tmp_alt);
141 echo util_make_link ($link, $link_content);
143 <td class="align-center">';
146 $tmp_alt = $package_name." ".$package_release." - ". _('Download');
147 $link_content = $HTML->getDownloadPic($tmp_alt, $tmp_alt);
148 $t_link_anchor = $HTML->toSlug($package_name)."-".$HTML->toSlug($package_release)."-title-content";
149 $link = '/frs/?group_id=' . $group_id . '&release_id=' . db_result($res_files, $f, 'release_id')."#".$t_link_anchor;
150 echo util_make_link ($link, $link_content);
157 echo '<div class="underline-link">' . util_make_link ('/frs/?group_id='.$group_id, _('View All Project Files')) . '</div>';
160 function isAvailable() {
161 return isset($this->content['title']);
163 function canBeUsedByProject(&$project) {
164 return $project->usesFRS();
167 function getCategory() {
168 return _('File-Release');
171 function getDescription() {
172 return _(' List the most recent packages available for download along with their revision. <br />A Release Notes icon allows you to see the latest changes and developers comments associated with this revision.<br />Then comes the monitor icon, selecting this icon will cause this package to be monitored for you.<br />Anytime the project development team posts a new release, you will be automatically notified via e-mail. All monitored File Releases are listed in your Personal Page and can be canceled from this page or from the main page of the file release system.');