Exemple #1
1
function ea_email_sent_shortcode()
{
    ob_start();
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Reading from superglobals
    $tCallerSkypeNameSg = esc_sql($_POST["skype_name"]);
    // ..verifying that the skype name exists
    if (verifyUserNameExists($tCallerSkypeNameSg) === false) {
        echo "<h3><i><b>Incorrect Skype name</b> - email not sent. Please go back and try again.</i></h3>";
        exit;
    }
    $tLengthNr = $_POST["length"];
    if (is_numeric($tLengthNr) === false) {
        handleError("Length variable was not numeric - possible SQL injection attempt");
    }
    // Setting up variables based on the superglobals
    $tCallerIdNr = getIdByUserName($tCallerSkypeNameSg);
    $tUniqueDbIdentifierSg = uniqid("id-", true);
    // http://php.net/manual/en/function.uniqid.php
    $tCallerDisplayNameSg = getDisplayNameById($tCallerIdNr);
    $tCallerEmailSg = getEmailById($tCallerIdNr);
    $tEmpathizerDisplayNameSg = getDisplayNameById(get_current_user_id());
    // If this is the first call: reduce the donation amount.
    $tAdjustedLengthNr = $tLengthNr;
    if (isFirstCall($tCallerIdNr) == true) {
        $tAdjustedLengthNr = $tAdjustedLengthNr - Constants::initial_call_minute_reduction;
    }
    $tRecDonationNr = (int) round(get_donation_multiplier() * $tAdjustedLengthNr);
    // Create the contents of the email message.
    $tMessageSg = "Hi " . $tCallerDisplayNameSg . ",\n\nThank you so much for your recent empathy call! Congratulations on contributing to a more empathic world. :)\n\nYou talked with: {$tEmpathizerDisplayNameSg}\nYour Skype session duration was: {$tLengthNr} minutes\nYour recommended contribution is: \${$tRecDonationNr}\n\nPlease follow this link to complete payment within 24 hours: " . getBaseUrl() . pages::donation_form . "?recamount={$tRecDonationNr}&dbToken={$tUniqueDbIdentifierSg}\n\nSee you next time!\n\nThe Empathy Team\n\nPS\nIf you have any feedback please feel free to reply to this email and tell us your ideas or just your experience!\n";
    // If the donation is greater than 0: send an email to the caller.
    if ($tRecDonationNr > 0) {
        ea_send_email($tCallerEmailSg, "Empathy App Payment", $tMessageSg);
        echo "<h3>Email successfully sent to caller.</h3>";
    } else {
        echo "<h4>No email sent: first time caller and call length was five minutes or less.</h4>";
    }
    // Add a new row to the db CallRecords table.
    db_insert(array(DatabaseAttributes::date_and_time => current_time('mysql', 1), DatabaseAttributes::recommended_donation => $tRecDonationNr, DatabaseAttributes::call_length => $tLengthNr, DatabaseAttributes::database_token => $tUniqueDbIdentifierSg, DatabaseAttributes::caller_id => $tCallerIdNr, DatabaseAttributes::empathizer_id => get_current_user_id()));
    $ob_content = ob_get_contents();
    //+++++++++++++++++++++++++++++++++++++++++
    ob_end_clean();
    return $ob_content;
}
Exemple #2
0
function ea_text_field_donation_multiplier_render()
{
    $tDonationMultiplier = get_donation_multiplier();
    ?>
	<input type='text' name='ea_settings[ea_text_field_donation_multiplier]'
               value='<?php 
    echo $tDonationMultiplier;
    ?>
'>
	<?php 
}
Exemple #3
0
function ea_email_form_shortcode()
{
    ob_start();
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Check user access level.
    $tContributorBl = hasCurrentUserRole(array(WPUserRoles::contributor));
    if ($tContributorBl == false) {
        // Exit if not empathizer or admin.
        echo "<strong>Oops! This page is only for our empathizers</strong>";
        exit;
    }
    $tMaxLengthNr = floor(get_max_donation() / get_donation_multiplier());
    ?>


    <form
        id="empathizerForm"
        action=<?php 
    echo getBaseUrl() . pages::email_sent;
    ?>
        type="hidden"
        method="POST"
    >
        <label for="skype_name">Skype Name</label>
        <input name="skype_name" id="skype_name" type="text" style="display:block">
        <label for="length">Call Duration</label>
        <input name="length" id="length" type="number" pattern="\d*" min="1" max="<?php 
    echo $tMaxLengthNr;
    ?>
" style="display:block">
        <input type="submit" value="Send donation email to caller" id="submit" style="display:block">
    </form>


    <?php 
    $ob_content = ob_get_contents();
    //+++++++++++++++++++++++++++++++++++++++++
    ob_end_clean();
    return $ob_content;
}