From 7d85fdf26829e061c896dcb726ed00a8933bab04 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 22 Jan 2013 15:18:27 +0100 Subject: [PATCH] After submitting the form, stay in the same page --- main/admin/archive_cleanup.php | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/main/admin/archive_cleanup.php b/main/admin/archive_cleanup.php index 05d68b7e3f..c3f3d55a73 100644 --- a/main/admin/archive_cleanup.php +++ b/main/admin/archive_cleanup.php @@ -17,7 +17,6 @@ $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')); @@ -25,26 +24,43 @@ $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"'); +$message = null; + if ($form->validate()) { $archive_path = api_get_path(SYS_ARCHIVE_PATH); - $htaccess = @file_get_contents($archive_path.'.htaccess'); + $htaccess = @file_get_contents($archive_path.'.htaccess'); $result = rmdirr($archive_path, true); - - if (!empty($htaccess)) { + + if (!empty($htaccess)) { @file_put_contents($archive_path.'/.htaccess', $htaccess); - } - if ($result) { + } + if ($result) { $message = 'ArchiveDirCleanupSucceeded'; $type = 'confirmation'; - } else { + } else { $message = 'ArchiveDirCleanupFailed'; $type = 'error'; } - header('Location: index.php?msg='.$message.'&type='.$type); - exit; + header('Location: '.api_get_self().'?msg='.$message.'&type='.$type); + exit; } Display::display_header(get_lang('ArchiveDirCleanup')); Display::display_normal_message(get_lang('ArchiveDirCleanupDescr')); + +if (isset($_GET['msg']) && isset($_GET['type'])) { + if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed'))) + switch($_GET['type']) { + case 'error': + $message = Display::return_message(get_lang($_GET['msg']), 'error'); + break; + case 'confirmation': + $message = Display::return_message(get_lang($_GET['msg']), 'confirm'); + } +} + +if (!empty($message)) { + echo $message; +} $form->display(); Display::display_footer(); \ No newline at end of file