3 * FusionForge File Release Facility
5 * Copyright 1999-2001 (c) VA Linux Systems , Darrell Brogdon
6 * Copyright 2002 (c) GForge, LLC
7 * Copyright 2010 (c), FusionForge Team
8 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org/
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once('../../env.inc.php');
28 require_once $gfcommon.'include/pre.php';
29 require_once $gfcommon.'frs/FRSPackage.class.php';
30 require_once $gfcommon.'frs/FRSRelease.class.php';
31 require_once $gfcommon.'frs/FRSFile.class.php';
32 require_once $gfcommon.'frs/include/frs_utils.php';
35 $group_id = getIntFromRequest('group_id');
36 $package_id = getIntFromRequest('package_id');
41 $g = group_get_object($group_id);
43 if (!$g || !is_object($g)) {
45 } elseif ($g->isError()) {
46 exit_error('Error', $g->getErrorMessage(), 'frs');
49 // check the permissions and see if this user is a release manager.
50 // If so, he can create a release
51 session_require_perm('frs', $group_id, 'write');
53 $packages = get_frs_packages($g);
55 $upload_dir = forge_get_config('ftp_upload_dir') . "/" . $g->getUnixName();
57 if (getStringFromRequest('submit')) {
58 $release_name = trim(getStringFromRequest('release_name'));
59 $userfile = getUploadedFile('userfile');
60 $userfile_name = $userfile['name'];
61 $type_id = getIntFromRequest('type_id');
62 $processor_id = getIntFromRequest('processor_id');
63 $release_date = getStringFromRequest('release_date');
64 // Build a Unix time value from the supplied Y-m-d value
65 $release_date = strtotime($release_date);
66 $release_notes = getStringFromRequest('release_notes');
67 $release_changes = getStringFromRequest('release_changes');
68 $preformatted = getStringFromRequest('preformatted');
69 $ftp_filename = getStringFromRequest('ftp_filename');
70 $manual_filename = getStringFromRequest('manual_filename');
71 $group_unix_name=group_getunixname($group_id);
75 $warning_msg .= _('Must define a release name.');
76 } else if (!$package_id) {
77 $warning_msg .= _('Must select a package.');
84 $frsp = new FRSPackage($g,$package_id);
85 if (!$frsp || !is_object($frsp)) {
86 exit_error(_('Could Not Get FRSPackage'),'frs');
87 } elseif ($frsp->isError()) {
88 exit_error($frsp->getErrorMessage(),'frs');
91 // Create a new FRSRelease in the db
93 $frsr = new FRSRelease($frsp);
94 if (!$frsr || !is_object($frsr)) {
95 exit_error(_('Could Not Get FRSRelease'),'frs');
96 } elseif ($frsr->isError()) {
97 exit_error($frsr->getErrorMessage(),'frs');
100 if (!$frsr->create($release_name,$release_notes,$release_changes,
101 $preformatted,$release_date)) {
103 exit_error($frsr->getErrorMessage(),'frs');
106 $ret = frs_add_file_from_form ($frsr, $type_id, $processor_id, $release_date,
107 $userfile, $ftp_filename, $manual_filename) ;
110 exit_error ($ret,'frs') ;
114 frs_admin_header(array('title'=>_('Quick Release System'),'group'=>$group_id));
116 printf (_('You can now <a href="%1$s"><strong>add files to this release</strong></a> if you wish, or edit the release. Please note that file(s) may not appear immediately on the <a href="%2$s">download page</a>. Allow several hours for propagation.'),
117 util_make_url ('/frs/admin/editrelease.php?release_id='.$frsr->getID().'&group_id='.$group_id.'&package_id='.$package_id),
118 util_make_url ('/frs/?group_id='.$group_id)
122 frs_admin_footer(array());
135 $release_changes = '';
138 $manual_filename = '';
141 frs_admin_header(array('title'=>_('Quick Release System'),'group'=>$group_id));
145 <form enctype="multipart/form-data" method="post" action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id"; ?>">
149 <strong><?php echo _('Package ID') ?>:</strong>
153 $res=db_query_params("SELECT * FROM frs_package WHERE group_id=$1 AND status_id='1'", array($group_id));
154 $rows=db_numrows($res);
155 if (!$res || $rows < 1) {
156 echo '<h4>'._('No File Types Available').'</h4>';
159 echo '<select name="package_id">';
160 for ($i=0; $i<$rows; $i++) {
161 echo '<option value="' . db_result($res,$i,'package_id') .
162 ((db_result($res,$i,'package_id') ==$package_id) ? '" selected="selected"' : '"').'>' .
163 db_result($res,$i,'name') . '</option>';
170 <?php printf(_('Or %1$s create a new package %2$s'), '<a href="'.util_make_url ('/frs/admin/?group_id='.$group_id).'">', '</a>') ?>
175 <strong><?php echo _('Release name') ?>:<?php echo utils_requiredField();?></strong>
178 <input type="text" required="required" name="release_name" value="<?php echo htmlspecialchars($release_name) ?>" />
183 <strong><?php echo _('Release date') ?>:</strong>
186 <input type="text" name="release_date" value="<?php echo date('Y-m-d H:i'); ?>" size="16" maxlength="16" />
191 <h4><?php echo _('File Name') ?>:<?php echo utils_requiredField();?></h4>
194 <div class="important">
195 <?php echo _('NOTE: In some browsers you must select the file in the file-upload dialog and click "OK". Double-clicking doesn\'t register the file.')?>
196 <?php printf(_('You can probably not upload files larger than about %.2f MiB in size.'), util_get_maxuploadfilesize() / 1048576); ?><br />
198 <?php echo _('Upload a new file') ?>: <input type="file" name="userfile" size="30" />
199 <?php if (forge_get_config('use_ftp_uploads')) {
202 printf(_('Alternatively, you can use FTP to upload a new file at %1$s.'), forge_get_config('ftp_upload_host'));
204 echo _('Choose an FTP file instead of uploading:').'<br />';
205 $ftp_files_arr=frs_filterfiles(ls($upload_dir,true));
206 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename',''); ?>
210 <?php if (forge_get_config('use_manual_uploads')) {
211 $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
214 printf(_('Alternatively, you can use a file you already uploaded (by SFTP or SCP) to the <a href="%2$s">project\'s incoming directory</a> (%1$s).'),
215 $incoming, "sftp://" . forge_get_config ('web_host') . $incoming . "/");
216 echo ' ' . _('This direct <tt>sftp://</tt> link only works with some browsers, such as Konqueror.') . '<br />';
217 echo _('Choose an already uploaded file:').'<br />';
218 $manual_files_arr=frs_filterfiles(ls($incoming,true));
219 echo html_build_select_box_from_arrays($manual_files_arr,$manual_files_arr,'manual_filename',''); ?>
227 <strong><?php echo _('File Type') ?>:</strong>
231 print frs_show_filetype_popup ('type_id',$type_id);
237 <strong><?php echo _('Processor Type') ?>:</strong>
241 print frs_show_processor_popup ('processor_id',$processor_id);
247 <strong><?php echo _('Release Notes') ?>:</strong>
250 <textarea name="release_notes" rows="7" cols="50"><?php echo htmlspecialchars($release_notes); ?></textarea>
255 <strong><?php echo _('Change Log') ?>:</strong>
258 <textarea name="release_changes" rows="7" cols="50"><?php echo htmlspecialchars($release_changes); ?></textarea>
262 <td colspan="2" style="text-align:center">
263 <input type="checkbox" name="preformatted" value="1" /> <?php echo _('Preserve my pre-formatted text') ?>
264 <p><input type="submit" name="submit" value="<?php echo _('Release File') ?>" /></p>
276 // c-file-style: "bsd"