delete_course.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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('DelCourse');
  22. if (isset($_GET['delete']) && $_GET['delete'] === 'yes') {
  23. CourseManager::delete_course($_course['sysCode']);
  24. $obj_cat = new Category();
  25. $obj_cat->update_category_delete($_course['sysCode']);
  26. // DELETE CONFIRMATION MESSAGE
  27. Session::erase('_cid');
  28. Session::erase('_real_cid');
  29. $noPHP_SELF = true;
  30. $message = '<h2>'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.') </h2>';
  31. $message .= get_lang('HasDel');
  32. $message .= '<br /><br /><a href="../../index.php">'.get_lang('BackHome').'</a>';
  33. } else {
  34. $message = '<h3>'.get_lang('Course').' : '.$current_course_name.' ('.$current_course_code.') </h3>';
  35. $message .= '<p>'.get_lang('ByDel').'</p>';
  36. $message .= '<p><a class="btn btn-primary" href="'.api_get_path(WEB_CODE_PATH).'course_info/maintenance.php?'.api_get_cidreq().'">'.
  37. get_lang('No').'</a>&nbsp;<a class="btn btn-danger" href="'.api_get_self().'?delete=yes&'.api_get_cidreq().'">'.
  38. get_lang('Yes').'</a></p>';
  39. $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance'));
  40. }
  41. $tpl = new Template($tool_name);
  42. $tpl->assign('content', Display::return_message($message, 'warning', false));
  43. $tpl->display_one_col_template();