gradebook_edit_cat.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. /**
  8. * Init
  9. */
  10. $language_file = 'gradebook';
  11. require_once '../inc/global.inc.php';
  12. require_once 'lib/be.inc.php';
  13. require_once 'lib/gradebook_functions.inc.php';
  14. require_once 'lib/fe/catform.class.php';
  15. api_block_anonymous_users();
  16. block_students();
  17. $edit_cat = isset($_REQUEST['editcat']) ? $_REQUEST['editcat'] : '';
  18. $catedit = Category :: load($edit_cat);
  19. $form = new CatForm(CatForm :: TYPE_EDIT, $catedit[0], 'edit_cat_form');
  20. if ($form->validate()) {
  21. $values = $form->exportValues();
  22. $cat = new Category();
  23. $cat->set_id($values['hid_id']);
  24. $cat->set_name($values['name']);
  25. if (empty ($values['course_code'])) {
  26. $cat->set_course_code(null);
  27. }else {
  28. $cat->set_course_code($values['course_code']);
  29. }
  30. $cat->set_description($values['description']);
  31. $cat->set_user_id($values['hid_user_id']);
  32. $cat->set_parent_id($values['hid_parent_id']);
  33. $cat->set_weight($values['weight']);
  34. if ($values['hid_parent_id'] == 0 ) {
  35. $cat->set_certificate_min_score($values['certif_min_score']);
  36. }
  37. if (empty ($values['visible'])) {
  38. $visible = 0;
  39. } else {
  40. $visible = 1;
  41. }
  42. $cat->set_visible($visible);
  43. $cat->save();
  44. header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat=' . $cat->get_parent_id());
  45. exit;
  46. }
  47. $selectcat = isset($_GET['selectcat']) ? Security::remove_XSS($_GET['selectcat']) : '';
  48. $interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$selectcat,'name' => get_lang('Gradebook'));
  49. $this_section = SECTION_COURSES;
  50. Display :: display_header(get_lang('EditCategory'));
  51. $form->display();
  52. Display :: display_footer();