function gallery_assist_delete_one_submit in Gallery Assist 6
Action: delete a image and all entries from the db.
_state
Parameters
Array $form:
2 string references to 'gallery_assist_delete_one_submit'
- gallery_assist_delete_one in ./
gallery_assist.module - Add to the form the data from the image that will be deleted. Menu callback which is activated by clicking on the link delete over the images.
- gallery_assist_edit_one in ./
gallery_assist.module - Allow to edit each Gallery Assist Item separately.
File
- ./
gallery_assist.module, line 609 - Drupal content type with gallery functionality.
Code
function gallery_assist_delete_one_submit($form, $form_state) {
$item = $form_state['values'];
//gallery_assist_invalidate_cache($node->nid);
$cq = "DELETE FROM {cache_gallery_assist_data} WHERE cid = '%s'";
db_query($cq, $item['nid']);
$was_cover = $item['cover'] == 1 ? TRUE : FALSE;
// Get the image paths.
$res = db_fetch_object(db_query("SELECT fid, uid, ref, filename, tpath, ppath, opath FROM {gallery_assist_item} WHERE pid=%d", $item['pid']));
// Build the Gallery Assist img path.
$res->thmb_path = variable_get('gallery_assist_directory', file_directory_path() . '/gallery_assist') . '/' . $res->uid . '/gallery_assist' . $res->ref . '/img/' . $res->filename;
if (function_exists('pathauto_menu')) {
if ($form['values']['aid'] > 0) {
db_query("DELETE FROM {url_alias} WHERE pid = %d", $form['values']['aid']);
}
}
// Delete fisicaly the files.
gallery_assist_delete_items($res);
// Delete tables etries, order: files, gallery_assist_translated and gallery_assist_item.
db_query('DELETE FROM {files} WHERE fid = %d', $item['fid']);
db_query('DELETE FROM {gallery_assist_translated} WHERE pid = %d', $item['pid']);
db_query('DELETE FROM {gallery_assist_item} WHERE pid = %d', $item['pid']);
drupal_set_message(t('@title has been successful deleted.', array(
'@title' => $item['ptitle'],
)), 'status');
if ($was_cover) {
drupal_set_message(t('This image was the gallery cover you have to select other image as cover.'), 'warning');
}
$form_state['redirect'] = $form_state['clicked_button']['#redirect'];
}