gradebook_edit_cat.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. require_once __DIR__.'/../inc/global.inc.php';
  8. api_block_anonymous_users();
  9. GradebookUtils::block_students();
  10. $edit_cat = isset($_REQUEST['editcat']) ? intval($_REQUEST['editcat']) : '';
  11. $catedit = Category::load($edit_cat);
  12. $form = new CatForm(
  13. CatForm::TYPE_EDIT,
  14. $catedit[0],
  15. 'edit_cat_form',
  16. 'post',
  17. api_get_self().'?'.api_get_cidreq().'&editcat='.$edit_cat
  18. );
  19. if ($form->validate()) {
  20. $values = $form->getSubmitValues();
  21. $cat = new Category();
  22. if (!empty($values['hid_id'])) {
  23. $cat = $cat->load($values['hid_id']);
  24. if (isset($cat[0])) {
  25. $cat = $cat[0];
  26. }
  27. }
  28. $cat->set_id($values['hid_id']);
  29. $cat->set_name($values['name']);
  30. if (empty($values['course_code'])) {
  31. $cat->set_course_code(null);
  32. } else {
  33. $cat->set_course_code($values['course_code']);
  34. }
  35. if (isset($values['grade_model_id'])) {
  36. $cat->set_grade_model_id($values['grade_model_id']);
  37. }
  38. $cat->set_description($values['description']);
  39. if (isset($values['skills'])) {
  40. $cat->set_skills($values['skills']);
  41. }
  42. $cat->set_user_id($values['hid_user_id']);
  43. $cat->set_parent_id($values['hid_parent_id']);
  44. $cat->set_weight($values['weight']);
  45. if (isset($values['generate_certificates'])) {
  46. $cat->setGenerateCertificates($values['generate_certificates']);
  47. } else {
  48. $cat->setGenerateCertificates(false);
  49. }
  50. if ($values['hid_parent_id'] == 0) {
  51. $cat->set_certificate_min_score($values['certif_min_score']);
  52. }
  53. if (empty($values['visible'])) {
  54. $visible = 0;
  55. } else {
  56. $visible = 1;
  57. }
  58. $cat->set_visible($visible);
  59. if (isset($values['is_requirement'])) {
  60. $cat->setIsRequirement(true);
  61. } else {
  62. $cat->setIsRequirement(false);
  63. }
  64. $cat->save();
  65. header('Location: '.Security::remove_XSS($_SESSION['gradebook_dest']).'?editcat=&selectcat='.$cat->get_parent_id().'&'.api_get_cidreq());
  66. exit;
  67. }
  68. $selectcat = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : '';
  69. $interbreadcrumb[] = array(
  70. 'url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat='.$selectcat.'&'.api_get_cidreq(),
  71. 'name' => get_lang('Gradebook')
  72. );
  73. $this_section = SECTION_COURSES;
  74. Display :: display_header(get_lang('EditCategory'));
  75. $form->display();
  76. Display :: display_footer();