parent
234a06e5d1
commit
9fd7fb0a31
@ -0,0 +1,65 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
require_once '../inc/global.inc.php'; |
||||
|
||||
api_protect_admin_script(); |
||||
|
||||
if (!api_get_configuration_value('document_manage_deleted_files')) { |
||||
api_not_allowed(true); |
||||
} |
||||
|
||||
$courseInfo = api_get_course_info(); |
||||
$sessionId = api_get_session_id(); |
||||
$files = DocumentManager::getDeletedDocuments($courseInfo, $sessionId); |
||||
|
||||
$actions = Display::url( |
||||
get_lang('DownloadAll'), |
||||
api_get_self().'?'.api_get_cidreq().'&action=download_all', |
||||
['class' => 'btn btn-default'] |
||||
); |
||||
|
||||
$actions .= Display::url( |
||||
get_lang('DeleteAll'), |
||||
api_get_self().'?'.api_get_cidreq().'&action=delete_all', |
||||
['class' => 'btn btn-danger'] |
||||
); |
||||
|
||||
$action = isset($_GET['action']) ? $_GET['action'] : ''; |
||||
$id = isset($_GET['id']) ? intval($_GET['id']) : ''; |
||||
$currentUrl = api_get_self().'?'.api_get_cidreq(); |
||||
|
||||
switch ($action) { |
||||
case 'delete': |
||||
DocumentManager::purgeDocument($id, $courseInfo, $sessionId); |
||||
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
||||
header('Location: '.$currentUrl); |
||||
exit; |
||||
break; |
||||
case 'delete_all': |
||||
DocumentManager::purgeDocuments($courseInfo, $sessionId); |
||||
Display::addFlash(Display::return_message(get_lang('Deleted'))); |
||||
header('Location: '.$currentUrl); |
||||
exit; |
||||
break; |
||||
case 'download': |
||||
DocumentManager::downloadDeletedDocument($id, $courseInfo, $sessionId); |
||||
break; |
||||
case 'download_all': |
||||
DocumentManager::downloadAllDeletedDocument($courseInfo, $sessionId); |
||||
break; |
||||
} |
||||
|
||||
$interbreadcrumb[] = array( |
||||
"url" => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(), |
||||
"name" => get_lang('Documents'), |
||||
); |
||||
$template = new Template(get_lang('DeletedDocuments')); |
||||
$template->assign('files', $files); |
||||
$template->assign('actions', $actions); |
||||
$template->assign('web_cid_query', api_get_cidreq()); |
||||
|
||||
$content = $template->fetch('default/document/recycle.tpl'); |
||||
$template->assign('content', $content); |
||||
$template->display_one_col_template(); |
||||
|
@ -0,0 +1,48 @@ |
||||
{% macro bytesToSize(bytes) %} |
||||
{% spaceless %} |
||||
{% set kilobyte = 1024 %} |
||||
{% set megabyte = kilobyte * 1024 %} |
||||
{% set gigabyte = megabyte * 1024 %} |
||||
{% set terabyte = gigabyte * 1024 %} |
||||
|
||||
{% if bytes < kilobyte %} |
||||
{{ bytes ~ ' B' }} |
||||
{% elseif bytes < megabyte %} |
||||
{{ (bytes / kilobyte)|number_format(2, '.') ~ ' KB' }} |
||||
{% elseif bytes < gigabyte %} |
||||
{{ (bytes / megabyte)|number_format(2, '.') ~ ' MB' }} |
||||
{% elseif bytes < terabyte %} |
||||
{{ (bytes / gigabyte)|number_format(2, '.') ~ ' GB' }} |
||||
{% else %} |
||||
{{ (bytes / terabyte)|number_format(2, '.') ~ ' TB' }} |
||||
{% endif %} |
||||
{% endspaceless %} |
||||
{% endmacro %} |
||||
|
||||
{% if files %} |
||||
<table class="table"> |
||||
<tr> |
||||
<th>{{ 'Path' | get_lang }}</th> |
||||
<th>{{ 'Size' | get_lang }}</th> |
||||
<th>{{ 'Actions' | get_lang }}</th> |
||||
</tr> |
||||
{% for file in files %} |
||||
<tr> |
||||
<td> |
||||
{{ file.path }} |
||||
</td> |
||||
<td> |
||||
{{ _self.bytesToSize(file.size) }} |
||||
</td> |
||||
|
||||
<td> |
||||
<a href="{{ web_self }}?{{web_cid_query}}&action=download&id={{ file.id }}" class="btn btn-default">{{ 'Download' | get_lang }}</a> |
||||
<a href="{{ web_self }}?{{web_cid_query}}&action=delete&id={{ file.id }}" class="btn btn-danger">{{ 'Delete' | get_lang }}</a> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
{% else %} |
||||
{{ 'NoData' | get_lang }} |
||||
{% endif %} |
||||
|
Loading…
Reference in new issue