@@ -17,7 +17,7 @@ |
||
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']); |
@@ -77,6 +77,9 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | +/** |
|
81 | + * @param MySociety\TheyWorkForYou\Db\Query $q |
|
82 | + */ |
|
80 | 83 | function _api_getPerson_output($q, $flatten=false) { |
81 | 84 | $output = array(); |
82 | 85 | $last_mod = 0; |
@@ -95,10 +98,16 @@ discard block |
||
95 | 98 | api_output($output, $last_mod); |
96 | 99 | } |
97 | 100 | |
101 | +/** |
|
102 | + * @param integer $house |
|
103 | + */ |
|
98 | 104 | function api_getPerson_constituency($constituency, $house) { |
99 | 105 | _api_getPerson_constituency(array($constituency), $house); |
100 | 106 | } |
101 | 107 | |
108 | +/** |
|
109 | + * @param integer $house |
|
110 | + */ |
|
102 | 111 | function api_getPerson_postcode($pc, $house) { |
103 | 112 | $pc = preg_replace('#[^a-z0-9 ]#i', '', $pc); |
104 | 113 | $types = array(); |
@@ -28,8 +28,9 @@ discard block |
||
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 |
||
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 |
||
85 | 88 | $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true); |
86 | 89 | $output[] = $out; |
87 | 90 | $time = strtotime($q->field($i, '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 |
||
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; |
@@ -17,7 +17,7 @@ discard block |
||
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 |
||
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; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | # Ministerialships and Select Committees |
44 | 44 | $db = new ParlDB; |
45 | 45 | $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC'); |
46 | - for ($i=0; $i<$q->rows(); $i++) { |
|
46 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
47 | 47 | $row['office'][] = $q->row($i); |
48 | 48 | } |
49 | 49 | } |
@@ -55,7 +55,7 @@ discard block |
||
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,10 +77,10 @@ discard block |
||
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 | - for ($i=0; $i<$q->rows(); $i++) { |
|
83 | + for ($i = 0; $i < $q->rows(); $i++) { |
|
84 | 84 | $house = $q->field($i, 'house'); |
85 | 85 | $out = _api_getPerson_row($q->row($i), $house == HOUSE_TYPE_ROYAL ? false : true); |
86 | 86 | $output[] = $out; |
@@ -107,13 +107,13 @@ discard block |
||
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 |
||
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 |
@@ -12,7 +12,7 @@ discard block |
||
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 |
||
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 )); |
|
32 | + $q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid)); |
|
33 | 33 | $url_gid = fix_gid_from_db($gid); |
34 | 34 | $url = new \MySociety\TheyWorkForYou\Url($hansardmajors[$q->field(0, 'major')]['page']); |
35 | 35 | $url->insert(array('id' => $url_gid)); |
@@ -43,7 +43,7 @@ discard block |
||
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 |
||
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 |
||
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) { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | } |
14 | 14 | |
15 | 15 | if ($type = ucfirst(get_http_var('type'))) { |
16 | - $class_name = "MySociety\TheyWorkForYou\SectionView\\${type}View"; |
|
16 | + $class_name = "MySociety\TheyWorkForYou\SectionView\\${type}view"; |
|
17 | 17 | $view = new $class_name(); |
18 | 18 | $data = $view->display(); |
19 | 19 | if ($data) { |
@@ -17,7 +17,7 @@ |
||
17 | 17 | $view = new $class_name(); |
18 | 18 | $data = $view->display(); |
19 | 19 | if ($data) { |
20 | - if ( !empty($data['template']) ) { |
|
20 | + if (!empty($data['template'])) { |
|
21 | 21 | $template = $data['template']; |
22 | 22 | } else { |
23 | 23 | $template = 'section/section'; |
@@ -53,7 +53,7 @@ |
||
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'; |
@@ -20,49 +20,49 @@ discard block |
||
20 | 20 | |
21 | 21 | $starttime = time(); |
22 | 22 | for ($personrow=0; $personrow<$q->rows(); $personrow++) { |
23 | - $person_id = $q->field($personrow, 'person_id'); |
|
23 | + $person_id = $q->field($personrow, '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('—', '-', $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('—', '-', $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 |
||
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 |
||
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"; |
@@ -9,7 +9,7 @@ discard block |
||
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; |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | if ($q->rows() <= 0) exit; |
20 | 20 | |
21 | 21 | $starttime = time(); |
22 | -for ($personrow=0; $personrow<$q->rows(); $personrow++) { |
|
22 | +for ($personrow = 0; $personrow < $q->rows(); $personrow++) { |
|
23 | 23 | $person_id = $q->field($personrow, '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 |
||
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"; |
@@ -16,7 +16,9 @@ discard block |
||
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 | for ($personrow=0; $personrow<$q->rows(); $personrow++) { |
@@ -104,7 +106,8 @@ discard block |
||
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 | } |
@@ -46,7 +46,7 @@ |
||
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; |
@@ -33,7 +33,7 @@ discard block |
||
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 |
||
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 |
||
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"; |
@@ -8,9 +8,9 @@ discard block |
||
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 |
||
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'); |
@@ -21,13 +21,13 @@ |
||
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 |
@@ -1,6 +1,6 @@ |
||
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'; |
@@ -9,7 +9,7 @@ |
||
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 |
@@ -27,11 +27,11 @@ |
||
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 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | class User { |
15 | - public function getUserDetails($user_id = False) { |
|
15 | + public function getUserDetails($user_id = false) { |
|
16 | 16 | global $THEUSER; |
17 | 17 | |
18 | 18 | $user = $THEUSER; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | if ($details['email'] != $THEUSER->email()) { |
253 | - $results['email_changed'] = True; |
|
253 | + $results['email_changed'] = true; |
|
254 | 254 | } |
255 | 255 | |
256 | 256 |
@@ -321,6 +321,9 @@ |
||
321 | 321 | return array(); |
322 | 322 | } |
323 | 323 | |
324 | + /** |
|
325 | + * @param Member $member |
|
326 | + */ |
|
324 | 327 | private function constructMPData($member, $user, $mp_house) { |
325 | 328 | $mp_data = array(); |
326 | 329 | $mp_data['name'] = $member->full_name(); |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | $data['email'] = $user->email(); |
34 | 34 | $data['emailpublic'] = $user->emailpublic() == true ? "Yes" : "No"; |
35 | 35 | $data['optin'] = $user->optin() == true ? "Yes" : "No"; |
36 | - $data['postcode'] = $user->postcode(); |
|
36 | + $data['postcode'] = $user->postcode(); |
|
37 | 37 | $data['website'] = $user->url(); |
38 | - $data['registrationtime'] = $user->registrationtime(); |
|
39 | - $data['status']= $user->status(); |
|
38 | + $data['registrationtime'] = $user->registrationtime(); |
|
39 | + $data['status'] = $user->status(); |
|
40 | 40 | $data["deleted"] = $user->deleted(); |
41 | 41 | $data["confirmed"] = $user->confirmed(); |
42 | 42 | $data["status"] = $user->status(); |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | // Who are we updating? $THEUSER or someone else? |
244 | 244 | if ($this_page == "otheruseredit") { |
245 | 245 | $who = 'the user’s'; |
246 | - $success = $THEUSER->update_other_user ( $details ); |
|
246 | + $success = $THEUSER->update_other_user($details); |
|
247 | 247 | } else { |
248 | 248 | $who = 'your'; |
249 | - $success = $THEUSER->update_self ( $details ); |
|
249 | + $success = $THEUSER->update_self($details); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | // If this goes well, the user will have their data |
279 | 279 | // added to the database and a confirmation email |
280 | 280 | // will be sent to them. |
281 | - $success = $THEUSER->add ( $details ); |
|
281 | + $success = $THEUSER->add($details); |
|
282 | 282 | |
283 | 283 | $errors = array(); |
284 | 284 | |
285 | 285 | if (!$success) { |
286 | - $errors["db"] = "Sorry, we were unable to create an account for you. Please <a href=\"mailto:". str_replace('@', '@', CONTACTEMAIL) . "\">let us know</a>. Thanks."; |
|
286 | + $errors["db"] = "Sorry, we were unable to create an account for you. Please <a href=\"mailto:" . str_replace('@', '@', CONTACTEMAIL) . "\">let us know</a>. Thanks."; |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | return $errors; |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | public function getRep($cons_type, $mp_house) { |
293 | 293 | global $THEUSER; |
294 | - if ( !$THEUSER->has_postcode() ) { |
|
294 | + if (!$THEUSER->has_postcode()) { |
|
295 | 295 | return array(); |
296 | 296 | } |
297 | 297 | |
@@ -304,11 +304,11 @@ discard block |
||
304 | 304 | // Scottish homepage |
305 | 305 | try { |
306 | 306 | $constituencies = \MySociety\TheyWorkForYou\Utility\Postcode::postcodeToConstituencies($THEUSER->postcode()); |
307 | - if ( isset($constituencies[$cons_type]) ) { |
|
307 | + if (isset($constituencies[$cons_type])) { |
|
308 | 308 | $constituency = $constituencies[$cons_type]; |
309 | 309 | $MEMBER = new Member(array('constituency'=>$constituency, 'house'=> $mp_house)); |
310 | 310 | } |
311 | - } catch ( MemberException $e ) { |
|
311 | + } catch (MemberException $e) { |
|
312 | 312 | return array(); |
313 | 313 | } |
314 | 314 | |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | $mreg = array(); |
346 | 346 | if ($THEUSER->isloggedin() && $THEUSER->postcode() != '' || $THEUSER->postcode_is_set()) { |
347 | 347 | $reps = \MySociety\TheyWorkForYou\Member::getRegionalList($THEUSER->postcode, $mp_house, $cons_type); |
348 | - foreach ( $reps as $rep ) { |
|
348 | + foreach ($reps as $rep) { |
|
349 | 349 | $member = new \MySociety\TheyWorkForYou\Member(array('person_id' => $rep['person_id'])); |
350 | 350 | $mreg[$rep['person_id']] = $this->constructMPData($member, $THEUSER, $mp_house); |
351 | 351 | } |