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.
25 require_once('../../env.inc.php');
26 require_once $gfcommon.'include/pre.php';
27 require_once $gfcommon.'frs/FRSPackage.class.php';
28 require_once $gfcommon.'frs/FRSRelease.class.php';
29 require_once $gfcommon.'frs/FRSFile.class.php';
30 require_once $gfcommon.'frs/include/frs_utils.php';
32 $group_id = getIntFromRequest('group_id');
33 $package_id = getIntFromRequest('package_id');
34 $release_id = getIntFromRequest('release_id');
38 if (!$package_id || !$release_id) {
39 session_redirect('/frs/admin/?group_id='.$group_id);
42 $group=group_get_object($group_id);
43 if (!$group || !is_object($group)) {
45 } elseif ($group->isError()) {
46 exit_error($group->getErrorMessage(),'frs');
48 session_require_perm ('frs', $group_id, 'write') ;
53 $frsp = new FRSPackage($group,$package_id);
54 if (!$frsp || !is_object($frsp)) {
55 exit_error(_('Could Not Get FRSPackage'),'frs');
56 } elseif ($frsp->isError()) {
57 exit_error($frsp->getErrorMessage(),'frs');
63 $frsr = new FRSRelease($frsp,$release_id);
64 if (!$frsr || !is_object($frsr)) {
65 exit_error(_('Could Not Get FRSRelease'),'frs');
66 } elseif ($frsr->isError()) {
67 exit_error($frsr->getErrorMessage(),'frs');
70 $upload_dir = forge_get_config('ftp_upload_dir') . "/" . $group->getUnixName();
74 * Here's where we do the dirty work based on the step the user has chosen
78 if (getStringFromRequest('step1')) {
79 $release_date = getStringFromRequest('release_date');
80 $release_name = getStringFromRequest('release_name');
81 $status_id = getIntFromRequest('status_id');
82 $uploaded_notes = getUploadedFile('uploaded_notes');
83 $uploaded_changes = getUploadedFile('uploaded_changes');
84 $release_notes = getStringFromRequest('release_notes');
85 $release_changes = getStringFromRequest('release_changes');
86 $preformatted = getStringFromRequest('preformatted');
89 // Check for uploaded release notes
90 if ($uploaded_notes["tmp_name"]) {
91 if (!is_uploaded_file($uploaded_notes['tmp_name'])) {
92 exit_error(_('Attempted File Upload Attack'),'frs');
94 if ($uploaded_notes['type'] !== 'text/plain') {
95 $error_msg .= _('Release Notes Are not in Text').'<br />';
96 $exec_changes = false;
98 $notes = fread(fopen($uploaded_notes['tmp_name'],'r'),$uploaded_notes['size']);
99 if (strlen($notes) < 20) {
100 $error_msg .= _('Release Notes Are Too Small').'<br />';
101 $exec_changes = false;
105 $notes = $release_notes;
108 // Check for uploaded change logs
109 if ($uploaded_changes['tmp_name']) {
110 if (!is_uploaded_file($uploaded_changes['tmp_name'])) {
111 exit_error(_('Attempted File Upload Attack'),'frs');
113 if ($uploaded_changes['type'] !== 'text/plain') {
114 $error_msg .= _('Change Log Is not in Text').'<br />';
115 $exec_changes = false;
117 $changes = fread(fopen($uploaded_changes['tmp_name'],'r'), $uploaded_changes['size']);
118 if (strlen($changes) < 20) {
119 $error_msg .= _('Change Log Is Too Small').'<br />';
120 $exec_changes = false;
124 $changes = $release_changes;
127 // If we haven't encountered any problems so far then save the changes
128 if ($exec_changes == true) {
129 //$date_list = split('[- :]',$release_date,5);
130 //$release_date = mktime($date_list[3],$date_list[4],0,$date_list[1],$date_list[2],$date_list[0]);
131 $release_date = strtotime($release_date);
132 if (!$frsr->update($status_id,$release_name,$notes,$changes,$preformatted,$release_date)) {
133 exit_error($frsr->getErrorMessage(),'frs');
135 $feedback .= _('Data Saved');
140 // Add file(s) to the release
141 if (getStringFromRequest('step2')) {
142 $userfile = getUploadedFile('userfile');
143 $userfile_name = $userfile['name'];
144 $type_id = getIntFromRequest('type_id');
145 $release_date = getStringFromRequest('release_date');
146 // Build a Unix time value from the supplied Y-m-d value
147 $release_date = strtotime($release_date);
148 $processor_id = getIntFromRequest('processor_id');
149 $group_unix_name=group_getunixname($group_id);
150 $ftp_filename = getStringFromRequest('ftp_filename');
151 $manual_filename = getStringFromRequest('manual_filename');
153 $ret = frs_add_file_from_form ($frsr, $type_id, $processor_id, $release_date,
154 $userfile, $ftp_filename, $manual_filename) ;
156 $feedback = _('File Released') ;
162 // Edit/Delete files in a release
163 if (getStringFromRequest('step3')) {
164 $step3 = getStringFromRequest('step3');
165 $file_id = getIntFromRequest('file_id');
166 $processor_id = getIntFromRequest('processor_id');
167 $type_id = getIntFromRequest('type_id');
168 $new_release_id = getIntFromRequest('new_release_id');
169 $release_time = getStringFromRequest('release_time');
170 $group_id = getIntFromRequest('group_id');
171 $release_id = getIntFromRequest('release_id');
172 $package_id = getIntFromRequest('package_id');
173 $file_id = getIntFromRequest('file_id');
174 $im_sure = getStringFromRequest('im_sure');
176 // If the user chose to delete the file and he's sure then delete the file
177 if( $step3 == "Delete File" ) {
179 $frsf = new FRSFile($frsr,$file_id);
180 if (!$frsf || !is_object($frsf)) {
181 exit_error(_('Could Not Get FRSFile'),'frs');
182 } elseif ($frsf->isError()) {
183 exit_error($frsf->getErrorMessage(),'frs');
185 if (!$frsf->delete()) {
186 exit_error($frsf->getErrorMessage(),'frs');
188 $feedback .= _('File Deleted');
192 $error_msg .= _('File not deleted: you did not check "I\'m Sure"');
194 // Otherwise update the file information
196 $frsf = new FRSFile($frsr,$file_id);
197 if (!$frsf || !is_object($frsf)) {
198 exit_error(_('Could Not Get FRSFile'),'frs');
199 } elseif ($frsf->isError()) {
200 exit_error($frsf->getErrorMessage(),'frs');
202 //$date_list = split('[- :]',$release_time,5);
203 //$release_time = mktime($date_list[3],$date_list[4],0,$date_list[1],$date_list[2],$date_list[0]);
204 $release_time = strtotime($release_time);
205 if (!$frsf->update($type_id,$processor_id,$release_time,$new_release_id)) {
206 exit_error($frsf->getErrorMessage(),'frs');
208 $feedback .= _('File Updated');
214 frs_admin_header(array('title'=>_('Edit Releases'),'group'=>$group_id));
216 * Show the forms for each step
220 <h2><?php echo _('Edit Release') ?></h2>
222 <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"; ?>">
223 <input type="hidden" name="step1" value="1" />
224 <table cellpadding="1" cellspacing="1">
226 <td width="10%"><strong><?php echo _('Release date') ?>:</strong></td>
227 <td><input type="text" name="release_date" value="<?php echo date('Y-m-d H:i',$frsr->getReleaseDate()) ?>" size="16" maxlength="16" /></td>
230 <td><strong><?php echo _('Release name') ?>:</strong></td>
231 <td><input type="text" name="release_name" value="<?php echo htmlspecialchars($frsr->getName()); ?>" /></td>
234 <td><strong><?php echo _('Status') ?></strong></td>
237 echo frs_show_status_popup('status_id',$frsr->getStatus());
244 <?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.') ?>
248 <td><strong><?php echo _('Upload Release Notes') ?>:</strong></td>
249 <td><input type="file" name="uploaded_notes" size="30" /></td>
252 <td><strong><?php echo _('Upload Change Log') ?>:</strong></td>
253 <td><input type="file" name="uploaded_changes" size="30" /></td>
257 <strong><?php echo _('Paste The Notes In') ?>:</strong><br />
258 <textarea name="release_notes" rows="10" cols="60"><?php echo $frsr->getNotes(); ?></textarea>
263 <strong><?php echo _('Paste The Change Log In') ?>:</strong><br />
264 <textarea name="release_changes" rows="10" cols="60"><?php echo $frsr->getChanges(); ?></textarea>
270 <input type="checkbox" name="preformatted" value="1" <?php echo (($frsr->getPreformatted())?'checked="checked"':''); ?> /> <?php echo _('Preserve my pre-formatted text.') ?>
272 <input type="submit" name="submit" value="<?php echo _('Submit/Refresh') ?>"/>
280 <h2><?php echo _('Add Files To This Release') ?></h2>
281 <p><?php echo _('Now, choose a file to upload into the system.') ?></p>
283 <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"; ?>">
284 <input type="hidden" name="step2" value="1" />
285 <fieldset><legend><strong><?php echo _("File Name") ?></strong></legend>
286 <?php echo _("Upload a new file") ?>: <input type="file" name="userfile" size="30" />
287 <?php if (forge_get_config('use_ftp_uploads')) {
289 printf(_('Alternatively, you can use FTP to upload a new file at %1$s.'), forge_get_config('ftp_upload_host'));
291 echo _('Choose an already uploaded file:').'<br />';
292 $ftp_files_arr=frs_filterfiles(ls($upload_dir,true));
293 echo html_build_select_box_from_arrays($ftp_files_arr,$ftp_files_arr,'ftp_filename',''); ?>
297 <?php if (forge_get_config('use_manual_uploads')) {
298 $incoming = forge_get_config('groupdir_prefix')."/".$group->getUnixName()."/incoming" ;
301 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).'),
302 $incoming, "sftp://" . forge_get_config ('web_host') . $incoming . "/");
303 echo ' ' . _('This direct <tt>sftp://</tt> link only works with some browsers, such as Konqueror.') . '<br />';
304 echo _('Choose an already uploaded file:').'<br />';
305 $manual_files_arr=frs_filterfiles(ls($incoming,true));
306 echo html_build_select_box_from_arrays($manual_files_arr,$manual_files_arr,'manual_filename',''); ?>
313 <strong><?php echo _('File Type') ?>:</strong>
315 print frs_show_filetype_popup ('type_id');
319 <strong><?php echo _('Processor Type') ?>:</strong>
321 print frs_show_processor_popup ('processor_id');
327 <input type="submit" name="submit" value="<?php echo _('Add This File') ?>" /></p>
331 // Get a list of files associated with this release
332 $res=db_query_params ('SELECT * FROM frs_file WHERE release_id=$1',
334 $rows=db_numrows($res);
337 echo '<h2>'._('Edit Files In This Release').'</h2>';
338 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");
339 $title_arr[]=_('Filename<br />Release').'<br />';
340 $title_arr[]=_('Processor<br />Release Date').'<br />';
341 $title_arr[]=_('File Type<br />Update').'<br />';
343 echo $GLOBALS['HTML']->listTableTop ($title_arr);
345 for($x=0; $x<$rows; $x++) {
347 <form action="<?php echo getStringFromServer('PHP_SELF')."?group_id=$group_id&release_id=$release_id&package_id=$package_id"; ?>" method="post">
348 <input type="hidden" name="file_id" value="<?php echo db_result($res,$x,'file_id'); ?>" />
349 <input type="hidden" name="step3" value="1" />
350 <tr <?php echo $HTML->boxGetAltRowStyle($x); ?>>
351 <td style="white-space: nowrap;"><?php echo db_result($res,$x,'filename'); ?></td>
352 <td><?php echo frs_show_processor_popup ('processor_id', db_result($res,$x,'processor_id')); ?></td>
353 <td><?php echo frs_show_filetype_popup ('type_id', db_result($res,$x,'type_id')); ?></td>
355 <tr <?php echo $HTML->boxGetAltRowStyle($x); ?>>
357 <?php echo frs_show_release_popup ($group_id, $name='new_release_id',db_result($res,$x,'release_id')); ?>
360 <input type="text" name="release_time" value="<?php echo date('Y-m-d',db_result($res,$x,'release_time')); ?>" size="10" maxlength="10" />
362 <td><input type="submit" name="submit" value="<?php echo _('Update/Refresh') ?> " /></td>
366 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
367 <input type="hidden" name="group_id" value="<?php echo $group_id; ?>" />
368 <input type="hidden" name="release_id" value="<?php echo $release_id; ?>" />
369 <input type="hidden" name="package_id" value="<?php echo $package_id; ?>" />
370 <input type="hidden" name="file_id" value="<?php echo db_result($res,$x,'file_id'); ?>" />
371 <input type="hidden" name="step3" value="Delete File" />
372 <tr <?php echo $HTML->boxGetAltRowStyle($x); ?>>
376 <input type="submit" name="submit" value="<?php echo _('Delete File') ?> " /> <input type="checkbox" name="im_sure" value="1" /> <?php echo _('I\'m Sure') ?>
382 echo $GLOBALS['HTML']->listTableBottom();
385 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>';
391 // c-file-style: "bsd"