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 | * Relationship existing assignment selector definition |
||
| 19 | * |
||
| 20 | * @package local_relationship |
||
| 21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
||
| 22 | */ |
||
| 23 | |||
| 24 | defined('MOODLE_INTERNAL') || die(); |
||
| 25 | |||
| 26 | /** |
||
| 27 | * relationship assignment candidates |
||
| 28 | */ |
||
| 29 | class local_relationship_existing_selector extends user_selector_base { |
||
| 30 | protected $relationshipgroup; |
||
| 31 | |||
| 32 | public function __construct($name, $options) { |
||
| 33 | $this->relationshipgroup = $options['relationshipgroup']; |
||
| 34 | parent::__construct($name, $options); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Candidate users |
||
| 39 | * @param string $search |
||
| 40 | * @return array |
||
| 41 | */ |
||
| 42 | public function find_users($search) { |
||
| 43 | global $DB; |
||
| 44 | |||
| 45 | list($usercondition, $params) = users_search_sql($search, 'u', $this->searchanywhere); |
||
| 46 | |||
| 47 | View Code Duplication | if(!empty($this->validatinguserids)) { |
|
| 48 | list($usertest, $userparams) = $DB->get_in_or_equal($this->validatinguserids, SQL_PARAMS_NAMED, 'val'); |
||
| 49 | $usercondition .= " AND u.id*1000000+rc.id " . $usertest; |
||
|
0 ignored issues
–
show
|
|||
| 50 | $params = array_merge($params, $userparams); |
||
|
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...
|
|||
| 51 | } |
||
| 52 | |||
| 53 | $params['relationshipgroupid'] = $this->relationshipgroup->id; |
||
| 54 | |||
| 55 | $countfields = 'SELECT COUNT(1)'; |
||
| 56 | $selectfields = "SELECT u.id*1000000+rc.id as id, rc.id AS relationshipcohortid, rc.roleid, u.id AS userid, CONCAT(u.firstname, ' ', u.lastname) AS fullname"; |
||
| 57 | |||
| 58 | $from = "FROM {relationship_members} rm |
||
| 59 | JOIN {relationship_cohorts} rc ON (rc.id = rm.relationshipcohortid) |
||
| 60 | JOIN {user} u ON (u.id = rm.userid) |
||
| 61 | WHERE rm.relationshipgroupid = :relationshipgroupid |
||
| 62 | AND {$usercondition}"; |
||
| 63 | |||
| 64 | $orderby= "ORDER BY roleid, fullname"; |
||
|
0 ignored issues
–
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces
This check looks for improperly formatted assignments. Every assignment must have exactly one space before and one space after the equals operator. To illustrate: $a = "a";
$ab = "ab";
$abc = "abc";
will have no issues, while $a = "a";
$ab = "ab";
$abc = "abc";
will report issues in lines 1 and 2. Loading history...
|
|||
| 65 | |||
| 66 | View Code Duplication | if (!$this->is_validating()) { |
|
| 67 | $sql = $countfields . "\n" . $from; |
||
|
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...
|
|||
| 68 | $count = $DB->count_records_sql($sql, $params); |
||
| 69 | if ($count > $this->maxusersperpage) { |
||
| 70 | return $this->too_many_results($search, $count); |
||
| 71 | } else if ($count == 0) { |
||
| 72 | return array(); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | $sql = $selectfields . "\n" . $from . "\n" . $orderby; |
||
| 77 | |||
| 78 | $users = array(); |
||
|
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...
|
|||
| 79 | $roleid = -1; |
||
| 80 | $index = false; |
||
|
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...
|
|||
| 81 | foreach($DB->get_recordset_sql($sql, $params) AS $cand) { |
||
| 82 | if($cand->roleid != $roleid) { |
||
| 83 | $role = $DB->get_record('role', array('id'=>$cand->roleid), '*', MUST_EXIST); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 10 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...
|
|||
| 84 | $index = role_get_name($role); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 9 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...
|
|||
| 85 | $users[$index] = array(); |
||
| 86 | |||
| 87 | $roleid = $cand->roleid; |
||
| 88 | } |
||
| 89 | |||
| 90 | $users[$index][$cand->id] = $cand; |
||
| 91 | } |
||
| 92 | return $users; |
||
| 93 | } |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Convert a user object to a string suitable for displaying as an option in the list box. |
||
| 97 | * |
||
| 98 | * @param object $user the user to display. |
||
| 99 | * @return string a string representation of the user. |
||
| 100 | */ |
||
| 101 | public function output_user($user) { |
||
| 102 | return $user->fullname; |
||
| 103 | } |
||
| 104 | |||
| 105 | protected function get_options() { |
||
| 106 | $options = parent::get_options(); |
||
|
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...
|
|||
| 107 | $options['relationshipgroup'] = $this->relationshipgroup; |
||
| 108 | return $options; |
||
| 109 | } |
||
| 110 | } |
||
| 111 |
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.