function photos_edit_confirm_delete_submit in Album Photos 7.3
Submit confirm delete photo.
File
- inc/
photos.edit.inc, line 1131 - Handles uploading and editing images.
Code
function photos_edit_confirm_delete_submit($form, &$form_state) {
$fid = $form_state['values']['fid'];
$type = isset($form_state['values']['type']) ? $form_state['values']['type'] : '';
if ($type != 'sub_album') {
// Remove from search index.
if (module_exists('search')) {
search_reindex($fid, 'photos');
}
// Delete image.
$v = photos_file_del($fid, 0, 1);
if (isset($_GET['pid']) && intval($_GET['pid']) == $_GET['pid']) {
photos_set_count('node_album', $_GET['pid']);
}
if (isset($_GET['uid']) && intval($_GET['uid']) == $_GET['uid']) {
photos_set_count('user_image', $_GET['uid']);
}
}
else {
// Remove from sub album.
$v = db_delete('photos_node')
->condition('fid', $fid)
->execute();
if (isset($_GET['nid']) && intval($_GET['nid']) == $_GET['nid']) {
photos_set_count('node_node', $_GET['nid']);
}
}
if (isset($_GET['go']) && $_GET['go'] == 1) {
drupal_add_http_header('Content-Type:', 'text/plain;');
echo $v;
}
elseif ($v) {
if ($type == 'sub_album') {
drupal_set_message(t('Delete success'));
}
else {
drupal_set_message(t('Delete success'));
}
$form_state['redirect'] = $_GET['destination'];
return;
}
else {
drupal_set_message(t('Delete failure'));
$form_state['redirect'] = $_GET['destination'];
return;
}
}