You are here

public function filedepot::deleteSubmission in filedepot 7

Same name and namespace in other branches
  1. 6 filedepot.class.php \filedepot::deleteSubmission()

File

./filedepot.class.php, line 1171
filedepot.class.php Main class for the Filedepot module

Class

filedepot
@file filedepot.class.php Main class for the Filedepot module

Code

public function deleteSubmission($id) {
  $query = db_query("SELECT cid,drupal_fid,tempname,fname,notify FROM {filedepot_filesubmissions} WHERE id=:id", array(
    'id' => $id,
  ));
  list($cid, $drupal_fid, $tempname, $fname, $notify) = array_values($query
    ->fetchAssoc());
  if (!empty($tempname) and file_exists("{$this->root_storage_path}{$cid}/submissions/{$tempname}")) {
    @unlink("{$this->root_storage_path}{$cid}/submissions/{$tempname}");

    // Send out notification of submission being deleted to user - before we delete the record as it's needed to create notification message
    if ($notify == 1) {
      filedepot_sendNotification($id, FILEDEPOT_NOTIFY_REJECT);
    }
    db_delete('filedepot_filesubmissions')
      ->condition('id', $id)
      ->execute();
    return TRUE;
  }
  else {
    return FALSE;
  }
}