/** * TrashFile function. * * @access protected * @param mixed $FileID * @return void */ protected function TrashFile($FileID) { $Media = $this->MediaModel()->GetID($FileID); if ($Media) { $this->MediaModel()->Delete($Media); $Deleted = FALSE; if (!$Deleted) { $DirectPath = MediaModel::PathUploads() . DS . $Media->Path; if (file_exists($DirectPath)) { $Deleted = @unlink($DirectPath); } } if (!$Deleted) { $CalcPath = FileUploadPlugin::FindLocalMedia($Media, TRUE, TRUE); if (file_exists($CalcPath)) { $Deleted = @unlink($CalcPath); } } } }
/** * Delete an uploaded file & its media record. * * @access protected * @param int $MediaID Unique ID on Media table. */ protected function TrashFile($MediaID) { $Media = $this->MediaModel()->GetID($MediaID); if ($Media) { $this->MediaModel()->Delete($Media); $Deleted = FALSE; // Allow interception $this->EventArguments['Parsed'] = Gdn_Upload::Parse($Media->Path); $this->EventArguments['Handled'] =& $Deleted; // Allow skipping steps below $this->FireEvent('TrashFile'); if (!$Deleted) { $DirectPath = MediaModel::PathUploads() . DS . $Media->Path; if (file_exists($DirectPath)) { $Deleted = @unlink($DirectPath); } } if (!$Deleted) { $CalcPath = FileUploadPlugin::FindLocalMedia($Media, TRUE, TRUE); if (file_exists($CalcPath)) { $Deleted = @unlink($CalcPath); } } } }