You are here

function avatar_selection_image_delete in Avatar Selection 7

Same name and namespace in other branches
  1. 5.2 avatar_selection.module \avatar_selection_image_delete()
  2. 5 avatar_selection.module \avatar_selection_image_delete()
  3. 6 avatar_selection.admin.inc \avatar_selection_image_delete()

Delete the specified avatar image.

Parameters

$fid: The image file id to be deleted.

2 calls to avatar_selection_image_delete()
avatar_selection_edit_delete_form_submit in ./avatar_selection.admin.inc
Submit the image list form in the Avatar Selection - 'Manage Avatars' page.
_avatar_selection_scan_images in ./avatar_selection.admin.inc
Scan the directory for new files.

File

./avatar_selection.admin.inc, line 767
Administrative page callbacks for the avatar_selection module.

Code

function avatar_selection_image_delete($fid) {
  file_delete(file_load($fid));
  $aid = db_query("SELECT aid FROM {avatar_selection} WHERE fid = :avatar", array(
    ':avatar' => $fid,
  ))
    ->fetchField();
  if ($aid) {
    $result = db_delete('avatar_selection')
      ->condition('aid', $aid)
      ->execute();
    $result = db_delete('avatar_selection_roles')
      ->condition('aid', $aid)
      ->execute();
    $result = db_delete('avatar_selection_og')
      ->condition('aid', $aid)
      ->execute();
  }
  return TRUE;
}