$message->error_permission();
}
- $log = new Logging;
- $log->set_bugid($bug['bugid']);
- $log->set_attachmentid($bugsys->in['attachmentid']);
-
$attachapi = new AttachmentAPI($bugsys);
$attachapi->set('attachmentid', $bugsys->in['attachmentid']);
- $attachapi->set_condition();
$attachapi->dorelations = array();
- $attachapi->fetch();
-
- $log->add_data(true, $attachapi->objdata, array('attachment'), true, 'attachment');
-
- $attachapi->set('description', $bugsys->in['description']);
- $attachapi->set('obsolete', $bugsys->in['obsolete']);
- $attachapi->update();
-
- $log->add_data(false, $attachapi->values, array('attachment'), true, 'attachment');
-
- $log->update_history();
+ $attachapi->set_condition();
- $message->redirect(_('The attachment was successfully modified.'), "showreport.php?bugid=$bug[bugid]");
+ if ($bugsys->in['__delete__'] != '')
+ {
+ if (!(can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid'])))
+ {
+ $message->error_permission();
+ }
+
+ $attachapi->delete();
+
+ $message->redirect(_('The attachment was successfully deleted.'), "showreport.php?bugid=$bug[bugid]");
+ }
+ else
+ {
+ $log = new Logging;
+ $log->set_bugid($bug['bugid']);
+ $log->set_attachmentid($bugsys->in['attachmentid']);
+
+ $attachapi->fetch();
+
+ $log->add_data(true, $attachapi->objdata, array('attachment'), true, 'attachment');
+
+ $attachapi->set('description', $bugsys->in['description']);
+ $attachapi->set('obsolete', $bugsys->in['obsolete']);
+ $attachapi->update();
+
+ $log->add_data(false, $attachapi->values, array('attachment'), true, 'attachment');
+
+ $log->update_history();
+
+ $message->redirect(_('The attachment was successfully modified.'), "showreport.php?bugid=$bug[bugid]");
+ }
}
// ###################################################################
$message->error_permission();
}
- $show['delete'] = ((can_perform('caneditattach', $bug['product'])) ? true : false);
+ $show['delete'] = (can_perform('caneditattach', $bug['product']) AND can_perform('candeletedata', $bug['productid']));
eval('$template->flush("' . $template->fetch('editattach') . '");');
}