function filebrowser_form_delete_confirm in Filebrowser 7.3
Same name and namespace in other branches
- 8 filebrowser.module \filebrowser_form_delete_confirm()
- 6.2 filebrowser.module \filebrowser_form_delete_confirm()
- 7.4 filebrowser.module \filebrowser_form_delete_confirm()
- 7.2 filebrowser.module \filebrowser_form_delete_confirm()
File delete confirmation form CHECK: $node is used but not defined in this function
1 string reference to 'filebrowser_form_delete_confirm'
File
- ./
filebrowser.module, line 814
Code
function filebrowser_form_delete_confirm($form, &$form_state, $fids) {
// Items to delete.
$items = array();
// This flag indicates that a folder has been selected for deletion.
$folder_selected = FALSE;
// Scan passed fids and retrieve item fullnames.
foreach ($fids as $fid) {
$file = _filebrowser_node_content_load($fid);
$node = node_load($file['nid']);
// Additional data.
$file['full-path'] = _filebrowser_encoding_to_fs($node, _filebrowser_get_node_root($node) . $file['path']);
$file['display-name'] = _filebrowser_safe_basename($file['full-path']);
// Retrieve item metadata (needed to retrieve item icon).
$result = module_invoke_all('filebrowser_metadata_get', $file);
if ($result && is_array($result)) {
$file = array_merge($file, $result);
}
// Retrieve thumbnail.
$file['thumbnail'] = _filebrowser_thumbnails_generate($node, $file);
// Store item data.
$items[$fid] = $file;
}
// Store items being deleted into a form value.
$form['items_to_delete'] = array(
'#type' => 'value',
'#value' => $items,
);
// Compose the list of files being deleted.
$list = '<ul>';
foreach ($items as $item) {
$list .= '<li>' . $item['thumbnail'] . ' ';
if ($item['kind']) {
$folder_selected = TRUE;
$list .= '<b>' . $item['display-name'] . '</b>';
}
else {
$list .= $item['display-name'];
}
$list .= '</li>';
}
$list .= '</ul>';
$form['items'] = array(
'#type' => 'item',
'#title' => t('Items being deleted'),
'#markup' => $list,
);
// If at least a folder has been selected, add a confirmation checkbox.
if ($folder_selected) {
$form['confirmation'] = array(
'#type' => 'checkbox',
'#title' => t('Confirm deletion of selected <b>subfolders</b> and all of their content.'),
'#default_value' => FALSE,
);
}
else {
// No confirmation needed, we'll add a "fake" field.
$form['confirmation'] = array(
'#type' => 'value',
'#value' => TRUE,
);
}
// show the form to the user
return confirm_form($form, t('Are you sure you want to delete the following items?'), isset($_GET['destination']) ? $_GET['destination'] : 'node/' . $node->nid, t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}