1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 04:32:01 +02:00

Fixes #802 - Deleting physical files from media-manager.

This commit is contained in:
Cameron 2017-12-09 15:06:10 -08:00
parent c31dbad0dd
commit f9ce811c49
2 changed files with 40 additions and 1 deletions

View File

@ -2551,6 +2551,20 @@ class media_admin_ui extends e_admin_ui
function afterDelete($deleted_data, $id) // call after 'delete' is successfully executed. - delete the file with the db record (optional pref)
{
if(!empty($deleted_data['media_url']))
{
$status = e107::getFile()->delete($deleted_data['media_url']);
$message = ($status !== false) ? LAN_UI_FILE_DELETED : LAN_UI_FILE_DELETED_FAILED;
$mes = e107::getParser()->lanVars($message,$deleted_data['media_url'], true);
$errType = ($status) ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR;
e107::getMessage()->add($mes, $errType);
}
}
function getPath($mime)

View File

@ -1152,7 +1152,32 @@ class e_file
{
return $newFile;
}
}
}
/**
* Delete a file.
* @param $file
* @return bool
*/
public function delete($file)
{
if(empty($file))
{
return false;
}
$file = e107::getParser()->replaceConstants($file);
if(file_exists($file))
{
return unlink($file);
}
return false;
}
/**