updatelib.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * ${PLUGINNAME} file description here.
  18. *
  19. * @package ${PLUGINNAME}
  20. * @copyright 2022 alex <${USEREMAIL}>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. require_once("$CFG->libdir/formslib.php");
  24. require_once($CFG->dirroot . '/enrol/locallib.php');
  25. class update_from extends moodleform
  26. {
  27. protected $id_change_fio;
  28. private function get_fio_default_value($id){
  29. global $DB;
  30. return $DB->get_record('teacherskey_data', array('id' => $id));
  31. }
  32. public function definition()
  33. {
  34. global $USER, $CFG, $PAGE;
  35. $myform = $this->_form;
  36. $id_change_fio = $this->_customdata;
  37. $row = $this->get_fio_default_value($id_change_fio);
  38. $attributes = array('size' => '30', 'placeholder' => get_string('fio', 'enrol_teacherskey'));
  39. $myform->addElement('text', 'fio', get_string('labelfio', 'enrol_teacherskey'), $attributes);
  40. $myform->setType('fio', PARAM_NOTAGS);
  41. $myform->setDefault('fio', $row->fio);
  42. $this->add_action_buttons();
  43. $myform->addElement('hidden', 'id');
  44. $myform->setType('id', PARAM_INT);
  45. $myform->setDefault('id', $id_change_fio);
  46. $myform->addElement('hidden', 'courseid');
  47. $myform->setType('courseid', PARAM_INT);
  48. $myform->setDefault('courseid', $row->courseid);
  49. }
  50. function validate($data, $files)
  51. {
  52. return array();
  53. }
  54. }