Subscription management
parent
94c1047805
commit
1fb10f6c44
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/*
|
||||
* ReDonate 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."); }
|
||||
|
||||
try
|
||||
{
|
||||
$sSubscription = Subscription::FindByEmail($router->uParameters[1], $router->uParameters[2]);
|
||||
}
|
||||
catch (NotFoundException $e)
|
||||
{
|
||||
throw new RouterException("No such subscription was found.");
|
||||
}
|
||||
|
||||
$sRouterAuthenticated = true;
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* ReDonate 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."); }
|
||||
|
||||
throw new NotFoundException("No such subscription was found.");
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*
|
||||
* ReDonate 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."); }
|
||||
|
||||
if(!empty($_POST['submit']))
|
||||
{
|
||||
if(empty($_POST['currency']))
|
||||
{
|
||||
flash_error("Please select a valid currency.");
|
||||
}
|
||||
|
||||
if(empty($_POST['amount']) || preg_match("([0-9]*[.,][0-9]+|[0-9]+)", $_POST['amount']) == false)
|
||||
{
|
||||
flash_error("Please enter a valid amount.");
|
||||
}
|
||||
|
||||
if(count(get_errors(false)) == 0)
|
||||
{
|
||||
$sSubscription->uAmount = str_replace(",", ".", $_POST['amount']);
|
||||
$sSubscription->uCurrency = $_POST['currency'];
|
||||
$sSubscription->InsertIntoDatabase();
|
||||
|
||||
flash_notice("The monthly pledge amount for this subscription was successfully updated.");
|
||||
redirect("/manage/{$sSubscription->sEmailAddress}/{$sSubscription->sSettingsKey}");
|
||||
}
|
||||
}
|
||||
|
||||
$sPageTitle = "Change pledge amount";
|
||||
$sPageContents = NewTemplater::Render("subscription/change_amount", $locale->strings, array(
|
||||
"email" => $sSubscription->sEmailAddress,
|
||||
"key" => $sSubscription->sSettingsKey
|
||||
));
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*
|
||||
* ReDonate 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."); }
|
||||
|
||||
if(!empty($_POST['submit']))
|
||||
{
|
||||
$sSubscription->uIsActive = false;
|
||||
$sSubscription->InsertIntoDatabase();
|
||||
|
||||
$sLogEntry = new LogEntry(0);
|
||||
$sLogEntry->uType = LogEntry::UNSUBSCRIPTION;
|
||||
$sLogEntry->uIp = $_SERVER['REMOTE_ADDR'];
|
||||
$sLogEntry->uData = json_encode(array("email" => $sSubscription->sEmailAddress));
|
||||
$sLogEntry->uCampaignId = $sCampaign->sId;
|
||||
$sLogEntry->uDate = time();
|
||||
$sLogEntry->uSessionId = session_id();
|
||||
$sLogEntry->InsertIntoDatabase();
|
||||
|
||||
flash_notice("We've unsubscribed you.");
|
||||
redirect("/manage/{$sSubscription->sEmailAddress}/{$sSubscription->sSettingsKey}");
|
||||
}
|
||||
|
||||
$sPageTitle = "Change pledge amount";
|
||||
$sPageContents = NewTemplater::Render("subscription/unsubscribe", $locale->strings, array(
|
||||
"email" => $sSubscription->sEmailAddress,
|
||||
"key" => $sSubscription->sSettingsKey,
|
||||
"name" => $sSubscription->sCampaign->sName
|
||||
));
|
@ -0,0 +1,30 @@
|
||||
<div class="formwrapper">
|
||||
<h2 class="spaced">Change pledge amount</h2>
|
||||
|
||||
{%if isempty|errors == false}
|
||||
{%foreach error in errors}
|
||||
<div class="errors">
|
||||
{%?error}
|
||||
</div>
|
||||
{%/foreach}
|
||||
{%/if}
|
||||
|
||||
<form method="post" action="/manage/{%?email}/{%?key}/change-amount">
|
||||
<div class="formfield">
|
||||
<label>Currency</label>
|
||||
{%select name="currency"}
|
||||
{%option value="usd" text="US Dollar"}
|
||||
{%option value="eur" text="Euro"}
|
||||
{%option value="btc" text="Bitcoin"}
|
||||
{%/select}
|
||||
</div>
|
||||
<div class="formfield">
|
||||
<label>Amount per month</label>
|
||||
{%input type="text" name="amount"}
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="formfield submit">
|
||||
<button type="submit" name="submit" value="submit">Save changes</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
@ -0,0 +1,23 @@
|
||||
<div class="formwrapper">
|
||||
<h2 class="spaced">Unsubscribe</h2>
|
||||
|
||||
{%if isempty|errors == false}
|
||||
{%foreach error in errors}
|
||||
<div class="errors">
|
||||
{%?error}
|
||||
</div>
|
||||
{%/foreach}
|
||||
{%/if}
|
||||
|
||||
<form method="post" action="/manage/{%?email}/{%?key}/unsubscribe">
|
||||
<div class="formfield">
|
||||
<p>
|
||||
Are you sure you want to unsubscribe from your pledge to {%?name}?
|
||||
You will no longer be reminded every month.
|
||||
</p>
|
||||
</div>
|
||||
<div class="formfield" style="text-align: center;">
|
||||
<button type="submit" name="submit" value="submit">Yes, unsubscribe me</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
Loading…
Reference in New Issue