3 * FusionForge FRS: Delete File Action
5 * Copyright 2014, Franck Villaume - TrivialDev
6 * http://fusionforge.org/
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 /* please do not add require here : use www/frs/index.php to add require */
25 /* global variables used */
28 $sysdebug_enable = false;
31 $package_id = getIntFromRequest('package_id');
32 $file_ids_string = getStringFromRequest('file_id');
33 if (!forge_check_perm('frs', $package_id, 'file')) {
34 $result['html'] = $HTML->error_msg(_('FRS Action Denied.'));
35 } elseif ($file_ids_string) {
36 $file_ids = explode(',', $file_ids_string);
37 $result['format'] = 'multi';
38 foreach ($file_ids as $key => $file_id) {
39 $frsf = frsfile_get_object($file_id);
40 if (!$frsf || !is_object($frsf)) {
41 $result[$key]['html'] = $HTML->error_msg(_('Error Getting FRSPackage'));
42 } elseif ($frsf->isError() || !$frsf->delete()) {
43 $result[$key]['html'] = $HTML->error_msg($frsf->getErrorMessage());
45 $result[$key]['html'] = $HTML->feedback(_('File successfully deleted.'));
46 $result[$key]['deletedom'] = 'fileid'.$file_id;
50 $result['html'] = $HTML->error_msg(_('Missing file_id'));
53 echo json_encode($result);