print "This script assumes that there are no votes from policies on\n"; print "Scottish Parliament divisions yet.\n"; exit(-1); } $db->query("SELECT * FROM pw_dyn_dreamvote ORDER BY division_date, division_number"); while ($row = $db->fetch_row_assoc()) { $dream_id = $row['dream_id']; $division_date = $row['division_date']; $division_number = $row['division_number']; $possibly_wrong_house = $row['house']; $db2->query("SELECT * FROM pw_division WHERE\n division_date = '{$division_date}' AND\n division_number = '{$division_number}' AND\n house != 'scotland'"); $nrows = $db2->rows(); if ($nrows == 0) { print "### MISSING: {$nrows} house {$possibly_wrong_house}, dream_id {$dream_id}, date {$division_date}, division_number {$division_number}\n"; } elseif ($nrows == 1) { $row2 = $db2->fetch_row_assoc(); $correct_house = $row2['house']; if ($correct_house != $possibly_wrong_house) { print "{$nrows} house {$possibly_wrong_house}, dream_id {$dream_id}, date {$division_date}, division_number {$division_number}\n"; print " Should correct house to: {$correct_house}\n"; if ($repair) { print " Repairing... "; $db2->query("UPDATE pw_dyn_dreamvote SET house = '{$correct_house}' WHERE\n division_date = '{$division_date}' AND\n division_number = {$division_number} AND\n dream_id = {$dream_id}"); print "done\n"; } } } else { print "### AMBIGUITY: {$nrows} house {$possibly_wrong_house}, dream_id {$dream_id}, date {$division_date}, division_number {$division_number}\n"; while ($row2 = $db2->fetch_row_assoc()) { $alternative_house = $row2['house']; print " could be house: {$house}\n";
$db = new DB(); $just_logged_in = do_login_screen(); if (user_isloggedin()) { $type = db_scrub($_GET["type"]); if ($type == 'motion') { $params = array(db_scrub($_GET["date"]), db_scrub($_GET["number"]), db_scrub($_GET["house"])); } else { trigger_error("Unknown wiki type " . htmlspecialchars($type), E_USER_ERROR); } $newtext = $_POST["newtext"]; $newtitle = $_POST["newtitle"]; $newdescription = $_POST["newdescription"]; $submit = db_scrub($_POST["submit"]); $rr = db_scrub($_GET["rr"]); $db->query("select * from pw_division where division_date = '{$params['0']}' \n and division_number = '{$params['1']}' and house = '{$params['2']}'"); $division_details = $db->fetch_row_assoc(); $prettydate = date("j M Y", strtotime($params[0])); $title = "Edit division description - " . $division_details['division_name'] . " - {$prettydate} - Division No. {$params['1']}"; $debate_gid = str_replace("uk.org.publicwhip/debate/", "", $division_details['debate_gid']); $debate_gid = str_replace("uk.org.publicwhip/lords/", "", $debate_gid); if ($type == "motion") { $motion_data = get_wiki_current_value($db, "motion", array($params[0], $params[1], $params[2])); $prev_name = extract_title_from_wiki_text($motion_data['text_body']); $prev_description = extract_motion_text_from_wiki_text($motion_data['text_body']); $prev_description_editable = extract_motion_text_from_wiki_text_for_edit($motion_data['text_body']); } if ($submit && !$just_logged_in) { if ($submit == "Save") { if ($type == 'motion') { $newtext = add_motion_missing_wrappers($newdescription, $newtitle); $curr_name = extract_title_from_wiki_text($newtext);
$type = "motion"; } if ($type) { if ($type == 'motion') { if ($_GET["date"]) { $params = array(db_scrub($_GET["date"]), db_scrub($_GET["number"]), db_scrub($_GET["house"])); } else { $params = null; } } else { trigger_error("Unknown wiki type " . htmlspecialchars($type), E_USER_ERROR); } } if ($params) { $db->query("select * from pw_division where division_date = '{$params['0']}' \n and division_number = '{$params['1']}' and house = '{$params['2']}'"); $division_details = $db->fetch_row_assoc(); $prettydate = date("j M Y", strtotime($params[0])); $title = "Division Description Changes - " . $division_details['division_name'] . " - {$prettydate} - Division No. {$params['1']}"; } else { $title = "All Division Description Edits"; } pw_header(); if ($params) { print "<p>All changes made to the description and title of this division."; $edit_link = "account/wiki.php?type=motion&date=" . $params[0] . "&number=" . $params[1] . "&house=" . $params[2] . "&rr=" . urlencode($_SERVER["REQUEST_URI"]); $division_link = "division.php?date=" . $params[0] . "&number=" . $params[1] . "&house=" . $params[2]; print "<p><a href=\"{$division_link}\">View division</a> | <a href=\"{$edit_link}\">Edit description</a>"; } else { print "<p>Recent changes made to description and title of any division."; } print "<table class=\"edits\">\n";
require_once "common.inc"; # $Id: mps-xml.php,v 1.8 2006/03/12 13:14:30 publicwhip Exp $ # The Public Whip, Copyright (C) 2003 Francis Irving and Julian Todd # This is free software, and you are welcome to redistribute it under # certain conditions. However, it comes with ABSOLUTELY NO WARRANTY. # For details see the file LICENSE.html in the top level of the source. require_once "db.inc"; $db = new DB(); header("Content-type: text/xml"); header("Content-Disposition: attachment; filename=\"mpinfo.xml\""); require_once "parliaments.inc"; print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; print "<publicwhip>\n"; $query = "select division_date from pw_division order by division_date desc limit 1"; $db->query($query); $row = $db->fetch_row_assoc(); $last_div_date = $row['division_date']; $mps_query_start = "select first_name, last_name, title, constituency,\n party, pw_mp.mp_id as mp_id,\n round(100*rebellions/votes_attended,0) as rebellions,\n round(100*votes_attended/votes_possible,0) as attendance,\n entered_reason, left_reason, entered_house, left_house,\n house\n from pw_mp,\n pw_cache_mpinfo where\n pw_mp.mp_id = pw_cache_mpinfo.mp_id"; $order = "entered_house, last_name, first_name, constituency"; $query = "{$mps_query_start} and house = 'commons' order by {$order}"; $db->query($query); while ($row = $db->fetch_row_assoc()) { print "\n"; print "<memberinfo id=\"uk.org.publicwhip/member/" . $row['mp_id'] . "\" \n"; if ($row['left_house'] >= $last_div_date) { print " data_date=\"" . $last_div_date . "\"\n"; } else { print " data_date=\"complete\"\n"; } $att = $row['attendance']; if ($att == "") {