Completed
Pull Request — master (#1459)
by Nick
09:53
created
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.
www/docs/alert/update-mp/index.php 1 patch
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-$new_style_template = TRUE;
3
+$new_style_template = true;
4 4
 
5 5
 include_once '../../../includes/easyparliament/init.php';
6 6
 include_once INCLUDESPATH . 'easyparliament/member.php';
Please login to merge, or discard this patch.
www/docs/user/login/fb.php 2 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     If the input is not OK, the form is displayed again with error messages.
10 10
 */
11 11
 
12
-$new_style_template = TRUE;
12
+$new_style_template = true;
13 13
 
14 14
 include_once '../../../includes/easyparliament/init.php';
15 15
 # need to include this as login code uses error_message
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@
 block discarded – undo
27 27
 
28 28
 $data['fb_login_url'] = $login->getLoginURL();
29 29
 if (isset($data['token'])) {
30
-  $success = $login->loginUser($data['token']);
31
-  if (!$success) {
30
+    $success = $login->loginUser($data['token']);
31
+    if (!$success) {
32 32
     $data['error'] = 'Could not login using Facebook token';
33 33
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
34
-  }
34
+    }
35 35
 } else {
36 36
     \MySociety\TheyWorkForYou\Renderer::output('login/facebook', $data);
37 37
 }
Please login to merge, or discard this patch.