3 * FusionForge File Release Facility
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002 (c) GForge, LLC
7 * Copyright 2010 (c), FusionForge Team
8 * http://fusionforge.org/
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
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
23 * along with FusionForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 $gfwww.'frs/include/frs_utils.php';
34 $group_id = getIntFromRequest('group_id');
35 $package_id = getIntFromRequest('package_id');
41 $g =& group_get_object($group_id);
42 if (!$g || !is_object($g)) {
44 } elseif ($g->isError()) {
45 exit_error('Error',$g->getErrorMessage());
48 // check the permissions and see if this user is a release manager.
49 // If so, he can create a release
50 session_require_perm ('frs', $group_id, 'write') ;
52 $packages = get_frs_packages($g);
54 $upload_dir = forge_get_config('ftp_upload_dir') . "/" . $g->getUnixName();
57 Quick file release system , Darrell Brogdon, SourceForge, Aug, 2000
59 With much code horked from editreleases.php
62 if (getStringFromRequest('submit')) {
63 $release_name = trim(getStringFromRequest('release_name'));
64 $userfile = getUploadedFile('userfile');
65 $userfile_name = $userfile['name'];
66 $type_id = getIntFromRequest('type_id');
67 $processor_id = getIntFromRequest('processor_id');
68 $release_date = getStringFromRequest('release_date');
69 // Build a Unix time value from the supplied Y-m-d value
70 $release_date = strtotime($release_date);
71 $release_notes = getStringFromRequest('release_notes');
72 $release_changes = getStringFromRequest('release_changes');
73 $preformatted = getStringFromRequest('preformatted');
74 $ftp_filename = getStringFromRequest('ftp_filename');
75 $manual_filename = getStringFromRequest('manual_filename');
76 $group_unix_name=group_getunixname($group_id);
80 $warning_msg .= _('Must define a release name.');
81 } else if (!$package_id) {
82 $warning_msg .= _('Must select a package.');
83 } else if (!$type_id || $type_id == "100") {
84 $warning_msg .= _('Must select a file type.');
85 } else if (!$processor_id || $processor_id == "100") {
86 $warning_msg .= _('Must select a processor type.');
92 $frsp = new FRSPackage($g,$package_id);
93 if (!$frsp || !is_object($frsp)) {
94 exit_error('Error','Could Not Get FRSPackage');
95 } elseif ($frsp->isError()) {
96 exit_error('Error',$frsp->getErrorMessage());
99 // Create a new FRSRelease in the db
101 $frsr = new FRSRelease($frsp);
102 if (!$frsr || !is_object($frsr)) {
103 exit_error('Error','Could Not Get FRSRelease');
104 } elseif ($frsr->isError()) {
105 exit_error('Error',$frsr->getErrorMessage());
108 if (!$frsr->create($release_name,$release_notes,$release_changes,
109 $preformatted,$release_date)) {
111 exit_error('Error',$frsr->getErrorMessage());
114 $ret = frs_add_file_from_form ($frsr, $type_id, $processor_id, $release_date,
115 $userfile, $ftp_filename, $manual_filename) ;
122 frs_admin_header(array('title'=>_('Quick Release System'),'group'=>$group_id));
124 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.'),
125 util_make_url ('/frs/admin/editrelease.php?release_id='.$frsr->getID().'&group_id='.$group_id.'&package_id='.$package_id),
126 util_make_url ('/frs/?group_id='.$group_id)
130 frs_admin_footer(array());
143 $release_changes = '';
146 $manual_filename = '';
149 frs_admin_header(array('title'=>_('Quick Release System'),'group'=>$group_id));
153 <form enctype="multipart/form-data" method="post" action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id"; ?>">
154 <table border="0" cellpadding="2" cellspacing="2">
157 <strong><?php echo _('Package ID') ?>:</strong>
161 $res=db_query_params("SELECT * FROM frs_package WHERE group_id=$1 AND status_id='1'", array($group_id));
162 $rows=db_numrows($res);
163 if (!$res || $rows < 1) {
164 echo '<h4>'._('No File Types Available').'</h4>';
167 echo '<select name="package_id">';
168 for ($i=0; $i<$rows; $i++) {
169 echo '<option value="' . db_result($res,$i,'package_id') .
170 ((db_result($res,$i,'package_id') ==$package_id) ? '" selected="selected"' : '"').'>' .
171 db_result($res,$i,'name') . '</option>';
178 <?php printf(_('Or %1$s create a new package %2$s'), '<a href="'.util_make_url ('/frs/admin/?group_id='.$group_id).'">', '</a>') ?>
183 <strong><?php echo _('Release name') ?>:<?php echo utils_requiredField();?></strong>
186 <input type="text" name="release_name" value="<?php echo htmlspecialchars($release_name) ?>" />
191 <strong><?php echo _('Release date') ?>:</strong>
194 <input type="text" name="release_date" value="<?php echo date('Y-m-d H:i'); ?>" size="16" maxlength="16" />
199 <h4><?php echo _('File Name') ?>:<?php echo utils_requiredField();?></h4>
202 <span class="important">
203 <?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.')?>
205 <?php echo _('Upload a new file') ?>: <input type="file" name="userfile" size="30" />
206 <?php if (forge_get_config('use_ftp_uploads')) {
209 printf(_('Alternatively, you can use FTP to upload a new file at %1$s.'), forge_get_config('ftp_upload_host'));
211 echo _('Choose an FTP file instead of uploading:').'<br />';
212 $ftp_files_arr=ls($upload_dir,true);
213 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename',''); ?>
217 <?php if (forge_get_config('use_manual_uploads')) {
218 $incoming = forge_get_config('groupdir_prefix')."/".$g->getUnixName()."/incoming" ;
221 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).'),
222 $incoming, "sftp://" . forge_get_config ('web_host') . $incoming . "/");
223 echo ' ' . _('This direct <tt>sftp://</tt> link only works with some browsers, such as Konqueror.') . '<br />';
224 echo _('Choose an already uploaded file:').'<br />';
225 $manual_files_arr=ls($incoming,true);
226 echo html_build_select_box_from_arrays($manual_files_arr,$manual_files_arr,'manual_filename',''); ?>
234 <strong><?php echo _('File Type') ?>:<?php echo utils_requiredField();?></strong>
238 print frs_show_filetype_popup ('type_id',$type_id);
244 <strong><?php echo _('Processor Type') ?>:<?php echo utils_requiredField();?></strong>
248 print frs_show_processor_popup ('processor_id',$processor_id);
254 <strong><?php echo _('Release Notes') ?>:</strong>
257 <textarea name="release_notes" rows="7" cols="50"><?php echo htmlspecialchars($release_notes); ?></textarea>
262 <strong><?php echo _('Change Log') ?>:</strong>
265 <textarea name="release_changes" rows="7" cols="50"><?php echo htmlspecialchars($release_changes); ?></textarea>
269 <td colspan="2" style="text-align:center">
270 <input type="checkbox" name="preformatted" value="1" /> <?php echo _('Preserve my pre-formatted text') ?>
271 <p><input type="submit" name="submit" value="<?php echo _('Release File') ?>" /></p>
283 // c-file-style: "bsd"