示例#1
0
    }
    /////////////////////////////////////////////////////////
    // DOES THE USER HAVE A POSTCODE ALREADY SET?
    // (Either in their logged-in details or in a cookie from a previous search.)
} elseif ($this_page == 'msp' && $THEUSER->postcode_is_set() && $name == '' && $cconstituency == '') {
    $this_page = 'yourmsp';
    if (postcode_is_scottish($THEUSER->postcode())) {
        regional_list($THEUSER->postcode(), 'SPC', 'msp');
        exit;
    } else {
        $PAGE->error_message('Your set postcode is not in Scotland.');
    }
} elseif ($this_page == 'mla' && $THEUSER->postcode_is_set() && $name == '' && $cconstituency == '') {
    $this_page = 'yourmla';
    if (postcode_is_ni($THEUSER->postcode())) {
        regional_list($THEUSER->postcode(), 'NIE', 'mla');
        exit;
    } else {
        $PAGE->error_message('Your set postcode is not in Northern Ireland.');
    }
} elseif ($THEUSER->postcode_is_set() && $name == '' && $cconstituency == '') {
    $MEMBER = new MEMBER(array('postcode' => $THEUSER->postcode()));
    member_redirect($MEMBER);
} elseif ($name && $cconstituency) {
    $MEMBER = new MEMBER(array('name' => $name, 'constituency' => $cconstituency));
    if ($MEMBER->house_disp == 2 && $this_page != 'peer' || !$MEMBER->canonical || $redirect) {
        member_redirect($MEMBER);
    }
    if ($MEMBER->the_users_mp) {
        $this_page = 'yourmp';
    }
示例#2
0
function get_regional_by_user_postcode($pc, $page)
{
    global $this_page;
    $this_page = "your{$page}";
    if ($page == 'msp' && postcode_is_scottish($pc)) {
        regional_list($pc, 'SPC', $page);
    } elseif ($page == 'mla' && postcode_is_ni($pc)) {
        regional_list($pc, 'NIE', $page);
    } else {
        throw new MySociety\TheyWorkForYou\MemberException('Your set postcode is not in the right region.');
    }
}