Passed
Pull Request — master (#1428)
by Nick
06:09
created
www/docs/api/api_getPerson.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party=false) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
         $URL = new \MySociety\TheyWorkForYou\Url('mp');
29 29
         $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house'], $row['person_id']);
30 30
     }
31
-    if ($has_party && isset($parties[$row['party']]))
32
-        $row['party'] = $parties[$row['party']];
31
+    if ($has_party && isset($parties[$row['party']])) {
32
+            $row['party'] = $parties[$row['party']];
33
+    }
33 34
     list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 35
     if ($image) {
35 36
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
@@ -49,7 +50,9 @@  discard block
 block discarded – undo
49 50
     }
50 51
 
51 52
     foreach ($row as $k => $r) {
52
-        if (is_string($r)) $row[$k] = html_entity_decode($r);
53
+        if (is_string($r)) {
54
+            $row[$k] = html_entity_decode($r);
55
+        }
53 56
     }
54 57
 
55 58
     return $row;
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
         $out = _api_getPerson_row($row, $house == HOUSE_TYPE_ROYAL ? false : true);
86 89
         $output[] = $out;
87 90
         $time = strtotime($row['lastupdate']);
88
-        if ($time > $last_mod)
89
-            $last_mod = $time;
91
+        if ($time > $last_mod) {
92
+                    $last_mod = $time;
93
+        }
90 94
     }
91 95
     # Only one MP, not an array
92 96
     if ($flatten && count($output) == 1 && $house == HOUSE_TYPE_COMMONS) {
@@ -134,13 +138,18 @@  discard block
 block discarded – undo
134 138
 
135 139
     $cons = array();
136 140
     foreach ($constituencies as $constituency) {
137
-        if ($constituency == '') continue;
138
-        if ($constituency == 'Orkney ')
139
-            $constituency = 'Orkney & Shetland';
141
+        if ($constituency == '') {
142
+            continue;
143
+        }
144
+        if ($constituency == 'Orkney ') {
145
+                    $constituency = 'Orkney & Shetland';
146
+        }
140 147
 
141 148
         if ($house == HOUSE_TYPE_COMMONS) {
142 149
             $normalised = MySociety\TheyWorkForYou\Utility\Constituencies::normaliseConstituencyName($constituency);
143
-            if ($normalised) $constituency = $normalised;
150
+            if ($normalised) {
151
+                $constituency = $normalised;
152
+            }
144 153
         }
145 154
 
146 155
         $cons[] = $constituency;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 <?php
18 18
 }
19 19
 
20
-function _api_getPerson_row($row, $has_party=FALSE) {
20
+function _api_getPerson_row($row, $has_party = FALSE) {
21 21
     global $parties;
22 22
     $row['full_name'] = member_full_name($row['house'], $row['title'], $row['given_name'],
23 23
         $row['family_name'], $row['lordofname']);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     }
31 31
     if ($has_party && isset($parties[$row['party']]))
32 32
         $row['party'] = $parties[$row['party']];
33
-    list($image,$sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
33
+    list($image, $sz) = MySociety\TheyWorkForYou\Utility\Member::findMemberImage($row['person_id']);
34 34
     if ($image) {
35 35
         list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
36 36
         $row['image'] = $image;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     return $row;
56 56
 }
57 57
 
58
-function api_getPerson_id($id, $house='') {
58
+function api_getPerson_id($id, $house = '') {
59 59
     $db = new ParlDB;
60 60
     $params = array(
61 61
         ':person_id' => $id
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     }
78 78
 }
79 79
 
80
-function _api_getPerson_output($q, $flatten=false) {
80
+function _api_getPerson_output($q, $flatten = false) {
81 81
     $output = array();
82 82
     $last_mod = 0;
83 83
     $house = null;
Please login to merge, or discard this patch.
www/docs/api/api_functions.php 4 patches
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   +14 added lines, -14 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
 }
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
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.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -146,20 +146,20 @@  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
                 ))->first();
156
-  if (!$q) {
156
+    if (!$q) {
157 157
     return false;
158
-  }
159
-  if ($q['status'] == 'Superuser') {
158
+    }
159
+    if ($q['status'] == 'Superuser') {
160 160
     return true;
161
-  } 
162
-  return false;
161
+    } 
162
+    return false;
163 163
 }
164 164
 
165 165
 function api_check_key($key) {
@@ -338,12 +338,12 @@  discard block
 block discarded – undo
338 338
     // we only want to convert to iso if it's an actual API call
339 339
     // so skip this if it's a documentation page
340 340
     if (!get_http_var('docs')) {
341
-      // and then catch any errors in the conversion and just ignore
342
-      // them and return the unconverted results
343
-      $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
344
-      if ($converted_out !== FALSE) {
341
+        // and then catch any errors in the conversion and just ignore
342
+        // them and return the unconverted results
343
+        $converted_out = @iconv('utf-8', 'iso-8859-1//TRANSLIT', $out);
344
+        if ($converted_out !== FALSE) {
345 345
         $out = $converted_out;
346
-      }
346
+        }
347 347
     }
348 348
 
349 349
     return $out;
Please login to merge, or discard this patch.
Braces   +31 added lines, -16 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);
@@ -204,7 +206,9 @@  discard block
 block discarded – undo
204 206
     $output = get_http_var('output');
205 207
     if (!get_http_var('docs')) {
206 208
         $cond = api_header($output, $last_mod);
207
-        if ($cond) return;
209
+        if ($cond) {
210
+            return;
211
+        }
208 212
     }
209 213
     if ($output == 'xml') {
210 214
         $out = '<?xml version="1.0" encoding="utf-8"?>'."\n";
@@ -215,7 +219,8 @@  discard block
 block discarded – undo
215 219
         $out = api_output_rabx($arr);
216 220
     } elseif ($output == 'json') {
217 221
         $out = json_encode($arr, JSON_PRETTY_PRINT);
218
-    } else { # JS
222
+    } else {
223
+# JS
219 224
         $out = api_output_js($arr);
220 225
         $callback = get_http_var('callback');
221 226
         if (preg_match('#^[A-Za-z0-9._[\]]+$#', $callback)) {
@@ -251,8 +256,9 @@  discard block
 block discarded – undo
251 256
     }
252 257
     #$type = 'text/plain';
253 258
     header("Content-Type: $type; charset=$charset");
254
-    if ($last_mod>0)
255
-        header('Last-Modified: ' . date('r', $last_mod));
259
+    if ($last_mod>0) {
260
+            header('Last-Modified: ' . date('r', $last_mod));
261
+    }
256 262
     return false;
257 263
 }
258 264
 
@@ -262,14 +268,18 @@  discard block
 block discarded – undo
262 268
 
263 269
 function api_output_php($arr) {
264 270
     $out = serialize($arr);
265
-    if (get_http_var('verbose')) $out = str_replace(';', ";\n", $out);
271
+    if (get_http_var('verbose')) {
272
+        $out = str_replace(';', ";\n", $out);
273
+    }
266 274
     return $out;
267 275
 }
268 276
 
269 277
 function api_output_rabx($arr) {
270 278
     $out = '';
271 279
     rabx_wire_wr($arr, $out);
272
-    if (get_http_var('verbose')) $out = str_replace(',', ",\n", $out);
280
+    if (get_http_var('verbose')) {
281
+        $out = str_replace(',', ",\n", $out);
282
+    }
273 283
     return $out;
274 284
 }
275 285
 
@@ -310,7 +320,9 @@  discard block
 block discarded – undo
310 320
             $out = '{' . $verbose;
311 321
             $b = false;
312 322
             foreach ($v as $k => $vv) {
313
-                if ($b) $out .= ",$verbose";
323
+                if ($b) {
324
+                    $out .= ",$verbose";
325
+                }
314 326
                 if ($verbose) {
315 327
                     $out .= str_repeat(' ', ($level+1)*2);
316 328
                     $out .= '"' . $k . '" : ';
@@ -320,7 +332,9 @@  discard block
 block discarded – undo
320 332
                 $out .= api_output_js($vv, $level+1);
321 333
                 $b = true;
322 334
             }
323
-            if ($verbose) $out .= "\n" . str_repeat(' ', $level*2);
335
+            if ($verbose) {
336
+                $out .= "\n" . str_repeat(' ', $level*2);
337
+            }
324 338
             $out .= '}';
325 339
         }
326 340
     } elseif (is_null($v)) {
@@ -352,13 +366,14 @@  discard block
 block discarded – undo
352 366
 # Call an API function
353 367
 
354 368
 function api_call_user_func_or_error($function, $params, $error, $type) {
355
-    if (function_exists($function))
356
-        call_user_func_array($function, $params);
357
-    elseif ($type == 'api')
358
-        api_error($error);
359
-    else
360
-        print "<p style='color:#cc0000'>$error</p>";
361
-}
369
+    if (function_exists($function)) {
370
+            call_user_func_array($function, $params);
371
+    } elseif ($type == 'api') {
372
+            api_error($error);
373
+    } else {
374
+            print "<p style='color:#cc0000'>$error</p>";
375
+    }
376
+    }
362 377
 
363 378
 # Used for testing for conditional responses
364 379
 
Please login to merge, or discard this patch.
www/docs/admin/featured.php 2 patches
Upper-Lower-Casing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
     $related2 = get_http_var('related2');
108 108
     $related3 = get_http_var('related3');
109 109
 
110
-    $gid = $url ? get_gid_from_url($url) : NULL;
111
-    $related_gid1 = $related1 ? get_gid_from_url($related1) : NULL;
112
-    $related_gid2 = $related2 ? get_gid_from_url($related2) : NULL;
113
-    $related_gid3 = $related3 ? get_gid_from_url($related3) : NULL;
110
+    $gid = $url ? get_gid_from_url($url) : null;
111
+    $related_gid1 = $related1 ? get_gid_from_url($related1) : null;
112
+    $related_gid2 = $related2 ? get_gid_from_url($related2) : null;
113
+    $related_gid3 = $related3 ? get_gid_from_url($related3) : null;
114 114
 
115 115
     print "<h2>Preview Content</h2>";
116
-    if ( $gid !== NULL ) {
116
+    if ( $gid !== null ) {
117 117
         $h = new MySociety\TheyWorkForYou\Homepage;
118 118
         $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 ));
119 119
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 }
154 154
 
155 155
 function get_gid_from_url($url) {
156
-    $gid = NULL;
156
+    $gid = null;
157 157
     $parts = parse_url($url);
158 158
     parse_str($parts['query'], $query);
159 159
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 $out = '';
13 13
 if (get_http_var('preview')) {
14 14
     preview_featured();
15
-} else if ( get_http_var('confirm') ) {
15
+} else if (get_http_var('confirm')) {
16 16
     $out = update_featured();
17 17
 }
18 18
 
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 print '</div>';
24 24
 
25 25
 function gid_to_url($gid) {
26
-    if ( !$gid ) {
26
+    if (!$gid) {
27 27
         return '';
28 28
     }
29 29
     global $hansardmajors;
30 30
     global $db;
31 31
 
32
-    $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array( ':gid' => $gid ))->first();
32
+    $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid))->first();
33 33
     $url_gid = fix_gid_from_db($gid);
34 34
     $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q['major']]['page']);
35 35
     $url->insert(array('id' => $url_gid));
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     $related = $featured->get_related();
44 44
     $context = $featured->get_context();
45 45
 
46
-    if ( get_http_var('url') ) {
46
+    if (get_http_var('url')) {
47 47
         $url = get_http_var('url');
48 48
         $title = get_http_var('title');
49 49
         $context = get_http_var('context');
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
     $related_gid3 = $related3 ? get_gid_from_url($related3) : NULL;
114 114
 
115 115
     print "<h2>Preview Content</h2>";
116
-    if ( $gid !== NULL ) {
116
+    if ($gid !== NULL) {
117 117
         $h = new MySociety\TheyWorkForYou\Homepage;
118
-        $featured = $h->getFeaturedDebate($gid, $title, $context, array( $related_gid1, $related_gid2, $related_gid3 ));
118
+        $featured = $h->getFeaturedDebate($gid, $title, $context, array($related_gid1, $related_gid2, $related_gid3));
119 119
 
120 120
         include INCLUDESPATH . 'easyparliament/templates/html/homepage/featured.php';
121 121
     } else {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     $parts = parse_url($url);
158 158
     parse_str($parts['query'], $query);
159 159
 
160
-    if ( $query['id'] ) {
160
+    if ($query['id']) {
161 161
         if (strpos($parts['path'], 'lords') !== false) {
162 162
             $gid = 'uk.org.publicwhip/lords/';
163 163
         } elseif (strpos($parts['path'], 'whall') !== false) {
Please login to merge, or discard this patch.
www/docs/admin/photos.php 3 patches
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 </form>
140 140
 
141 141
 <p style="clear:both; margin-top: 3em"><a href="/images/mps/photo-status.php">List MPs without photos</a></p>
142
-EOF;
142
+eof;
143 143
 
144 144
     return $out;
145 145
 }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     <span class="formw"><input type="submit" name="submit" value="Update attribution"></span>
194 194
 </div>
195 195
 </form>
196
-EOF;
196
+eof;
197 197
 
198 198
     return $out;
199 199
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
         } else {
112 112
             $desc .= ' [no photo]';
113 113
         }
114
-        $out .= '<option value="'.$p_id.'">'.$desc.'</option>' . "\n";
114
+        $out .= '<option value="' . $p_id . '">' . $desc . '</option>' . "\n";
115 115
     }
116 116
 
117 117
     $out .= ' </select></span> </div> ';
Please login to merge, or discard this patch.
Braces   +36 added lines, -26 removed lines patch added patch discarded remove patch
@@ -35,28 +35,33 @@  discard block
 block discarded – undo
35 35
     $pid = intval(get_http_var('pid'));
36 36
     $errors = array();
37 37
 
38
-    if (!array_key_exists('photo', $_FILES))
39
-        array_push($errors, 'Not got the photo.');
40
-    elseif ($_FILES['photo']['error'] > 0)
41
-        array_push($errors, 'There was an error uploading the photo.');
42
-    elseif (!is_uploaded_file($_FILES['photo']['tmp_name']))
43
-        array_push($errors, 'Did not get an uploaded file.');
44
-    else {
38
+    if (!array_key_exists('photo', $_FILES)) {
39
+            array_push($errors, 'Not got the photo.');
40
+    } elseif ($_FILES['photo']['error'] > 0) {
41
+            array_push($errors, 'There was an error uploading the photo.');
42
+    } elseif (!is_uploaded_file($_FILES['photo']['tmp_name'])) {
43
+            array_push($errors, 'Did not get an uploaded file.');
44
+    } else {
45 45
         $tmp_name = $_FILES['photo']['tmp_name'];
46 46
 
47 47
         $image = new Imagick();
48 48
         $image->readImage($tmp_name);
49
-        if (!$image)
50
-            array_push($errors, 'Failed to read image from uploaded file');
49
+        if (!$image) {
50
+                    array_push($errors, 'Failed to read image from uploaded file');
51
+        }
51 52
             $imageS = clone $image;
52
-        if (!$image->scaleImage(0, 118))
53
-            array_push($errors, 'Scaling large failed');
54
-        if (!$imageS->scaleImage(0, 59))
55
-            array_push($errors, 'Scaling small failed');
56
-        if (!$image->writeImage("$dir/mpsL/$pid.jpeg"))
57
-            array_push($errors, "Saving to $dir/mpsL/$pid.jpeg failed");
58
-        if (!$imageS->writeImage("$dir/mps/$pid.jpeg"))
59
-            array_push($errors, "Saving to $dir/mps/$pid.jpeg failed");
53
+        if (!$image->scaleImage(0, 118)) {
54
+                    array_push($errors, 'Scaling large failed');
55
+        }
56
+        if (!$imageS->scaleImage(0, 59)) {
57
+                    array_push($errors, 'Scaling small failed');
58
+        }
59
+        if (!$image->writeImage("$dir/mpsL/$pid.jpeg")) {
60
+                    array_push($errors, "Saving to $dir/mpsL/$pid.jpeg failed");
61
+        }
62
+        if (!$imageS->writeImage("$dir/mps/$pid.jpeg")) {
63
+                    array_push($errors, "Saving to $dir/mps/$pid.jpeg failed");
64
+        }
60 65
         if (!$errors) {
61 66
             print "<pre>";
62 67
             chdir($dir);
@@ -69,8 +74,9 @@  discard block
 block discarded – undo
69 74
         }
70 75
     }
71 76
 
72
-    if ($errors)
73
-        return display_photo_form($errors);
77
+    if ($errors) {
78
+            return display_photo_form($errors);
79
+    }
74 80
     return "<p><em>Photo uploaded and resized for pid $pid</em> &mdash; check how it looks <a href=\"/mp?p=$pid\">on their page</a></p>" . display_photo_form();
75 81
 }
76 82
 
@@ -98,7 +104,9 @@  discard block
 block discarded – undo
98 104
         $house = $row['house'];
99 105
         $desc = member_full_name($house, $row['title'], $row['given_name'], $row['family_name'], $row['lordofname']) .
100 106
                 " " . $houses[$house];
101
-        if ($row['party']) $desc .= ' (' . $row['party'] . ')';
107
+        if ($row['party']) {
108
+            $desc .= ' (' . $row['party'] . ')';
109
+        }
102 110
         if ($row['constituency']) {
103 111
             $desc .= ', ' . $row['constituency'];
104 112
         }
@@ -149,13 +157,15 @@  discard block
 block discarded – undo
149 157
     $attr_link = get_http_var('attr_link');
150 158
     $errors = array();
151 159
 
152
-    if (!$pid || !$attr_text)
153
-        array_push($errors, 'Missing information');
154
-    elseif ($attr_link && substr($attr_link, 0, 4) != 'http')
155
-        array_push($errors, 'Bad link');
160
+    if (!$pid || !$attr_text) {
161
+            array_push($errors, 'Missing information');
162
+    } elseif ($attr_link && substr($attr_link, 0, 4) != 'http') {
163
+            array_push($errors, 'Bad link');
164
+    }
156 165
 
157
-    if ($errors)
158
-        return display_attribution_form($errors);
166
+    if ($errors) {
167
+            return display_attribution_form($errors);
168
+    }
159 169
 
160 170
     # UPDATE
161 171
     global $db;
Please login to merge, or discard this patch.
scripts/video-mark-missing.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,6 +37,6 @@
 block discarded – undo
37 37
 if ($to)
38 38
     $query .= " and hpos<=$hpos_to";
39 39
 
40
-print "Executing $query...\n";
40
+print "executing $query...\n";
41 41
 $q = $db->query($query);
42 42
 print '  ' . $q->affected_rows() . " rows have been marked as missing\n";
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 $date = substr($from, 0, 10);
18 18
 $from = 'uk.org.publicwhip/debate/' . $from;
19
-if ($to) $to = 'uk.org.publicwhip/debate/' . $to;
19
+if ($to) {
20
+    $to = 'uk.org.publicwhip/debate/' . $to;
21
+}
20 22
 
21 23
 $q = $db->query('select hpos from hansard where gid="' . $from . '"')->first();
22 24
 $hpos_from = $q['hpos'];
@@ -34,8 +36,9 @@  discard block
 block discarded – undo
34 36
 
35 37
 $query = "update hansard set video_status = video_status | 8
36 38
     where major=1 and hdate='$date' and hpos>=$hpos_from";
37
-if ($to)
39
+if ($to) {
38 40
     $query .= " and hpos<=$hpos_to";
41
+}
39 42
 
40 43
 print "Executing $query...\n";
41 44
 $q = $db->query($query);
Please login to merge, or discard this patch.
scripts/alertgonemps.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,7 +139,7 @@
 block discarded – undo
139 139
 	global $globalsuccess, $sentemails, $nomail, $start_time;
140 140
 
141 141
 	$sentemails++;
142
-	mlog("SEND $sentemails : Sending email to $current[email] ... ");
142
+	mlog("send $sentemails : Sending email to $current[email] ... ");
143 143
 	$d = array('to' => $current['email'], 'template' => $template);
144 144
 	$m = array(
145 145
 		'DATA' => join("\n", $data),
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 $fromflag = false;
23 23
 $toemail = '';
24 24
 $template = 'alert_gone';
25
-for ($k=1; $k<$argc; $k++) {
25
+for ($k = 1; $k < $argc; $k++) {
26 26
 	if ($argv[$k] == '--nomail')
27 27
 		$nomail = true;
28 28
 	if (preg_match('#^--only=(.*)$#', $argv[$k], $m))
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			$user_id = 0;
112 112
 			$unregistered++;
113 113
 		}	
114
-		mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
114
+		mlog("\nEMAIL: $email, uid $user_id; memory usage : " . memory_get_usage() . "\n");
115 115
 	}
116 116
 
117 117
     $lh = $member->left_house();
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 } else {
132 132
       $sss .= 'Something went wrong! Total time: ';
133 133
 }
134
-$sss .= (getmicrotime()-$global_start)."\n\n";
134
+$sss .= (getmicrotime() - $global_start) . "\n\n";
135 135
 mlog($sss);
136 136
 mlog(date('r') . "\n");
137 137
 
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	$m = array(
145 145
 		'DATA' => join("\n", $data),
146 146
 		'MANAGE' => 'https://www.theyworkforyou.com/D/' . $current['token'],
147
-        'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are',
148
-        'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts',
147
+        'ALERT_IS' => count($data) == 1 ? 'alert is' : 'alerts are',
148
+        'ALERTS' => count($data) == 1 ? 'an alert' : 'some alerts',
149 149
 	);
150 150
 	if (!$nomail) {
151 151
 		$success = send_template_email($d, $m, true);
152 152
 		mlog("sent ... ");
153 153
 		# sleep if time between sending mails is less than a certain number of seconds on average
154
-		if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
154
+		if (((time() - $start_time) / $sentemails) < 0.5) { # number of seconds per mail not to be quicker than
155 155
 			mlog("pausing ... ");
156 156
 			sleep(1);
157 157
 		}
Please login to merge, or discard this patch.
Braces   +51 added lines, -25 removed lines patch added patch discarded remove patch
@@ -23,14 +23,18 @@  discard block
 block discarded – undo
23 23
 $toemail = '';
24 24
 $template = 'alert_gone';
25 25
 for ($k=1; $k<$argc; $k++) {
26
-	if ($argv[$k] == '--nomail')
27
-		$nomail = true;
28
-	if (preg_match('#^--only=(.*)$#', $argv[$k], $m))
29
-		$onlyemail = $m[1];
30
-	if (preg_match('#^--from=(.*)$#', $argv[$k], $m))
31
-		$fromemail = $m[1];
32
-	if (preg_match('#^--to=(.*)$#', $argv[$k], $m))
33
-		$toemail = $m[1];
26
+	if ($argv[$k] == '--nomail') {
27
+			$nomail = true;
28
+	}
29
+	if (preg_match('#^--only=(.*)$#', $argv[$k], $m)) {
30
+			$onlyemail = $m[1];
31
+	}
32
+	if (preg_match('#^--from=(.*)$#', $argv[$k], $m)) {
33
+			$fromemail = $m[1];
34
+	}
35
+	if (preg_match('#^--to=(.*)$#', $argv[$k], $m)) {
36
+			$toemail = $m[1];
37
+	}
34 38
 	if (preg_match('#^--template=(.*)$#', $argv[$k], $m)) {
35 39
 		$template = $m[1];
36 40
 		# Tee hee
@@ -41,7 +45,9 @@  discard block
 block discarded – undo
41 45
 #if (DEVSITE)
42 46
 #	$nomail = true;
43 47
 
44
-if ($nomail) mlog("NOT SENDING EMAIL\n");
48
+if ($nomail) {
49
+    mlog("NOT SENDING EMAIL\n");
50
+}
45 51
 if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) {
46 52
 	mlog("Can't have both from/to and only!\n");
47 53
 	exit;
@@ -70,13 +76,23 @@  discard block
 block discarded – undo
70 76
 foreach ($alertdata as $alertitem) {
71 77
 	$active++;
72 78
 	$email = $alertitem['email'];
73
-    if ($onlyemail && $email != $onlyemail) continue;
74
-    if ($fromemail && strtolower($email) == $fromemail) $fromflag = true;
75
-    if ($fromemail && !$fromflag) continue;
76
-    if ($toemail && strtolower($email) >= $toemail) continue;
79
+    if ($onlyemail && $email != $onlyemail) {
80
+        continue;
81
+    }
82
+    if ($fromemail && strtolower($email) == $fromemail) {
83
+        $fromflag = true;
84
+    }
85
+    if ($fromemail && !$fromflag) {
86
+        continue;
87
+    }
88
+    if ($toemail && strtolower($email) >= $toemail) {
89
+        continue;
90
+    }
77 91
     $criteria_raw = $alertitem['criteria'];
78 92
 
79
-	if (!strstr($criteria_raw, 'speaker:')) continue;
93
+	if (!strstr($criteria_raw, 'speaker:')) {
94
+	    continue;
95
+	}
80 96
 
81 97
 	preg_match('#speaker:(\d+)#', $criteria_raw, $m);
82 98
 	$person_id = $m[1];
@@ -85,7 +101,9 @@  discard block
 block discarded – undo
85 101
         $members[$person_id] = new MEMBER(array('person_id' => $person_id));
86 102
 	}
87 103
     $member = $members[$person_id];
88
-    if ($member->current_member_anywhere()) continue;
104
+    if ($member->current_member_anywhere()) {
105
+        continue;
106
+    }
89 107
 
90 108
     if (in_array($member->full_name(), array(
91 109
         'Mr Paul Boateng', 'Mrs Helen Liddell', 'Jack McConnell', 'Tim Boswell',
@@ -94,11 +112,14 @@  discard block
 block discarded – undo
94 112
         'Hilary Armstrong', 'Des Browne', 'Quentin Davies', 'Beverley Hughes',
95 113
         'John Hutton', 'Jim Knight', 'Thomas McAvoy', 'John McFall', 'John Prescott',
96 114
         'John Reid', 'Angela Smith', 'Don Touhig', 'Michael Wills', 'Ian Paisley',
97
-    ))) continue;
115
+    ))) {
116
+        continue;
117
+    }
98 118
 
99 119
 	if ($email != $current['email']) {
100
-		if ($email_text)
101
-            write_and_send_email($current, $email_text, $template);
120
+		if ($email_text) {
121
+		            write_and_send_email($current, $email_text, $template);
122
+		}
102 123
 		$current['email'] = $email;
103 124
 		$current['token'] = $alertitem['alert_id'] . '-' . $alertitem['registrationtoken'];
104 125
 		$email_text = array();
@@ -117,11 +138,13 @@  discard block
 block discarded – undo
117 138
     $lh = $member->left_house();
118 139
     $lh = array_shift($lh);
119 140
     $text = '* ' . $member->full_name() . ', left ' . $lh['date_pretty'];
120
-    if (!in_array($text, $email_text))
121
-	    $email_text[] = $text;
122
-}
123
-if ($email_text)
141
+    if (!in_array($text, $email_text)) {
142
+    	    $email_text[] = $text;
143
+    }
144
+    }
145
+if ($email_text) {
124 146
     write_and_send_email($current, $email_text, $template);
147
+}
125 148
 
126 149
 mlog("\n");
127 150
 
@@ -151,7 +174,8 @@  discard block
 block discarded – undo
151 174
 		$success = send_template_email($d, $m, true);
152 175
 		mlog("sent ... ");
153 176
 		# sleep if time between sending mails is less than a certain number of seconds on average
154
-		if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
177
+		if (((time() - $start_time) / $sentemails) < 0.5 ) {
178
+# number of seconds per mail not to be quicker than
155 179
 			mlog("pausing ... ");
156 180
 			sleep(1);
157 181
 		}
@@ -160,6 +184,8 @@  discard block
 block discarded – undo
160 184
 		$success = 1;
161 185
 	}
162 186
 	mlog("done\n");
163
-	if (!$success) $globalsuccess = 0;
164
-}
187
+	if (!$success) {
188
+	    $globalsuccess = 0;
189
+	}
190
+	}
165 191
 
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
 $toemail = '';
24 24
 $template = 'alert_gone';
25 25
 for ($k=1; $k<$argc; $k++) {
26
-	if ($argv[$k] == '--nomail')
27
-		$nomail = true;
28
-	if (preg_match('#^--only=(.*)$#', $argv[$k], $m))
29
-		$onlyemail = $m[1];
30
-	if (preg_match('#^--from=(.*)$#', $argv[$k], $m))
31
-		$fromemail = $m[1];
32
-	if (preg_match('#^--to=(.*)$#', $argv[$k], $m))
33
-		$toemail = $m[1];
34
-	if (preg_match('#^--template=(.*)$#', $argv[$k], $m)) {
35
-		$template = $m[1];
36
-		# Tee hee
37
-		$template = "../../../../../../../../../../home/twfy-live/email-alert-templates/alert_mailout_$template";
38
-	}
26
+    if ($argv[$k] == '--nomail')
27
+        $nomail = true;
28
+    if (preg_match('#^--only=(.*)$#', $argv[$k], $m))
29
+        $onlyemail = $m[1];
30
+    if (preg_match('#^--from=(.*)$#', $argv[$k], $m))
31
+        $fromemail = $m[1];
32
+    if (preg_match('#^--to=(.*)$#', $argv[$k], $m))
33
+        $toemail = $m[1];
34
+    if (preg_match('#^--template=(.*)$#', $argv[$k], $m)) {
35
+        $template = $m[1];
36
+        # Tee hee
37
+        $template = "../../../../../../../../../../home/twfy-live/email-alert-templates/alert_mailout_$template";
38
+    }
39 39
 }
40 40
 
41 41
 #if (DEVSITE)
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 
44 44
 if ($nomail) mlog("NOT SENDING EMAIL\n");
45 45
 if (($fromemail && $onlyemail) || ($toemail && $onlyemail)) {
46
-	mlog("Can't have both from/to and only!\n");
47
-	exit;
46
+    mlog("Can't have both from/to and only!\n");
47
+    exit;
48 48
 }
49 49
 
50 50
 $active = 0;
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 $members = array();
69 69
 $start_time = time();
70 70
 foreach ($alertdata as $alertitem) {
71
-	$active++;
72
-	$email = $alertitem['email'];
71
+    $active++;
72
+    $email = $alertitem['email'];
73 73
     if ($onlyemail && $email != $onlyemail) continue;
74 74
     if ($fromemail && strtolower($email) == $fromemail) $fromflag = true;
75 75
     if ($fromemail && !$fromflag) continue;
76 76
     if ($toemail && strtolower($email) >= $toemail) continue;
77 77
     $criteria_raw = $alertitem['criteria'];
78 78
 
79
-	if (!strstr($criteria_raw, 'speaker:')) continue;
79
+    if (!strstr($criteria_raw, 'speaker:')) continue;
80 80
 
81
-	preg_match('#speaker:(\d+)#', $criteria_raw, $m);
82
-	$person_id = $m[1];
83
-	if (!isset($members[$person_id])) {
81
+    preg_match('#speaker:(\d+)#', $criteria_raw, $m);
82
+    $person_id = $m[1];
83
+    if (!isset($members[$person_id])) {
84 84
         $queries++;
85 85
         $members[$person_id] = new MEMBER(array('person_id' => $person_id));
86
-	}
86
+    }
87 87
     $member = $members[$person_id];
88 88
     if ($member->current_member_anywhere()) continue;
89 89
 
@@ -96,29 +96,29 @@  discard block
 block discarded – undo
96 96
         'John Reid', 'Angela Smith', 'Don Touhig', 'Michael Wills', 'Ian Paisley',
97 97
     ))) continue;
98 98
 
99
-	if ($email != $current['email']) {
100
-		if ($email_text)
99
+    if ($email != $current['email']) {
100
+        if ($email_text)
101 101
             write_and_send_email($current, $email_text, $template);
102
-		$current['email'] = $email;
103
-		$current['token'] = $alertitem['alert_id'] . '-' . $alertitem['registrationtoken'];
104
-		$email_text = array();
105
-		$q = $db->query('SELECT user_id FROM users WHERE email = :email', array(
102
+        $current['email'] = $email;
103
+        $current['token'] = $alertitem['alert_id'] . '-' . $alertitem['registrationtoken'];
104
+        $email_text = array();
105
+        $q = $db->query('SELECT user_id FROM users WHERE email = :email', array(
106 106
             ':email' => $email))->first();
107 107
         if ($q) {
108 108
             $user_id = $q['user_id'];
109 109
             $registered++;
110
-		} else {
111
-			$user_id = 0;
112
-			$unregistered++;
113
-		}	
114
-		mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
115
-	}
110
+        } else {
111
+            $user_id = 0;
112
+            $unregistered++;
113
+        }	
114
+        mlog("\nEMAIL: $email, uid $user_id; memory usage : ".memory_get_usage()."\n");
115
+    }
116 116
 
117 117
     $lh = $member->left_house();
118 118
     $lh = array_shift($lh);
119 119
     $text = '* ' . $member->full_name() . ', left ' . $lh['date_pretty'];
120 120
     if (!in_array($text, $email_text))
121
-	    $email_text[] = $text;
121
+        $email_text[] = $text;
122 122
 }
123 123
 if ($email_text)
124 124
     write_and_send_email($current, $email_text, $template);
@@ -127,39 +127,39 @@  discard block
 block discarded – undo
127 127
 
128 128
 $sss = "Active alerts: $active\nEmail lookups: $registered registered, $unregistered unregistered\nQuery lookups: $queries\nSent emails: $sentemails\n";
129 129
 if ($globalsuccess) {
130
-      $sss .= 'Everything went swimmingly, in ';
130
+        $sss .= 'Everything went swimmingly, in ';
131 131
 } else {
132
-      $sss .= 'Something went wrong! Total time: ';
132
+        $sss .= 'Something went wrong! Total time: ';
133 133
 }
134 134
 $sss .= (getmicrotime()-$global_start)."\n\n";
135 135
 mlog($sss);
136 136
 mlog(date('r') . "\n");
137 137
 
138 138
 function write_and_send_email($current, $data, $template) {
139
-	global $globalsuccess, $sentemails, $nomail, $start_time;
140
-
141
-	$sentemails++;
142
-	mlog("SEND $sentemails : Sending email to $current[email] ... ");
143
-	$d = array('to' => $current['email'], 'template' => $template);
144
-	$m = array(
145
-		'DATA' => join("\n", $data),
146
-		'MANAGE' => 'https://www.theyworkforyou.com/D/' . $current['token'],
139
+    global $globalsuccess, $sentemails, $nomail, $start_time;
140
+
141
+    $sentemails++;
142
+    mlog("SEND $sentemails : Sending email to $current[email] ... ");
143
+    $d = array('to' => $current['email'], 'template' => $template);
144
+    $m = array(
145
+        'DATA' => join("\n", $data),
146
+        'MANAGE' => 'https://www.theyworkforyou.com/D/' . $current['token'],
147 147
         'ALERT_IS' => count($data)==1 ? 'alert is' : 'alerts are',
148 148
         'ALERTS' => count($data)==1 ? 'an alert' : 'some alerts',
149
-	);
150
-	if (!$nomail) {
151
-		$success = send_template_email($d, $m, true);
152
-		mlog("sent ... ");
153
-		# sleep if time between sending mails is less than a certain number of seconds on average
154
-		if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
155
-			mlog("pausing ... ");
156
-			sleep(1);
157
-		}
158
-	} else {
159
-		mlog(join('', $data));
160
-		$success = 1;
161
-	}
162
-	mlog("done\n");
163
-	if (!$success) $globalsuccess = 0;
149
+    );
150
+    if (!$nomail) {
151
+        $success = send_template_email($d, $m, true);
152
+        mlog("sent ... ");
153
+        # sleep if time between sending mails is less than a certain number of seconds on average
154
+        if (((time() - $start_time) / $sentemails) < 0.5 ) { # number of seconds per mail not to be quicker than
155
+            mlog("pausing ... ");
156
+            sleep(1);
157
+        }
158
+    } else {
159
+        mlog(join('', $data));
160
+        $success = 1;
161
+    }
162
+    mlog("done\n");
163
+    if (!$success) $globalsuccess = 0;
164 164
 }
165 165
 
Please login to merge, or discard this patch.
scripts/mprss.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 			$contentencoded = $row['body'];
54 54
 				
55 55
 			$hdate = format_date($row['hdate'], 'Y-m-d');
56
-			if ($row['htime'] != NULL) {
56
+			if ($row['htime'] != null) {
57 57
 				$htime = format_time($row['htime'], 'H:i:s');
58 58
 			} else {
59 59
 				$htime = '00:00:00';
Please login to merge, or discard this patch.
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -22,47 +22,47 @@  discard block
 block discarded – undo
22 22
 foreach ($q as $person) {
23 23
     $person_id = $person['person_id'];
24 24
 
25
-	$args = array ( 'person_id' => $person_id );
26
-	$speeches = $HANSARDLIST->display('person', $args, 'none');
25
+    $args = array ( 'person_id' => $person_id );
26
+    $speeches = $HANSARDLIST->display('person', $args, 'none');
27 27
 
28
-	// Some data about this person that we'll need for the feed.
29
-	$MEMBER = new MEMBER(array('person_id' => $person_id));
30
-	$MPURL = new \MySociety\TheyWorkForYou\Url('mp');
31
-	$MPURL->insert(array('pid'=>$person_id));
32
-	$mpurl = $MPURL->generate();
28
+    // Some data about this person that we'll need for the feed.
29
+    $MEMBER = new MEMBER(array('person_id' => $person_id));
30
+    $MPURL = new \MySociety\TheyWorkForYou\Url('mp');
31
+    $MPURL->insert(array('pid'=>$person_id));
32
+    $mpurl = $MPURL->generate();
33 33
 
34
-	$date = gmdate('Y-m-d');
35
-	$time = gmdate('H:i:s');
36
-	$datenow = $date . 'T' . $time . '+00:00';
34
+    $date = gmdate('Y-m-d');
35
+    $time = gmdate('H:i:s');
36
+    $datenow = $date . 'T' . $time . '+00:00';
37 37
 
38
-	// Prepare the meat of the RSS file.
39
-	$items = '';
40
-	$entries = '';
41
-	if (isset ($speeches['rows']) && count($speeches['rows']) > 0) {
38
+    // Prepare the meat of the RSS file.
39
+    $items = '';
40
+    $entries = '';
41
+    if (isset ($speeches['rows']) && count($speeches['rows']) > 0) {
42 42
 
43
-		foreach ($speeches['rows'] as $n => $row) {
43
+        foreach ($speeches['rows'] as $n => $row) {
44 44
 
45
-			// While we're linking to individual speeches,
46
-			// the text is the body of the parent, ie (sub)section.
47
-			$title = _htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
45
+            // While we're linking to individual speeches,
46
+            // the text is the body of the parent, ie (sub)section.
47
+            $title = _htmlentities(str_replace('&#8212;', '-', $row['parent']['body']));
48 48
 
49
-			$link = isset($row['listurl']) ? $row['listurl'] : '';
50
-			$link = 'https://' . DOMAIN . $link;
49
+            $link = isset($row['listurl']) ? $row['listurl'] : '';
50
+            $link = 'https://' . DOMAIN . $link;
51 51
 
52
-			$description = _htmlentities(trim_characters($row['body'], 0, 200));
53
-			$contentencoded = $row['body'];
52
+            $description = _htmlentities(trim_characters($row['body'], 0, 200));
53
+            $contentencoded = $row['body'];
54 54
 
55
-			$hdate = format_date($row['hdate'], 'Y-m-d');
56
-			if ($row['htime'] != NULL) {
57
-				$htime = format_time($row['htime'], 'H:i:s');
58
-			} else {
59
-				$htime = '00:00:00';
60
-			}
55
+            $hdate = format_date($row['hdate'], 'Y-m-d');
56
+            if ($row['htime'] != NULL) {
57
+                $htime = format_time($row['htime'], 'H:i:s');
58
+            } else {
59
+                $htime = '00:00:00';
60
+            }
61 61
 
62
-			$date = $hdate . 'T' . $htime . '+00:00';
62
+            $date = $hdate . 'T' . $htime . '+00:00';
63 63
 
64
-			$items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
65
-			$entries .= "<item rdf:about=\"$link\">
64
+            $items .= '<rdf:li rdf:resource="' . $link . '" />' . "\n";
65
+            $entries .= "<item rdf:about=\"$link\">
66 66
 	<title>$title</title>
67 67
 	<link>$link</link>
68 68
 	<description>$description</description>
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 </item>
72 72
 ";
73 73
 
74
-		}
75
-	}
74
+        }
75
+    }
76 76
 
77
-	// Prepare the whole text of the RSS file.
78
-	$rsstext = '<?xml version="1.0" encoding="utf-8"?>
77
+    // Prepare the whole text of the RSS file.
78
+    $rsstext = '<?xml version="1.0" encoding="utf-8"?>
79 79
 <rdf:RDF
80 80
   xmlns:dc="http://purl.org/dc/elements/1.1/"
81 81
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 
102 102
 </rdf:RDF>';
103 103
 
104
-	// Write the text to the file...
105
-	$filename = $rsspath . $person_id . '.rdf';
106
-	$fh = @fopen($filename, "w");
107
-	if (!$fh) { # Problem writing, just carry on
108
-		echo "Could not write to file ($filename)\n";
109
-		continue;
110
-	}
111
-	fwrite($fh, $rsstext);
112
-	fclose ($fh);
104
+    // Write the text to the file...
105
+    $filename = $rsspath . $person_id . '.rdf';
106
+    $fh = @fopen($filename, "w");
107
+    if (!$fh) { # Problem writing, just carry on
108
+        echo "Could not write to file ($filename)\n";
109
+        continue;
110
+    }
111
+    fwrite($fh, $rsstext);
112
+    fclose ($fh);
113 113
 }
114 114
 
115 115
 #print "Took " . (time()-$starttime) . " seconds\n";
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 $rsspath = BASEDIR . '/rss/mp/';
10 10
 
11 11
 // Make things group writable.
12
-umask (002);
12
+umask(002);
13 13
 
14 14
 $HANSARDLIST = new HANSARDLIST();
15 15
 $db = $HANSARDLIST->db;
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 foreach ($q as $person) {
23 23
     $person_id = $person['person_id'];
24 24
 
25
-	$args = array ( 'person_id' => $person_id );
25
+	$args = array('person_id' => $person_id);
26 26
 	$speeches = $HANSARDLIST->display('person', $args, 'none');
27 27
 
28 28
 	// Some data about this person that we'll need for the feed.
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		continue;
110 110
 	}
111 111
 	fwrite($fh, $rsstext);
112
-	fclose ($fh);
112
+	fclose($fh);
113 113
 }
114 114
 
115 115
 #print "Took " . (time()-$starttime) . " seconds\n";
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 // Get all the person ids we need feeds for...
18 18
 $q = $db->query("SELECT person_id FROM member WHERE left_house='9999-12-31'");
19
-if ($q->rows() <= 0) exit;
19
+if ($q->rows() <= 0) {
20
+    exit;
21
+}
20 22
 
21 23
 $starttime = time();
22 24
 foreach ($q as $person) {
@@ -104,7 +106,8 @@  discard block
 block discarded – undo
104 106
 	// Write the text to the file...
105 107
 	$filename = $rsspath . $person_id . '.rdf';
106 108
 	$fh = @fopen($filename, "w");
107
-	if (!$fh) { # Problem writing, just carry on
109
+	if (!$fh) {
110
+# Problem writing, just carry on
108 111
 		echo "Could not write to file ($filename)\n";
109 112
 		continue;
110 113
 	}
Please login to merge, or discard this patch.
scripts/populate-policy-images.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
49
+while ( ( $policy = fgetcsv($file) ) !== false ) {
50 50
     if ( intval($policy[0]) ) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     exit(1);
34 34
 }
35 35
 
36
-if ( !file_exists($csvfile) ) {
36
+if (!file_exists($csvfile)) {
37 37
     print "$csvfile cannot be found\n";
38 38
     exit(1);
39 39
 }
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 }
47 47
 
48 48
 $count = 0;
49
-while ( ( $policy = fgetcsv($file) ) !== FALSE ) {
50
-    if ( intval($policy[0]) ) {
49
+while (($policy = fgetcsv($file)) !== FALSE) {
50
+    if (intval($policy[0])) {
51 51
         $policy_id = $policy[0];
52 52
         $img_id = $policy[1] ? $policy[1] : $policy_id;
53 53
         $title = $policy[2];
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
                 ':image_attribution' => $attribution,
70 70
                 ':license_url' => $licence_url)
71 71
         );
72
-        if ( $q->success() ) {
72
+        if ($q->success()) {
73 73
             $count += $q->affected_rows();
74 74
         } else {
75 75
             print "failed to update data for $policy_id\n";
Please login to merge, or discard this patch.
tests/Bootstrap.php 2 patches
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@  discard block
 block discarded – undo
8 8
 // Test to make sure we have the test DB environment variables. If not, this isn't testing, so abort.
9 9
 // Define the DB connection constants before we do anything else.
10 10
 if (
11
-    isset($_SERVER['TWFY_TEST_DB_HOST']) AND
12
-    isset($_SERVER['TWFY_TEST_DB_USER']) AND
13
-    isset($_SERVER['TWFY_TEST_DB_PASS']) AND
11
+    isset($_SERVER['TWFY_TEST_DB_HOST']) and
12
+    isset($_SERVER['TWFY_TEST_DB_USER']) and
13
+    isset($_SERVER['TWFY_TEST_DB_PASS']) and
14 14
     isset($_SERVER['TWFY_TEST_DB_NAME'])
15 15
 ) {
16 16
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 }
38 38
 
39 39
 // Explicitly declare we're in testing (avoids trying deploy-only things)
40
-define('TESTING', TRUE);
40
+define('TESTING', true);
41 41
 
42 42
 // Load up the init script (handles the rest of the config, DB connection etc)
43 43
 include_once('www/includes/easyparliament/init.php');
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@
 block discarded – undo
21 21
     define('OPTION_TWFY_DB_NAME', $_SERVER['TWFY_TEST_DB_NAME']);
22 22
     
23 23
     // Define the base directory
24
-    define ("BASEDIR", dirname(__FILE__) . '/../www/docs'); 
24
+    define("BASEDIR", dirname(__FILE__) . '/../www/docs'); 
25 25
 
26 26
     # point to the default mapit
27 27
     define('OPTION_MAPIT_URL', 'https://mapit.mysociety.org/');
28 28
 
29 29
     // If there isn't a config file (most likely this is running an automated test) copy one in.
30
-    if ( ! file_exists(dirname(__FILE__) . '/../conf/general')) {
30
+    if (!file_exists(dirname(__FILE__) . '/../conf/general')) {
31 31
         copy(dirname(__FILE__) . '/../conf/general-example', dirname(__FILE__) . '/../conf/general');
32 32
     }
33 33
 
Please login to merge, or discard this patch.