delete_course.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script is about deleting a course.
  5. * It displays a message box ('are you sure you wish to delete this course')
  6. * and deletes the course if the user answers affirmatively
  7. *
  8. * @package chamilo.course_info
  9. */
  10. /**
  11. * Code
  12. */
  13. use \ChamiloSession as Session;
  14. // Language files that need to be included
  15. $language_file = array('admin', 'course_info');
  16. require_once '../inc/global.inc.php';
  17. require_once '../gradebook/lib/be/gradebookitem.class.php';
  18. require_once '../gradebook/lib/be/category.class.php';
  19. $this_section = SECTION_COURSES;
  20. $current_course_tool = TOOL_COURSE_MAINTENANCE;
  21. api_protect_course_script(true);
  22. $_course = api_get_course_info();
  23. $current_course_code = $_course['official_code'];
  24. $current_course_name = $_course['name'];
  25. if (!api_is_allowed_to_edit()) {
  26. api_not_allowed(true);
  27. }
  28. $tool_name = get_lang('DelCourse');
  29. if (isset($_GET['delete']) && $_GET['delete'] == 'yes') {
  30. CourseManager::delete_course($_course['sysCode']);
  31. $obj_cat = new Category();
  32. $obj_cat->update_category_delete($_course['sysCode']);
  33. // DELETE CONFIRMATION MESSAGE
  34. Session::erase('_cid');
  35. Session::erase('_real_cid');
  36. $noPHP_SELF = true;
  37. $message = '<h2>'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.') </h2>';
  38. $message .=get_lang('HasDel');
  39. $message .= '<br /><br /><a href="../../index.php">'.get_lang('BackHome').' '.api_get_setting('siteName').'</a>';
  40. } else {
  41. $message = '<h3>'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.') </h3>';
  42. $message .= '<p>'.get_lang('ByDel').'</p>';
  43. $message .= '<p><a class="btn btn-primary" href="'.api_get_path(WEB_CODE_PATH).'course_info/maintenance.php?'.api_get_cidreq().'">'.
  44. get_lang('No').'</a>&nbsp;<a class="btn" href="'.api_get_self().'?delete=yes&'.api_get_cidreq().'">'.
  45. get_lang('Yes').'</a></p>';
  46. $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
  47. }
  48. Display :: display_header($tool_name, 'Settings');
  49. echo Display::page_header($tool_name);
  50. Display::display_warning_message($message, false);
  51. Display :: display_footer();