Passed
Branch master (91a665)
by Roberto
03:13
created
lib.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -329,7 +329,7 @@
 block discarded – undo
329 329
 
330 330
         $cohorts = $DB->get_records('relationship_cohorts', array('relationshipid' => $relationship->id));
331 331
 
332
-        if(count($cohorts) == 0) {
332
+        if (count($cohorts) == 0) {
333 333
             $DB->delete_records('relationship_cohorts', array('relationshipid' => $relationship->id));
334 334
 
335 335
             $tags = tag_get_tags_array('relationship', $relationship->id);
Please login to merge, or discard this patch.
edit.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 
54 54
 if (optional_param('confirmdelete', 0, PARAM_BOOL) && confirm_sesskey() && $relationship->id) {
55 55
     $res = relationship_delete_relationship($relationship);
56
-    if($res == -1) {
56
+    if ($res == -1) {
57 57
         print_error('has_cohorts', 'local_relationship');
58 58
     }
59 59
     redirect($returnurl);
Please login to merge, or discard this patch.
locallib.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
 
24 24
 defined('MOODLE_INTERNAL') || die();
25 25
 
26
-require_once($CFG->dirroot . '/user/selector/lib.php');
27
-require_once($CFG->dirroot . '/tag/lib.php');
26
+require_once($CFG->dirroot.'/user/selector/lib.php');
27
+require_once($CFG->dirroot.'/tag/lib.php');
28 28
 
29
-function relationship_set_header($context, $url, $relationship=null, $module=null) {
29
+function relationship_set_header($context, $url, $relationship = null, $module = null) {
30 30
     global $PAGE, $COURSE, $DB;
31 31
 
32 32
     if ($context->contextlevel != CONTEXT_COURSECAT) {
@@ -43,27 +43,27 @@  discard block
 block discarded – undo
43 43
 
44 44
     $PAGE->navbar->add($category->name, new moodle_url('/course/index.php', array('categoryid'=>$category->id)));
45 45
     $PAGE->navbar->add($navtitle, new moodle_url('/local/relationship/index.php', array('contextid'=>$context->id)));
46
-    if($module) {
46
+    if ($module) {
47 47
         $PAGE->navbar->add(get_string($module, 'local_relationship'),
48 48
                            new moodle_url("/local/relationship/{$module}.php", array('relationshipid'=>$relationship->id)));
49 49
     }
50 50
 }
51 51
 
52
-function relationship_set_title($relationship=null, $action=null, $param=null) {
52
+function relationship_set_title($relationship = null, $action = null, $param = null) {
53 53
     global $OUTPUT;
54 54
 
55 55
     echo $OUTPUT->header();
56
-    if($relationship) {
57
-        echo $OUTPUT->heading(get_string('relationship', 'local_relationship') . ': ' . format_string($relationship->name));
56
+    if ($relationship) {
57
+        echo $OUTPUT->heading(get_string('relationship', 'local_relationship').': '.format_string($relationship->name));
58 58
         echo html_writer::empty_tag('BR');
59 59
     }
60
-    if($action) {
60
+    if ($action) {
61 61
         echo $OUTPUT->heading(get_string($action, 'local_relationship', $param), '4');
62 62
     }
63 63
 }
64 64
 
65
-function relationship_groups_parse_name($format, $value, $value_is_a_name=false) {
66
-    if($value_is_a_name) {
65
+function relationship_groups_parse_name($format, $value, $value_is_a_name = false) {
66
+    if ($value_is_a_name) {
67 67
         if (strstr($format, '@') !== false) {
68 68
             $str = str_replace('@', $value, $format);
69 69
         } else {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     } else {
73 73
         if (strstr($format, '@') !== false) { // Convert $value to a character series
74 74
             $letter = 'A';
75
-            for($i=0; $i<$value; $i++) {
75
+            for ($i = 0; $i < $value; $i++) {
76 76
                 $letter++;
77 77
             }
78 78
             $str = str_replace('@', $letter, $format);
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $all_roles = role_get_names();
88 88
     $ctx_roles = get_roles_for_contextlevels(CONTEXT_COURSE);
89 89
     $roles = array();
90
-    foreach($ctx_roles AS $id=>$roleid) {
91
-        if($roleid > 2) {
90
+    foreach ($ctx_roles AS $id=>$roleid) {
91
+        if ($roleid > 2) {
92 92
             $roles[$roleid] = $all_roles[$roleid]->localname;
93 93
         }
94 94
     }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     $context = context::instance_by_id($relationship->contextid);
104 104
 
105 105
     $contextids = array();
106
-    foreach($context->get_parent_context_ids(true) as $ctxid) {
106
+    foreach ($context->get_parent_context_ids(true) as $ctxid) {
107 107
         $context = context::instance_by_id($ctxid);
108 108
         if (has_capability('moodle/cohort:view', $context)) {
109 109
             $contextids[] = $ctxid;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                AND g.idnumber NOT LIKE 'relationship_{$relationshipid}_%'
140 140
           ORDER BY g.name";
141 141
     $groups = array();
142
-    foreach($DB->get_records_sql($sql, array('relationshipid'=>$relationshipid)) as $r) {
142
+    foreach ($DB->get_records_sql($sql, array('relationshipid'=>$relationshipid)) as $r) {
143 143
         $groups[$r->name][] = $r;
144 144
     }
145 145
     return $groups;
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 
207 207
     if (!empty($search)) {
208 208
         $conditions = array('name', 'idnumber', 'description');
209
-        $searchparam = '%' . $DB->sql_like_escape($search) . '%';
209
+        $searchparam = '%'.$DB->sql_like_escape($search).'%';
210 210
         foreach ($conditions as $key=>$condition) {
211 211
             $conditions[$key] = $DB->sql_like($condition, "?", false);
212 212
             $params[] = $searchparam;
213 213
         }
214
-        $tests[] = '(' . implode(' OR ', $conditions) . ')';
214
+        $tests[] = '('.implode(' OR ', $conditions).')';
215 215
     }
216 216
     $wherecondition = implode(' AND ', $tests);
217 217
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
              WHERE $wherecondition";
222 222
     $order = " ORDER BY name ASC";
223 223
     $allrelationships = $DB->count_records('relationship', array('contextid'=>$contextid));
224
-    $totalrelationships = $DB->count_records_sql($countfields . $sql, $params);
225
-    $relationships = $DB->get_records_sql($fields . $sql . $order, $params, $page*$perpage, $perpage);
226
-    foreach($relationships as $rl) {
224
+    $totalrelationships = $DB->count_records_sql($countfields.$sql, $params);
225
+    $relationships = $DB->get_records_sql($fields.$sql.$order, $params, $page*$perpage, $perpage);
226
+    foreach ($relationships as $rl) {
227 227
         $rl->tags = tag_get_tags_array('relationship', $rl->id);
228 228
     }
229 229
 
Please login to merge, or discard this patch.
classes/candidate_selector.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 
39 39
         list($usercondition, $params) = users_search_sql($search, 'u', $this->searchanywhere);
40 40
 
41
-        if(!empty($this->validatinguserids)) {
41
+        if (!empty($this->validatinguserids)) {
42 42
             list($usertest, $userparams) = $DB->get_in_or_equal($this->validatinguserids, SQL_PARAMS_NAMED, 'val');
43
-            $usercondition .= " AND u.id*1000000+rc.id " . $usertest;
43
+            $usercondition .= " AND u.id*1000000+rc.id ".$usertest;
44 44
             $params = array_merge($params, $userparams);
45 45
         }
46 46
 
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
                        OR (rc.allowdupsingroups = 0 AND rm.id IS NULL))
67 67
                   AND {$usercondition}";
68 68
 
69
-        $orderby= "ORDER BY roleid, in_group, fullname";
69
+        $orderby = "ORDER BY roleid, in_group, fullname";
70 70
 
71 71
         if (!$this->is_validating()) {
72
-            $sql = $countfields . "\n" . $from;
72
+            $sql = $countfields."\n".$from;
73 73
             $count = $DB->count_records_sql($sql, $params);
74 74
             if ($count > $this->maxusersperpage) {
75 75
                 return $this->too_many_results($search, $count);
@@ -78,19 +78,19 @@  discard block
 block discarded – undo
78 78
             }
79 79
         }
80 80
 
81
-        $sql = $selectfields . "\n" . $from .  "\n" . $orderby;
81
+        $sql = $selectfields."\n".$from."\n".$orderby;
82 82
 
83 83
         $users = array();
84 84
         $roleid = -1;
85 85
         $in_group = -1;
86 86
         $index = false;
87
-        foreach($DB->get_recordset_sql($sql, $params) AS $cand) {
88
-            if($cand->roleid != $roleid || $cand->in_group != $in_group) {
87
+        foreach ($DB->get_recordset_sql($sql, $params) AS $cand) {
88
+            if ($cand->roleid != $roleid || $cand->in_group != $in_group) {
89 89
                 $role = $DB->get_record('role', array('id'=>$cand->roleid), '*', MUST_EXIST);
90 90
                 $role_name = role_get_name($role);
91 91
 
92
-                $str_alloc = $cand->in_group == 1  ? get_string('allocated', 'local_relationship') : get_string('notallocated', 'local_relationship');
93
-                $index = $role_name . $str_alloc;
92
+                $str_alloc = $cand->in_group == 1 ? get_string('allocated', 'local_relationship') : get_string('notallocated', 'local_relationship');
93
+                $index = $role_name.$str_alloc;
94 94
                 $users[$index] = array();
95 95
 
96 96
                 $roleid = $cand->roleid;
Please login to merge, or discard this patch.
classes/form/edit_cohort.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@
 block discarded – undo
35 35
 
36 36
         $cohorts = relationship_get_cohort_options($relationshipcohort->relationshipid);
37 37
         $relationshipcohorts = relationship_get_cohorts($relationshipcohort->relationshipid);
38
-        foreach($relationshipcohorts AS $rc) {
38
+        foreach ($relationshipcohorts AS $rc) {
39 39
             unset($cohorts[$rc->cohortid]);
40 40
         }
41 41
 
42 42
         $mform->addElement('select', 'cohortid', get_string('cohort', 'cohort'), $cohorts);
43 43
 
44 44
         $roles = relationship_get_role_options();
45
-        foreach($relationshipcohorts AS $rc) {
45
+        foreach ($relationshipcohorts AS $rc) {
46 46
             unset($roles[$rc->roleid]);
47 47
         }
48 48
         $mform->addElement('select', 'roleid', get_string('role'), $roles);
49 49
 
50
-        if($relationshipcohort->id) {
50
+        if ($relationshipcohort->id) {
51 51
             $mform->freeze('roleid');
52 52
             $mform->freeze('cohortid');
53 53
         }
Please login to merge, or discard this patch.
classes/form/autogroup.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     function definition() {
41 41
         global $DB;
42 42
 
43
-        $mform =& $this->_form;
43
+        $mform = & $this->_form;
44 44
 
45 45
         $relationshipid = $this->_customdata['relationshipid'];
46 46
 
Please login to merge, or discard this patch.
classes/existing_selector.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 
45 45
         list($usercondition, $params) = users_search_sql($search, 'u', $this->searchanywhere);
46 46
 
47
-        if(!empty($this->validatinguserids)) {
47
+        if (!empty($this->validatinguserids)) {
48 48
             list($usertest, $userparams) = $DB->get_in_or_equal($this->validatinguserids, SQL_PARAMS_NAMED, 'val');
49
-            $usercondition .= " AND u.id*1000000+rc.id " . $usertest;
49
+            $usercondition .= " AND u.id*1000000+rc.id ".$usertest;
50 50
             $params = array_merge($params, $userparams);
51 51
         }
52 52
 
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
                 WHERE rm.relationshipgroupid = :relationshipgroupid
62 62
                   AND {$usercondition}";
63 63
 
64
-        $orderby= "ORDER BY roleid, fullname";
64
+        $orderby = "ORDER BY roleid, fullname";
65 65
 
66 66
         if (!$this->is_validating()) {
67
-            $sql = $countfields . "\n" . $from;
67
+            $sql = $countfields."\n".$from;
68 68
             $count = $DB->count_records_sql($sql, $params);
69 69
             if ($count > $this->maxusersperpage) {
70 70
                 return $this->too_many_results($search, $count);
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
             }
74 74
         }
75 75
 
76
-        $sql = $selectfields . "\n" . $from .  "\n" . $orderby;
76
+        $sql = $selectfields."\n".$from."\n".$orderby;
77 77
 
78 78
         $users = array();
79 79
         $roleid = -1;
80 80
         $index = false;
81
-        foreach($DB->get_recordset_sql($sql, $params) AS $cand) {
82
-            if($cand->roleid != $roleid) {
81
+        foreach ($DB->get_recordset_sql($sql, $params) AS $cand) {
82
+            if ($cand->roleid != $roleid) {
83 83
                 $role = $DB->get_record('role', array('id'=>$cand->roleid), '*', MUST_EXIST);
84 84
                 $index = role_get_name($role);
85 85
                 $users[$index] = array();
Please login to merge, or discard this patch.