function test_url() { $url = cobrand_url('mysite', 'url', 'cocode'); $this->assertEqual('rewritten_url', $url, 'Should return the url as rewritten by the cobrand if the cobrand defines a url function'); $url = cobrand_url('nosite', 'url', 'cocode'); $this->assertEqual('url', $url, 'Should return the url passed if there is no cobrand url function'); }
function rabx_mail_error_msg($code, $text) { global $cobrand, $cocode; /* Return an appropriate error message for a RABX error code. * Log errors other than multiple send attempts */ $error_msg = ""; $base_url = cobrand_url($cobrand, '/', $cocode); if ($code == FYR_QUEUE_MESSAGE_ALREADY_QUEUED) { $error_msg = "You've already sent this message. To send a new message, please <a href=\"$base_url\">start again</a>."; } elseif ($code == FYR_QUEUE_GROUP_ALREADY_QUEUED) { $error_msg = "You've already sent these messages. To send a new message, please <a href=\"$base_url\">start again</a>."; } else { error_log("write.php msg_write error: ". $code . " " . $text); $error_msg = "Sorry, an error has occurred. Please contact <a href=\"mailto:team@writetothem.com\">team@writetothem.com</a>."; } return $error_msg; }
function mismatch_error() { global $cobrand, $cocode; $url = cobrand_url($cobrand, "/", $cocode); template_show_error("There’s been a mismatch error. Sorry about\n this, <a href=\"{$url}\">please start again</a>."); }
function display_reps($va_type, $representatives, $va_info, $options) { global $representatives_info, $fyr_postcode, $cobrand, $cocode; $rep_list = ''; $photo = 0; $default_options = cobrand_rep_list_options($cobrand); $options = array_merge($default_options, $options); foreach ($representatives as $rep_specificid) { $rep_info = $representatives_info[$rep_specificid]; $rep_list .= '<li>'; $url = general_write_rep_url($va_type, $rep_specificid, $fyr_postcode); $a = '<a href="' . cobrand_url($cobrand, $url, $cocode) . '">'; if ($rep_specificid == '2000005') { $rep_list .= $a . '<img alt="" title="Portrait of Stom Teinberg MP" src="images/zz99zz.jpeg" align="left" border="0">'; $photo = 1; } elseif (array_key_exists('image', $rep_info)) { $rep_list .= $a . '<img alt="" title="Portrait of ' . htmlspecialchars($rep_info['name']) . '" src="' . $rep_info['image'] . '" align="left">'; $photo = 1; } if ($photo == 0) $rep_list .= $a; $rep_list .= htmlspecialchars($rep_info['name']) . '</a>'; if (array_key_exists('party', $rep_info)) { if ($options['extra_space']) { $rep_list .= '<br>'; } $rep_list .= '<span class="party">' . htmlspecialchars($rep_info['party']) . '</span>'; } } if (array_key_exists('include_write_all', $options) && $options['include_write_all'] && count($representatives) > 1){ $rep_list .= '<li class="all">'; $rep_list .= write_all_link($va_type, $va_info['rep_name_plural']); $rep_list .= '</li>'; } $rep_type = str_replace(' ', '-', strtolower($va_info['rep_name_plural'])); $out = '<ul class="' . $rep_type . '" '; if ($photo==1) $out .= ' id="photo"'; if (array_key_exists('small', $options) && $options['small']) $out .= ' style="font-size:83%"'; $out .= '>'; $out .= $rep_list . '</ul>'; return $out; }
$missing_token_message = cobrand_missing_token_message($cobrand); 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) . "&answer=yes", $cocode); $no_url = cobrand_url($cobrand, "/firsttime?token=" . urlencode($token) . "&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
template_draw("confirm-accept", $values); exit; } $template_params = array('host' => fyr_get_host(), 'cobrand' => $cobrand); $token = get_http_var('token'); if (!$token) { $missing_token_message = cobrand_missing_token_message($cobrand); 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); } $result = msg_confirm_email($token); 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);