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 | * Assign users to Relationship's Group 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($CFG->dirroot.'/local/relationship/lib.php'); |
||
26 | require_once($CFG->dirroot.'/local/relationship/locallib.php'); |
||
27 | |||
28 | require_login(); |
||
29 | |||
30 | $relationshipgroupid = required_param('relationshipgroupid', PARAM_INT); |
||
31 | $relationshipgroup = $DB->get_record('relationship_groups', array('id' => $relationshipgroupid), '*', MUST_EXIST); |
||
0 ignored issues
–
show
|
|||
32 | $relationship = $DB->get_record('relationship', array('id' => $relationshipgroup->relationshipid), '*', MUST_EXIST); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 8 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. ![]() |
|||
33 | $context = context::instance_by_id($relationship->contextid, MUST_EXIST); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 13 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. ![]() |
|||
34 | |||
35 | require_capability('local/relationship:view', $context); |
||
36 | |||
37 | $canassign = has_capability('local/relationship:assign', $context); |
||
38 | $editable = $canassign && empty($relationship->component); |
||
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. ![]() |
|||
39 | |||
40 | $baseurl = new moodle_url('/local/relationship/assign.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. ![]() |
|||
41 | $returnurl = new moodle_url('/local/relationship/groups.php', array('relationshipid' => $relationship->id)); |
||
42 | |||
43 | if (optional_param('cancel', false, PARAM_BOOL)) { |
||
44 | redirect($returnurl); |
||
45 | } |
||
46 | |||
47 | relationship_set_header($context, $baseurl, $relationship, 'groups'); |
||
48 | relationship_set_title($relationship, 'assignto', format_string($relationshipgroup->name)); |
||
49 | |||
50 | echo $OUTPUT->notification(get_string('removeuserwarning', 'local_relationship')); |
||
51 | |||
52 | // Get the user_selector we will need. |
||
53 | if ($editable) { |
||
54 | $potentialuserselector = new local_relationship_candidate_selector('addselect', array('relationshipgroup' => $relationshipgroup)); |
||
55 | } |
||
56 | $existinguserselector = new local_relationship_existing_selector('removeselect', array('relationshipgroup' => $relationshipgroup)); |
||
57 | |||
58 | // Process incoming user assignments to the relationship |
||
59 | |||
60 | if ($canassign && optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) { |
||
61 | $userstoassign = $potentialuserselector->get_selected_users(); |
||
62 | if (!empty($userstoassign)) { |
||
63 | foreach ($userstoassign as $adduser) { |
||
64 | relationship_add_member($relationshipgroup->id, $adduser->relationshipcohortid, $adduser->userid); |
||
65 | } |
||
66 | $potentialuserselector->invalidate_selected_users(); |
||
67 | $existinguserselector->invalidate_selected_users(); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | // Process removing user assignments to the relationship |
||
72 | if ($canassign && optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { |
||
73 | $userstoremove = $existinguserselector->get_selected_users(); |
||
74 | if (!empty($userstoremove)) { |
||
75 | foreach ($userstoremove as $removeuser) { |
||
76 | relationship_remove_member($relationshipgroup->id, $removeuser->relationshipcohortid, $removeuser->userid); |
||
77 | } |
||
78 | $potentialuserselector->invalidate_selected_users(); |
||
79 | $existinguserselector->invalidate_selected_users(); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | // Print the form. |
||
84 | if ($editable) { |
||
85 | ?> |
||
86 | <form id="assignform" method="post" action="<?php echo $PAGE->url ?>"> |
||
87 | <div> |
||
88 | <input type="hidden" name="sesskey" value="<?php echo sesskey() ?>"/> |
||
89 | |||
90 | <table summary="" class="generaltable generalbox boxaligncenter" cellspacing="0"> |
||
91 | <tr> |
||
92 | <td id="existingcell"> |
||
93 | <p> |
||
94 | <label for="removeselect"><?php print_string('currentusers', 'local_relationship'); ?></label> |
||
95 | </p> |
||
96 | <?php $existinguserselector->display() ?> |
||
97 | </td> |
||
98 | <td id="buttonscell"> |
||
99 | <div id="addcontrols"> |
||
100 | <input name="add" id="add" type="submit" |
||
101 | value="<?php echo $OUTPUT->larrow().' '.s(get_string('add')); ?>" |
||
102 | title="<?php p(get_string('add')); ?>"/><br/> |
||
103 | </div> |
||
104 | |||
105 | <div id="removecontrols"> |
||
106 | <input name="remove" id="remove" type="submit" |
||
107 | value="<?php echo s(get_string('remove')).' '.$OUTPUT->rarrow(); ?>" |
||
108 | title="<?php p(get_string('remove')); ?>"/> |
||
109 | </div> |
||
110 | </td> |
||
111 | <td id="potentialcell"> |
||
112 | <p><label for="addselect"><?php print_string('potusers', 'local_relationship'); ?></label></p> |
||
113 | <?php $potentialuserselector->display() ?> |
||
114 | </td> |
||
115 | </tr> |
||
116 | </table> |
||
117 | </div> |
||
118 | </form> |
||
119 | <?php |
||
120 | } else { |
||
121 | ?> |
||
122 | <div> |
||
123 | <table summary="" class="generaltable generalbox boxaligncenter" cellspacing="0"> |
||
124 | <tr> |
||
125 | <td id="existingcell"> |
||
126 | <p><label for="removeselect"><?php print_string('currentusers', 'local_relationship'); ?></label> |
||
127 | </p> |
||
128 | <?php $existinguserselector->display() ?> |
||
129 | </td> |
||
130 | </tr> |
||
131 | </table> |
||
132 | </div> |
||
133 | <?php |
||
134 | |||
135 | } |
||
136 | |||
137 | echo $OUTPUT->footer(); |
||
138 |
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.