Reminder e-mail generation

master
Sven Slootweg 12 years ago
parent 2c28760631
commit 63a9fbddb7

@ -94,6 +94,11 @@ class Campaign extends CPHPDatabaseRecordClass
return ($this->sOwnerId == $userid);
}
public function GetPaymentMethods()
{
return PaymentMethod::CreateFromQuery("SELECT * FROM payment_methods WHERE `CampaignId` = :CampaignId", array(":CampaignId" => $this->sId), 30);
}
public function GetPaymentMethod($type)
{
try

@ -54,6 +54,42 @@ class PaymentMethod extends CPHPDatabaseRecordClass
}
}
public function GenerateUrl($sRequest)
{
$sUrlName = $this->GetUrlName();
return "http://redonate.net/pay/{$sRequest->sSubscription->sEmailAddress}/{$sRequest->sId}/{$sRequest->sKey}/{$sUrlName}";
}
public function GetName()
{
switch($this->sType)
{
case PaymentMethod::PAYPAL:
return "PayPal";
case PaymentMethod::BITCOIN:
return "Bitcoin";
case 0:
return "{$this->sCustomName}";
default:
throw Exception("No valid payment method type.");
}
}
public function GetUrlName()
{
switch($this->sType)
{
case PaymentMethod::PAYPAL:
return "paypal";
case PaymentMethod::BITCOIN:
return "bitcoin";
case 0:
return "{$this->sId}";
default:
throw Exception("No valid payment method type.");
}
}
public static function ValidateAddress($type, $address)
{
switch($type)

@ -42,4 +42,39 @@ class PaymentRequest extends CPHPDatabaseRecordClass
'Subscription' => "SubscriptionId"
)
);
public function GenerateEmail()
{
global $locale;
$sMethods = array();
foreach($this->sCampaign->GetPaymentMethods() as $sPaymentMethod)
{
$sMethods[] = array(
"name" => $sPaymentMethod->GetName(),
"url" => $sPaymentMethod->GenerateUrl($this)
);
}
$sText = NewTemplater::Render("email/reminder.txt", $locale->strings, array(
"campaign-name" => $this->sCampaign->sName,
"amount" => Currency::Format($this->sCurrency, $this->sAmount),
"skip-url" => "http://redonate.net/pay/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}/skip",
"unsubscribe-url" => "http://redonate.com/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}",
"methods" => $sMethods
));
$sHtml = NewTemplater::Render("email/layout.html", $locale->strings, array(
"contents" => NewTemplater::Render("email/reminder.html", $locale->strings, array(
"campaign-name" => $this->sCampaign->sName,
"amount" => Currency::Format($this->sCurrency, $this->sAmount),
"skip-url" => "http://redonate.net/pay/{$this->sSubscription->sEmailAddress}/{$this->sId}/{$this->sKey}/skip",
"unsubscribe-url" => "http://redonate.com/manage/{$this->sSubscription->sEmailAddress}/{$this->sSubscription->sSettingsKey}",
"methods" => $sMethods
))
));
return array("text" => $sText, "html" => $sHtml);
}
}

@ -0,0 +1,17 @@
<?php
/*
* projectname is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_APP)) { die("Unauthorized."); }
$sPaymentRequest = new PaymentRequest(1);
var_dump($sPaymentRequest->GenerateEmail());

@ -79,7 +79,8 @@ $router->routes = array(
'auth_error' => "modules/error/nosuchpayment.php"
),
"^/campaign/([a-zA-Z0-9-]+)$" => "modules/landing.php",
"^/campaign/([a-zA-Z0-9-]+)/subscribe$" => "modules/subscribe.php"
"^/campaign/([a-zA-Z0-9-]+)/subscribe$" => "modules/subscribe.php",
"^/test$" => "modules/test.php"
)
);

@ -0,0 +1,48 @@
<p>
<strong>Hi there,</strong>
</p>
<p>
This is your donation pledge reminder for this month. You pledged to
donate {%?amount} every month to {%?campaign-name}.
</p>
<p>
To make your donation for this month, use one of the following links:
</p>
<ul>
{%foreach method in methods}
<li><strong>{%?method[name]}:</strong> <a href="{%?method[url]}">{%?method[url]}</a></li>
{%/foreach}
</ul>
<p>
If you want to skip the donation for this month, then please click the
following link so that we can record it in the statistics:
</p>
<p>
<a href="{%?skip-url}">{%?skip-url}</a>
</p>
<p>
Don't worry - the campaign administrator can't see who has donated, and
who hasn't!
</p>
<p>
If you have any further questions about ReDonate, feel free to reply to
this e-mail. We read every e-mail, and reply to them personally.
</p>
<p>
<em>- Sven Slootweg, ReDonate</em>
</p>
<hr>
<p>
If you want to cancel your donation pledge, please visit
<a href="{%?unsubscribe-url}">{%?unsubscribe-url}</a>.
</p>

@ -0,0 +1,26 @@
Hi there,
This is your donation pledge reminder for this month. You pledged to
donate {%?amount} every month to {%?campaign-name}.
To make your donation for this month, use one of the following links:
{%foreach method in methods}
* {%?method[name]}: {%?method[url]}{%/foreach}
If you want to skip the donation for this month, then please click the
following link so that we can record it in the statistics:
{%?skip-url}
Don't worry - the campaign administrator can't see who has donated, and
who hasn't!
If you have any further questions about ReDonate, feel free to reply to
this e-mail. We read every e-mail, and reply to them personally.
- Sven Slootweg, ReDonate
-----
If you want to cancel your donation pledge, please visit
{%?unsubscribe-url}.
Loading…
Cancel
Save