Example #1
0
function show_check_email($error_msg) {
     
    /* Show them the "check your email and click the link" template. */
     global $fyr_representative, $fyr_voting_area; 
     global $fyr_values, $fyr_date, $fyr_group_msg, $cobrand;
     $our_values = array_merge($fyr_values, array('representative' => $fyr_representative,
            'voting_area' => $fyr_voting_area, 'date' => $fyr_date, 'group_msg' => $fyr_group_msg,
            'error_msg' => $error_msg, 'cobrand' => $cobrand, 'host' => fyr_get_host()));
     template_draw("write-checkemail", $our_values); 
}
Example #2
0
if ($a_forward) {
    # Subset of representatives
    $area_types = fyr_parse_area_type_list($a_forward);
    if ($area_types) {
        $area_type_desc = fyr_describe_area_type_list($area_types);
        if (!$forced_rep_type) {
            $fyr_all_url = htmlspecialchars(url_new('', false, 'pc', get_http_var('pc'), 'fyr_extref', fyr_external_referrer(), 'cocode', get_http_var('cocode')));
        }
        $blurb_top = "<h2>Write to your {$area_type_desc}</h2><p>Over 200,000 messages sent last year.</p>";
    }
}
if ($template != 'index-advice') {
    header('Cache-Control: max-age=3600');
}
$options = cobrand_postcode_form_options($cobrand);
$form = postcode_form($pc, $cobrand, $cocode, $a_forward, $error_message, $options);
$num_messages = null;
if ($cobrand && file_exists("../../data/cobrand.csv")) {
    if (($handle = fopen("../../data/cobrand.csv", "r")) !== false) {
        while (($row = fgetcsv($handle)) !== false) {
            if ($row[0] === $cobrand) {
                $num_messages = $row[1];
                break;
            }
        }
        fclose($handle);
    }
}
// Display page
template_draw($template, array('body_id' => 'home', "title" => $title, "blurb-top" => $blurb_top, "form" => $form, "error" => $error_message, "all_url" => $fyr_all_url, "cobrand" => $cobrand, "num_messages" => $num_messages, "template" => $template, "host" => fyr_get_host()));
Example #3
0
    array_push($fyr_rep_lists, $text);
    array_push($fyr_representatives, "$col_blurb$text$col_after");
    array_push($fyr_headings, "<h3>$heading</h3>");
    debug_timestamp();
}

// Display page, using all the fyr_* variables set above.
template_draw("who", array(
    "reps" => $fyr_representatives,
    "template" => "who", 
    "headings" => $fyr_headings,
    "error" => $fyr_error,
    "county_note" => $fyr_county_note,
    "all_url" => $fyr_all_url,
    "cobrand" => $cobrand, 
    "host" => fyr_get_host(), 
    "rep_lists" => $fyr_rep_lists, 
    "rep_descs" => $fyr_rep_descs
    ));

debug_timestamp();

function write_all_link($va_type, $rep_desc_plural) {
    global $cobrand, $cocode;
    global $fyr_postcode;
    if ($rep_desc_plural == 'London Assembly Members')
        $rep_desc_plural = 'London Assembly list members';
    if ($rep_desc_plural == 'MSPs')
        $rep_desc_plural = 'regional MSPs';
    $url = general_write_all_url($va_type, $fyr_postcode);
    $a = cobrand_write_all_link($cobrand, $url, $rep_desc_plural, $cocode);
Example #4
0
// A/B Testing Hack!
if (isset($_GET['t'])) {
    $template = $_GET['t'];
} else {
    $template = 'who';
}
// Inject extra content for Lords
// A/B Testing Hack!
if ($template == 'who' && !$area_types) {
    array_push($fyr_headings, 'House of Lords');
    array_push($fyr_blurbs, '<p>Lords are not elected by you, but they still get to vote in Parliament just like your MP. You may want to write to a Lord (<a href="about-lords">more info</a>).</p>');
    array_push($fyr_representatives, '<ul class="rep-list lords"><li><a href="/lords">Write to a Lord</a></li></ul>');
    array_push($fyr_more, '');
}
// Display page, using all the fyr_* variables set above.
template_draw($template, array("reps" => $fyr_representatives, "template" => "who", "headings" => $fyr_headings, "blurbs" => $fyr_blurbs, "more" => $fyr_more, "all_url" => $fyr_all_url, "cobrand" => $cobrand, "host" => fyr_get_host(), "rep_lists" => $fyr_rep_lists, "rep_descs" => $fyr_rep_descs));
debug_timestamp();
# ---
function get_postcode()
{
    $postcode = canonicalise_postcode(get_http_var('pc'));
    if (!$postcode) {
        header('Location: /');
        exit;
    }
    debug("FRONTEND", "postcode is {$postcode}");
    fyr_rate_limit(array('postcode' => array($postcode, "Postcode that's been typed in ")));
    return $postcode;
}
function get_area_types()
{
Example #5
0
    if (!$missing_token_message) {
        $missing_token_message = "Please make sure you copy the URL from your email properly. The token was missing.";
    }
    template_show_error($missing_token_message);
}
$answer = get_http_var('answer');
if ($answer != "yes" && $answer != "no") {
    $missing_answer_message = cobrand_missing_answer_message($cobrand);
    if (!$missing_answer_message) {
        $missing_answer_message = "Please make sure you copy the URL from your email properly. The answer type was missing.";
    }
    template_show_error($missing_answer_message);
}
$yes_url = cobrand_url($cobrand, "/firsttime?token=" . urlencode($token) . "&amp;answer=yes", $cocode);
$no_url = cobrand_url($cobrand, "/firsttime?token=" . urlencode($token) . "&amp;answer=no", $cocode);
$values = array('first_time_yes' => "\"{$yes_url}\"", 'first_time_no' => "\"{$no_url}\"", 'cobrand' => $cobrand, 'cocode' => $cocode, 'host' => fyr_get_host());
// Look up info about the message
$msg_id = msg_get_questionnaire_message($token);
msg_check_error($msg_id);
if (!$msg_id) {
    $unfound_token_message = cobrand_unfound_token_message($cobrand);
    if (!$unfound_token_message) {
        $unfound_token_message = "Failed to look up message id for token";
    }
    template_show_error($unfound_token_message);
}
$msg_info = msg_admin_get_message($msg_id);
msg_check_error($msg_info);
$values = array_merge($msg_info, $values);
// 0 is the responsiveness question
$result = msg_record_questionnaire_answer($token, 0, $answer);
Example #6
0
if (rabx_is_error($result)) {
    if ($result->code == FYR_QUEUE_MESSAGE_EXPIRED) {
        $url = cobrand_url($cobrand, "/", $cocode);
        $text = <<<EOF
You took so long to confirm your message that under our privacy policy 
your message has already been removed from our database. 
If you’d still like to write a message, you can <a href="{$url}">try again from the
beginning
EOF;
        template_show_error($text);
    } else {
        template_show_error($result->text);
    }
}
if (!$result) {
    template_draw("confirm-trouble", $template_params);
} else {
    $values = msg_admin_get_message($result);
    if (rabx_is_error($values)) {
        template_show_error($values->text);
    } elseif ($values['cobrand'] && cobrand_post_letter_send($values)) {
        // Do nothing - cobrand_post_letter_send must do the special action e.g. header or template_draw etc.
    } else {
        $values['cobrand'] = $cobrand;
        $values['host'] = fyr_get_host();
        template_draw("confirm-accept", $values);
    }
}
?>