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 Groups page |
||
| 19 | * |
||
| 20 | * @package local_relationship |
||
| 21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||
| 22 | */ |
||
| 23 | |||
| 24 | require_once(__DIR__.'/../../config.php'); |
||
| 25 | require_once($CFG->dirroot.'/course/lib.php'); |
||
| 26 | require($CFG->dirroot.'/local/relationship/lib.php'); |
||
| 27 | require_once($CFG->dirroot.'/local/relationship/locallib.php'); |
||
| 28 | |||
| 29 | require_login(); |
||
| 30 | |||
| 31 | $category = null; |
||
| 32 | if ($relationshipgroupid = optional_param('relationshipgroupid', 0, PARAM_INT)) { |
||
| 33 | $relationshipgroup = $DB->get_record('relationship_groups', array('id' => $relationshipgroupid), '*', MUST_EXIST); |
||
| 34 | $relationship = $DB->get_record('relationship', array('id' => $relationshipgroup->relationshipid), '*', MUST_EXIST); |
||
|
0 ignored issues
–
show
|
|||
| 35 | } else { |
||
| 36 | $relationshipid = required_param('relationshipid', PARAM_INT); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 25 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...
|
|||
| 37 | $relationship = $DB->get_record('relationship', array('id' => $relationshipid), '*', MUST_EXIST); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 27 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...
|
|||
| 38 | $relationshipgroup = new stdClass(); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 22 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...
|
|||
| 39 | $relationshipgroup->id = 0; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 18 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...
|
|||
| 40 | $relationshipgroup->relationshipid = $relationshipid; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 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...
|
|||
| 41 | $relationshipgroup->name = ''; |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 16 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...
|
|||
| 42 | $relationshipgroup->uniformdistribution = 0; |
||
| 43 | } |
||
| 44 | $context = context::instance_by_id($relationship->contextid, MUST_EXIST); |
||
| 45 | |||
| 46 | require_capability('local/relationship:manage', $context); |
||
| 47 | if (!empty($relationship->component)) { |
||
| 48 | print_error('cantedit', 'local_relationship'); |
||
| 49 | } |
||
| 50 | |||
| 51 | $baseurl = new moodle_url('/local/relationship/edit_group.php', array('relationshipgroupid' => $relationshipgroupid)); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 3 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...
|
|||
| 52 | $returnurl = new moodle_url('/local/relationship/groups.php', array('relationshipid' => $relationship->id)); |
||
| 53 | |||
| 54 | if (optional_param('confirmdelete', 0, PARAM_BOOL) && confirm_sesskey() && $relationshipgroup->id) { |
||
| 55 | relationship_delete_group($relationshipgroup); |
||
| 56 | redirect($returnurl); |
||
| 57 | } |
||
| 58 | |||
| 59 | $uniformdistribution = optional_param('uniformdistribution', -1, PARAM_BOOL); |
||
| 60 | if (($uniformdistribution == 0 || $uniformdistribution == 1) && $relationshipgroup->id) { |
||
| 61 | $DB->set_field('relationship_groups', 'uniformdistribution', $uniformdistribution, array('id' => $relationshipgroup->id)); |
||
| 62 | redirect($returnurl); |
||
| 63 | } |
||
| 64 | |||
| 65 | if (optional_param('distributeremaining', 0, PARAM_BOOL) && $relationship->id) { |
||
| 66 | relationship_uniformly_distribute_members($relationship->id); |
||
| 67 | redirect($returnurl); |
||
| 68 | } |
||
| 69 | |||
| 70 | relationship_set_header($context, $baseurl, $relationship, 'groups'); |
||
| 71 | |||
| 72 | if (optional_param('delete', 0, PARAM_BOOL) && $relationshipgroup->id) { |
||
| 73 | $desc = format_string($relationshipgroup->name); |
||
| 74 | relationship_set_title($relationship, 'deletegroup', $desc); |
||
| 75 | echo $OUTPUT->notification(get_string('removegroupwarning', 'local_relationship')); |
||
| 76 | $yesurl = new moodle_url('/local/relationship/edit_group.php', array('relationshipgroupid' => $relationshipgroup->id, 'relationshipid' => $relationship->id, 'delete' => 1, 'confirmdelete' => 1, 'sesskey' => sesskey())); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 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...
|
|||
| 77 | $message = get_string('confirmdeletegroup', 'local_relationship', $desc); |
||
| 78 | echo $OUTPUT->confirm($message, $yesurl, $returnurl); |
||
| 79 | echo $OUTPUT->footer(); |
||
| 80 | die; |
||
| 81 | } |
||
| 82 | |||
| 83 | $editform = new \local_relationship\form\edit_group(null, array('data' => $relationshipgroup)); |
||
| 84 | |||
| 85 | if ($editform->is_cancelled()) { |
||
| 86 | redirect($returnurl); |
||
| 87 | } else if ($data = $editform->get_data()) { |
||
| 88 | if ($data->id) { |
||
| 89 | relationship_update_group($data); |
||
| 90 | } else { |
||
| 91 | relationship_add_group($data); |
||
| 92 | } |
||
| 93 | |||
| 94 | // Use new context id, it could have been changed. |
||
| 95 | redirect(new moodle_url('/local/relationship/groups.php', array('relationshipid' => $relationship->id))); |
||
| 96 | } |
||
| 97 | |||
| 98 | if ($relationshipgroup->id) { |
||
| 99 | $desc = format_string($relationshipgroup->name); |
||
| 100 | relationship_set_title($relationship, 'editgroup', $desc); |
||
| 101 | } else { |
||
| 102 | relationship_set_title($relationship, 'addgroup'); |
||
| 103 | } |
||
| 104 | echo $editform->display(); |
||
| 105 | echo $OUTPUT->footer(); |
||
| 106 | |||
| 107 |
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.