Esempio n. 1
0
<ul>
	<li> 
		<a href="<?php 
    echo MM_ModuleUtils::getUrl($crntPage, MM_MODULE_ACTIVITY_LOG);
    ?>
" class='<?php 
    echo $module == MM_MODULE_ACTIVITY_LOG ? "active" : "";
    ?>
'>
			<i class="fa fa-list"></i>
			Activity Log
		</a>
	</li>
	
	<?php 
    $paypalService = MM_PaymentServiceFactory::getPaymentService(MM_PaymentService::$PAYPAL_SERVICE_TOKEN);
    if ($paypalService->isActive()) {
        ?>
	<li> 
		<a href="<?php 
        echo MM_ModuleUtils::getUrl($crntPage, MM_MODULE_PAYPAL_IPN_LOG);
        ?>
" class='<?php 
        echo $module == MM_MODULE_PAYPAL_IPN_LOG ? "active" : "";
        ?>
'>
			<i class="fa fa-paypal"></i>
			PayPal IPN Log
		</a>
	</li>
	<?php 
Esempio n. 2
0
    $crntPartner = 1;
    foreach ($partners as $partner) {
        renderFieldOption($crntPartner, $partner->affiliateId, $partner->commissionProfileId);
        $crntPartner++;
    }
} else {
    renderFieldOption(1, "", MM_CommissionProfile::$DFLT_COMMISSION_PROFILE_ID);
}
?>
				</div>
			</div>
		</td>
	</tr>
	
	<?php 
$onsiteService = MM_PaymentServiceFactory::getOnsitePaymentService();
if ($onsiteService && $onsiteService->isActive() && $onsiteService->supportsFeature(MM_PaymentServiceFeatures::CARD_ON_FILE)) {
    ?>
	<tr>
		<td colspan="2">
		<div style="width: 540px; margin-top: 5px; margin-bottom:4px;" class="mm-divider"></div>
		</td>
	</tr>
	<tr>
		<td>Purchase Confirmation Message<?php 
    echo MM_Utils::getInfoIcon("Enter a purchase confirmation message for this product. It will be displayed to the member when they click to purchase a product using a card on file.");
    ?>
</td> 
		<td>
			<div>
				<?php 
Esempio n. 3
0
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
global $current_user;
$couponsSupported = MM_PaymentServiceFactory::couponsSupported();
$view = new MM_CouponView();
$dataGrid = new MM_DataGrid($_REQUEST, "id", "desc", 10);
$data = $view->getViewData($dataGrid);
$dataGrid->setTotalRecords($data);
$dataGrid->recordName = "coupon";
$rows = array();
foreach ($data as $key => $item) {
    $coupon = new MM_Coupon($item->id);
    $availableDates = "";
    $endDate = $coupon->getEndDate(true);
    if (!empty($endDate)) {
        $availableDates = $coupon->getStartDate(true) . " - " . $endDate;
    } else {
        $availableDates = "After " . $coupon->getStartDate(true);
    }
    switch ($coupon->getQuantity()) {
        case "-1":
        case "":
            $quantityDescription = number_format($item->quantity_used) . " used";
            break;
        default:
            $quantityDescription = number_format($item->quantity_used) . " of " . number_format($coupon->getQuantity()) . " used ";
Esempio n. 4
0
File: x.php Progetto: huynp/Critical
 * 
 * This script processes payment notifications/callbacks from payment service providers, and routes these messages to the appropriate services
 * A url parameter "service" is expected, with the value containing the token identifier for the service the message is intended for
 * For example, a PayPal IPN notification is expected to be received at http://<sitename>/wp-content/plugins/membermouse/x.php?service=paypal
 * 
 * The placement and name of this script are intended to keep the url as small as possible, under the circumstances
 * 
 */
require_once "../../../wp-load.php";
require_once "includes/mm-constants.php";
require_once "includes/init.php";
$request = isset($_POST) ? $_POST : array();
if (isset($_GET['service']) || isset($_POST['service'])) {
    $serviceToken = isset($_GET['service']) ? strtoupper($_GET['service']) : strtoupper($_POST['service']);
    $service = MM_PaymentServiceFactory::getPaymentService($serviceToken);
    $response = !is_null($service) ? $service->processNotification($request) : new MM_PaymentServiceResponse("Improper notification format received", MM_PaymentServiceResponse::$ERROR);
} else {
    //unspecified service (which means improper remote setup), see if there is a default payment service that can/will handle it
    $serviceArray = MM_PaymentServiceFactory::getPaymentServicesArray();
    if (count($serviceArray) == 1) {
        $service = array_pop($serviceArray);
        $response = $service->processNotification($request);
    } else {
        $response = new MM_PaymentServiceResponse("Improper notification format received", MM_PaymentServiceResponse::$ERROR);
    }
}
//echo the response to caller
$responseMsg = $response->getMessage();
if (!empty($responseMsg)) {
    echo $responseMsg;
}
<?php

/**
 * 
 * MemberMouse(TM) (http://www.membermouse.com)
 * (c) MemberMouse, LLC. All rights reserved.
 */
$limeLightProduct = new MM_LimeLightProduct($p->id);
$limeLightService = MM_PaymentServiceFactory::getPaymentService(MM_PaymentService::$LIMELIGHT_SERVICE_TOKEN);
?>
<div id="mm-form-container">
	<table cellspacing="10">
		<tr>
			<td width="150">MemberMouse Product</td>
			<td>
				<select name='mm_product_id' id='mm_product_id' onchange="mmjs.getMMProductDescription();">
				<?php 
$unmappedProducts = MM_LimeLightProduct::getUnmappedProducts();
// add currently selected product
if ($limeLightProduct->isValid()) {
    $product = new MM_Product($limeLightProduct->getMMProductId());
    if ($product->isValid()) {
        $unmappedProducts[$limeLightProduct->getMMProductId()] = $product->getName();
    }
}
echo MM_HtmlUtils::generateSelectionsList($unmappedProducts, $limeLightProduct->getMMProductId());
?>
				</select>
				
				<div id="mm_product_description" style="margin-top:10px;"></div>
			</td>
Esempio n. 6
0
							<?php 
    echo $testService->displayConfigOptions();
    ?>
						</div>
					</td>
				</tr>
			</table>
			<?php 
}
?>
			
			<p class="mm-section-header">Onsite Payment Method</p>
			
			<?php 
if (class_exists("MM_TestPaymentService") && MM_TestPaymentService::isSiteUsingTestService()) {
    $testPymtService = MM_PaymentServiceFactory::getPaymentService(MM_PaymentService::$TEST_SERVICE_TOKEN);
    if ($testPymtService->getMode() == MM_TestPaymentService::$MODE_ALWAYS_OVERRIDE) {
        ?>
			<p style="font-size:11px;">
			<?php 
        echo MM_Utils::getIcon('warning', 'red', '1.3em', '2px');
        ?>
 <em>Currently the test payment service is enabled and configured to always 
			be used as the onsite payment method. While the test payment service is configured this way the onsite payment method activated in this section
			will not be used.</em></p>
			<?php 
    }
}
?>
			
			<p id="mm-https-notice" style="font-size:11px; display:none;">
Esempio n. 7
0
if (isset($_POST["mm_selected_currency"])) {
    //update default currency
    if (in_array($_POST['mm_selected_currency'], array_keys(MM_CurrencyUtil::getSupportedCurrencies()))) {
        MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_CURRENCY, $_POST["mm_selected_currency"]);
    }
    if (isset($_POST["mm_postfix_iso_to_currency"]) && $_POST["mm_postfix_iso_to_currency"] == "1") {
        MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_CURRENCY_FORMAT_POSTFIX_ISO, true);
    } else {
        MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_CURRENCY_FORMAT_POSTFIX_ISO, false);
    }
}
$currentCurrency = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_CURRENCY);
$postfixIsoToCurrency = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_CURRENCY_FORMAT_POSTFIX_ISO);
$postfixIsoToCurrency = empty($postfixIsoToCurrency) ? false : $postfixIsoToCurrency;
//check the support of the active payment services for the currently selected currency
$activePaymentServices = MM_PaymentServiceFactory::getAvailablePaymentServices();
$unsupportedPaymentServices = array();
foreach ($activePaymentServices as $aps) {
    if (!$aps->isSupportedCurrency($currentCurrency)) {
        $unsupportedPaymentServices[] = $aps->getName();
    }
}
$warningMsg = "";
$warningBox = "";
$numUnsupported = count($unsupportedPaymentServices);
if ($numUnsupported > 0) {
    $lastService = "";
    if ($numUnsupported > 1) {
        $lastService = array_pop($unsupportedPaymentServices);
        $lastService = " and {$lastService}";
    }
Esempio n. 8
0
        returnStatus('error', 'Authentication Failed');
        exit;
    }
} else {
    MM_DiagnosticLog::log(MM_DiagnosticLog::$MM_ERROR, "System does not support sha256 hmac... proceeding to process schedules without auth");
}
$eventId = $request['reference_id'];
$eventType = $wpdb->get_var("SELECT event_type from " . MM_TABLE_SCHEDULED_EVENTS . " where id='{$eventId}'");
switch ($eventType) {
    case MM_ScheduledEvent::$PAYMENT_SERVICE_EVENT:
        $paymentEvent = new MM_ScheduledPaymentEvent($eventId);
        $billingStatus = $request['status'];
        $paymentEvent->setBillingStatus($billingStatus);
        if ($paymentEvent->getStatus() == MM_ScheduledEvent::$EVENT_PROCESSED) {
            returnStatus("ok", "Event {$eventId} already processed");
        }
        $paymentService = MM_PaymentServiceFactory::getPaymentServiceById($paymentEvent->getPaymentServiceId());
        if (is_null($paymentService)) {
            returnStatus("error", "Improper event configuration: Payment service with id {$paymentService->getPaymentServiceId()} not found");
        }
        $response = $paymentService->processScheduledPaymentEvent($paymentEvent);
        if (MM_PaymentServiceResponse::isError($response) || MM_PaymentServiceResponse::isFailed($response)) {
            returnStatus("error", $response->message);
        }
        returnStatus("ok", "");
        break;
    default:
        //TODO: logging
        returnStatus('error', 'Invalid Event Type');
        break;
}
Esempio n. 9
0
 private function insertMMDefaultData()
 {
     global $wpdb, $current_user;
     // insert default option values
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ACCT_SECURITY_ENABLED, MM_OptionUtils::$DEFAULT_ACCT_SECURITY_ENABLED);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ACCT_SECURITY_MAX_IPS, MM_OptionUtils::$DEFAULT_ACCT_SECURITY_MAX_IPS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ON_LOGIN_USE_WP_FRONTPAGE, MM_OptionUtils::$DEFAULT_ON_LOGIN_USE_WP_FRONTPAGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_AFTER_LOGIN_USE_WP_FRONTPAGE, MM_OptionUtils::$DEFAULT_AFTER_LOGIN_USE_WP_FRONTPAGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SHOW_LOGIN_LOGOUT_LINK, MM_OptionUtils::$DEFAULT_SHOW_LOGIN_LOGOUT_LINK);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_HIDE_PROTECTED_MENU_ITEMS, MM_OptionUtils::$DEFAULT_HIDE_PROTECTED_MENU_ITEMS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_LOGIN_PAGE, MM_OptionUtils::$DEFAULT_USE_MM_LOGIN_PAGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_RESET_PASSWORD_PAGE, MM_OptionUtils::$DEFAULT_USE_MM_RESET_PASSWORD_PAGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_COUNTRY_SELECTIONS, MM_OptionUtils::$DEFAULT_COUNTRY_SELECTIONS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_FORGOT_PASSWORD_SUBJECT, MM_OptionUtils::$DEFAULT_FORGOT_PASSWORD_SUBJECT);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_FORGOT_PASSWORD_BODY, MM_OptionUtils::$DEFAULT_FORGOT_PASSWORD_BODY);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_AFFILIATE, MM_OptionUtils::$DEFAULT_AFFILIATE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SUB_AFFILIATE, MM_OptionUtils::$DEFAULT_SUB_AFFILIATE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_AFFILIATE_LIFESPAN, MM_OptionUtils::$DEFAULT_AFFILIATE_LIFESPAN);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_LOGIN_TOKEN_LIFESPAN, MM_OptionUtils::$DEFAULT_LOGIN_TOKEN_LIFESPAN);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_CHECKOUT_FORM_TEST_DATA, MM_OptionUtils::$DEFAULT_USE_CHECKOUT_FORM_TEST_DATA);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_PURCHASE_CONFIRMATION_DIALOG_WIDTH, MM_OptionUtils::$DEFAULT_PURCHASE_CONFIRMATION_DIALOG_WIDTH);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_PURCHASE_CONFIRMATION_DIALOG_HEIGHT, MM_OptionUtils::$DEFAULT_PURCHASE_CONFIRMATION_DIALOG_HEIGHT);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_DEFAULT_CHECKOUT_ITEM_TYPE, MM_OptionUtils::$DEFAULT_CHECKOUT_ITEM_TYPE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_DEFAULT_CHECKOUT_ITEM_ID, MM_OptionUtils::$DEFAULT_CHECKOUT_ITEM_ID);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SHOW_PREVIEW_BAR, MM_OptionUtils::$DEFAULT_SHOW_PREVIEW_BAR);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_HIDE_ADMIN_BAR, MM_OptionUtils::$DEFAULT_HIDE_ADMIN_BAR);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ENABLE_WP_AUTOP, MM_OptionUtils::$DEFAULT_ENABLE_WP_AUTOP);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ENABLE_USERNAME_CHANGE, MM_OptionUtils::$DEFAULT_ENABLE_USERNAME_CHANGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ALLOW_LOGGED_OUT_PURCHASES, MM_OptionUtils::$DEFAULT_ALLOW_LOGGED_OUT_PURCHASES);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ALLOW_DUPLICATE_SUBSCRIPTIONS, MM_OptionUtils::$DEFAULT_ALLOW_DUPLICATE_SUBSCRIPTIONS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CHECKOUT_PAID_MESSAGE, MM_OptionUtils::$DEFAULT_CHECKOUT_PAID_MESSAGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CHECKOUT_FREE_MESSAGE, MM_OptionUtils::$DEFAULT_CHECKOUT_FREE_MESSAGE);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CHECKOUT_MESSAGE_CSS, MM_OptionUtils::$DEFAULT_CHECKOUT_MESSAGE_CSS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CURRENCY, MM_OptionUtils::$DEFAULT_CURRENCY);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_JQUERY_UI, MM_OptionUtils::$DEFAULT_USE_JQUERY_UI);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ALLOW_OVERDUE_ACCESS, MM_OptionUtils::$DEFAULT_ALLOW_OVERDUE_ACCESS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CAPTCHA_ENABLED, MM_OptionUtils::$DEFAULT_CAPTCHA_ENABLED);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_RESET_PASSWORD, MM_OptionUtils::$DEFAULT_USE_MM_CSS);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_DIAGNOSTIC_MODE, MM_DiagnosticLog::$MODE_OFF);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_FORCE_USE_DB_CACHE, 0);
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CURRENCY_FORMAT_POSTFIX_ISO, 'false');
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_AFFILIATE_ALIAS, "");
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SUB_AFFILIATE_ALIAS, "");
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_AFFILIATE_LIFESPAN, "");
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SITE_IN_TEST_MODE, "0");
     //0 for false, 1 for true
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CAPTCHA_KEY, "");
     MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_CAPTCHA_PRIVATE_KEY, "");
     // options that vary based on if this is an upgrade versus a new install
     $lastMajorVersion = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_MAJOR_VERSION);
     if (empty($lastMajorVersion)) {
         // set options for new installs
         // for 2.0.7 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_DISABLE_EXPLICIT_LINKS, MM_OptionUtils::$DEFAULT_DISABLE_EXPLICIT_LINKS);
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_PURCHASE_LINK_STYLE, MM_OptionUtils::$DEFAULT_PURCHASE_LINK_STYLE);
         // for 2.0.8 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SMARTTAG_VERSION, MM_OptionUtils::$DEFAULT_SMARTTAG_VERSION);
         // for 2.0.9 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ACTIVITY_LOG_CLEANUP_ENABLED, MM_OptionUtils::$DEFAULT_ACTIVITY_LOG_CLEANUP_ENABLED);
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ACTIVITY_LOG_CLEANUP_INTERVAL, MM_OptionUtils::$DEFAULT_ACTIVITY_LOG_CLEANUP_INTERVAL);
         // for 2.1.2 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_CHECKOUT, MM_OptionUtils::$DEFAULT_USE_MM_CSS);
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_MY_ACCOUNT, MM_OptionUtils::$DEFAULT_USE_MM_CSS);
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_LOGIN, MM_OptionUtils::$DEFAULT_USE_MM_CSS);
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_FORGOT_PASSWORD, MM_OptionUtils::$DEFAULT_USE_MM_CSS);
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ENABLE_MEMBERSHIP_PRORATION, MM_OptionUtils::$DEFAULT_ENABLE_MEMBERSHIP_PRORATION);
     } else {
         // set options for existing installs
         // for 2.0.7 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_DISABLE_EXPLICIT_LINKS, "0");
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_PURCHASE_LINK_STYLE, MM_LINK_STYLE_EXPLICIT);
         // for 2.0.8 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_SMARTTAG_VERSION, "2.0");
         // for 2.0.9 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ACTIVITY_LOG_CLEANUP_ENABLED, "0");
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ACTIVITY_LOG_CLEANUP_INTERVAL, "");
         // for 2.1.2 release
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_CHECKOUT, "0");
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_MY_ACCOUNT, "0");
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_LOGIN, "0");
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_USE_MM_CSS_FORGOT_PASSWORD, "0");
         MM_OptionUtils::setDefaultValue(MM_OptionUtils::$OPTION_KEY_ENABLE_MEMBERSHIP_PRORATION, "0");
     }
     MM_Role::addRoles();
     // create default employee account if one doesn't exist, using the current user
     $install_sql = "select * from " . MM_TABLE_EMPLOYEE_ACCOUNTS . " where is_default='1' LIMIT 1;";
     $row = $wpdb->get_row($install_sql);
     if ($row == null) {
         //the current user isn't an employee
         $install_sql = "insert into " . MM_TABLE_EMPLOYEE_ACCOUNTS . " set display_name='%s', email='%s', is_default='%d', role_id='%s', user_id='%d'";
         $displayName = !empty($current_user->display_name) ? $current_user->display_name : "Support";
         $wpdb->query($wpdb->prepare($install_sql, $displayName, $current_user->user_email, 1, MM_Role::$ROLE_ADMINISTRATOR, $current_user->ID));
         $emailId = $wpdb->insert_id;
     } else {
         $emailId = $row->id;
     }
     // install default overdue payment notification email
     $crntValue = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_OVERDUE_PAYMENT_NOTIFICATION_INSTALLED);
     if ($crntValue === false || $crntValue === "") {
         $action = new MM_Action();
         $action->setEventType(MM_Event::$MEMBER_STATUS_CHANGE);
         $action->setActionType(MM_Action::$MM_ACTION_SEND_EMAIL);
         $emailToId = MM_Action::$CURRENT_MEMBER_PLACEHOLDER;
         $emailFromId = $emailId;
         $emailCC = "";
         $emailSubject = MM_OptionUtils::$DEFAULT_OVERDUE_PAYMENT_SUBJECT;
         $emailBody = MM_OptionUtils::$DEFAULT_OVERDUE_PAYMENT_BODY;
         $action->setActionValue(MM_Action::prepareSendEmailValue($emailToId, $emailFromId, $emailCC, $emailSubject, $emailBody));
         // set attributes
         $attributes = array();
         $attributes["status_id"] = MM_Status::$OVERDUE;
         $action->setEventAttributes($attributes);
         $result = $action->commitData();
         if (MM_Response::isSuccess($result)) {
             MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_OVERDUE_PAYMENT_NOTIFICATION_INSTALLED, "1");
         }
     }
     // create default membership level
     if (!$this->hasRecords(MM_TABLE_MEMBERSHIP_LEVELS, 'is_default', '1')) {
         $install_sql = "INSERT INTO " . MM_TABLE_MEMBERSHIP_LEVELS . " SET " . "\tname = 'Free Membership'," . "\tis_free='1'," . "\tis_default='1'," . "\tstatus='1'," . "\tdescription='Default Free Membership'," . "\temail_subject='%s'," . "\temail_body='%s'," . "\temail_from_id='%d'" . "";
         $wpdb->query($wpdb->prepare($install_sql, MM_MembershipLevel::$DFLT_EMAIL_SUBJECT, MM_MembershipLevel::$DFLT_EMAIL_BODY, $emailId));
     }
     // create default commission profile
     if (!$this->hasRecords(MM_TABLE_COMMISSION_PROFILES, 'is_default', '1')) {
         $install_sql = "INSERT INTO " . MM_TABLE_COMMISSION_PROFILES . " SET " . "\tname = 'Standard Commission Profile'," . "\tis_default='1'," . "\tdescription='This is the default commission profile'," . "\tinitial_commission_enabled='1'," . "\trebill_commissions_enabled='0'," . "\trebill_commission_type='default'," . "\trebill_commission_value='0'," . "\tdo_limit_rebill_commissions='0'," . "\trebill_commission_limit='0', " . "\tdo_reverse_commissions='1'" . "";
         $wpdb->query($install_sql);
     }
     // make sure active payment services are updated
     if (class_exists('MM_PaymentServiceFactory') && class_exists('MM_PaymentService')) {
         $services = MM_PaymentServiceFactory::getAvailablePaymentServices();
         foreach ($services as $service) {
             if ($service instanceof MM_PaymentService) {
                 $service->install();
             }
         }
     }
     //add smart tags
     $this->addSmartTags();
     $sql = "select count(*) as total from " . MM_TABLE_API_KEYS;
     $row = $wpdb->get_row($sql);
     if ($row->total <= 0) {
         $sql = "insert into " . MM_TABLE_API_KEYS . " set " . "name='Default Access', " . "api_key='" . MM_Utils::createRandomString(10) . "',\t" . "api_secret='" . MM_Utils::createRandomString(10) . "', " . "status='1'";
         $wpdb->query($sql);
     }
     $sql = array();
     require_once MM_PLUGIN_ABSPATH . "/data/countries.sql.php";
     $numCountries = count($sql);
     $countryCheckSql = "select count(*) as total from " . MM_TABLE_COUNTRIES;
     $row = $wpdb->get_row($countryCheckSql);
     if ($row->total < $numCountries) {
         foreach ($sql as $query) {
             if ($wpdb->query($query) === false) {
                 return false;
             }
         }
     }
     unset($sql);
     $sql = array();
     require_once MM_PLUGIN_ABSPATH . "/data/country_subdivisions.sql.php";
     $numCountrySubdivisions = count($sql);
     $countrySubdivisionCheckSql = "select count(*) as total from " . MM_TABLE_COUNTRY_SUBDIVISIONS;
     $row = $wpdb->get_row($countrySubdivisionCheckSql);
     if ($row->total < $numCountrySubdivisions) {
         foreach ($sql as $query) {
             if ($wpdb->query($query) === false) {
                 return false;
             }
         }
     }
     unset($sql);
     $result = $this->setupCorePages();
     if (!$result) {
         return false;
     }
     $cacheWriteable = @MM_Utils::cacheIsWriteable();
     $sql = array();
     //TODO TRANSIENT: in version 2.0.1 renamed WordPress Mail to None. Once all customers have been upgraded to None then this
     // if statement can be removed
     if ($this->hasRecords(MM_TABLE_EMAIL_SERVICE_PROVIDERS, 'provider_token', 'default')) {
         $sql[] = "UPDATE " . MM_TABLE_EMAIL_SERVICE_PROVIDERS . " SET provider_name='None' WHERE provider_token='default';";
     } else {
         $sql[] = "INSERT IGNORE INTO " . MM_TABLE_EMAIL_SERVICE_PROVIDERS . " SET provider_name='None', provider_token='default', active='1';";
     }
     //email service providers
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_EMAIL_SERVICE_PROVIDERS . " SET provider_name='MailChimp', provider_token='mailchimp', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_EMAIL_SERVICE_PROVIDERS . " SET provider_name='iContact', provider_token='icontact', api_key='" . MM_IContactEmailServiceProvider::$API_KEY . "'";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_EMAIL_SERVICE_PROVIDERS . " SET provider_name='AWeber', provider_token='aweber', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_EMAIL_SERVICE_PROVIDERS . " SET provider_name='GetResponse', provider_token='getresponse', active='0';";
     //affiliate providers
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_AFFILIATE_PROVIDERS . " SET provider_name='None', provider_token='default', active='1';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_AFFILIATE_PROVIDERS . " SET provider_name='iDevAffiliate', provider_token='idevaffiliate';";
     //payment services
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='PAYPAL', name='PayPal', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='AUTHORIZENET', name='Authorize.net', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='AUTHORIZENETCIM', name='Authorize.net CIM', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='BRAINTREE', name='Braintree', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='CHARGIFY', name='Chargify', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='LIMELIGHT', name='Lime Light', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='STRIPE', name='Stripe', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='TWOCHECKOUT', name='2Checkout', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='CLICKBANK', name='ClickBank', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='LITLE', name='Litle', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='COINBASE', name='Coinbase (Wallet Required)', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='COINBASEMINIMAL', name='Coinbase (Wallet Ignored)', settings='', active='0';";
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_PAYMENT_SERVICES . " SET token='TEST', name='Test Payment Service', settings='', active='0';";
     //shipping methods
     $sql[] = "INSERT IGNORE INTO " . MM_TABLE_SHIPPING_METHODS . " SET token='FLATRATE', name='Flat Rate', settings='', active='1';";
     //active by default
     foreach ($sql as $query) {
         $wpdb->query($query);
     }
     unset($sql);
     //apply any updates that may have been made to the schemas of the active payment services
     $activePaymentServices = MM_PaymentServiceFactory::getAvailablePaymentServices();
     foreach ($activePaymentServices as $ps) {
         $ps->install();
     }
     // Need to search and replace and remnance of [MM_Member_Data name='password'] in
     // Forgot Password email with the new Reset Password Core Page Link Smart Tag
     $pattern = "\\[mm_member_data name=(['|\"]{1})password(['|\"]{1})\\]";
     $forgotPasswordBody = MM_OptionUtils::getOption(MM_OptionUtils::$OPTION_KEY_FORGOT_PASSWORD_BODY);
     $forgotPasswordBody = preg_replace("/{$pattern}/i", "<a href=\"[MM_CorePage_Link type='resetpassword']\">click here to reset your password</a>", $forgotPasswordBody);
     MM_OptionUtils::setOption(MM_OptionUtils::$OPTION_KEY_FORGOT_PASSWORD_BODY, $forgotPasswordBody);
     return true;
 }