3 * Project Admin: Edit Releases of Packages
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2002-2004 (c) GForge Team
7 * http://fusionforge.org/
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 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');
35 $release_id = getIntFromRequest('release_id');
39 if (!$package_id || !$release_id) {
40 session_redirect('/frs/admin/?group_id='.$group_id);
43 $group=group_get_object($group_id);
44 if (!$group || !is_object($group)) {
46 } elseif ($group->isError()) {
47 exit_error($group->getErrorMessage(),'frs');
49 session_require_perm ('frs', $group_id, 'write') ;
54 $frsp = new FRSPackage($group,$package_id);
55 if (!$frsp || !is_object($frsp)) {
56 exit_error(_('Could Not Get FRSPackage'),'frs');
57 } elseif ($frsp->isError()) {
58 exit_error($frsp->getErrorMessage(),'frs');
64 $frsr = new FRSRelease($frsp,$release_id);
65 if (!$frsr || !is_object($frsr)) {
66 exit_error(_('Could Not Get FRSRelease'),'frs');
67 } elseif ($frsr->isError()) {
68 exit_error($frsr->getErrorMessage(),'frs');
71 $upload_dir = forge_get_config('ftp_upload_dir') . "/" . $group->getUnixName();
75 * Here's where we do the dirty work based on the step the user has chosen
79 if (getStringFromRequest('step1')) {
80 $release_date = getStringFromRequest('release_date');
81 $release_name = getStringFromRequest('release_name');
82 $status_id = getIntFromRequest('status_id');
83 $uploaded_notes = getUploadedFile('uploaded_notes');
84 $uploaded_changes = getUploadedFile('uploaded_changes');
85 $release_notes = getStringFromRequest('release_notes');
86 $release_changes = getStringFromRequest('release_changes');
87 $preformatted = getStringFromRequest('preformatted');
90 // Check for uploaded release notes
91 if ($uploaded_notes["tmp_name"]) {
92 if (!is_uploaded_file($uploaded_notes['tmp_name'])) {
93 exit_error(_('Attempted File Upload Attack'),'frs');
95 if ($uploaded_notes['type'] !== 'text/plain') {
96 $error_msg .= _('Release Notes Are not in Text').'<br />';
97 $exec_changes = false;
99 $notes = fread(fopen($uploaded_notes['tmp_name'],'r'),$uploaded_notes['size']);
100 if (strlen($notes) < 20) {
101 $error_msg .= _('Release Notes Are Too Small').'<br />';
102 $exec_changes = false;
106 $notes = $release_notes;
109 // Check for uploaded change logs
110 if ($uploaded_changes['tmp_name']) {
111 if (!is_uploaded_file($uploaded_changes['tmp_name'])) {
112 exit_error(_('Attempted File Upload Attack'),'frs');
114 if ($uploaded_changes['type'] !== 'text/plain') {
115 $error_msg .= _('Change Log Is not in Text').'<br />';
116 $exec_changes = false;
118 $changes = fread(fopen($uploaded_changes['tmp_name'],'r'), $uploaded_changes['size']);
119 if (strlen($changes) < 20) {
120 $error_msg .= _('Change Log Is Too Small').'<br />';
121 $exec_changes = false;
125 $changes = $release_changes;
128 // If we haven't encountered any problems so far then save the changes
129 if ($exec_changes == true) {
130 //$date_list = split('[- :]',$release_date,5);
131 //$release_date = mktime($date_list[3],$date_list[4],0,$date_list[1],$date_list[2],$date_list[0]);
132 $release_date = strtotime($release_date);
133 if (!$frsr->update($status_id,$release_name,$notes,$changes,$preformatted,$release_date)) {
134 exit_error($frsr->getErrorMessage(),'frs');
136 $feedback .= _('Data Saved');
141 // Add file(s) to the release
142 if (getStringFromRequest('step2')) {
143 $userfile = getUploadedFile('userfile');
144 $userfile_name = $userfile['name'];
145 $type_id = getIntFromRequest('type_id');
146 $release_date = getStringFromRequest('release_date');
147 // Build a Unix time value from the supplied Y-m-d value
148 $release_date = strtotime($release_date);
149 $processor_id = getIntFromRequest('processor_id');
150 $group_unix_name=group_getunixname($group_id);
151 $ftp_filename = getStringFromRequest('ftp_filename');
152 $manual_filename = getStringFromRequest('manual_filename');
154 $ret = frs_add_file_from_form ($frsr, $type_id, $processor_id, $release_date,
155 $userfile, $ftp_filename, $manual_filename) ;
157 $feedback = _('File Released') ;
163 // Edit/Delete files in a release
164 if (getStringFromRequest('step3')) {
165 $step3 = getStringFromRequest('step3');
166 $file_id = getIntFromRequest('file_id');
167 $processor_id = getIntFromRequest('processor_id');
168 $type_id = getIntFromRequest('type_id');
169 $new_release_id = getIntFromRequest('new_release_id');
170 $release_time = getStringFromRequest('release_time');
171 $group_id = getIntFromRequest('group_id');
172 $release_id = getIntFromRequest('release_id');
173 $package_id = getIntFromRequest('package_id');
174 $file_id = getIntFromRequest('file_id');
175 $im_sure = getStringFromRequest('im_sure');
177 // If the user chose to delete the file and he's sure then delete the file
178 if( $step3 == "Delete File" ) {
180 $frsf = new FRSFile($frsr,$file_id);
181 if (!$frsf || !is_object($frsf)) {
182 exit_error(_('Could Not Get FRSFile'),'frs');
183 } elseif ($frsf->isError()) {
184 exit_error($frsf->getErrorMessage(),'frs');
186 if (!$frsf->delete()) {
187 exit_error($frsf->getErrorMessage(),'frs');
189 $feedback .= _('File Deleted');
193 $error_msg .= _('File not deleted: you did not check "I\'m Sure"');
195 // Otherwise update the file information
197 $frsf = new FRSFile($frsr,$file_id);
198 if (!$frsf || !is_object($frsf)) {
199 exit_error(_('Could Not Get FRSFile'),'frs');
200 } elseif ($frsf->isError()) {
201 exit_error($frsf->getErrorMessage(),'frs');
203 //$date_list = split('[- :]',$release_time,5);
204 //$release_time = mktime($date_list[3],$date_list[4],0,$date_list[1],$date_list[2],$date_list[0]);
205 $release_time = strtotime($release_time);
206 if (!$frsf->update($type_id,$processor_id,$release_time,$new_release_id)) {
207 exit_error($frsf->getErrorMessage(),'frs');
209 $feedback .= _('File Updated');
215 frs_admin_header(array('title'=>_('Edit Releases'),'group'=>$group_id));
217 * Show the forms for each step
221 <h2><?php echo _('Edit Release') ?></h2>
223 <form enctype="multipart/form-data" method="post" action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&release_id=$release_id&package_id=$package_id"; ?>">
224 <input type="hidden" name="step1" value="1" />
225 <table border="0" cellpadding="1" cellspacing="1">
227 <td width="10%"><strong><?php echo _('Release date') ?>:</strong></td>
228 <td><input type="text" name="release_date" value="<?php echo date('Y-m-d H:i',$frsr->getReleaseDate()) ?>" size="16" maxlength="16" /></td>
231 <td><strong><?php echo _('Release name') ?>:</strong></td>
232 <td><input type="text" name="release_name" value="<?php echo htmlspecialchars($frsr->getName()); ?>" /></td>
235 <td><strong><?php echo _('Status') ?></strong></td>
238 echo frs_show_status_popup('status_id',$frsr->getStatus());
245 <?php echo _('Edit the Release Notes or Change Log for this release of this package. These changes will apply to all files attached to this release.<br />You can either upload the release notes and change log individually, or paste them in together below.') ?>
249 <td><strong><?php echo _('Upload Release Notes') ?>:</strong></td>
250 <td><input type="file" name="uploaded_notes" size="30" /></td>
253 <td><strong><?php echo _('Upload Change Log') ?>:</strong></td>
254 <td><input type="file" name="uploaded_changes" size="30" /></td>
258 <strong><?php echo _('Paste The Notes In') ?>:</strong><br />
259 <textarea name="release_notes" rows="10" cols="60"><?php echo $frsr->getNotes(); ?></textarea>
264 <strong><?php echo _('Paste The Change Log In') ?>:</strong><br />
265 <textarea name="release_changes" rows="10" cols="60"><?php echo $frsr->getChanges(); ?></textarea>
271 <input type="checkbox" name="preformatted" value="1" <?php echo (($frsr->getPreformatted())?'checked="checked"':''); ?> /> <?php echo _('Preserve my pre-formatted text.') ?>
273 <input type="submit" name="submit" value="<?php echo _('Submit/Refresh') ?>"/>
281 <h2><?php echo _('Add Files To This Release') ?></h2>
282 <p><?php echo _('Now, choose a file to upload into the system.') ?></p>
284 <form enctype="multipart/form-data" method="post" action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&release_id=$release_id&package_id=$package_id"; ?>">
285 <input type="hidden" name="step2" value="1" />
286 <fieldset><legend><strong><?php echo _("File Name") ?></strong></legend>
287 <?php echo _("Upload a new file") ?>: <input type="file" name="userfile" size="30" />
288 <?php if (forge_get_config('use_ftp_uploads')) {
290 printf(_('Alternatively, you can use FTP to upload a new file at %1$s.'), forge_get_config('ftp_upload_host'));
292 echo _('Choose an already uploaded file:').'<br />';
293 $ftp_files_arr=ls($upload_dir,true);
294 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename',''); ?>
298 <?php if (forge_get_config('use_manual_uploads')) {
299 $incoming = forge_get_config('groupdir_prefix')."/".$group->getUnixName()."/incoming" ;
302 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).'),
303 $incoming, "sftp://" . forge_get_config ('web_host') . $incoming . "/");
304 echo ' ' . _('This direct <tt>sftp://</tt> link only works with some browsers, such as Konqueror.') . '<br />';
305 echo _('Choose an already uploaded file:').'<br />';
306 $manual_files_arr=ls($incoming,true);
307 echo html_build_select_box_from_arrays($manual_files_arr,$manual_files_arr,'manual_filename',''); ?>
314 <strong><?php echo _('File Type') ?>:</strong>
316 print frs_show_filetype_popup ('type_id');
320 <strong><?php echo _('Processor Type') ?>:</strong>
322 print frs_show_processor_popup ('processor_id');
328 <input type="submit" name="submit" value="<?php echo _('Add This File') ?>" /></p>
332 // Get a list of files associated with this release
333 $res=db_query_params ('SELECT * FROM frs_file WHERE release_id=$1',
335 $rows=db_numrows($res);
338 echo '<h2>'._('Edit Files In This Release').'</h2>';
339 print(_('Once you have added files to this release you <strong>must</strong> update each of these files with the correct information or they will not appear on your download summary page.')."\n");
340 $title_arr[]=_('Filename<br />Release').'<br />';
341 $title_arr[]=_('Processor<br />Release Date').'<br />';
342 $title_arr[]=_('File Type<br />Update').'<br />';
344 echo $GLOBALS['HTML']->listTableTop ($title_arr);
346 for($x=0; $x<$rows; $x++) {
348 <form action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&release_id=$release_id&package_id=$package_id"; ?>" method="post">
349 <input type="hidden" name="file_id" value="<?php echo db_result($res,$x,'file_id'); ?>" />
350 <input type="hidden" name="step3" value="1" />
351 <tr <?php echo $HTML->boxGetAltRowStyle($x); ?>>
352 <td style="white-space: nowrap;"><?php echo db_result($res,$x,'filename'); ?></td>
353 <td><?php echo frs_show_processor_popup ('processor_id', db_result($res,$x,'processor_id')); ?></td>
354 <td><?php echo frs_show_filetype_popup ('type_id', db_result($res,$x,'type_id')); ?></td>
356 <tr <?php echo $HTML->boxGetAltRowStyle($x); ?>>
359 <?php echo frs_show_release_popup ($group_id, $name='new_release_id',db_result($res,$x,'release_id')); ?>
364 <input type="text" name="release_time" value="<?php echo date('Y-m-d',db_result($res,$x,'release_time')); ?>" size="10" maxlength="10" />
367 <td><input type="submit" name="submit" value="<?php echo _('Update/Refresh') ?> " /></td>
371 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
372 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
373 <input type="hidden" name="release_id" value="<?php echo $release_id; ?>" />
374 <input type="hidden" name="package_id" value="<?php echo $package_id; ?>" />
375 <input type="hidden" name="file_id" value="<?php echo db_result($res,$x,'file_id'); ?>" />
376 <input type="hidden" name="step3" value="Delete File" />
377 <tr <?php echo $HTML->boxGetAltRowStyle($x); ?>>
382 <input type="submit" name="submit" value="<?php echo _('Delete File') ?> " /> <input type="checkbox" name="im_sure" value="1" /> <?php echo _('I\'m Sure') ?>
389 echo $GLOBALS['HTML']->listTableBottom();
392 echo '<p>' . sprintf(ngettext('There is %1$s user monitoring this package.', 'There are %1$s users monitoring this package.', $frsp->getMonitorCount()), $frsp->getMonitorCount()) . '</p>';
398 // c-file-style: "bsd"