Passed
Push — master ( 9b6994...2073b4 )
by Struan
17:27
created
www/docs/api/api_getAlerts.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 function api_getAlerts_start_date($start_date) {
4
-  $args = array ('start_date' => $start_date, 'end_date' => get_http_var('end_date'));
5
-  $alert = new ALERT();
6
-  $data = $alert->fetch_between($confirmed=1, $deleted=0, $args['start_date'], $args['end_date']);
7
-  api_output($data);
4
+    $args = array ('start_date' => $start_date, 'end_date' => get_http_var('end_date'));
5
+    $alert = new ALERT();
6
+    $data = $alert->fetch_between($confirmed=1, $deleted=0, $args['start_date'], $args['end_date']);
7
+    api_output($data);
8 8
 }
9 9
 
10 10
 ?>
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 function api_getAlerts_start_date($start_date) {
4
-  $args = array ('start_date' => $start_date, 'end_date' => get_http_var('end_date'));
4
+  $args = array('start_date' => $start_date, 'end_date' => get_http_var('end_date'));
5 5
   $alert = new ALERT();
6
-  $data = $alert->fetch_between($confirmed=1, $deleted=0, $args['start_date'], $args['end_date']);
6
+  $data = $alert->fetch_between($confirmed = 1, $deleted = 0, $args['start_date'], $args['end_date']);
7 7
   api_output($data);
8 8
 }
9 9
 
Please login to merge, or discard this patch.
www/docs/api/api_getHansard.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,9 @@
 block discarded – undo
66 66
     if ($o == 'p') {
67 67
         $data = \MySociety\TheyWorkForYou\Utility\Search::searchByUsage($search);
68 68
         $out = array();
69
-        if (!isset($data['speakers'])) $data['speakers'] = array();
69
+        if (!isset($data['speakers'])) {
70
+            $data['speakers'] = array();
71
+        }
70 72
         foreach ($data['speakers'] as $pid => $s) {
71 73
             $out[$pid] = array(
72 74
                 'house' => $s['house'],
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-include_once INCLUDESPATH."easyparliament/member.php";
3
+include_once INCLUDESPATH . "easyparliament/member.php";
4 4
 
5 5
 function api_getHansard_front() {
6 6
 ?>
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 }
30 30
 
31 31
 function api_getHansard_search($s) {
32
-    _api_getHansard_search( array(
32
+    _api_getHansard_search(array(
33 33
         's' => $s,
34 34
         'pid' => get_http_var('person')
35
-    ) );
35
+    ));
36 36
 }
37 37
 function api_getHansard_person($pid) {
38 38
     _api_getHansard_search(array(
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 }
42 42
 
43 43
 function _api_getHansard_date($type, $d) {
44
-    $args = array ('date' => $d);
44
+    $args = array('date' => $d);
45 45
     $LIST = _api_getListObject($type);
46 46
     $LIST->display('date', $args, 'api');
47 47
 }
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     $type = isset($array['type']) ? $array['type'] : '';
57 57
     $search = filter_user_input($search, 'strict');
58 58
     if ($pid) {
59
-        $search .= ($search?' ':'') . 'speaker:' . $pid;
59
+        $search .= ($search ? ' ' : '') . 'speaker:' . $pid;
60 60
     }
61 61
     if ($type) {
62 62
         $search .= " section:" . $type;
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     }
92 92
 #    $query_desc_short = $SEARCHENGINE->query_description_short();
93 93
     $pagenum = get_http_var('page');
94
-    $args = array (
94
+    $args = array(
95 95
         's' => $search,
96 96
         'p' => $pagenum,
97 97
         'num' => get_http_var('num'),
98 98
         'pop' => 1,
99
-        'o' => ($o=='d' || $o=='r') ? $o : 'd',
99
+        'o' => ($o == 'd' || $o == 'r') ? $o : 'd',
100 100
     );
101 101
     $LIST = new HANSARDLIST();
102 102
     $data = $LIST->display('search', $args, 'none');
Please login to merge, or discard this patch.
www/docs/api/api_getGeometry.php 2 patches
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,13 +38,17 @@  discard block
 block discarded – undo
38 38
 
39 39
 function api_getGeometry_name($name) {
40 40
     $out = _api_getGeometry_name($name);
41
-    if ($out) api_output($out);
42
-    else api_error('Name not recognised');
43
-}
41
+    if ($out) {
42
+        api_output($out);
43
+    } else {
44
+        api_error('Name not recognised');
45
+    }
46
+    }
44 47
 
45 48
 function _api_getGeometry_name($name) {
46
-    if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL)
47
-        return null;
49
+    if (!defined('OPTION_MAPIT_URL') || !OPTION_MAPIT_URL) {
50
+            return null;
51
+    }
48 52
 
49 53
     $name = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($name);
50 54
 
@@ -68,8 +72,9 @@  discard block
 block discarded – undo
68 72
 
69 73
 function _api_cacheCheck($fn, $arg='') {
70 74
     $cache = INCLUDESPATH . '../docs/api/cache/' . $fn;
71
-    if (is_file($cache))
72
-        return unserialize(file_get_contents($cache));
75
+    if (is_file($cache)) {
76
+            return unserialize(file_get_contents($cache));
77
+    }
73 78
     $out = mapit_call($fn, $arg);
74 79
     $fp = fopen($cache, 'w');
75 80
     if ($fp) {
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     return null;
67 67
 }
68 68
 
69
-function _api_cacheCheck($fn, $arg='') {
69
+function _api_cacheCheck($fn, $arg = '') {
70 70
     $cache = INCLUDESPATH . '../docs/api/cache/' . $fn;
71 71
     if (is_file($cache))
72 72
         return unserialize(file_get_contents($cache));
@@ -83,58 +83,58 @@  discard block
 block discarded – undo
83 83
 function _api_ni_centroids() {
84 84
     return array(
85 85
         # East Londonderry
86
-        66129 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907 ),
87
-        14276 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907 ),
86
+        66129 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907),
87
+        14276 => array('centre_lat' => 54.980766, 'centre_lon' => -6.904907),
88 88
         # Foyle
89
-        66131 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456 ),
90
-        14273 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456 ),
89
+        66131 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456),
90
+        14273 => array('centre_lat' => 54.933453, 'centre_lon' => -7.267456),
91 91
         # West Tyrone
92
-        66141 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278 ),
93
-        14292 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278 ),
92
+        66141 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278),
93
+        14292 => array('centre_lat' => 54.619797, 'centre_lon' => -7.410278),
94 94
         # Fermanagh &amp; South Tyrone
95
-        14296 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237 ),
96
-        66130 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237 ),
95
+        14296 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237),
96
+        66130 => array('centre_lat' => 54.354958, 'centre_lon' => -7.443237),
97 97
         # Newry &amp; Armagh
98
-        14303 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770 ),
99
-        66134 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770 ),
98
+        14303 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770),
99
+        66134 => array('centre_lat' => 54.297295, 'centre_lon' => -6.613770),
100 100
         # Upper Bann
101
-        14300 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098 ),
102
-        66140 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098 ),
101
+        14300 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098),
102
+        66140 => array('centre_lat' => 54.399750, 'centre_lon' => -6.350098),
103 103
         # South Down
104
-        14306 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344 ),
105
-        66138 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344 ),
104
+        14306 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344),
105
+        66138 => array('centre_lat' => 54.213860, 'centre_lon' => -6.152344),
106 106
         # Lagan Valley
107
-        14309 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398 ),
108
-        66132 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398 ),
107
+        14309 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398),
108
+        66132 => array('centre_lat' => 54.441296, 'centre_lon' => -6.108398),
109 109
         # Strangford
110
-        14312 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343 ),
111
-        66139 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343 ),
110
+        14312 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343),
111
+        66139 => array('centre_lat' => 54.514706, 'centre_lon' => -5.751343),
112 112
         # North Down
113
-        14325 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384 ),
114
-        66136 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384 ),
113
+        14325 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384),
114
+        66136 => array('centre_lat' => 54.651592, 'centre_lon' => -5.718384),
115 115
         # South Antrim
116
-        14318 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905 ),
117
-        66137 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905 ),
116
+        14318 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905),
117
+        66137 => array('centre_lat' => 54.699234, 'centre_lon' => -6.102905),
118 118
         # East Antrim
119
-        66128 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179 ),
120
-        14284 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179 ),
119
+        66128 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179),
120
+        14284 => array('centre_lat' => 54.832336, 'centre_lon' => -5.883179),
121 121
         # North Antrim
122
-        66135 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125 ),
123
-        14280 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125 ),
122
+        66135 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125),
123
+        14280 => array('centre_lat' => 54.993374, 'centre_lon' => -6.328125),
124 124
         # Mid Ulster
125
-        66133 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044 ),
126
-        14288 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044 ),
125
+        66133 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044),
126
+        14288 => array('centre_lat' => 54.721447, 'centre_lon' => -6.795044),
127 127
         # Belfast North
128
-        14321 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511 ),
129
-        66125 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511 ),
128
+        14321 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511),
129
+        66125 => array('centre_lat' => 54.618607, 'centre_lon' => -5.917511),
130 130
         # Belfast East
131
-        14329 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792 ),
132
-        66124 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792 ),
131
+        14329 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792),
132
+        66124 => array('centre_lat' => 54.598324, 'centre_lon' => -5.892792),
133 133
         # Belfast South
134
-        14331 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064 ),
135
-        66126 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064 ),
134
+        14331 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064),
135
+        66126 => array('centre_lat' => 54.582409, 'centre_lon' => -5.925064),
136 136
         # Belfast West
137
-        14315 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650 ),
138
-        66127 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650 ),
137
+        14315 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650),
138
+        66127 => array('centre_lat' => 54.606277, 'centre_lon' => -5.956650),
139 139
     );
140 140
 }
Please login to merge, or discard this patch.
www/docs/api/api_getCommittee.php 2 patches
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -57,8 +57,11 @@  discard block
 block discarded – undo
57 57
     $name = preg_replace('#\s+Committee#', '', $name);
58 58
 
59 59
     $date = parse_date(get_http_var('date'));
60
-    if ($date) $date = '"' . $date['iso'] . '"';
61
-    else $date = 'date(now())';
60
+    if ($date) {
61
+        $date = '"' . $date['iso'] . '"';
62
+    } else {
63
+        $date = 'date(now())';
64
+    }
62 65
     $q = $db->query("select distinct(dept) from moffice
63 66
         where dept like :department
64 67
         and from_date <= $date and $date <= to_date", array(
@@ -108,8 +111,11 @@  discard block
 block discarded – undo
108 111
     $db = new ParlDB;
109 112
 
110 113
     $date = parse_date($date);
111
-    if ($date) $date = '"' . $date['iso'] . '"';
112
-    else $date = 'date(now())';
114
+    if ($date) {
115
+        $date = '"' . $date['iso'] . '"';
116
+    } else {
117
+        $date = 'date(now())';
118
+    }
113 119
     $q = $db->query("select distinct(dept) from moffice
114 120
         where source = 'chgpages/selctee'
115 121
         and from_date <= $date and $date <= to_date");
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             ));
67 67
     if ($q->rows() > 1) {
68 68
         # More than one committee matches
69
-        for ($i=0; $i<$q->rows(); $i++) {
69
+        for ($i = 0; $i < $q->rows(); $i++) {
70 70
             $output['committees'][] = array(
71 71
                 'name' => $q->field($i, 'dept')
72 72
             );
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         if ($q->rows()) {
86 86
             $output = array();
87 87
             $output['committee'] = $q->field(0, 'dept');
88
-            for ($i=0; $i<$q->rows(); $i++) {
88
+            for ($i = 0; $i < $q->rows(); $i++) {
89 89
                 $member = array(
90 90
                     'person_id' => $q->field($i, 'person'),
91 91
                     'name' => $q->field($i, 'given_name') . ' ' . $q->field($i, 'family_name'),
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         where source = 'chgpages/selctee'
115 115
         and from_date <= $date and $date <= to_date");
116 116
     if ($q->rows()) {
117
-        for ($i=0; $i<$q->rows(); $i++) {
117
+        for ($i = 0; $i < $q->rows(); $i++) {
118 118
             $output['committees'][] = array(
119 119
                 'name' => $q->field($i, 'dept')
120 120
             );
Please login to merge, or discard this patch.
www/docs/api/api_convertURL.php 2 patches
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -75,22 +75,25 @@
 block discarded – undo
75 75
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url = :url order by gid limit 1', array(
76 76
         ':url' => $url
77 77
         ));
78
-    if ($q->rows())
79
-        return api_converturl_url_output($q);
78
+    if ($q->rows()) {
79
+            return api_converturl_url_output($q);
80
+    }
80 81
 
81 82
     $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
82 83
         ':url' => $url_nohash . '%'
83 84
         ));
84
-    if ($q->rows())
85
-        return api_converturl_url_output($q);
85
+    if ($q->rows()) {
86
+            return api_converturl_url_output($q);
87
+    }
86 88
 
87 89
     $url_bound = str_replace('cmhansrd/cm', 'cmhansrd/vo', $url_nohash);
88 90
     if ($url_bound != $url_nohash) {
89 91
         $q = $db->query('select gid,major,htype,subsection_id from hansard where source_url like :url order by gid limit 1', array(
90 92
             ':url' => $url_bound . '%'
91 93
             ));
92
-        if ($q->rows())
93
-            return api_converturl_url_output($q);
94
+        if ($q->rows()) {
95
+                    return api_converturl_url_output($q);
96
+        }
94 97
     }
95 98
     api_error('Sorry, URL could not be converted');
96 99
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     $LISTURL = new \MySociety\TheyWorkForYou\Url($hansardmajors[$id_data['major']]['page_all']);
41 41
     $fragment = '';
42 42
     if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
43
-        $LISTURL->insert( array( 'id' => $id_data['gid'] ) );
43
+        $LISTURL->insert(array('id' => $id_data['gid']));
44 44
     } else {
45 45
         $parent_epobject_id = $id_data['subsection_id'];
46 46
         $parent_gid = '';
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
                     ':epobject_id' => $parent_epobject_id
51 51
                     ));
52 52
         if ($r->rows() > 0) {
53
-            $parent_gid = fix_gid_from_db( $r->field(0, 'gid') );
53
+            $parent_gid = fix_gid_from_db($r->field(0, 'gid'));
54 54
         }
55 55
         if ($parent_gid != '') {
56
-            $LISTURL->insert( array( 'id' => $parent_gid ) );
56
+            $LISTURL->insert(array('id' => $parent_gid));
57 57
             $fragment = '#g' . gid_to_anchor($id_data['gid']);
58 58
         }
59 59
     }
Please login to merge, or discard this patch.
www/docs/api/api_getComments.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 }
25 25
 
26 26
 function api_getComments_start_date($start_date) {
27
-        $args = array (
27
+        $args = array(
28 28
             'start_date' => $start_date,
29 29
             'end_date' => get_http_var('end_date')
30 30
         );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 }
34 34
 
35 35
 function api_getComments_search($s) {
36
-        $args = array (
36
+        $args = array(
37 37
             's' => $s,
38 38
             'p' => get_http_var('page'),
39 39
             'num' => get_http_var('num'),
Please login to merge, or discard this patch.
www/docs/api/api_getMPsInfo.php 2 patches
Braces   +21 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
     $ids = preg_split('#\s*,\s*#', $ids, -1, PREG_SPLIT_NO_EMPTY);
21 21
     $safe_ids = array(0);
22 22
     foreach ($ids as $id) {
23
-        if (ctype_digit($id)) $safe_ids[] = $id;
23
+        if (ctype_digit($id)) {
24
+            $safe_ids[] = $id;
25
+        }
24 26
     }
25 27
     $ids = join(',', $safe_ids);
26 28
 
@@ -32,13 +34,15 @@  discard block
 block discarded – undo
32 34
         $output = array();
33 35
         for ($i=0; $i<$q->rows(); $i++) {
34 36
             $data_key = $q->field($i, 'data_key');
35
-            if (count($fields) && !in_array($data_key, $fields))
36
-                continue;
37
+            if (count($fields) && !in_array($data_key, $fields)) {
38
+                            continue;
39
+            }
37 40
             $pid = $q->field($i, 'person_id');
38 41
             $output[$pid][$data_key] = $q->field($i, 'data_value');
39 42
             $time = strtotime($q->field($i, 'lastupdate'));
40
-            if ($time > $last_mod)
41
-                $last_mod = $time;
43
+            if ($time > $last_mod) {
44
+                            $last_mod = $time;
45
+            }
42 46
         }
43 47
         $q = $db->query("select memberinfo.*, person_id from memberinfo, member
44 48
             where memberinfo.member_id=member.member_id and person_id in (" . $ids . ")
@@ -46,16 +50,22 @@  discard block
 block discarded – undo
46 50
         if ($q->rows()) {
47 51
             for ($i=0; $i<$q->rows(); $i++) {
48 52
                 $data_key = $q->field($i, 'data_key');
49
-                if (count($fields) && !in_array($data_key, $fields))
50
-                    continue;
53
+                if (count($fields) && !in_array($data_key, $fields)) {
54
+                                    continue;
55
+                }
51 56
                 $mid = $q->field($i, 'member_id');
52 57
                 $pid = $q->field($i, 'person_id');
53
-                if (!isset($output[$pid]['by_member_id'])) $output[$pid]['by_member_id'] = array();
54
-                if (!isset($output[$pid]['by_member_id'][$mid])) $output[$pid]['by_member_id'][$mid] = array();
58
+                if (!isset($output[$pid]['by_member_id'])) {
59
+                    $output[$pid]['by_member_id'] = array();
60
+                }
61
+                if (!isset($output[$pid]['by_member_id'][$mid])) {
62
+                    $output[$pid]['by_member_id'][$mid] = array();
63
+                }
55 64
                 $output[$pid]['by_member_id'][$mid][$data_key] = $q->field($i, 'data_value');
56 65
                 $time = strtotime($q->field($i, 'lastupdate'));
57
-                if ($time > $last_mod)
58
-                    $last_mod = $time;
66
+                if ($time > $last_mod) {
67
+                                    $last_mod = $time;
68
+                }
59 69
             }
60 70
         }
61 71
         ksort($output);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         where person_id in (" . $ids . ")");
31 31
     if ($q->rows()) {
32 32
         $output = array();
33
-        for ($i=0; $i<$q->rows(); $i++) {
33
+        for ($i = 0; $i < $q->rows(); $i++) {
34 34
             $data_key = $q->field($i, 'data_key');
35 35
             if (count($fields) && !in_array($data_key, $fields))
36 36
                 continue;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
             where memberinfo.member_id=member.member_id and person_id in (" . $ids . ")
45 45
             order by person_id,member_id");
46 46
         if ($q->rows()) {
47
-            for ($i=0; $i<$q->rows(); $i++) {
47
+            for ($i = 0; $i < $q->rows(); $i++) {
48 48
                 $data_key = $q->field($i, 'data_key');
49 49
                 if (count($fields) && !in_array($data_key, $fields))
50 50
                     continue;
Please login to merge, or discard this patch.
www/docs/api/index.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
     $match = 0;
27 27
     foreach ($methods as $method => $data) {
28 28
         if (strtolower($q_method) == strtolower($method)) {
29
-      if (isset($data['superuser']) && $data['superuser']) {
29
+        if (isset($data['superuser']) && $data['superuser']) {
30 30
         $super_check = api_is_superuser_key($key);
31 31
         if (!$super_check) {
32 32
                 if (get_http_var('docs')) {
33
-                  api_front_page();
33
+                    api_front_page();
34 34
                 } else {
35
-                  api_error('Invalid API key.');
36
-                  exit;
37
-              }
35
+                    api_error('Invalid API key.');
36
+                    exit;
37
+                }
38 38
             }
39
-      }
39
+        }
40 40
 
41 41
             api_log_call($key);
42 42
             $match++;
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
             '". Possible functions are: ' .
74 74
             join(', ', array_keys($methods));
75 75
         if (get_http_var('output')) {
76
-          api_error($msg);
76
+            api_error($msg);
77 77
         } else {
78
-          api_front_page($msg);
78
+            api_front_page($msg);
79 79
         }
80 80
     } else {
81 81
         if (get_http_var('docs')) {
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -103,13 +103,15 @@  discard block
 block discarded – undo
103 103
 <p>
104 104
 <?php foreach ($methods[$method]['parameters'] as $parameter) {
105 105
     print $parameter . ': <input type="text" name="'.$parameter.'" value="';
106
-    if ($val = get_http_var($parameter))
107
-        print _htmlspecialchars($val);
106
+    if ($val = get_http_var($parameter)) {
107
+            print _htmlspecialchars($val);
108
+    }
108 109
     print '" size="30"><br>';
109 110
 }
110 111
 ?>
111 112
 Output:
112
-<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>>
113
+<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) {
114
+    print ' checked'?>>
113 115
 <label for="output_js">JS</label>
114 116
 <input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>>
115 117
 <label for="output_xml">XML</label>
@@ -124,9 +126,11 @@  discard block
 block discarded – undo
124 126
 <?php
125 127
     if ($explorer) {
126 128
         $qs = array();
129
+}
127 130
         foreach ($methods[$method]['parameters'] as $parameter) {
128
-            if (get_http_var($parameter))
129
-                $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter)));
131
+            if (get_http_var($parameter)) {
132
+                            $qs[] = _htmlspecialchars(rawurlencode($parameter) . '=' . urlencode(get_http_var($parameter)));
133
+            }
130 134
         }
131 135
         print '<h4><a name="output"></a>Output</h4>';
132 136
         print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/';
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             foreach ($data['parameters'] as $parameter) {
48 48
                 if ($q_param = trim(get_http_var($parameter))) {
49 49
                     $match++;
50
-                    include_once 'api_'. $method . '.php';
50
+                    include_once 'api_' . $method . '.php';
51 51
                     api_call_user_func_or_error('api_' . $method . '_' . $parameter, array($q_param), 'API call not yet functional', 'api');
52 52
                     break;
53 53
                 }
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
                     api_error('No parameter provided to function "' .
58 58
                     _htmlspecialchars($q_method) .
59 59
                         '". Possible choices are: ' .
60
-                        join(', ', $data['parameters']) );
60
+                        join(', ', $data['parameters']));
61 61
                 } else {
62
-                    include_once 'api_'. $method . '.php';
62
+                    include_once 'api_' . $method . '.php';
63 63
                     api_call_user_func_or_error('api_' . $method, array(), 'API call not yet functional', 'api');
64 64
                     break;
65 65
                 }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     $DATA->set_page_metadata($this_page, 'title', "$method function");
94 94
     $PAGE->page_start();
95 95
     $PAGE->stripe_start();
96
-    include_once 'api_'. $method . '.php';
96
+    include_once 'api_' . $method . '.php';
97 97
     print '<p align="center"><strong>https://www.theyworkforyou.com/api/' . $method . '</strong></p>';
98 98
     api_call_user_func_or_error('api_' . $method . '_front', array(), 'No documentation yet', 'html');
99 99
 ?>
@@ -102,20 +102,20 @@  discard block
 block discarded – undo
102 102
 <form method="get" action="?#output">
103 103
 <p>
104 104
 <?php foreach ($methods[$method]['parameters'] as $parameter) {
105
-    print $parameter . ': <input type="text" name="'.$parameter.'" value="';
105
+    print $parameter . ': <input type="text" name="' . $parameter . '" value="';
106 106
     if ($val = get_http_var($parameter))
107 107
         print _htmlspecialchars($val);
108 108
     print '" size="30"><br>';
109 109
 }
110 110
 ?>
111 111
 Output:
112
-<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output')=='js' || !get_http_var('output')) print ' checked'?>>
112
+<input id="output_js" type="radio" name="output" value="js"<?php if (get_http_var('output') == 'js' || !get_http_var('output')) print ' checked'?>>
113 113
 <label for="output_js">JS</label>
114
-<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output')=='xml') print ' checked'?>>
114
+<input id="output_xml" type="radio" name="output" value="xml"<?php if (get_http_var('output') == 'xml') print ' checked'?>>
115 115
 <label for="output_xml">XML</label>
116
-<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output')=='php') print ' checked'?>>
116
+<input id="output_php" type="radio" name="output" value="php"<?php if (get_http_var('output') == 'php') print ' checked'?>>
117 117
 <label for="output_php">Serialised PHP</label>
118
-<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output')=='rabx') print ' checked'?>>
118
+<input id="output_rabx" type="radio" name="output" value="rabx"<?php if (get_http_var('output') == 'rabx') print ' checked'?>>
119 119
 <label for="output_rabx">RABX</label>
120 120
 
121 121
 <input type="submit" value="Go">
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         }
131 131
         print '<h4><a name="output"></a>Output</h4>';
132 132
         print '<p>URL for this: <strong>https://www.theyworkforyou.com/api/';
133
-        print $method . '?' . join('&amp;', $qs) . '&amp;output='._htmlspecialchars(get_http_var('output')).'</strong></p>';
133
+        print $method . '?' . join('&amp;', $qs) . '&amp;output=' . _htmlspecialchars(get_http_var('output')) . '</strong></p>';
134 134
         print '<pre>' . _htmlspecialchars($explorer) . '</pre>';
135 135
     }
136 136
     $sidebar = api_sidebar();
Please login to merge, or discard this patch.
www/docs/api/api_functions.php 4 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 }
147 147
 
148 148
 function api_is_superuser_key($key) {
149
-  $db = new ParlDB;
150
-  $q = $db->query('SELECT api_key.user_id, users.status
149
+    $db = new ParlDB;
150
+    $q = $db->query('SELECT api_key.user_id, users.status
151 151
                FROM   api_key, users
152 152
                WHERE  users.user_id = api_key.user_id
153 153
                AND    api_key.api_key = :key', array(
154 154
                 ':key' => $key
155 155
                 ));
156
-  if (!$q->rows())
156
+    if (!$q->rows())
157 157
     return false;
158
-  if ($q->field(0, 'status') == 'Superuser')
158
+    if ($q->field(0, 'status') == 'Superuser')
159 159
     return true;
160
-  else
160
+    else
161 161
     return false;
162 162
 }
163 163
 
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
     // we only want to convert to iso if it's an actual API call
336 336
     // so skip this if it's a documentation page
337 337
     if (!get_http_var('docs')) {
338
-      // and then catch any errors in the conversion and just ignore
339
-      // them and return the unconverted results
340
-      $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
-      if ($converted_out !== FALSE) {
338
+        // and then catch any errors in the conversion and just ignore
339
+        // them and return the unconverted results
340
+        $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
+        if ($converted_out !== FALSE) {
342 342
         $out = $converted_out;
343
-      }
343
+        }
344 344
     }
345 345
 
346 346
     return $out;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -338,7 +338,7 @@
 block discarded – undo
338 338
       // and then catch any errors in the conversion and just ignore
339 339
       // them and return the unconverted results
340 340
       $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
341
-      if ($converted_out !== FALSE) {
341
+      if ($converted_out !== false) {
342 342
         $out = $converted_out;
343 343
       }
344 344
     }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 # Key-related functions
133 133
 
134 134
 function api_log_call($key) {
135
-    if ($key=='DOCS') return;
135
+    if ($key == 'DOCS') return;
136 136
     $ip = $_SERVER['REMOTE_ADDR'];
137 137
     $query = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
138 138
     $query = preg_replace('#key=[A-Za-z0-9]+&?#', '', $query);
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 
198 198
 # Output functions
199 199
 
200
-function api_output($arr, $last_mod=null) {
200
+function api_output($arr, $last_mod = null) {
201 201
     $output = get_http_var('output');
202 202
     if (!get_http_var('docs')) {
203 203
         $cond = api_header($output, $last_mod);
204 204
         if ($cond) return;
205 205
     }
206 206
     if ($output == 'xml') {
207
-        $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
207
+        $out = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
208 208
         $out .= '<twfy>' . api_output_xml($arr) . '</twfy>';
209 209
     } elseif ($output == 'php') {
210 210
         $out = api_output_php($arr);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     print $out;
223 223
 }
224 224
 
225
-function api_header($o, $last_mod=null) {
225
+function api_header($o, $last_mod = null) {
226 226
     if ($last_mod && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
227 227
         $t = cond_parse_http_date($_SERVER['HTTP_IF_MODIFIED_SINCE']);
228 228
         if (isset($t) && $t >= $last_mod) {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
     }
249 249
     #$type = 'text/plain';
250 250
     header("Content-Type: $type; charset=$charset");
251
-    if ($last_mod>0)
251
+    if ($last_mod > 0)
252 252
         header('Last-Modified: ' . date('r', $last_mod));
253 253
     return false;
254 254
 }
@@ -271,11 +271,11 @@  discard block
 block discarded – undo
271 271
 }
272 272
 
273 273
 $api_xml_arr = 0;
274
-function api_output_xml($v, $k=null) {
274
+function api_output_xml($v, $k = null) {
275 275
     global $api_xml_arr;
276 276
     $verbose = get_http_var('verbose') ? "\n" : '';
277 277
     if (is_array($v)) {
278
-        if (count($v) && array_keys($v) === range(0, count($v)-1)) {
278
+        if (count($v) && array_keys($v) === range(0, count($v) - 1)) {
279 279
             $elt = 'match';
280 280
             $api_xml_arr++;
281 281
             $out = "<$elt>";
@@ -296,36 +296,36 @@  discard block
 block discarded – undo
296 296
     }
297 297
 }
298 298
 
299
-function api_output_js($v, $level=0) {
299
+function api_output_js($v, $level = 0) {
300 300
     $verbose = get_http_var('verbose') ? "\n" : '';
301 301
     $out = '';
302 302
     if (is_array($v)) {
303 303
         # PHP arrays are both JS arrays and objects
304
-        if (count($v) && array_keys($v) === range(0, count($v)-1)) {
305
-            $out = '[' . join(",$verbose" , array_map('api_output_js', $v)) . ']';
304
+        if (count($v) && array_keys($v) === range(0, count($v) - 1)) {
305
+            $out = '[' . join(",$verbose", array_map('api_output_js', $v)) . ']';
306 306
         } else {
307 307
             $out = '{' . $verbose;
308 308
             $b = false;
309 309
             foreach ($v as $k => $vv) {
310 310
                 if ($b) $out .= ",$verbose";
311 311
                 if ($verbose) {
312
-                    $out .= str_repeat(' ', ($level+1)*2);
312
+                    $out .= str_repeat(' ', ($level + 1) * 2);
313 313
                     $out .= '"' . $k . '" : ';
314 314
                 } else {
315 315
                     $out .= '"' . $k . '":';
316 316
                 }
317
-                $out .= api_output_js($vv, $level+1);
317
+                $out .= api_output_js($vv, $level + 1);
318 318
                 $b = true;
319 319
             }
320
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
320
+            if ($verbose) $out .= "\n" . str_repeat(' ', $level * 2);
321 321
             $out .= '}';
322 322
         }
323 323
     } elseif (is_null($v)) {
324 324
         $out = "null";
325 325
     } elseif (is_string($v)) {
326 326
         $out = '"' . str_replace(
327
-            array("\\",'"',"\n","\t","\r", "‶", "″", "“", "”"),
328
-            array("\\\\",'\"','\n','\t','\r', '\"', '\"', '\"', '\"'), $v) . '"';
327
+            array("\\", '"', "\n", "\t", "\r", "‶", "″", "“", "”"),
328
+            array("\\\\", '\"', '\n', '\t', '\r', '\"', '\"', '\"', '\"'), $v) . '"';
329 329
     } elseif (is_bool($v)) {
330 330
         $out = $v ? 'true' : 'false';
331 331
     } elseif (is_int($v) || is_float($v)) {
Please login to merge, or discard this patch.
Braces   +49 added lines, -29 removed lines patch added patch discarded remove patch
@@ -132,7 +132,9 @@  discard block
 block discarded – undo
132 132
 # Key-related functions
133 133
 
134 134
 function api_log_call($key) {
135
-    if ($key=='DOCS') return;
135
+    if ($key=='DOCS') {
136
+        return;
137
+    }
136 138
     $ip = $_SERVER['REMOTE_ADDR'];
137 139
     $query = !empty($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
138 140
     $query = preg_replace('#key=[A-Za-z0-9]+&?#', '', $query);
@@ -153,23 +155,27 @@  discard block
 block discarded – undo
153 155
                AND    api_key.api_key = :key', array(
154 156
                 ':key' => $key
155 157
                 ));
156
-  if (!$q->rows())
157
-    return false;
158
-  if ($q->field(0, 'status') == 'Superuser')
159
-    return true;
160
-  else
161
-    return false;
162
-}
158
+  if (!$q->rows()) {
159
+      return false;
160
+  }
161
+  if ($q->field(0, 'status') == 'Superuser') {
162
+      return true;
163
+  } else {
164
+      return false;
165
+  }
166
+  }
163 167
 
164 168
 function api_check_key($key) {
165 169
     $db = new ParlDB;
166 170
     $q = $db->query('SELECT user_id, disabled FROM api_key WHERE api_key = :key', array(
167 171
         ':key' => $key
168 172
         ));
169
-    if (!$q->rows())
170
-        return false;
171
-    if ($q->field(0, 'disabled'))
172
-        return 'disabled';
173
+    if (!$q->rows()) {
174
+            return false;
175
+    }
176
+    if ($q->field(0, 'disabled')) {
177
+            return 'disabled';
178
+    }
173 179
     return true;
174 180
 }
175 181
 
@@ -201,7 +207,9 @@  discard block
 block discarded – undo
201 207
     $output = get_http_var('output');
202 208
     if (!get_http_var('docs')) {
203 209
         $cond = api_header($output, $last_mod);
204
-        if ($cond) return;
210
+        if ($cond) {
211
+            return;
212
+        }
205 213
     }
206 214
     if ($output == 'xml') {
207 215
         $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
@@ -212,7 +220,8 @@  discard block
 block discarded – undo
212 220
         $out = api_output_rabx($arr);
213 221
     } elseif ($output == 'json') {
214 222
         $out = json_encode($arr, JSON_PRETTY_PRINT);
215
-    } else { # JS
223
+    } else {
224
+# JS
216 225
         $out = api_output_js($arr);
217 226
         $callback = get_http_var('callback');
218 227
         if (preg_match('#^[A-Za-z0-9._[\]]+$#', $callback)) {
@@ -248,8 +257,9 @@  discard block
 block discarded – undo
248 257
     }
249 258
     #$type = 'text/plain';
250 259
     header("Content-Type: $type; charset=$charset");
251
-    if ($last_mod>0)
252
-        header('Last-Modified: ' . date('r', $last_mod));
260
+    if ($last_mod>0) {
261
+            header('Last-Modified: ' . date('r', $last_mod));
262
+    }
253 263
     return false;
254 264
 }
255 265
 
@@ -259,14 +269,18 @@  discard block
 block discarded – undo
259 269
 
260 270
 function api_output_php($arr) {
261 271
     $out = serialize($arr);
262
-    if (get_http_var('verbose')) $out = str_replace(';', ";\n", $out);
272
+    if (get_http_var('verbose')) {
273
+        $out = str_replace(';', ";\n", $out);
274
+    }
263 275
     return $out;
264 276
 }
265 277
 
266 278
 function api_output_rabx($arr) {
267 279
     $out = '';
268 280
     rabx_wire_wr($arr, $out);
269
-    if (get_http_var('verbose')) $out = str_replace(',', ",\n", $out);
281
+    if (get_http_var('verbose')) {
282
+        $out = str_replace(',', ",\n", $out);
283
+    }
270 284
     return $out;
271 285
 }
272 286
 
@@ -307,7 +321,9 @@  discard block
 block discarded – undo
307 321
             $out = '{' . $verbose;
308 322
             $b = false;
309 323
             foreach ($v as $k => $vv) {
310
-                if ($b) $out .= ",$verbose";
324
+                if ($b) {
325
+                    $out .= ",$verbose";
326
+                }
311 327
                 if ($verbose) {
312 328
                     $out .= str_repeat(' ', ($level+1)*2);
313 329
                     $out .= '"' . $k . '" : ';
@@ -317,7 +333,9 @@  discard block
 block discarded – undo
317 333
                 $out .= api_output_js($vv, $level+1);
318 334
                 $b = true;
319 335
             }
320
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
336
+            if ($verbose) {
337
+                $out .= "\n" . str_repeat(' ', $level*2);
338
+            }
321 339
             $out .= '}';
322 340
         }
323 341
     } elseif (is_null($v)) {
@@ -349,13 +367,14 @@  discard block
 block discarded – undo
349 367
 # Call an API function
350 368
 
351 369
 function api_call_user_func_or_error($function, $params, $error, $type) {
352
-    if (function_exists($function))
353
-        call_user_func_array($function, $params);
354
-    elseif ($type == 'api')
355
-        api_error($error);
356
-    else
357
-        print "<p style='color:#cc0000'>$error</p>";
358
-}
370
+    if (function_exists($function)) {
371
+            call_user_func_array($function, $params);
372
+    } elseif ($type == 'api') {
373
+            api_error($error);
374
+    } else {
375
+            print "<p style='color:#cc0000'>$error</p>";
376
+    }
377
+    }
359 378
 
360 379
 # Used for testing for conditional responses
361 380
 
@@ -405,8 +424,9 @@  discard block
 block discarded – undo
405 424
         $H = $ma[4];
406 425
         $M = $ma[5];
407 426
         $S = $ma[6];
408
-    } else
409
-        return null;
427
+    } else {
428
+            return null;
429
+    }
410 430
 
411 431
     return gmmktime($H, $M, $S, $m, $d, $Y);
412 432
 }
Please login to merge, or discard this patch.