function taxonomy_image_delete in Taxonomy Image 5
Same name and namespace in other branches
- 6 taxonomy_image.module \taxonomy_image_delete()
4 calls to taxonomy_image_delete()
- migrate in contributed/update_term_images.php
- taxonomy_image_admin in ./taxonomy_image.module
- taxonomy_image_attach_taxonomy in contributed/taxonomy_image_attach/taxonomy_image_attach.module
- Implementation of hook_taxonomy.
Capture term updates - including submission of the term edit form
- taxonomy_image_taxonomy in ./taxonomy_image.module
- Implementation of hook_taxonomy().
File
- ./taxonomy_image.module, line 1033
- taxonomy_image.module
Simple module for providing an association between taxonomy terms and images.
Written by Jeremy Andrews <jeremy@kerneltrap.org>, May 2004.
Code
function taxonomy_image_delete($tid) {
$old_path = db_result(db_query('SELECT path FROM {term_image} WHERE tid=%d', $tid));
$how_many = db_result(db_query("SELECT COUNT(path) FROM {term_image} WHERE path='%s'", $old_path));
$taxonomy_image_path = file_directory_path() . '/' . variable_get('taxonomy_image_path', 'category_pictures');
if (drupal_substr($old_path, 0, drupal_strlen($taxonomy_image_path)) != $taxonomy_image_path) {
$file_del_ok = TRUE;
$db_del_ok = TRUE;
}
else {
if ($how_many == 1) {
$file_del_ok = db_query("DELETE FROM {files} WHERE filepath='%s'", $old_path);
}
else {
$file_del_ok = TRUE;
drupal_set_message(t('Not deleted from the files table because it is use on !count other terms.', array(
'!count' => $how_many - 1,
)));
}
}
$db_del_ok = db_query('DELETE FROM {term_image} WHERE tid=%d', $tid);
if ($file_del_ok && $db_del_ok) {
drupal_set_message(t('@name image removed.', array(
'@name' => $old_path,
)));
}
else {
drupal_set_message(t('Image delete failed. File: !file, Db: !db.', array(
'!file' => $file_del_ok ? 'yes' : 'no',
'!db' => $db_del_ok ? 'yes' : 'no',
)));
}
return;
}