Example #1
0
            $data['policydivisions'] = $divisions->getMemberDivisionsForPolicy($policyID);
        } else {
            $data['policydivisions'] = $divisions->getAllMemberDivisionsByPolicy();
        }
        // data for the 'what else would you like to see' question box
        $data['user_code'] = bin2hex(urandom_bytes(16));
        $data['auth_signature'] = auth_sign_with_shared_secret($data['user_code'], OPTION_SURVEY_SECRET);
        $data['page_url'] = "http://" . DOMAIN . $_SERVER['REQUEST_URI'] . ($policyID ? '&' : '?') . 'answered=1';
        $data['answered_q'] = $answered_q;
        // Send the output for rendering
        MySociety\TheyWorkForYou\Renderer::output('mp/divisions', $data);
        break;
    case '':
    default:
        $policiesList = new MySociety\TheyWorkForYou\Policies();
        $policies = $policiesList->limitToSet('summary')->shuffle();
        // Generate limited voting record list
        $data['policyPositions'] = new MySociety\TheyWorkForYou\PolicyPositions($policies, $MEMBER, 6);
        // Send the output for rendering
        MySociety\TheyWorkForYou\Renderer::output('mp/profile', $data);
        break;
}
/////////////////////////////////////////////////////////
// SUPPORTING FUNCTIONS
/* Person lookup functions */
function get_person_by_id($pid)
{
    global $pagetype, $this_page;
    $MEMBER = new MySociety\TheyWorkForYou\Member(array('person_id' => $pid));
    if (!$MEMBER->valid) {
        throw new MySociety\TheyWorkForYou\MemberException('Sorry, that ID number wasn’t recognised.');