コード例 #1
0
ファイル: write.php プロジェクト: nallachaitu/writetothem
function renderForm($form, $pageName, $options)
{
    global $fyr_form, $fyr_values, $warning_text;
    global $rep_text, $fyr_group_msg, $fyr_valid_reps, $cobrand;
    global $general_error, $cocode;
    debug("FRONTEND", "Form values:", $fyr_values);
    
    // $renderer =& $page->defaultRenderer();
    if (is_object($form)) {
        $renderer =& $options['renderer'];
        if ($options['table_layout']){
            $renderer->setGroupTemplate('<TR><TD ALIGN=right colspan=2> {content} </TD></TR>', 'previewStuff'); // TODO CSS this
            $renderer->setElementTemplate('
            <!-- BEGIN error -->
            <TR><TD colspan=2>
            <span class="error">{error}:</span>
            </TD></TR>                                                   
            <!-- END error -->
            <TR><TD colspan=2>
            {element}
            </TD></TR>', 'body');
        } else {
            $renderer->setElementTemplate('
            <!-- BEGIN error -->
            <p class="error">{error}:</p>
            <!-- END error -->
            {element}', 'body');
        }
        $renderer->setElementTemplate('{element}', 'previewStuff');
        $form->accept($renderer);
    // Make HTML
        $fyr_form = $renderer->toHtml();
        if ($options['table_layout']){     
            $fyr_form = preg_replace('#(<form.*?>)(.*?)(</form>)#s','$1<div id="writebox">$2</div>$3',$fyr_form);
        }
    } else {
        $fyr_form = $form;
    }

    // Add time-shift warning if in debug mode
    if (OPTION_FYR_REFLECT_EMAILS) {
        $fyr_today = msg_get_date();
        msg_check_error($fyr_today);
        if ($fyr_today != date('Y-m-d')) {
            $fyr_form = "<p style=\"text-align: center; color: #ff0000; \">Note: On this test site, the date is faked to be $fyr_today</p>" . $fyr_form;
        }
    }

    $prime_minister = false;
    global $fyr_preview, $fyr_representative, $fyr_voting_area, $fyr_date;
    if ($fyr_values['who'] == 47292) { # Hardcoded
        $prime_minister = true;
    }

    $cobrand_letter_help = false;
    global $cobrand;
    if ($pageName == 'writeForm' && $cobrand) {
        $cobrand_letter_help = cobrand_get_letter_help($cobrand, $fyr_values);

   }
    $our_values = array_merge($fyr_values, array('representative' => $fyr_representative,
            'voting_area' => $fyr_voting_area, 'form' => $fyr_form,
            'date' => $fyr_date, 'prime_minister' => $prime_minister,
            'cobrand_letter_help' => $cobrand_letter_help, 
            'cobrand' => $cobrand,
            'group_msg' => $fyr_group_msg, 'warning_text' => $warning_text, 
            'general_error' => $general_error, 
            'host' => fyr_get_host()));

    if ($fyr_group_msg) {
        # check if there are any reps whose message will be sent via somewhere 
        # else
        $any_via = false;
        foreach ($fyr_valid_reps as $rep) {
            if ($rep['method'] == 'via') {
                $any_via = true;
            }
        }
        $our_values['any_via'] = $any_via;
        $our_values['title_text'] = "your " . $fyr_voting_area['rep_name_long_plural'] ;
    } else {
        $our_values['title_text'] = trim($fyr_voting_area['rep_prefix'] . " " .
            $fyr_representative['name'] . " " . $fyr_voting_area['rep_suffix']) . ", " .
            $fyr_voting_area['name'];
    }
    if ($pageName == "writeForm") {
        template_draw("write-write", $our_values);
    } elseif ($pageName == 'previewForm') {
        // Generate preview
        $formatted_body = fyr_format_message_body_for_preview($our_values['body']);
        $our_values['body_indented'] = $formatted_body;
        $our_values['rep_text'] = $rep_text;
        $fyr_preview = template_string("fax-content", $our_values);
        template_draw("write-preview", array_merge($our_values, array('preview' => $fyr_preview)));
    } else {
        $message = cobrand_generic_error_message($cobrand, $cocode, $pageName);
        if (!$message) {
             $message = 'Sorry. An error has occurred: pageName "'
                    . htmlspecialchars($pageName) .
                '". Please get in touch with us at
                <a href="mailto:team&#64;writetothem.com">team&#64;writetothem.com</a>,
                quoting this message. You can <a href="/">try again from the
                beginning</a>.';
        }
        template_show_error($message);
    }
}
コード例 #2
0
    function display($self_link) {
        $this->self_link = $self_link;

        #print "<pre>"; print_r($_POST); print "</pre>";
        $view = get_http_var('view', 'needattention');
        $id = get_http_var("id");
        $rep_id = get_http_var("rep_id");

        // Display about id
        if ($id) {
            if ($this->do_actions($id)) {
#               header("Location: ".$_SERVER['REQUEST_URI'] . "\n");
#               exit;
            }

            // Navigation bar
            $this->render_bar($view, false, $id);

            // Display general information
            print "<h2>Message id " . make_ids_links($id) . ":</h2>";

            $message = msg_admin_get_message($id);
            msg_check_error($message);
            $this->print_message($message);

            // Commands
            $form = new HTML_QuickForm('messageForm', 'post', $self_link);
            if (!get_http_var('note')) {
                $actiongroup[] = &HTML_QuickForm::createElement('text', 'notebody', null, array('size'=>30));
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'note', 'Note');
            }
            $actiongroup[] = &HTML_QuickForm::createElement('static', null, null, " <b>Action:</b>");
            if ($message['frozen']) {
                if ($message['state'] != 'error' and $message['state'] != 'failed' and $message['state'] != 'failed_closed') 
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'error', 'Error with email');
                if ($message['state'] != 'failed' and $message['state'] != 'failed_closed')
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'failed', 'Fail silently');
                if ($message['state'] != 'error' and $message['state'] != 'failed' and $message['state'] != 'failed_closed')
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'thaw', 'Thaw');
            }
            else {
                if ($message['state'] != 'error' and $message['state'] != 'failed' and $message['state'] != 'failed_closed') 
                    $actiongroup[] = &HTML_QuickForm::createElement('submit', 'freeze', 'Freeze');
            }
            if ($message['no_questionnaire'])
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'yes_questionnaire', 'Allow Questionnaire');
            else
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'no_questionnaire', 'No Questionnaire');
            if ($message['state'] == 'pending')
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'ready', 'Confirm');
            elseif ($message['state'] == 'failed' || $message['state'] == 'failed_closed')
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'ready', 'Retry');

            if (!get_http_var('body'))
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'body', 'View Body');
            else
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'nobody', 'Hide Body');
            if (!get_http_var('wire_emails'))
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'wire_emails', 'View Emails');
            else
                $actiongroup[] = &HTML_QuickForm::createElement('submit', 'no_wire_emails', 'Hide Emails');
            $form->addElement('hidden', 'id', $id);
            $form->addElement('hidden', 'token', get_token());
            $form->addGroup($actiongroup, "actiongroup", "",' ', false);

            admin_render_form($form);
            print 'Similar messages: ';
            print '<a href="'
                    .  htmlspecialchars(url_new("", true, 'view', 'similarbody', 'simto', $id, 'id', null))
                    .  '">different rep</a>, ';
            print '<a href="'
                    .  htmlspecialchars(url_new("", true, 'view', 'similarbodysamerep', 'simto', $id, 'id', null))
                    .  '">same rep</a> ';

            // Links to send messages to sender
            print " Email sender: <small>";
            make_mailto_link($message['sender_email'], 
                "Your message to " . $message['recipient_name'] . " has not been sent",
                "Hi " . $message['sender_name']. ",

Unfortunately, your message to " . $message['recipient_name'] . " has not been sent. You can only use our service to write to your own elected representatives, not to representatives for other places.  Here is a full explanation as to why we have this policy:
    http://www.writetothem.com/about-qa#onlyrep

There's a copy of your message below, so you can send it another way, if you like.

-------------------------------------------------------------",
                "write-to-own-reps-only");
            make_mailto_link($message['sender_email'], 
                "Your message to " . $message['recipient_name'],
                "Hi " . $message['sender_name']. ",



-------------------------------------------------------------\n\n".
                $message['message'],
                "blank-mail-quoting-message");
            print "</small>";

            // Body text if enabled
            if (get_http_var('body')) {
                print "<h2>Body text of message (only read if you really need to)</h2>";
                print "<blockquote>";
                print nl2br(htmlspecialchars($message['message']));
                print "</blockquote>";
            }

            // Body text if enabled
            if (get_http_var('wire_emails')) {
                foreach (array('representative', 'confirm', 'confirm-reminder', 'failure', 'questionnaire', 'questionnaire-reminder') as $type) {
                    print "<h2>Wire text of email - $type</h2>";
                    $wire = msg_admin_get_wire_email($message['id'], $type);
                    if (msg_get_error($wire)) {
                        print "Error contacting queue:";
                        print_r($wire);
                    } else {
                        print "<pre>";
                        print ms_make_clickable(htmlspecialchars($wire));
                        print "</pre>";
                    }
                }
            }

            // Questionnaire answers if there are any
            if (is_array($message['questionnaires']) and count($message['questionnaires']) > 0) {
                print "<h2>Questionnaire Responses</h2>";
                foreach ($message['questionnaires'] as $q) {
                    if ($q['question_id'] == 0) {
                        print "Reply within two/three weeks:";
                    } elseif ($q['question_id'] == 1) {
                        print "First time contacted any representative:";
                    } else {
                        print $q['question_id'] . ":";
                    }
                    print " <b>" . $q['answer'] .  "</b><br>";
                }
            }
 
            // Log of what has happened to message
            $allevents = get_http_var('allevents', 0);

            print '<h2>' .
                    ($allevents
                        ? 'All events for this message'
                        : 'Important events for this message')
                    . '</h2>';

            print ($allevents
                    ? '<a href="'
                        . htmlspecialchars(url_new('', true, 'allevents', null))
                        . '">View only important events</a>'
                    : '<a href="'
                        . htmlspecialchars(url_new('', true, 'allevents', 1))
                        . '">View all events</a>');
                    
            $recents = msg_admin_message_events($id, !$allevents);
            if (msg_get_error($recents)) {
                print "Error contacting queue:";
                print_r($recents);
                $recents = array();
            }

            $this->print_events($recents);

            if (count($message['bounces']) > 0) {
                print "<h2>Bounce Messages</h2>";
                foreach ($message['bounces'] as $bounce) {
                    print "<hr>";
                    print "<blockquote>" .  nl2br(htmlspecialchars($bounce)) .  "</blockquote>";
                }
                print "<hr>";
                if ($message['state'] == 'bounce_confirm') {
                    $form = new HTML_QuickForm('bounceForm', 'post', $self_link);
                    $bouncegroup[] = &HTML_QuickForm::createElement('submit', 'error', 'Fatal Delivery Error');
                    $bouncegroup[] = &HTML_QuickForm::createElement('submit', 'bounce_wait', 'Temporary Problem');
                    $bouncegroup[] = &HTML_QuickForm::createElement('submit', 'ready', 'Fatal Delivery Error, but should retry with same details');
                    $form->addGroup($bouncegroup, "bouncegroup", "Which kind of bounce message is this?",' ', false);
                    $form->addElement('hidden', 'id', $id);
                    $form->addElement('hidden', 'token', get_token());
                    admin_render_form($form);
                }
            }
         } elseif ($view == 'statistics') {
            // Display general statistics
            $stats = msg_admin_get_stats(1);
            if (msg_get_error($stats)) {
                print "Error contacting queue:";
                print_r($stats);
            }

            $freq_referrers_day = msg_admin_get_popular_referrers(60 * 60 * 24);
            if (msg_get_error($freq_referrers_day)) {
                print "Error contacting queue:";
                print_r($freq_referrers_day);
            }

            $freq_referrers_week = msg_admin_get_popular_referrers(60 * 60 * 24 * 7);
            if (msg_get_error($freq_referrers_week)) {
                print "Error contacting queue:";
                print_r($freq_referrers_week);
            }

            // Navigation bar
            $this->render_bar($view, false, $id);


?>
<h2>Queue statistics</h2>
<p>
<b><?=$stats["created_1"]?></b> new in last hour,
<b><?=$stats["created_24"]?></b> new in last day,
<b><?=$stats["created_168"]?></b> new in last week
<br>last fax sent <b><?=strftime('%e %b %Y, %H:%M', $stats["last_fax_time"])?></b>, 
last email sent <b><?=strftime('%e %b %Y, %H:%M', $stats["last_email_time"])?></b>
</p>
<h2>Messages in each state by type (created in last day)</h2>
<? $this->_display_state_table($stats, "day "); ?>
<h2>Messages in each state by type (created in last week)</h2>
<? $this->_display_state_table($stats, "week "); ?>
<h2>Messages in each state by type (created in last four weeks)</h2>
<? $this->_display_state_table($stats, "four "); ?>
<h2>Messages in each state by type (all time)</h2>
<? $this->_display_state_table($stats, "alltime "); ?>

<h2>Top referrers in last day</h2>
<table border=1>
<?
    foreach ($freq_referrers_day as $row) {
        if ($row[1] > 1 && $row[0] != "") {
            print "<tr><td>" . trim_url($row[0]) . "</td><td>$row[1]</td></tr>";
        }
    }
?>
</table>
<h2>Top referrers in last week</h2>
<table border=1>
<?
    foreach ($freq_referrers_week as $row) {
        if ($row[1] > 1 && $row[0] != "") {
            print "<tr><td>" . trim_url($row[0]) . "</td><td>$row[1]</td></tr>";
        }
    }
?>
</table>
<?
         } elseif ($rep_id) {
            $repinfo = dadem_get_representative_info($rep_id);
            dadem_check_error($repinfo);
            $sameperson = null;
            if ($repinfo['parlparse_person_id']) {
                $sameperson = dadem_get_same_person($repinfo['parlparse_person_id']);
                dadem_check_error($sameperson);
            }
            if (!$sameperson) 
                $sameperson = array($rep_id);
 
            $messages = array();
            $this->render_bar("rep_id", true, $id);
            $rep_ids = '';
            foreach ($sameperson as $this_rep_id) {
                $params = array('rep_id' => $this_rep_id);
                $new_messages = msg_admin_get_queue('rep_id', $params);
                if (msg_get_error($new_messages)) {
                    print "Error contacting queue:";
                    print_r($new_messages);
                    $new_messages = array();
                }
                $messages = array_merge($messages, $new_messages);
                $rep_ids = ' ' . $this_rep_id;
            }

            $by_year = array();
            foreach ($messages as $message) {
                if ($message['dispatched'])
                    $year = strftime('%Y', $message['dispatched']);
                else
                    $year = strftime('%Y', $message['created']);

                $by_year[$year][] = $message;
            }
            
            $years = array_keys($by_year);
            sort($years);
            foreach ($years as $year) {
                $year_array = $by_year[$year];
                print "<h2>Year $year for rep ids $rep_ids";
                print " (" . count($year_array) . " of them): </h2>";

                $q_by_email = array();
                $q_by_email_yes = array();
                $dispatched_by_email = array();
                $sent_by_email = array();
                $q_0_no = 0; $q_0_yes = 0;
                $q_1_no = 0; $q_1_yes = 0;
                $dispatched = 0;
                foreach ($year_array as $message) {
                    if (!array_key_exists($message['sender_email'], $q_by_email)) {
                        $q_by_email[$message['sender_email']] = 0;
                        $q_by_email_yes[$message['sender_email']] = 0;
                        $sent_by_email[$message['sender_email']] = 0;
                    }
                    $q_by_email[$message['sender_email']] += $message['questionnaire_0_no'];
                    $q_by_email[$message['sender_email']] += $message['questionnaire_0_yes'];
                    $q_by_email_yes[$message['sender_email']] += $message['questionnaire_0_yes'];
                    $q_0_no += $message['questionnaire_0_no'];
                    $q_0_yes += $message['questionnaire_0_yes'];
                    $q_1_no += $message['questionnaire_1_no'];
                    $q_1_yes += $message['questionnaire_1_yes'];
                    if ($message['dispatched'] && ($message['state'] == 'sent' || $message['state'] == 'finished')) {
                        $sent_by_email[$message['sender_email']] = $sent_by_email[$message['sender_email']] + 1;
                        $dispatched++;
                        $dispatched_by_email[$message['sender_email']] = true;
                    }
                }
                print "Dispatched: $dispatched (unique: " . count($dispatched_by_email) . ")";
                if ($q_0_yes + $q_0_no > 0) {
                    print " Responsiveness: $q_0_yes / " . ($q_0_no + $q_0_yes);
                }
                if ($q_1_yes + $q_1_no > 0) {
                    print " First time: $q_1_yes / " . ($q_1_no + $q_1_yes);
                }

                $html = '';
                foreach ($q_by_email as $email => $q_count) {
                    $sent_count = $sent_by_email[$email];
                    $q_count_yes = $q_by_email_yes[$email];
                    if ($q_count > 1 || $sent_count > 1) {
                        $html .= "<tr><td>$email</td><td>$sent_count</td><td>$q_count_yes / $q_count</td></tr>";
                    }
                }
                if ($html) {
                    print '<table border="1">';
                    print '<th>Multiple mailers</th><th>Message dispatched</th><th>Responses to first question</th>';
                    print $html;
                    print '</table>';
                } else {
                    print ' Nobody succesfully sent more than one message to this rep using same email.';
                }
                print '<p>';

                $this->print_messages($year_array, null);
            }
         } else {
            // Perform actions on checked items
            $sender_emails = array();
            $sender_full = array();
            foreach ($_POST as $k=>$v) {
                if (stristr($k, "check_")) {
                    $checkid = str_replace("check_", "", $k);
                    $this->do_actions($checkid);
                    $message = msg_admin_get_message($checkid);
                    msg_check_error($message);
                    array_push($sender_emails, $message['sender_email']);
                    array_push($sender_full, $message['sender_name'] . 
                            " &lt;" .  $message['sender_email'] . "&gt;");
                }
            }
            if (count($sender_emails) > 0) {
                print "<p><b>Email list for BCCing:</b><br>" .
                    implode(",", array_unique($sender_emails));
                print "<p><b>List of names and addresses:</b><br>" .
                    implode("<br>", array_unique($sender_full));
            }

            // Decide what message view to show
            $params = array();
            $reverse = false;
            if (stristr($view, "_rev")) {
                $view = str_replace("_rev", "", $view);
                $reverse = true;
            }
            if (get_http_var('search')) {
                $view = "search";
            }

            // Set up additional parameters for view if necessary.
            if ($view == "similarbody" || $view == 'similarbodysamerep') {
                $params['msgid'] = get_http_var('simto');
            } else if ($view == "search" || $view == "logsearch") {
                $params['query'] = get_http_var('query');
            }
            
            // Get details about view
            $messages = msg_admin_get_queue($view, $params);
            if (msg_get_error($messages)) {
                print "Error contacting queue:";
                print_r($messages);
                $messages = array();
            }

            // Navigation bar
            $this->render_bar($view, $reverse, $id);

            // Display messages
            print "<h2>Messages which";
            if ($view == "similarbody") {
                print " have similar bodies to " . make_ids_links(get_http_var('simto'));
            } elseif ($view == "similarbodysamerep") {
                print " are to the same representative and have similar bodies to " . make_ids_links(get_http_var('simto'));
            } elseif ($view == "search") {
                print " match search query '" . htmlspecialchars(get_http_var('query')) . "'";
            } elseif ($view == "logsearch") {
                print " whose log matches '" . htmlspecialchars(get_http_var('query')) . "'";
            } else {
                print " are $view";
            }
            print " (" . count($messages) . " messages): </h2>";
            if ($reverse) {
                $messages = array_reverse($messages);
            }
            $this->print_messages($messages, ($view == 'similarbody' || $view == 'similarbodysamerep') ? $params['msgid'] : null);
            if ($view == 'recentchanged' or $view == 'recentcreated')
                print "<p>..."; /* indicate that this isn't all the messages... */

            // Help
            ?>
            <h2>Help &mdash; what views/searches are there?</h2>
            <p>
            <b>Need Attention:</b> Message which are frozen, most likely
            due to possible abuse, or need bounce messages classifying.
            <br><b>Failing:</b> Messages for which delivery is failing, most like
            incorrect contact details.  Sorted by recipient.
            <br><b>Recently Created:</b> Most recent messages constituents have made.
            <br><b>Recently Changed:</b> Messages which something has happened to recently.
            <br><b>Similar to:</b> Shows messages with bodies similar to a given message.
            Click on "View similar messages" from a message page to get to this view.  Displays
            colourful diffs of the differences.
            <br><b>Contains:</b> Searches the sender details, recipient details and message
            body.  Enter multiple terms separate by spaces, all must be
            present to match.  If you query by state name ('pending') or
            representative type ('EUR') you must enter the whole word, case
            sensitive.  Otherwise queries are case insensitive.  Yes, you
            can query on the referrer URL.  If you have one, you can enter
            a confirmation or questionnaire token from an email, such as
            cqyv7yrisjugc5i5rfz4w75tmnxzi.  Examples: '<b>ready EUR</b>' - all messages to MEPs
            which are ready to be sent.  '<b>francis theyworkforyou</b>' - probably
            all messages written by someone called Francis who came to WTT via
            theyworkforyou.com.
            </p>
            <?
        }
        if ($view != "statistics") {
?>
<h2>Help &mdash; what do the buttons do?</h2>
<?
        if (!$id) {
?>
<p>They apply to all items you have checked.</p>
<?
        }
?>
<p>
<b>note</b> adds the text entered as a remark in the message's log
<br><b>freeze</b> stops delivery to representative, but other stuff
(such as confirmation message) still happens
<br><b>thaw</b> undoes a freeze, so message gets delivered.
<br><b>no questionnaire</b> makes the message one for which no questionnaire is sent.
<br><b>error with email</b> rejects a message, sending a "could not deliver" email to constituent.
<br><b>fail silently</b> rejects a message, with no email to the constituent.
<br><b>confirm</b> moves 'pending' to 'ready', the same as user clicking confirm link in email
<br><b>retry</b> moves a failed message back to 'ready', restarting the sending process
<br><b>view body</b> should only be done if you have good reason to believe it is an abuse of our service.
<br><b>edit contact details</b> by clicking on the recipient name
</p>
<p>To find out <b>state meanings</b>, point the mouse to find out what they are
</p>
<?
        if (!$id) {
        ?>
<h2>Help &mdash; what do the states mean?</h2>
<p>Here is a diagram of state changes:</p>
<p><img src="queue-state-machine.png"></p>

<p>Description of states in the normal lifetime of a message:</p>

<dl>
<dt>new</dt>
<dd>The message has been created by the user but it has not yet been sent to
them for confirmation.</dd>

<dt>pending</dt>
<dd>The message has been sent to the user but not confirmed yet. A reminder
copy of the message is sent if the user does not confirm it within a day.</dd>

<dt>ready</dt>
<dd>The message has been confirmed by the user but it has not yet been
successfully sent; <em>or</em> it has been sent by email but encountered a
fatal bounce for a transient error condition (such as the recipient's mailbox
being full).</dd>

<dt>bounce_wait <em>email only</em></dt>
<dd>The message has been sent, but we hang on to it for a little while in case
a bounce message arrives. Bounce messages are either automatically classified
(where they meet the RFC1892 standard for delivery status notifications) or
passed into the bounce_confirm state for manual classification.</dd>

<dt>sent</dt>
<dd>The message has been sent (and, in case of an email, no bounce message has
arrived within the set time). This is the state in which the questionnaire and
questionnaire reminder are sent.</dd>

<dt>finished</dt>
<dd>All our processing of the message has completed successfully.</dd>
</dl>

</dl>

        <?
        }
        }
    }
コード例 #3
0
ファイル: write.php プロジェクト: vijo/writetothem
function assign_message_ids()
{
    global $fyr_values, $stash, $msgid_list, $repid_list;
    if (array_key_exists('fyr_msgid_list', $fyr_values) && array_key_exists('fyr_repid_list', $fyr_values)) {
        $msgid_list = explode('_', $fyr_values['fyr_msgid_list']);
        $repid_list = explode('_', $fyr_values['fyr_repid_list']);
    } else {
        $repid_list = array();
        $msgid_list = array();
        foreach (array_keys($stash['valid_reps']) as $repid) {
            $msgid = msg_create();
            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);
    }
}
コード例 #4
0
ファイル: response.php プロジェクト: vijo/writetothem
    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);
msg_check_error($result);
if ($answer == "yes") {
    template_draw("response-yes", $values);
} elseif ($answer == "no") {
    template_draw("response-no", $values);
} else {
    template_show_error("Unknown answer.");
}
?>