gradebook_add_cat.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. // $Id: gradebook_add_cat.php 880 2007-05-07 09:32:52Z bert $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2006 Dokeos S.A.
  7. Copyright (c) 2006 Ghent University (UGent)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. $language_file = 'gradebook';
  21. $cidReset = true;
  22. include_once ('../inc/global.inc.php');
  23. include_once ('lib/be.inc.php');
  24. include_once ('lib/gradebook_functions.inc.php');
  25. include_once ('lib/fe/catform.class.php');
  26. api_block_anonymous_users();
  27. block_students();
  28. $catadd = new Category();
  29. $catadd->set_user_id($_user['user_id']);
  30. $catadd->set_parent_id(Database::escape_string($_GET['selectcat']));
  31. $catcourse = Category :: load ($_GET['selectcat']);
  32. $catadd->set_course_code($catcourse[0]->get_course_code());
  33. $form = new CatForm(CatForm :: TYPE_ADD, $catadd, 'add_cat_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']));
  34. if ($form->validate()) {
  35. $values = $form->exportValues();
  36. $cat = new Category();
  37. if ($values['hid_parent_id'] == '0') {
  38. if ($values['select_course'] == 'COURSEINDEPENDENT') {
  39. $cat->set_name($values['name']);
  40. $cat->set_course_code(null);
  41. } else {
  42. $cat->set_course_code($values['select_course']);
  43. $cat->set_name($values['name']);
  44. }
  45. } else {
  46. $cat->set_name($values['name']);
  47. $cat->set_course_code($values['course_code']);//?
  48. }
  49. $cat->set_description($values['description']);
  50. $cat->set_user_id($values['hid_user_id']);
  51. $cat->set_parent_id($values['hid_parent_id']);
  52. $cat->set_weight($values['weight']);
  53. if (empty ($values['visible']))
  54. $visible = 0;
  55. else
  56. $visible = 1;
  57. $cat->set_visible($visible);
  58. $cat->add();
  59. header('Location: gradebook.php?addcat=&selectcat=' . $cat->get_parent_id());
  60. exit;
  61. }
  62. $interbreadcrumb[] = array (
  63. 'url' => 'gradebook.php?selectcat='.Security::remove_XSS($_GET['selectcat']),
  64. 'name' => get_lang('Gradebook'
  65. ));
  66. Display :: display_header(get_lang('NewCategory'));
  67. $form->display();
  68. Display :: display_footer();
  69. ?>