Add captcha page [MAILPOET-2015]

This commit is contained in:
wxa
2019-07-03 13:49:55 +03:00
committed by M. Shull
parent f8ea514887
commit 08af443c1f
9 changed files with 148 additions and 6 deletions

View File

@ -9,10 +9,14 @@ if (!defined('ABSPATH')) exit;
class Subscription {
const ENDPOINT = 'subscription';
const ACTION_CAPTCHA = 'captcha';
const ACTION_CAPTCHA_IMAGE = 'captchaImage';
const ACTION_CONFIRM = 'confirm';
const ACTION_MANAGE = 'manage';
const ACTION_UNSUBSCRIBE = 'unsubscribe';
public $allowed_actions = [
self::ACTION_CAPTCHA,
self::ACTION_CAPTCHA_IMAGE,
self::ACTION_CONFIRM,
self::ACTION_MANAGE,
self::ACTION_UNSUBSCRIBE,
@ -28,6 +32,17 @@ class Subscription {
$this->subscription_pages = $subscription_pages;
}
function captcha($data) {
$subscription = $this->initSubscriptionPage(UserSubscription\Pages::ACTION_CAPTCHA, $data);
}
function captchaImage($data) {
$captcha = new UserSubscription\Captcha;
$width = !empty($data['width']) ? (int)$data['width'] : null;
$height = !empty($data['height']) ? (int)$data['height'] : null;
return $captcha->renderImage($width, $height);
}
function confirm($data) {
$subscription = $this->initSubscriptionPage(UserSubscription\Pages::ACTION_CONFIRM, $data);
$subscription->confirm();