Exemple #1
0
function _api_getMembers_output($sql) {
	$db = new ParlDB;
	$q = $db->query($sql);
	$output = array();
  $last_mod = 0;
  for ($i=0; $i<$q->rows(); $i++) {
    $out = _api_getMP_row($q->row($i));
    $output[] = $out;
    $time = strtotime($q->field($i, 'lastupdate'));
    if ($time > $last_mod)
      $last_mod = $time;
  }
  api_output($output, $last_mod);
}
Exemple #2
0
function api_getPerson_id($id)
{
    $db = new ParlDB();
    $q = $db->query("select * from member\n\t\twhere person_id = '" . mysql_escape_string($id) . "'\n\t\torder by left_house desc");
    if ($q->rows()) {
        $output = array();
        $last_mod = 0;
        for ($i = 0; $i < $q->rows(); $i++) {
            $house = $q->field($i, 'house');
            if ($house == 0) {
                $out = _api_getRoyal_row($q->row($i));
            } else {
                if ($house == 1) {
                    $out = _api_getMP_row($q->row($i));
                } else {
                    if ($house == 2) {
                        $out = _api_getLord_row($q->row($i));
                    } else {
                        if ($house == 3) {
                            $out = _api_getMLA_row($q->row($i));
                        } else {
                            if ($house == 4) {
                                $out = _api_getMSP_row($q->row($i));
                            }
                        }
                    }
                }
            }
            $output[] = $out;
            $time = strtotime($q->field($i, 'lastupdate'));
            if ($time > $last_mod) {
                $last_mod = $time;
            }
        }
        api_output($output, $last_mod);
    } else {
        api_error('Unknown person ID');
    }
}
Exemple #3
0
		left join personinfo on member.person_id = personinfo.person_id
			and personinfo.data_key='date_of_birth'
	where consinfo.data_key = 'bbc_constituency_id'
		and consinfo.data_value = " . mysql_real_escape_string($bbc_cons_id));
if (!$q->rows())
	error('Unknown constituency ID');

$cons = $q->field(0, 'constituency');
$pid = $q->field(0, 'person_id');

$action = get_http_var('action');
if ($action == 'latest') {
	header("Location: http://www.theyworkforyou.com/rss/mp/$pid.rdf");
	exit;
} elseif ($action == 'data') {
	$output = _api_getMP_row($q->row(0));
	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/'
Exemple #4
0
function _api_getMP_constituency($constituency)
{
    $db = new ParlDB();
    if ($constituency == '') {
        return false;
    }
    if ($constituency == 'Orkney ') {
        $constituency = 'Orkney &amp; Shetland';
    }
    $normalised = normalise_constituency_name($constituency);
    if ($normalised) {
        $constituency = $normalised;
    }
    $q = $db->query("SELECT * FROM member\n\t\tWHERE constituency = '" . mysql_real_escape_string($constituency) . "'\n\t\tAND left_reason = 'still_in_office' AND house=1");
    if ($q->rows > 0) {
        return _api_getMP_row($q->row(0));
    }
    if (get_http_var('always_return')) {
        $q = $db->query("SELECT * FROM member\n\t\t\tWHERE house=1 AND constituency = '" . mysql_real_escape_string($constituency) . "'\n\t\t\tORDER BY left_house DESC LIMIT 1");
        if ($q->rows > 0) {
            return _api_getMP_row($q->row(0));
        }
    }
    return false;
}