delete_course.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This script is about deleting a course.
  6. * It displays a message box ('are you sure you wish to delete this course')
  7. * and deletes the course if the user answers affirmatively.
  8. *
  9. * @package chamilo.course_info
  10. */
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. $this_section = SECTION_COURSES;
  13. $current_course_tool = TOOL_COURSE_MAINTENANCE;
  14. api_protect_course_script(true);
  15. $_course = api_get_course_info();
  16. $current_course_code = $_course['official_code'];
  17. $current_course_name = $_course['name'];
  18. if (!api_is_allowed_to_edit()) {
  19. api_not_allowed(true);
  20. }
  21. $tool_name = get_lang('Completely delete this course');
  22. if (isset($_GET['delete']) && $_GET['delete'] === 'yes') {
  23. CourseManager::delete_course($_course['sysCode']);
  24. // DELETE CONFIRMATION MESSAGE
  25. Session::erase('_cid');
  26. Session::erase('_real_cid');
  27. $message = '<h2>'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.') </h2>';
  28. $message .= get_lang('has been deleted');
  29. $message .= '<br /><br /><a href="../../index.php">'.get_lang('Back to Home Page.').'</a>';
  30. } else {
  31. $message = '<h3>'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.') </h3>';
  32. $message .= '<p>'.get_lang('Deleting this area will permanently delete all the content (documents, links...) it contains and unregister all its members (not remove them from other courses). <p>Do you really want to delete the course?').'</p>';
  33. $message .= '<p><a class="btn btn-primary"
  34. href="'.api_get_path(WEB_CODE_PATH).'course_info/maintenance.php?'.api_get_cidreq().'">'.
  35. get_lang('No').'</a>&nbsp;<a class="btn btn-danger" href="'.api_get_self().'?delete=yes&'.api_get_cidreq().'">'.
  36. get_lang('Yes').'</a></p>';
  37. $interbreadcrumb[] = [
  38. 'url' => 'maintenance.php',
  39. 'name' => get_lang('Backup'),
  40. ];
  41. }
  42. $tpl = new Template($tool_name);
  43. $tpl->assign('content', Display::return_message($message, 'warning', false));
  44. $tpl->display_one_col_template();