} $id = $ids[count($ids) - 1]; $matches[] = $id; $reason[] = '(of ' . $lordofname_full . ')'; } } $f = file('../phplib/DoBsP.bsv'); foreach ($f as $r) { list($id, $dob, $education) = explode('|', $r); $education = trim(str_replace('; ', "\n", $education)); if (!$education) { continue; } if (preg_match("#.*{$place}.*#i", $education, $m)) { $ids = dadem_get_same_person('uk.org.publicwhip/person/' . $id); if (dadem_get_error($ids)) { continue; } $id = $ids[count($ids) - 1]; $matches[] = $id; $reason[] = '(' . $m[0] . ')'; } } if (!count($matches)) { $error = 'No Lords associated with that place, I\'m afraid. Pick another place.'; lords_form(array('place' => $error)); # } elseif (count($matches)==1) { # header('Location: ' . url_new('write', false, 'fyr_extref', fyr_external_referrer(), 'cocode', get_http_var('cocode'), 'who', $matches[0])); # exit; } else { $reps_info = dadem_get_representatives_info($matches);
msg_check_error($msgid); array_push($msgid_list, $msgid); array_push($repid_list, $repid); } $fyr_values['fyr_msgid_list'] = implode('_', $msgid_list); $fyr_values['fyr_repid_list'] = implode('_', $repid_list); } } else { // Message intended for individual representative // Information specific to this representative debug("FRONTEND", "Single representative $fyr_who"); $fyr_representative = dadem_get_representative_info($fyr_who); if (dadem_get_error($fyr_representative)) { $location = "who?pc=" . urlencode($fyr_postcode); $a = get_http_var('a'); if ($a) { $location .= "&a=" . urlencode($a); } header("Location: " . $location); exit; } // The voting area is the ward/division. e.g. West Chesterton Electoral Division $fyr_voting_area = mapit_get_voting_area_info($fyr_representative['voting_area']); if (mapit_get_error($fyr_voting_area)) { header("Location: /who?pc=" . urlencode($fyr_postcode)); exit; }
function get_rep($id) { debug("FRONTEND", "Single representative {$id}"); $rep = dadem_get_representative_info($id); if (dadem_get_error($rep)) { back_to_who(); } return $rep; }
} } // If in a county, but not a county electoral division, display explanation // (which is lack of data from Ordnance Survey) $fyr_county_note = false; if (array_key_exists('CTY', $voting_areas) && !array_key_exists('CED', $voting_areas)) { $fyr_county_note = true; } $voting_areas_info = mapit_get_voting_areas_info(array_values($voting_areas)); mapit_check_error($voting_areas_info); debug_timestamp(); $area_representatives = dadem_get_representatives(array_values($voting_areas)); $error = dadem_get_error($area_representatives); dadem_check_error($area_representatives); debug_timestamp(); $all_representatives = array(); foreach (array_values($area_representatives) as $rr) { $all_representatives = array_merge($all_representatives, $rr); } $representatives_info = dadem_get_representatives_info($all_representatives); dadem_check_error($representatives_info); debug_timestamp(); $meps_hidden = euro_check($area_representatives, $voting_areas); // For each voting area in order, find all the representatives. Put // descriptive text and form text in an array for the template to
function dadem_check_error($data) { if ($error_message = dadem_get_error($data)) { err($error_message); } }
function print_messages($messages, $msgid = null) { ?> <table border="1" width="100%"> <tr> <th>Created</th> <th>Message ID /<br>Group ID</th> <th>Last state change</th> <th>State /<br>Last action</th> <th>Sender</th> <th>Recipient</th> <th>Client IP / <br> Referrer / Cobrand</th> <th>Length (chars)</th> <th>Questionnaire</th> <th>Tick</th> </tr> <form action="<?=htmlspecialchars(url_new("", false, 'view', get_http_var('view'), 'simto', get_http_var('simto'), 'page', get_http_var('page'))) ?>" method="post"> <? $c = 1; foreach ($messages as $message) { print '<tr' . ($c==1 ? ' class="v"' : '') . '>'; print "<td>" . strftime('%Y-%m-%d %H:%M:%S', $message['created']) . "</td>"; print '<td><a href="' . $this->self_link . "&id=".urlencode($message['id']) . '">' . $message['id'] . '</a>' . "<br>${message['group_id']}" . '</td>'; print "<td>" . strftime('%Y-%m-%d %H:%M:%S', $message['laststatechange']) . "</td>"; print "<td>"; print add_tooltip($message['state'], $this->state_help_notes($message['state'])); /* Only show frozen flag if the message is in a state this can * affect. */ if ($message['frozen']) { if ($message['state'] == 'new' or $message['state'] == 'pending' or $message['state'] == 'ready') print "<br><b>frozen</b>"; else print "<br>frozen"; } if ($message['numactions'] > 0) { if ($message['state'] == 'pending') { print "<br>" . ($message['numactions'] - 1) . " ". make_plural(($message['numactions'] - 1), 'reminder'); } elseif ($message['state'] == 'sent' || $message['state'] == 'failed_closed') { print "<br>". $message['numactions'] . " " . make_plural($message['numactions'], 'day'); } elseif ($message['state'] == 'ready') { print "<br>". $message['numactions'] . " " . make_plural($message['numactions'], 'failure'); } else { print "<br>". $message['numactions'] . " " . make_plural($message['numactions'], 'attempt'); } } if ($message['lastaction'] > 0 && $message['state'] != 'failed_closed') print "<br>" . strftime('%Y-%m-%d %H:%M:%S', $message['lastaction']); print "</td>"; print "<td>" . htmlspecialchars($message['sender_name']) . "<br>" . str_replace($message['sender_postcode'], '<a href="'.OPTION_BASE_URL.'/who?pc='.urlencode($message['sender_postcode']).'">'.$message['sender_postcode'].'</a>', htmlspecialchars($message['sender_addr']) ) . "<br>" . htmlspecialchars($message['sender_email']) . "</td>"; $display_name = $message['recipient_name']; if (!isset($display_name) || $display_name == "") { $display_name = "scrubbed, id " . $message['recipient_id'] . ", " . $message['recipient_type']; } print '<td><a href="' . htmlspecialchars(url_new('', false, 'page', 'reps', 'rep_id', $message['recipient_id'], 'pc', $message['sender_postcode'])) . '">' . htmlspecialchars($display_name) . "</a>" . " (<a href=\"" . htmlspecialchars(url_new('', false, 'page', 'fyrqueue', 'rep_id', $message['recipient_id'])) . '">msgs</a>)' ."<br>"; if ($message['recipient_via']) { $repinfo = dadem_get_representative_info($message['recipient_id']); if (!dadem_get_error($repinfo)) { $vainfo = mapit_get_voting_area_info($repinfo['voting_area']); $parentinfo = mapit_get_voting_area_info($vainfo['parent_area_id']); mapit_check_error($parentinfo); print '<a href="' . htmlspecialchars(url_new('', false, 'page', 'reps', 'ds_va_id', $vainfo['parent_area_id'], 'pc', $message['sender_postcode'])) . '">' . htmlspecialchars("via " . $parentinfo['name']) . "</a>:<br>"; } else { print 'recipient_via contact, but rep id not found '; } } if ($message['recipient_email']) print htmlspecialchars($message['recipient_email']) . "<br>"; if ($message['recipient_fax']) print htmlspecialchars($message['recipient_fax']) . "<br>"; print "</td>"; print "<td><a href=\"ipaddrinfo.cgi?ipaddr=${message['sender_ipaddr']}\">${message['sender_ipaddr']}</a>". "<br>" . trim_url($message['sender_referrer']) . "<br>" . $message['cobrand'] . " " . $message['cocode'] . "</td>"; print "<td>${message['message_length']}</td>"; $outof0 = ($message['questionnaire_0_no'] + $message['questionnaire_0_yes']); $outof1 = ($message['questionnaire_1_no'] + $message['questionnaire_1_yes']); print '<td>'; if ($outof0) { print 'responded:'; print $message['questionnaire_0_yes'] .'/'. $outof0; } if ($outof0 && $outof1) print '<br>'; if ($outof1) { print ' firsttime:'; print $message['questionnaire_1_yes'] .'/'. $outof1; } if ($message['no_questionnaire']) { print "<br>no quest"; } if (!$outof0 && !$outof1) { print ' '; } print '</td>'; /* Javascript code changes shading of table row for checked * messages to make them look "selected". */ print '<td><input type="checkbox" name="check_' . $message['id'] . '" onclick="this.parentNode.parentNode.className = this.checked ? \'h\' : \'' . ($c == 1 ? 'v' : '') . '\'" >'; print '</td>'; print "</tr>"; # this.checked this .className= if (array_key_exists('diff', $message)) { /* Each element of the array consists either of an array of * two strings, which are the strings unique to the "from" * and "to" strings; or a string, representing a common * part; or null, indicating an elided part. */ print '<tr'.($c==1?' class="v"':'').'><td colspan = "9">'; print "<b>Differences: </b> "; if (isset($msgid) and $message['id'] == $msgid) { print 'This is the message being compared against. <span class="difffrom">Text that appears only in this message, </span><span class="diffto">or only in the other message.</span>'; } else { foreach ($message['diff'] as $elem) { if (!isset($elem)) { print '<span class="diffsnipped">[ ... snipped ... ]</span>'; } else if (is_array($elem)) { print '<span class="difffrom">' . htmlspecialchars($elem[0]) . '</span><span class="diffto">' . htmlspecialchars($elem[1]) . '</span>'; } else { print htmlspecialchars($elem); } } } print "</td></tr>"; } $c = 1 - $c; } if (count($messages) > 1) { ?><tr><td colspan=9><b>Ticked items:</b> <input name="token" value="<? print get_token(); ?>" type="hidden" /> <input size="20" name="notebody" type="text" /> <input name="note" value="Note" type="submit" /> <b>Action:</b> <input name="freeze" value="Freeze" type="submit" /> <input name="thaw" value="Thaw" type="submit" /> <input name="error" value="Error with email" type="submit" /> <input name="failed" value="Fail silently" type="submit" /> </td><tr> <? } ?> </form> </table> <? }
} elseif (preg_match("#$place#i", $lordofname_full)) { $ids = dadem_get_same_person('uk.org.publicwhip/person/'.$pid); if (dadem_get_error($ids)) continue; $id = $ids[count($ids)-1]; $matches[] = $id; $reason[] = '(of ' . $lordofname_full . ')'; } } $f = file('../phplib/DoBsP.bsv'); foreach ($f as $r) { list($id, $dob, $education) = explode('|', $r); $education = trim(str_replace('; ', "\n", $education)); if (!$education) continue; if (preg_match("#.*$place.*#i", $education, $m)) { $ids = dadem_get_same_person('uk.org.publicwhip/person/'.$id); if (dadem_get_error($ids)) continue; $id = $ids[count($ids)-1]; $matches[] = $id; $reason[] = '('.$m[0].')'; } } if (!count($matches)) { $error = 'No Lords associated with that place, I\'m afraid. Pick another place.'; lords_form(array('place'=>$error)); # } elseif (count($matches)==1) { # header('Location: ' . url_new('write', false, 'fyr_extref', fyr_external_referrer(), 'cocode', get_http_var('cocode'), 'who', $matches[0])); # exit; } else { $reps_info = dadem_get_representatives_info($matches); dadem_check_error($reps_info); print '<p>';