You are here

function avatar_selection_image_delete in Avatar Selection 5.2

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

Delete the specified avatar image.

Parameters

$image: Path to the image to be deleted.

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

File

./avatar_selection.module, line 1094
The Avatar Selection module allows the user to pick an avatar image from a list already loaded by an administrative user, and to the administrator to disable uploading other avatar files by the user.

Code

function avatar_selection_image_delete($image) {
  $dir = file_create_path('avatar_selection');
  if (file_check_location($dir . '/' . $image, $dir)) {
    $aid = db_result(db_query("SELECT aid FROM {avatar_selection} WHERE avatar = '%s'", $image));
    if ($aid) {
      $result = db_query("DELETE FROM {avatar_selection} WHERE aid = %d", $aid);
      $result = db_query("DELETE FROM {avatar_selection_roles} WHERE aid = %d", $aid);
      $result = db_query("DELETE FROM {avatar_selection_og} WHERE aid = %d", $aid);
      file_delete($dir . '/' . $image);
      if (!image_get_info($dir . '/' . $image)) {
        return 1;
      }
    }
  }
  return 0;
}