These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 | /** |
||
| 18 | * Edit Relationship's Group form definition |
||
| 19 | * |
||
| 20 | * @package local_relationship |
||
| 21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||
| 22 | */ |
||
| 23 | |||
| 24 | namespace local_relationship\form; |
||
| 25 | defined('MOODLE_INTERNAL') || die(); |
||
| 26 | |||
| 27 | require_once($CFG->dirroot.'/lib/formslib.php'); |
||
| 28 | |||
| 29 | class edit_group extends \moodleform { |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Define the relationshipgroup edit form |
||
| 33 | */ |
||
| 34 | public function definition() { |
||
| 35 | |||
| 36 | $mform = $this->_form; |
||
|
0 ignored issues
–
show
|
|||
| 37 | $relationshipgroup = $this->_customdata['data']; |
||
| 38 | |||
| 39 | $mform->addElement('text', 'name', get_string('groupname', 'local_relationship'), 'maxlength="254" size="50"'); |
||
| 40 | $mform->addRule('name', get_string('required'), 'required', null, 'client'); |
||
| 41 | $mform->setType('name', PARAM_NOTAGS); |
||
| 42 | |||
| 43 | $mform->addElement('text', 'userlimit', get_string('userlimit', 'local_relationship'), 'maxlength="5" size="4"'); |
||
| 44 | $mform->setType('userlimit', PARAM_INT); |
||
| 45 | $mform->addRule('userlimit', null, 'numeric', null, 'client'); |
||
| 46 | $mform->setDefault('userlimit', 0); |
||
| 47 | $mform->addHelpButton('userlimit', 'userlimit', 'local_relationship'); |
||
| 48 | |||
| 49 | $mform->addElement('hidden', 'id'); |
||
| 50 | $mform->setType('id', PARAM_INT); |
||
| 51 | $mform->addElement('hidden', 'relationshipid'); |
||
| 52 | $mform->setType('relationshipid', PARAM_INT); |
||
| 53 | |||
| 54 | $this->add_action_buttons(); |
||
| 55 | |||
| 56 | $this->set_data($relationshipgroup); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function validation($data, $files) { |
||
| 60 | global $DB; |
||
| 61 | |||
| 62 | $errors = parent::validation($data, $files); |
||
| 63 | |||
| 64 | if ($DB->record_exists_select('relationship_groups', |
||
| 65 | "relationshipid = :relationshipid AND name = :name AND id != :id", |
||
| 66 | array('relationshipid' => $data['relationshipid'], 'name' => $data['name'], 'id' => $data['id'])) |
||
| 67 | ) { |
||
| 68 | $errors['name'] = get_string('group_already_exists', 'local_relationship'); |
||
| 69 | } else { |
||
| 70 | $groups = relationship_get_other_courses_group_names($data['relationshipid']); |
||
| 71 | if (isset($groups[$data['name']])) { |
||
| 72 | $c = reset($groups[$data['name']]); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 14 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 73 | $errors['name'] = get_string('course_group_already_exists', 'local_relationship', $c->fullname); |
||
| 74 | } |
||
| 75 | } |
||
| 76 | |||
| 77 | return $errors; |
||
| 78 | } |
||
| 79 | |||
| 80 | } |
||
| 81 | |||
| 82 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.