chamilo/archive folder cleaner implements #3748 bis

skala
Julio Montoya 14 years ago
parent 87e60d678e
commit f36672a62f
  1. 52
      main/admin/archive_cleanup.php
  2. 11
      main/admin/index.php
  3. 4
      main/inc/lib/main_api.lib.php

@ -0,0 +1,52 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
$language_file = array('admin');
// resetting the course id
$cidReset = true;
// including some necessary files
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions
//api_protect_admin_script(true);
api_protect_global_admin_script();
// setting breadcrumbs
$interbreadcrumb[]=array('url' => 'index.php','name' => get_lang('PlatformAdmin'));
$form = new FormValidator('archive_cleanup_form');
$form->addElement('style_submit_button','proceed', get_lang('ArchiveDirCleanupProceedButton'),'class="save"');
if ($form->validate()) {
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
$htaccess = @file_get_contents($archive_path.'.htaccess');
$result = rmdirr($archive_path, true);
if (!empty($htaccess)) {
@file_put_contents($archive_path.'/.htaccess', $htaccess);
}
if ($result) {
$message = 'ArchiveDirCleanupSucceeded';
$type = 'confirmation';
} else {
$message = 'ArchiveDirCleanupFailed';
$type = 'error';
}
header('Location: index.php?msg='.$message.'&type='.$type);
exit;
}
Display::display_header(get_lang('ArchiveDirCleanup'));
Display::display_normal_message(get_lang('ArchiveDirCleanupDescr'));
$form->display();
Display::display_footer();

@ -52,6 +52,17 @@ if (api_is_platform_admin()) {
$keyword_url = Security::remove_XSS((empty($_GET['keyword']) ? '' : $_GET['keyword']));
}
if (isset($_GET['msg']) && isset($_GET['type'])) {
if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed')))
switch($_GET['type']) {
case 'error':
Display::display_error_message(get_lang($_GET['msg']));
case 'confirmation':
Display::display_confirmation_message(get_lang($_GET['msg']));
}
}
if (api_is_platform_admin()) {
?>
<div class="admin_section">

@ -3191,7 +3191,7 @@ if (!function_exists('sys_get_temp_dir')) {
* @author Yannick Warnier, adaptation for the Chamilo LMS, April, 2008
* @author Ivan Tcholakov, a sanity check about Directory class creation has been added, September, 2009
*/
function rmdirr($dirname, $delete_only_content = false) {
function rmdirr($dirname, $delete_only_content_in_folder = false) {
$res = true;
// A sanity check.
@ -3229,7 +3229,7 @@ function rmdirr($dirname, $delete_only_content = false) {
$dir->close();
}
if ($delete_only_content == false) {
if ($delete_only_content_in_folder == false) {
$res = rmdir($dirname);
if ($res === false) {
error_log(__FILE__.' line '.__LINE__.': '.((bool)ini_get('track_errors') ? $php_errormsg : 'error not recorded because track_errors is off in your php.ini'), 0);

Loading…
Cancel
Save