settings_params.php 3.3 KB

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