function media_multiple_delete_confirm_submit in D7 Media 7
Attempt to delete files and notify the user of the result.
1 string reference to 'media_multiple_delete_confirm_submit'
- media_multiple_delete_confirm in includes/
media.pages.inc - Confirm the request to delete files.
File
- includes/
media.pages.inc, line 118 - Common pages for the Media module.
Code
function media_multiple_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$results = array();
$files = array_keys($form_state['values']['files']);
foreach ($files as $fid) {
$file = file_load($fid);
$files[$fid] = $file;
$results[$fid] = file_delete($file);
}
// The result of file_delete can be an array if the file is in use, or TRUE/FALSE.
foreach ($results as $fid => $result) {
if (is_array($result)) {
drupal_set_message(t('The file @title is in use and cannot be deleted.', array(
'@title' => $files[$fid]->filename,
)), 'warning');
}
elseif (!$result) {
drupal_set_message(t('The file @title was not deleted due to an error.', array(
'@title' => $files[$fid]->filename,
)), 'error');
}
else {
$message = t('File @title was deleted', array(
'@title' => $files[$fid]->filename,
));
watchdog('media', $message);
drupal_set_message($message);
}
}
if (isset($form_state['values']['redirect_on_success'])) {
$form_state['redirect'] = $form_state['values']['redirect_on_success'];
}
}
}