Skip to content

Commit

Permalink
Renamed Give_Email_Login to Give_Email_Access
Browse files Browse the repository at this point in the history
Renamed $email_login to $email_access #496
  • Loading branch information
Devin Walker committed Mar 30, 2016
1 parent 367cc03 commit 37fe4c5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
8 changes: 4 additions & 4 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ final class Give {
/**
* Give No Login Object
*
* @var Give_No_Logins object
* @var Give_Email_Access object
* @since 1.0
*/
public $email_login;
public $email_access;

/**
* Main Give Instance
Expand Down Expand Up @@ -175,7 +175,7 @@ public static function instance() {
// self::$instance->donators_gravatars = new Give_Donators_Gravatars();
self::$instance->customers = new Give_DB_Customers();
self::$instance->template_loader = new Give_Template_Loader();
self::$instance->email_login = new Give_No_Logins();
self::$instance->email_access = new Give_Email_Access();

}

Expand Down Expand Up @@ -280,7 +280,7 @@ private function includes() {
require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
require_once GIVE_PLUGIN_DIR . 'includes/class-give-no-logins.php';
require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';

require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
* @package Give
* @copyright Copyright (c) 2016, WordImpress
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 1.3.7
* @since 1.4
*/

defined( 'ABSPATH' ) or exit;

class Give_No_Logins {
/**
* Class Give_Email_Access
*/
class Give_Email_Access {

public $token_exists = false;
public $token_email = false;
Expand All @@ -23,6 +26,9 @@ class Give_No_Logins {

private $verify_throttle;

/**
* Give_Email_Access constructor.
*/
function __construct() {

// get it started
Expand Down Expand Up @@ -87,7 +93,7 @@ function can_send_email( $customer_id ) {
);

if ( $row_id < 1 ) {
give_set_error( 'give_email_logins_exhausted', __( 'Please wait a few minutes before requesting a new token', 'give' ) );
give_set_error( 'give_email_access_attempts_exhausted', __( 'Please wait a few minutes before requesting a new email access link', 'give' ) );

return false;
}
Expand Down Expand Up @@ -296,10 +302,10 @@ function create_columns() {
global $wpdb;

//Create columns in customers table
$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`");
$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" );

//Columns added properly
if($query) {
if ( $query ) {
give_update_option( 'email_access_installed', 1 );
}

Expand Down
6 changes: 3 additions & 3 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function give_donation_history() {
$email_access = give_get_option( 'email_access' );

//Is user logged in? Does an email-access token exist?
if ( is_user_logged_in() || ( $email_access == 'on' && Give()->email_login->token_exists ) ) {
if ( is_user_logged_in() || ( $email_access == 'on' && Give()->email_access->token_exists ) ) {
ob_start();
give_get_template_part( 'history', 'donations' );

Expand Down Expand Up @@ -241,7 +241,7 @@ function give_receipt_shortcode( $atts, $content = null ) {
$email_access = give_get_option( 'email_access' );

// No payment_key found & Email Access is Turned on:
if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_login->token_exists ) {
if ( ! isset( $payment_key ) && $email_access == 'on' && ! Give()->email_access->token_exists ) {

ob_start();

Expand All @@ -259,7 +259,7 @@ function give_receipt_shortcode( $atts, $content = null ) {
$user_can_view = give_can_view_receipt( $payment_key );

// Key was provided, but user is logged out. Offer them the ability to login and view the receipt
if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_login->token_exists ) {
if ( ! $user_can_view && $email_access == 'on' && ! Give()->email_access->token_exists ) {

ob_start();

Expand Down
2 changes: 1 addition & 1 deletion includes/user-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function give_get_users_purchases( $user = 0, $number = 20, $pagination = false,
$user = get_current_user_id();
}

if ( 0 === $user && !Give()->email_login->token_exists ) {
if ( 0 === $user && !Give()->email_access->token_exists ) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions templates/email-login-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
$customer = Give()->customers->get_customer_by( 'email', $email );

if ( isset( $customer->id ) ) {
if ( Give()->email_login->can_send_email( $customer->id ) ) {
Give()->email_login->send_email( $customer->id, $email );
if ( Give()->email_access->can_send_email( $customer->id ) ) {
Give()->email_access->send_email( $customer->id, $email );
$show_form = false;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion templates/history-donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$donations = give_get_users_purchases( get_current_user_id(), 20, true, 'any' );

//Email Access Token?
if(Give()->email_login->token_exists) {
if(Give()->email_access->token_exists) {
$donations = give_get_users_purchases( 0, 20, true, 'any' );
}

Expand Down

0 comments on commit 37fe4c5

Please sign in to comment.