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 * http://fusionforge.org/
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once('../../env.inc.php');
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfcommon.'frs/FRSPackage.class.php';
29 require_once $gfcommon.'frs/FRSRelease.class.php';
30 require_once $gfcommon.'frs/FRSFile.class.php';
31 require_once $gfwww.'frs/include/frs_utils.php';
33 $group_id = getIntFromRequest('group_id');
34 $package_id = getIntFromRequest('package_id');
39 $g = group_get_object($group_id);
41 if (!$g || !is_object($g)) {
43 } elseif ($g->isError()) {
44 exit_error('Error',$g->getErrorMessage(),'frs');
47 // check the permissions and see if this user is a release manager.
48 // If so, he can create a release
49 session_require_perm ('frs', $group_id, 'write') ;
51 $packages = get_frs_packages($g);
53 $upload_dir = forge_get_config('ftp_upload_dir') . "/" . $g->getUnixName();
55 if (getStringFromRequest('submit')) {
56 $release_name = trim(getStringFromRequest('release_name'));
57 $userfile = getUploadedFile('userfile');
58 $userfile_name = $userfile['name'];
59 $type_id = getIntFromRequest('type_id');
60 $processor_id = getIntFromRequest('processor_id');
61 $release_date = getStringFromRequest('release_date');
62 // Build a Unix time value from the supplied Y-m-d value
63 $release_date = strtotime($release_date);
64 $release_notes = getStringFromRequest('release_notes');
65 $release_changes = getStringFromRequest('release_changes');
66 $preformatted = getStringFromRequest('preformatted');
67 $ftp_filename = getStringFromRequest('ftp_filename');
68 $manual_filename = getStringFromRequest('manual_filename');
69 $group_unix_name=group_getunixname($group_id);
73 $warning_msg .= _('Must define a release name.');
74 } else if (!$package_id) {
75 $warning_msg .= _('Must select a package.');
76 } else if (!$type_id || $type_id == "100") {
77 $warning_msg .= _('Must select a file type.');
78 } else if (!$processor_id || $processor_id == "100") {
79 $warning_msg .= _('Must select a processor type.');
85 $frsp = new FRSPackage($g,$package_id);
86 if (!$frsp || !is_object($frsp)) {
87 exit_error(_('Could Not Get FRSPackage'),'frs');
88 } elseif ($frsp->isError()) {
89 exit_error($frsp->getErrorMessage(),'frs');
92 // Create a new FRSRelease in the db
94 $frsr = new FRSRelease($frsp);
95 if (!$frsr || !is_object($frsr)) {
96 exit_error(_('Could Not Get FRSRelease'),'frs');
97 } elseif ($frsr->isError()) {
98 exit_error($frsr->getErrorMessage(),'frs');
101 if (!$frsr->create($release_name,$release_notes,$release_changes,
102 $preformatted,$release_date)) {
104 exit_error($frsr->getErrorMessage(),'frs');
107 $ret = frs_add_file_from_form ($frsr, $type_id, $processor_id, $release_date,
108 $userfile, $ftp_filename, $manual_filename) ;
111 exit_error ($ret,'frs') ;
115 frs_admin_header(array('title'=>_('Quick Release System'),'group'=>$group_id));
117 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.'),
118 util_make_url ('/frs/admin/editrelease.php?release_id='.$frsr->getID().'&group_id='.$group_id.'&package_id='.$package_id),
119 util_make_url ('/frs/?group_id='.$group_id)
123 frs_admin_footer(array());
136 $release_changes = '';
139 $manual_filename = '';
142 frs_admin_header(array('title'=>_('Quick Release System'),'group'=>$group_id));
146 <form enctype="multipart/form-data" method="post" action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id"; ?>">
147 <table border="0" cellpadding="2" cellspacing="2">
150 <strong><?php echo _('Package ID') ?>:</strong>
154 $res=db_query_params("SELECT * FROM frs_package WHERE group_id=$1 AND status_id='1'", array($group_id));
155 $rows=db_numrows($res);
156 if (!$res || $rows < 1) {
157 echo '<h4>'._('No File Types Available').'</h4>';
160 echo '<select name="package_id">';
161 for ($i=0; $i<$rows; $i++) {
162 echo '<option value="' . db_result($res,$i,'package_id') .
163 ((db_result($res,$i,'package_id') ==$package_id) ? '" selected="selected"' : '"').'>' .
164 db_result($res,$i,'name') . '</option>';
171 <?php printf(_('Or %1$s create a new package %2$s'), '<a href="'.util_make_url ('/frs/admin/?group_id='.$group_id).'">', '</a>') ?>
176 <strong><?php echo _('Release name') ?>:<?php echo utils_requiredField();?></strong>
179 <input type="text" name="release_name" value="<?php echo htmlspecialchars($release_name) ?>" />
184 <strong><?php echo _('Release date') ?>:</strong>
187 <input type="text" name="release_date" value="<?php echo date('Y-m-d H:i'); ?>" size="16" maxlength="16" />
192 <h4><?php echo _('File Name') ?>:<?php echo utils_requiredField();?></h4>
195 <div class="important">
196 <?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.')?>
197 <?php printf(_('You can probably not upload files larger than about %.2f MiB in size.'), util_get_maxuploadfilesize() / 1048576); ?><br />
199 <?php echo _('Upload a new file') ?>: <input type="file" name="userfile" size="30" />
200 <?php if (forge_get_config('use_ftp_uploads')) {
203 printf(_('Alternatively, you can use FTP to upload a new file at %1$s.'), forge_get_config('ftp_upload_host'));
205 echo _('Choose an FTP file instead of uploading:').'<br />';
206 $ftp_files_arr=ls($upload_dir,true);
207 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename',''); ?>
211 <?php if (forge_get_config('use_manual_uploads')) {
212 $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
215 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).'),
216 $incoming, "sftp://" . forge_get_config ('web_host') . $incoming . "/");
217 echo ' ' . _('This direct <tt>sftp://</tt> link only works with some browsers, such as Konqueror.') . '<br />';
218 echo _('Choose an already uploaded file:').'<br />';
219 $manual_files_arr=ls($incoming,true);
220 echo html_build_select_box_from_arrays($manual_files_arr,$manual_files_arr,'manual_filename',''); ?>
228 <strong><?php echo _('File Type') ?>:<?php echo utils_requiredField();?></strong>
232 print frs_show_filetype_popup ('type_id',$type_id);
238 <strong><?php echo _('Processor Type') ?>:<?php echo utils_requiredField();?></strong>
242 print frs_show_processor_popup ('processor_id',$processor_id);
248 <strong><?php echo _('Release Notes') ?>:</strong>
251 <textarea name="release_notes" rows="7" cols="50"><?php echo htmlspecialchars($release_notes); ?></textarea>
256 <strong><?php echo _('Change Log') ?>:</strong>
259 <textarea name="release_changes" rows="7" cols="50"><?php echo htmlspecialchars($release_changes); ?></textarea>
263 <td colspan="2" style="text-align:center">
264 <input type="checkbox" name="preformatted" value="1" /> <?php echo _('Preserve my pre-formatted text') ?>
265 <p><input type="submit" name="submit" value="<?php echo _('Release File') ?>" /></p>
277 // c-file-style: "bsd"