function render_mps_row($mp, &$style, $order, $MPURL) { $style = $style == '1' ? '2' : '1'; $name = member_full_name(3, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']); ?> <tr> <td class="row-<?php echo $style; ?> "><a href="<?php echo $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 3); ?> "><?php echo $name; ?> </a></td> <td class="row-<?php echo $style; ?> "><?php echo $mp['party']; ?> </td> <td class="row-<?php echo $style; ?> "><?php echo $mp['constituency']; ?> </td> </tr> <?php }
function _api_getPerson_row($row, $has_party = FALSE) { global $parties; $row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']); if ($row['house'] == 1) { $URL = new URL('mp'); $row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house']); } if ($has_party && isset($parties[$row['party']])) { $row['party'] = $parties[$row['party']]; } list($image, $sz) = find_rep_image($row['person_id']); if ($image) { list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image)); $row['image'] = $image; $row['image_height'] = $height; $row['image_width'] = $width; } if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || $row['left_house'] == '2010-04-12')) { # XXX # Ministerialships and Select Committees $db = new ParlDB(); $q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC'); for ($i = 0; $i < $q->rows(); $i++) { $row['office'][] = $q->row($i); } } foreach ($row as $k => $r) { if (is_string($r)) { $row[$k] = html_entity_decode($r); } } return $row; }
function render_peers_row($peer, $order) { global $parties; $name = member_full_name(2, $peer['title'], $peer['first_name'], $peer['last_name'], $peer['constituency']); if (strstr($name, ',')) { $name = "\"{$name}\""; } print $peer['person_id'] . ',' . ucfirst($name) . ','; if (array_key_exists($peer['party'], $parties)) { print $parties[$peer['party']]; } else { print $peer['party']; } print ',' . 'http://' . DOMAIN . WEBPATH . 'senator/' . make_member_url($name, $peer['constituency']); print "\n"; }
function render_mlas_row($mla, $order) { global $parties; $con = html_entity_decode($mla['constituency']); if (strstr($con, ',')) { $con = "\"{$con}\""; } $name = member_full_name(3, $mla['title'], $mla['first_name'], $mla['last_name'], $mla['constituency']); if (strstr($name, ',')) { $name = "\"{$name}\""; } print $mla['person_id'] . ',' . ucfirst($name) . ','; if (array_key_exists($mla['party'], $parties)) { print $parties[$mla['party']]; } else { print $mla['party']; } print ',' . $con . ',' . 'http://www.openaustralia.org/mla/' . make_member_url($mla['first_name'] . ' ' . $mla['last_name']); print "\n"; }
function render_msps_row($msp, $order) { global $parties; $con = $msp['constituency']; if (strstr($con, ',')) { $con = "\"{$con}\""; } $name = member_full_name(4, $msp['title'], $msp['first_name'], $msp['last_name'], $msp['constituency']); if (strstr($name, ',')) { $name = "\"{$name}\""; } print $msp['person_id'] . ',' . ucfirst($name) . ','; if (array_key_exists($msp['party'], $parties)) { print $parties[$msp['party']]; } else { print $msp['party']; } print ',' . $con . ',' . 'http://www.theyworkforyou.com/msp/' . make_member_url($msp['first_name'] . ' ' . $msp['last_name']); print "\n"; }
function render_mps_row($mp, $order) { global $parties; $con = html_entity_decode($mp['constituency']); if (strstr($con, ',')) { $con = "\"{$con}\""; } print $mp['person_id'] . ','; print html_entity_decode($mp['first_name']) . ',' . html_entity_decode($mp['last_name']) . ','; if (array_key_exists($mp['party'], $parties)) { print $parties[$mp['party']]; } else { print $mp['party']; } print ',' . $con . ',' . 'http://www.theyworkforyou.com/mp/' . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency']); if ($order == 'expenses') { print ', £' . $mp['data_value']; } elseif ($order == 'debates') { print ', ' . $mp['data_value']; } print "\n"; }
function render_mps_row($mp, &$style, $order, $MPURL) { $style = $style == '1' ? '2' : '1'; $name = member_full_name(4, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']); ?> <tr> <td class="row"> <?php list($image,$sz) = find_rep_image($mp['person_id'], true, true); if ($image) { echo '<a href="' . $MPURL->generate().make_member_url($mp['first_name'].' '.$mp['last_name'], $mp['constituency'], 1) . '" class="speakerimage"><img height="59" class="portrait" alt="" src="', $image, '"'; echo '></a>'; } ?> </td> <td class="row-<?php echo $style; ?>"><a href="<?php echo $MPURL->generate().make_member_url($mp['first_name'].' '.$mp['last_name'], $mp['constituency'], 4); ?>"><?php echo $name; ?></a></td> <td class="row-<?php echo $style; ?>"><?php echo $mp['party']; ?></td> <td class="row-<?php echo $style; ?>"><?php echo $mp['constituency']; ?></td> </tr> <?php }
?> '><?php echo $name; ?> </a>, and your regional MSPs were <?php foreach ($mreg as $k => $n) { print "<a href='/msp/" . make_member_url($n, '', 4) . "'>{$n}</a>"; if ($k < count($mreg) - 2) { print ', '; } elseif ($k == count($mreg) - 2) { print ' and '; } } echo '.</li>'; } elseif ($country == 'N') { $mp_url = '/mla/' . make_member_url($name, '', 3); ?> <li>You were in the <strong><?php echo $current['NIE']; ?> </strong> constituency; your constituency MLA was <a href='<?php echo $mp_url; ?> '><?php echo $name; ?> </a>.</li> <?php } echo '</ul>'; if (count($new) && $current['SPC'] == $new['SPC']) {
function render_mps_row($mp, &$style, $order, $MPURL) { // Stripes $style = $style == '1' ? '2' : '1'; $name = member_full_name(1, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']); $url = $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1); # $MPURL->insert(array('pid'=>$mp['person_id'])); list($image, $sz) = find_rep_image($mp['person_id'], true); ?> <tr> <td class="row"> <?php if ($image) { echo '<a href="', $url, '">', '<img class="portrait" alt="" src="', $image, '">', '</a>'; } ?> </td> <td class="row-<?php echo $style; ?> "><a href="<?php echo $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1); ?> "><?php echo $name; ?> </a></td> <td class="row-<?php echo $style; ?> "><?php echo $mp['party']; ?> </td> <td class="row-<?php echo $style; ?> "><?php echo $mp['constituency']; ?> </td> <td class="row-<?php echo $style; ?> "><?php if (is_array($mp['dept'])) { print join('<br>', array_map('manymins', $mp['pos'], $mp['dept'])); } elseif ($mp['dept'] || $mp['pos']) { print prettify_office($mp['pos'], $mp['dept']); } else { print ' '; } ?> </td> <?php if ($order == 'expenses') { ?> <td class="row-<?php echo $style; ?> ">£<?php echo number_format($mp['data_value']); ?> </td> <?php } elseif ($order == 'debates') { ?> <td class="row-<?php echo $style; ?> "><?php echo number_format($mp['data_value']); ?> </td> <?php } elseif ($order == 'safety') { ?> <td class="row-<?php echo $style; ?> "><?php echo $mp['data_value']; ?> </td> <?php } ?> </tr> <?php }
public function url($absolute = true) { $house = $this->house_disp; if ($house == HOUSE_TYPE_COMMONS) { $URL = new URL('mp'); } elseif ($house == HOUSE_TYPE_LORDS) { $URL = new URL('peer'); } elseif ($house == HOUSE_TYPE_NI) { $URL = new URL('mla'); } elseif ($house == HOUSE_TYPE_SCOTLAND) { $URL = new URL('msp'); } elseif ($house == HOUSE_TYPE_ROYAL) { $URL = new URL('royal'); } $member_url = make_member_url($this->full_name(true), $this->constituency(), $house, $this->person_id()); if ($absolute) { return 'http://' . DOMAIN . $URL->generate('none') . $member_url; } else { return $URL->generate('none') . $member_url; } }
function render_peers_row($peer, &$style, $order, $URL) { global $parties; // Stripes $style = $style == '1' ? '2' : '1'; $name = member_full_name(2, $peer['title'], $peer['first_name'], $peer['last_name'], $peer['constituency']); if (array_key_exists($peer['party'], $parties)) { $party = $parties[$peer['party']]; } else { $party = $peer['party']; } # $MPURL->insert(array('pid'=>$peer['person_id'])); ?> <tr> <td class="row"> <?php list($image, $sz) = find_rep_image($peer['person_id'], true, 'lord'); if ($image) { echo '<a href="' . $URL->generate() . make_member_url($name) . '" class="speakerimage"><img height="59" class="portrait" alt="" src="', $image, '"'; echo '></a>'; } ?> </td> <td class="row-<?php echo $style; ?> "><a href="<?php echo $URL->generate() . make_member_url($name, null, 2); ?> "><?php echo ucfirst($name); ?> </a></td> <td class="row-<?php echo $style; ?> "><?php echo $party; ?> </td> <td class="row-<?php echo $style; ?> "><?php if (is_array($peer['dept'])) { print join('<br>', array_map('manymins', $peer['pos'], $peer['dept'])); } elseif ($peer['dept']) { print prettify_office($peer['pos'], $peer['dept']); } else { print ' '; } ?> </td> <?php if ($order == 'debates') { ?> <td class="row-<?php echo $style; ?> "><?php echo number_format($peer['data_value']); ?> </td> <?php } ?> </tr> <?php }
foreach (array('house', 'first_name', 'last_name', 'title', 'person_id') as $key) { unset($output[$key]); } if (isset($party_sites[$output['party']])) { $output['party_site'] = $party_sites[$output['party']]; } elseif ($output['full_name'] == 'Richard Taylor') { $output['party_site'] = 'http://www.healthconcern.org.uk/'; } elseif ($output['full_name'] == 'Dai Davies') { $output['party_site'] = 'http://www.blaenaugwentpeoplesvoice.org/'; } else { $output['party_site'] = ''; } if (isset($output['image'])) $output['image'] = 'http://www.theyworkforyou.com' . $output['image']; $output['bbc'] = 'http://news.bbc.co.uk/1/shared/mpdb/html/' . $bbc_cons_id . '.stm'; $output['link'] = 'http://www.theyworkforyou.com/mp/' . make_member_url(htmlentities($output['full_name']), $cons, 1); # XXX make_member_url needs it encoded! $output['email_alert'] = 'http://www.theyworkforyou.com/alert/?only=1&pid=' . $pid; #$output['writetothem'] = 'http://www.writetothem.com/'; #$output['hearfromyourmp'] = 'http://www.hearfromyourmp.com/'; # Link to WTT/HFYMP? api_output($output); } else { error('Unknown action'); } function error($error = 'Unknown error') { api_error($error); exit; }
public function _get_data_by_group($args) { // $args can have an optional 'order' element. $use_extracol = isset($args['order']) && in_array($args['order'], array('debates')); $use_personinfo = $use_extracol; # Defaults $order = 'family_name'; $sqlorder = 'family_name, given_name'; $params = array(); $query = 'SELECT distinct member.person_id, title, given_name, family_name, lordofname, constituency, party, left_reason, dept, position '; if ($use_extracol) { $query .= ', data_value '; $order = $args['order']; $sqlorder = 'data_value+0 DESC, family_name, given_name'; unset($args['date']); $key_lookup = array('debates' => 'debate_sectionsspoken_inlastyear'); $personinfo_key = $key_lookup[$order]; } $query .= 'FROM member LEFT OUTER JOIN moffice ON member.person_id = moffice.person '; if (isset($args['date'])) { $query .= 'AND from_date <= :date AND :date <= to_date '; $params[':date'] = $args['date']; } else { $query .= 'AND to_date="9999-12-31" '; } if ($use_personinfo) { $query .= 'LEFT OUTER JOIN personinfo ON member.person_id = personinfo.person_id AND data_key="' . $personinfo_key . '" '; } $query .= ' JOIN person_names p ON p.person_id = member.person_id AND p.type = "name" '; if (isset($args['date'])) { $query .= 'AND start_date <= :date AND :date <= end_date '; } else { $query .= 'AND end_date="9999-12-31" '; } $query .= 'WHERE house=' . $args['house'] . ' '; if (isset($args['date'])) { $query .= 'AND entered_house <= :date AND :date <= left_house '; } elseif (!isset($args['all']) || $args['house'] == 1) { $query .= 'AND left_house = (SELECT MAX(left_house) FROM member) '; } if (isset($args['order'])) { $order = $args['order']; if ($args['order'] == 'given_name') { $sqlorder = 'given_name, family_name'; } elseif ($args['order'] == 'constituency') { $sqlorder = 'constituency'; } elseif ($args['order'] == 'party') { $sqlorder = 'party, family_name, given_name, constituency'; } } $q = $this->db->query($query . "ORDER BY {$sqlorder}", $params); $data = array(); for ($row = 0; $row < $q->rows(); $row++) { $p_id = $q->field($row, 'person_id'); $dept = $q->field($row, 'dept'); $pos = $q->field($row, 'position'); if (isset($data[$p_id])) { $data[$p_id]['dept'] = array_merge((array) $data[$p_id]['dept'], (array) $dept); $data[$p_id]['pos'] = array_merge((array) $data[$p_id]['pos'], (array) $pos); } else { $name = member_full_name($args['house'], $q->field($row, 'title'), $q->field($row, 'given_name'), $q->field($row, 'family_name'), $q->field($row, 'lordofname')); $constituency = $q->field($row, 'constituency'); $url = make_member_url($name, $constituency, $args['house'], $p_id); $narray = array('person_id' => $p_id, 'given_name' => $q->field($row, 'given_name'), 'family_name' => $q->field($row, 'family_name'), 'lordofname' => $q->field($row, 'lordofname'), 'name' => $name, 'url' => $url, 'constituency' => $constituency, 'party' => $q->field($row, 'party'), 'left_reason' => $q->field($row, 'left_reason'), 'dept' => $dept, 'pos' => $pos); if ($use_extracol) { $narray['data_value'] = $q->field($row, 'data_value'); } if ($narray['party'] == 'SPK') { $narray['party'] = '-'; $narray['pos'] = 'Speaker'; $narray['dept'] = 'House of Commons'; } elseif ($narray['party'] == 'CWM' || $narray['party'] == 'DCWM') { $narray['party'] = '-'; $narray['pos'] = 'Deputy Speaker'; $narray['dept'] = 'House of Commons'; } $data[$p_id] = $narray; } } if ($args['house'] == 2 && ($order == 'name' || $order == 'constituency')) { uasort($data, array($this, 'by_peer_name')); } $data = array('info' => array('order' => $order), 'data' => $data); return $data; }
function display_user($user_id = "") { global $THEUSER, $PAGE, $DATA, $this_page, $who; // We're either going to be: // Displaying the details of a user who's just been edited // (their user_id will be in $user_id now). // Viewing THEUSER's own data. // Viewing someone else's data (their id will be in the GET string // user_id variable). // We could do something cleverer so that if THEUSER has sufficient // privileges we display more data when they're viewing someone else's info // than what your average punter sees. // If $user_id is a user id, we've just edited that user's info. // FIRST: Work out whose info we're going to show. $edited = false; // Have we just edited someone's info? if (is_numeric($user_id) && $user_id == $THEUSER->user_id()) { // Display this user's just edited info. $display = "this user"; $edited = true; } elseif (is_numeric($user_id)) { // Display someone else's just edited info. $display = "another user"; $edited = true; } elseif (is_numeric(get_http_var("u"))) { // Display someone else's info. $user_id = get_http_var("u"); $display = "another user"; } elseif ($THEUSER->isloggedin()) { // Display this user's info. $display = "this user"; $user_id = $THEUSER->user_id(); } else { // Nothing to show! $URL = new URL('userlogin'); $URL->insert(array('ret' => '/user/')); $loginurl = $URL->generate(); header("Location: {$loginurl}"); exit; } // SECOND: Get the data for whoever we're going to show. $db = new ParlDB(); if ($display == "another user") { // Viewing someone else's info. $USER = new USER(); $valid = $USER->init($user_id); if ($valid && $USER->confirmed() && !$USER->deleted()) { // Don't want to display unconfirmed or deleted users. $name = $USER->firstname() . " " . $USER->lastname(); $url = $USER->url(); if ($USER->emailpublic() == true) { $email = $USER->email(); } $status = $USER->status(); $registrationtime = $USER->registrationtime(); // Change the page title to reflect whose info we're viewing. $DATA->set_page_metadata($this_page, "title", "{$name}"); $q = $db->query('select count(*) as c from video_timestamps where deleted=0 and user_id= ' . $USER->user_id()); $video = $q->field(0, 'c'); } else { // This user_id doesn't exist. $display = "none"; } } elseif ($display == "this user") { // Display THEUSER's info. $name = $THEUSER->firstname() . " " . $THEUSER->lastname(); $url = $THEUSER->url(); if ($edited) { // We want to show all the info to the user. $email = $THEUSER->email(); $emailpublic = $THEUSER->emailpublic() == true ? "Yes" : "No"; $optin = $THEUSER->optin() == true ? "Yes" : "No"; $postcode = $THEUSER->postcode(); } else { // We're showing them how they're seen to other people. if ($THEUSER->emailpublic()) { $email = $THEUSER->email(); } $registrationtime = $THEUSER->registrationtime(); $status = $THEUSER->status(); } $q = $db->query('select count(*) as c from video_timestamps where deleted=0 and user_id= ' . $THEUSER->user_id()); $video = $q->field(0, 'c'); // Change the page title to make it clear we're viewing THEUSER's // own info. Make them less worried about other people seeing some of the // info that shouldn't be public. $DATA->set_page_metadata($this_page, "title", "Your details"); } else { // There's nothing to display! } // THIRD: Print out what we've got. $PAGE->page_start(); if ($display != "none") { $PAGE->stripe_start(); if (isset($registrationtime)) { // Make registration time more user-friendly. list($date, $time) = explode(' ', $registrationtime); $registrationtime = format_date($date, LONGDATEFORMAT); } if ($edited) { print "\t\t\t\t<p><strong>" . ucfirst($who) . " details have been updated:</strong></p>\n"; } if ($this_page == 'userviewself' && !$edited) { $EDITURL = new URL('useredit'); ?> <p><strong>This is how other people see you.</strong> <a href="<?php echo $EDITURL->generate(); ?> ">Edit your details</a>.</p> <?php } ?> <div class="row"> <span class="label">Name</span> <span class="formw"><?php if (substr($name, -3) == ' MP') { print '<a href="/mp/' . make_member_url(substr($name, 0, -3)) . '">'; } echo htmlentities($name); if (substr($name, -3) == ' MP') { print '</a>'; } ?> </span> </div> <div class="row"> <span class="label">Email</span> <span class="formw"><?php if (isset($email)) { $escaped_email = str_replace('@', '@', htmlentities($email)); ?> <a href="mailto:<?php echo $escaped_email . "\">" . $escaped_email; ?> </a><?php } else { ?> Not public<?php } ?> </span> </div> <?php if (isset($postcode)) { if ($postcode == '') { $postcode = 'none'; } ?> <div class="row"> <br> <span class="label">UK Postcode</span> <span class="formw"><?php echo htmlentities($postcode); ?> <small>(not public)</small></span> </div> <?php } if (isset($url)) { if ($url == '') { $url = 'none'; } else { $url = '<a href="' . htmlentities($url) . '">' . htmlentities($url) . '</a>'; } ?> <div class="row"> <span class="label">Website</span> <span class="formw"><?php echo $url; ?> </span> </div> <?php } if (isset($emailpublic)) { ?> <div class="row"> <br>Let other people see your email address? <strong><?php echo htmlentities($emailpublic); ?> </strong></div> <?php } if (isset($optin)) { ?> <div class="row">Receive TheyWorkForYou.com emails? <strong><?php echo htmlentities($optin); ?> </strong></div> <?php } if (isset($status)) { ?> <div class="row"> <span class="label">Status</span> <span class="formw"><?php echo htmlentities($status); ?> </span> </div> <?php } if (isset($registrationtime)) { ?> <div class="row"> <span class="label">Joined</span> <span class="formw"><?php echo htmlentities($registrationtime); ?> </span> </div> <?php } if (isset($video)) { echo '<div class="row"><span class="label">Videos timestamped</span> <span class="formw">', $video, '</span></div>'; } if ($edited && $this_page == 'userviewself') { $EDITURL = new URL('useredit'); $VIEWURL = new URL('userviewself'); ?> <p> <br><a href="<?php echo $EDITURL->generate(); ?> ">Edit again</a> or <a href="<?php echo $VIEWURL->generate(); ?> ">see how others see you</a>.</p> <?php } $PAGE->stripe_end(); # Email alerts if ($this_page == 'userviewself') { $PAGE->stripe_start(); print '<h3>Your email alerts</h3>'; alerts_manage($THEUSER->email()); $PAGE->stripe_end(); } if (!$edited) { $args = array('user_id' => $user_id, 'page' => get_http_var('p')); $COMMENTLIST = new COMMENTLIST(); $COMMENTLIST->display('user', $args); } } else { $message = array('title' => 'Sorry...', 'text' => "We don't have a user ID, so we can't show you anyone's details."); $PAGE->message($message); } $PAGE->page_end(); }
foreach (array('house', 'first_name', 'last_name', 'title', 'person_id') as $key) { unset($output[$key]); } if (isset($party_sites[$output['party']])) { $output['party_site'] = $party_sites[$output['party']]; } elseif ($output['full_name'] == 'Richard Taylor') { $output['party_site'] = 'http://www.healthconcern.org.uk/'; } elseif ($output['full_name'] == 'Dai Davies') { $output['party_site'] = 'http://www.blaenaugwentpeoplesvoice.org/'; } else { $output['party_site'] = ''; } if (isset($output['image'])) { $output['image'] = 'http://www.theyworkforyou.com' . $output['image']; } $output['bbc'] = 'http://news.bbc.co.uk/1/shared/mpdb/html/' . $bbc_cons_id . '.stm'; $output['link'] = 'http://www.theyworkforyou.com/mp/' . make_member_url(htmlentities($output['full_name']), $cons, 1); # XXX make_member_url needs it encoded! $output['email_alert'] = 'http://www.theyworkforyou.com/alert/?only=1&pid=' . $pid; #$output['writetothem'] = 'http://www.writetothem.com/'; #$output['hearfromyourmp'] = 'http://www.hearfromyourmp.com/'; # Link to WTT/HFYMP? api_output($output); } else { error('Unknown action'); } function error($error = 'Unknown error') { api_error($error); exit; }
function render_mps_row($mp, &$style, $order, $MPURL) { // Stripes $style = $style == '1' ? '2' : '1'; $name = member_full_name(1, $mp['title'], $mp['first_name'], $mp['last_name'], $mp['constituency']); # $MPURL->insert(array('pid'=>$mp['person_id'])); ?> <tr> <td class="row"> <?php list($image, $sz) = find_rep_image($mp['person_id'], true, true); if ($image) { echo '<a href="' . $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1) . '" class="speakerimage"><img height="59" class="portrait" alt="" src="', $image, '"'; echo '></a>'; } ?> </td> <td class="row-<?php echo $style; ?> "><a href="<?php echo $MPURL->generate() . make_member_url($mp['first_name'] . ' ' . $mp['last_name'], $mp['constituency'], 1); ?> "><?php echo $name; ?> </a> <?php if ($mp['left_reason'] == 'general_election_not_standing') { print '<br><em>Standing down</em>'; } ?> </td> <td class="row-<?php echo $style; ?> "><?php echo $mp['party']; ?> </td> <td class="row-<?php echo $style; ?> "><?php echo $mp['constituency']; ?> </td> <td class="row-<?php echo $style; ?> "><?php if (is_array($mp['pos'])) { print join('<br>', array_map('prettify_office', $mp['pos'], $mp['dept'])); } elseif ($mp['pos'] || $mp['dept']) { print prettify_office($mp['pos'], $mp['dept']); } else { print ' '; } ?> </td> <?php if ($order == 'expenses') { ?> <td class="row-<?php echo $style; ?> ">£<?php echo number_format($mp['data_value']); ?> </td> <?php } elseif ($order == 'debates') { ?> <td class="row-<?php echo $style; ?> "><?php echo number_format($mp['data_value']); ?> </td> <?php } elseif ($order == 'safety') { ?> <td class="row-<?php echo $style; ?> "><?php echo $mp['data_value']; ?> </td> <?php } ?> </tr> <?php }
function display_user($user_id = "") { global $THEUSER, $PAGE, $DATA, $this_page, $who; // We're either going to be: // Displaying the details of a user who's just been edited // (their user_id will be in $user_id now). // Viewing THEUSER's own data. // Viewing someone else's data (their id will be in the GET string // user_id variable). // We could do something cleverer so that if THEUSER has sufficient // privileges we display more data when they're viewing someone else's info // than what your average punter sees. // If $user_id is a user id, we've just edited that user's info. // FIRST: Work out whose info we're going to show. $edited = false; // Have we just edited someone's info? if (is_numeric($user_id) && $user_id == $THEUSER->user_id()) { // Display this user's just edited info. $display = "this user"; $edited = true; } elseif (is_numeric($user_id)) { // Display someone else's just edited info. $display = "another user"; $edited = true; } elseif (is_numeric(get_http_var("u"))) { // Display someone else's info. $user_id = get_http_var("u"); $display = "another user"; } elseif ($THEUSER->isloggedin()) { // Display this user's info. $display = "this user"; $user_id = $THEUSER->user_id(); } else { // Nothing to show! $URL = new URL('userlogin'); $URL->insert(array('ret' => '/user/')); $loginurl = $URL->generate(); header("Location: {$loginurl}"); exit; } // SECOND: Get the data for whoever we're going to show. if ($display == "another user") { // Viewing someone else's info. $USER = new USER(); $valid = $USER->init($user_id); if ($valid && $USER->confirmed() && !$USER->deleted()) { // Don't want to display unconfirmed or deleted users. $name = $USER->firstname() . " " . $USER->lastname(); $url = $USER->url(); if ($USER->emailpublic() == true) { $email = $USER->email(); } $status = $USER->status(); $registrationtime = $USER->registrationtime(); // Change the page title to reflect whose info we're viewing. $DATA->set_page_metadata($this_page, "title", "{$name}"); } else { // This user_id doesn't exist. $display = "none"; } } elseif ($display == "this user") { // Display THEUSER's info. $name = $THEUSER->firstname() . " " . $THEUSER->lastname(); $url = $THEUSER->url(); if ($edited) { // We want to show all the info to the user. $email = $THEUSER->email(); $emailpublic = $THEUSER->emailpublic() == true ? "Yes" : "No"; $optin = $THEUSER->optin() == true ? "Yes" : "No"; $postcode = $THEUSER->postcode(); } else { // We're showing them how they're seen to other people. if ($THEUSER->emailpublic()) { $email = $THEUSER->email(); } $registrationtime = $THEUSER->registrationtime(); $status = $THEUSER->status(); } // Change the page title to make it clear we're viewing THEUSER's // own info. Make them less worried about other people seeing some of the // info that shouldn't be public. $DATA->set_page_metadata($this_page, "title", "Your details"); } else { // There's nothing to display! } // THIRD: Print out what we've got. $PAGE->page_start(); if ($display != "none") { $PAGE->stripe_start(); if (isset($registrationtime)) { // Make registration time more user-friendly. list($date, $time) = explode(' ', $registrationtime); $registrationtime = format_date($date, LONGDATEFORMAT); } if ($edited) { print "\t\t\t\t<p><strong>" . ucfirst($who) . " details have been updated:</strong></p>\n"; } if ($this_page == 'userviewself' && !$edited) { $EDITURL = new URL('useredit'); ?> <p><strong>This is how other people see you.</strong> <a href="<?php echo $EDITURL->generate(); ?> ">Edit your details</a>.</p> <?php } ?> <div class="row"> <span class="label">Name</span> <span class="formw"><?php if (substr($name, -3) == ' MP') { print '<a href="/mp/' . make_member_url(substr($name, 0, -3)) . '">'; } echo htmlentities($name); if (substr($name, -3) == ' MP') { print '</a>'; } ?> </span> </div> <div class="row"> <span class="label">Email</span> <span class="formw"><?php if (isset($email)) { $escaped_email = str_replace('@', '@', htmlentities($email)); ?> <a href="mailto:<?php echo $escaped_email . "\">" . $escaped_email; ?> </a><?php } else { ?> Not public<?php } ?> </span> </div> <?php if (isset($postcode)) { if ($postcode == '') { $postcode = 'none'; } ?> <div class="row"> <br> <span class="label">UK Postcode</span> <span class="formw"><?php echo htmlentities($postcode); ?> <small>(not public)</small></span> </div> <?php } if (isset($url)) { if ($url == '') { $url = 'none'; } else { $url = '<a href="' . htmlentities($url) . '">' . htmlentities($url) . '</a>'; } ?> <div class="row"> <span class="label">Website</span> <span class="formw"><?php echo $url; ?> </span> </div> <?php } if (isset($emailpublic)) { ?> <div class="row"> <br>Let other people see your email address? <strong><?php echo htmlentities($emailpublic); ?> </strong></div> <?php } if (isset($optin)) { ?> <div class="row">Receive TheyWorkForYou.com emails? <strong><?php echo htmlentities($optin); ?> </strong></div> <?php } if (isset($status)) { ?> <div class="row"> <span class="label">Status</span> <span class="formw"><?php echo htmlentities($status); ?> </span> </div> <?php } if (isset($registrationtime)) { ?> <div class="row"> <span class="label">Joined</span> <span class="formw"><?php echo htmlentities($registrationtime); ?> </span> </div> <?php } if ($edited && $this_page == 'userviewself') { $EDITURL = new URL('useredit'); $VIEWURL = new URL('userviewself'); ?> <p> <br><a href="<?php echo $EDITURL->generate(); ?> ">Edit again</a> or <a href="<?php echo $VIEWURL->generate(); ?> ">see how others see you</a>.</p> <?php } $PAGE->stripe_end(); # Email alerts if ($this_page == 'userviewself') { $PAGE->stripe_start(); print '<h3>Your email alerts</h3>'; $db = new ParlDB(); $q = $db->query('SELECT * FROM alerts WHERE email = "' . mysql_escape_string($THEUSER->email()) . '" ORDER BY confirmed,deleted,alert_id'); $out = ''; for ($i = 0; $i < $q->rows(); ++$i) { $row = $q->row($i); $criteria = explode(' ', $row['criteria']); $ccc = array(); foreach ($criteria as $c) { if (preg_match('#^speaker:(\\d+)#', $c, $m)) { $MEMBER = new MEMBER(array('person_id' => $m[1])); $ccc[] = 'spoken by ' . $MEMBER->full_name(); } else { $ccc[] = $c; } } $criteria = join(' ', $ccc); $token = $row['alert_id'] . '-' . $row['registrationtoken']; if (!$row['confirmed']) { $action = '<a href="/A/' . $token . '">Confirm</a>'; } elseif ($row['deleted']) { $action = '<form action="/alert/undelete/" method="post"><input type="hidden" name="t" value="' . $token . '"><input type="submit" value="Undelete"></form>'; } else { $action = '<form action="/alert/delete/" method="post"><input type="hidden" name="t" value="' . $token . '"><input type="submit" value="Delete"></form>'; } $out .= '<tr><td>' . $criteria . '</td><td>' . $action . '</td></tr>'; } print '<p>To add a new alert, simply visit an MP or Peer\'s page or conduct a search — to be given the option of turning them into alerts automatically — or visit <a href="/alert/">the manual addition page</a>.</p>'; if ($out) { print '<p>Here are your email alerts:</p>'; print '<table cellpadding="3" cellspacing="0"><tr><th>Criteria</th><th>Action</th></tr>' . $out . '</table>'; } else { print '<p>You currently have no email alerts set up.</p>'; } $PAGE->stripe_end(); } if (!$edited) { $args = array('user_id' => $user_id, 'page' => get_http_var('p')); $COMMENTLIST = new COMMENTLIST(); $COMMENTLIST->display('user', $args); } } else { $message = array('title' => 'Sorry...', 'text' => "We don't have a user ID, so we can't show you anyone's details."); $PAGE->message($message); } $PAGE->page_end(); }
function url($absolute = true) { $house = $this->house_disp; if ($house == 1) { $URL = new URL('mp'); } elseif ($house == 2) { $URL = new URL('peer'); } elseif ($house == 3) { $URL = new URL('mla'); } elseif ($house == 4) { $URL = new URL('msp'); } elseif ($house == 0) { $URL = new URL('royal'); } $member_url = make_member_url($this->full_name(true), $this->constituency(), $house); if ($absolute) { return 'http://' . DOMAIN . $URL->generate('none') . $member_url; } else { return $URL->generate('none') . $member_url; } }
:</p> <p><img src='http://matthew.theyworkforyou.com/boundaries/maps_now/<?php echo $map_url_current; ?> .png' alt='Map showing boundary of the <?php echo $current_disp; ?> constituency' width=400 height=400> <p class="footer"><small>Images produced from the Ordnance Survey <a href="http://www.election-maps.co.uk/" rel="nofollow">election-maps</a> service. Images reproduced with permission of <a href="http://www.ordnancesurvey.co.uk/" rel="nofollow">Ordnance Survey</a> and <a href="http://www.lpsni.gov.uk/" rel="nofollow">Land and Property Services</a>.</small></p> </div> <ul class="results"> <?php $mp_url = '/mp/' . make_member_url($mp_name, $current, 1); if (is_scottish($new)) { print '<li>Scotland does not have any boundary changes, so you remain in your constituency of <strong>' . $current_disp . '</strong>; your MP was <a href="' . $mp_url . '">' . $mp_name . '</a>.'; } else { if (isset($new)) { print '<li>For the general election, you are in the <strong>' . $new . '</strong> constituency.'; } else { print '<li>We cannot look up the constituency for the election for some reason, sorry.'; } ?> <li>You were in the <strong><?php echo $current_disp; ?> </strong> constituency; your MP was <a href='<?php