See Release Notes
Long Term Support Release
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 namespace enrol_lti\local\ltiadvantage\form; 18 use enrol_lti\local\ltiadvantage\repository\deployment_repository; 19 20 defined('MOODLE_INTERNAL') || die(); 21 22 require_once($CFG->libdir . '/formslib.php'); 23 24 /** 25 * The deployment_form class, for registering a deployment for a registered platform. 26 * 27 * @package enrol_lti 28 * @copyright 2021 Jake Dallimore <jrhdallimore@gmail.com> 29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 30 */ 31 class deployment_form extends \moodleform { 32 33 /** 34 * Define the form. 35 */ 36 protected function definition() { 37 $mform = $this->_form; 38 $strrequired = get_string('required'); 39 40 // Registration id. 41 $mform->addElement('hidden', 'registrationid'); 42 $mform->setType('registrationid', PARAM_INT); 43 44 // Name. 45 $mform->addElement('text', 'name', get_string('adddeployment:name', 'enrol_lti')); 46 $mform->setType('name', PARAM_TEXT); 47 $mform->addRule('name', $strrequired, 'required', null, 'client'); 48 $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); 49 50 // Deployment Id. 51 $mform->addElement('text', 'deploymentid', get_string('adddeployment:deploymentid', 'enrol_lti')); 52 $mform->setType('deploymentid', PARAM_TEXT); 53 $mform->addRule('deploymentid', $strrequired, 'required', null, 'client'); 54 $mform->addRule('deploymentid', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); 55 56 $mform->addHelpButton('deploymentid', 'adddeployment:deploymentid', 'enrol_lti'); 57 58 $buttonarray = []; 59 $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('savechanges')); 60 $buttonarray[] = $mform->createElement('cancel'); 61 $mform->addGroup($buttonarray, 'buttonar', '', ' ', false); 62 } 63 64 /** 65 * Provides uniqueness validation of the deployment id. 66 * 67 * @param array $data any form data 68 * @param array $files any submitted files 69 * @return array array of errors. 70 */ 71 public function validation($data, $files) { 72 $errors = parent::validation($data, $files); 73 74 // Validate the uniqueness of the deploymentid within the registration. 75 $deploymentrepo = new deployment_repository(); 76 if ($deploymentrepo->find_by_registration($data['registrationid'], $data['deploymentid'])) { 77 $errors['deploymentid'] = get_string('adddeployment:invaliddeploymentiderror', 'enrol_lti'); 78 } 79 80 return $errors; 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body