settings_params.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * Settings iLM params manager.
  4. *
  5. * @author Patricia Alves Rodrigues
  6. * @author Leônidas O. Brandão
  7. * @version v 1.0 2013/09/11
  8. * @package mod_iassign_settings
  9. * @since 2013/09/11
  10. * @copyright iMatica (<a href="http://www.matematica.br">iMath</a>) - Computer Science Dep. of IME-USP (Brazil)
  11. *
  12. * <b>License</b>
  13. * - http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  14. */
  15. global $CFG, $USER, $PAGE, $OUTPUT, $DB;
  16. require_once("../../config.php");
  17. require_once ($CFG->dirroot . '/mod/iassign/locallib.php');
  18. require_once ($CFG->dirroot . '/mod/iassign/params_form.php');
  19. require_login();
  20. if (isguestuser()) { // security!
  21. die();
  22. }
  23. //Parameters GET e POST (parâmetros GET e POST)
  24. $ilm_param_id = optional_param('ilm_param_id', 0, PARAM_INT);
  25. $ilm_id = optional_param('ilm_id', 0, PARAM_INT);
  26. $status = optional_param('status', 0, PARAM_INT);
  27. $action = optional_param('action', NULL, PARAM_TEXT);
  28. $url = new moodle_url('/admin/settings.php', array('section' => 'modsettingiassign'));
  29. $from = optional_param('from', NULL, PARAM_TEXT);
  30. $contextuser = context_user::instance($USER->id);
  31. $PAGE->set_url($url);
  32. $PAGE->set_context($contextuser);
  33. $PAGE->blocks->show_only_fake_blocks(); //
  34. $PAGE->set_pagelayout('popup');
  35. if ($action == 'edit') {
  36. $title = get_string('edit_param', 'iassign') . $OUTPUT->help_icon('config_param', 'iassign');
  37. $PAGE->set_title($title);
  38. $param = ilm_settings::add_edit_copy_param($ilm_param_id, $action);
  39. $mform = new param_ilm_form();
  40. $mform->set_data($param);
  41. if ($mform->is_cancelled()) {
  42. close_window();
  43. die;
  44. }
  45. else if ($formdata = $mform->get_submitted_data()) {
  46. ilm_settings::edit_param($formdata);
  47. close_window(0, true);
  48. die;
  49. }
  50. echo $OUTPUT->header();
  51. echo $OUTPUT->heading($title);
  52. $mform->display();
  53. echo $OUTPUT->footer();
  54. die;
  55. }
  56. if ($action == 'copy') {
  57. $title = get_string('copy_param', 'iassign') . $OUTPUT->help_icon('config_param', 'iassign');
  58. $PAGE->set_title($title);
  59. $param = ilm_settings::add_edit_copy_param($ilm_param_id, $action);
  60. $mform = new param_ilm_form();
  61. $mform->set_data($param);
  62. if ($mform->is_cancelled()) {
  63. close_window();
  64. die;
  65. }
  66. else if ($formdata = $mform->get_data()) {
  67. ilm_settings::copy_param($formdata);
  68. close_window(0, true);
  69. die;
  70. }
  71. echo $OUTPUT->header();
  72. echo $OUTPUT->heading($title);
  73. $mform->display();
  74. echo $OUTPUT->footer();
  75. die;
  76. }
  77. if ($action == 'add') {
  78. $title = get_string('add_param', 'iassign') . $OUTPUT->help_icon('config_param', 'iassign');
  79. $PAGE->set_title($title);
  80. $param = ilm_settings::add_edit_copy_param($ilm_id, $action);
  81. $mform = new param_ilm_form();
  82. $mform->set_data($param);
  83. if ($mform->is_cancelled()) {
  84. close_window();
  85. die;
  86. }
  87. else if ($formdata = $mform->get_data()) {
  88. ilm_settings::add_param($formdata);
  89. close_window(0, true);
  90. die;
  91. }
  92. echo $OUTPUT->header();
  93. echo $OUTPUT->heading($title);
  94. $mform->display();
  95. echo $OUTPUT->footer();
  96. die;
  97. }
  98. if ($action == 'delete') {
  99. $title = get_string('delete_param', 'iassign');
  100. $PAGE->set_title($title);
  101. $PAGE->set_pagelayout('redirect');
  102. ilm_settings::delete_param($ilm_param_id);
  103. redirect(new moodle_url('/admin/settings.php?', array('section' => 'modsettingiassign', 'action' => 'config', 'ilm_id' => $ilm_id)));
  104. }