示例#1
0
		<div class="row ">
			<div class="cell ">	
				<div class="padding10px">
					<div class="table widefatDiv">
						<div class="row brBottom">
							<div class="cell width125px">	
								<?php 
_e('Custom URL', 'mgm');
?>

							</div>
							<div class="cell width5px">:</div>
							<div class="cell textalignleft">
								<?php 
echo add_query_arg(array('method' => 'register', 'package' => $package_enc), mgm_home_url('purchase_subscription'));
?>

							</div>
						</div>
						<div class="row brBottom">
							<div class="cell width125px">	
								<?php 
_e('Wordpress URL', 'mgm');
?>

							</div>
							<div class="cell width5px">:</div>
							<div class="cell textalignleft">
								<?php 
echo add_query_arg(array('package' => $package_enc), site_url('wp-login.php?action=register', 'login'));
    function get_button_unsubscribe($options = array())
    {
        // action
        $action = add_query_arg(array('module' => $this->code, 'method' => 'payment_unsubscribe'), mgm_home_url('payments'));
        // message
        $message = sprintf(__('You have subscribed to <b>%s</b> via <b>%s</b>, if you wish to unsubscribe, please click the following link. <br>', 'mgm'), get_option('blogname'), $this->name);
        // html
        $html = '<div class="mgm_margin_bottom_10px">
					<h4>' . __('Unsubscribe', 'mgm') . '</h4>
					<div class="mgm_margin_bottom_10px">' . $message . '</div>
			   </div>
			   <form name="mgm_unsubscribe_form" id="mgm_unsubscribe_form" method="post" action="' . $action . '">
					<input type="hidden" name="user_id" value="' . $options['user_id'] . '"/>
					<input type="hidden" name="membership_type" value="' . $options['membership_type'] . '"/>
					<input type="button" name="btn_unsubscribe" value="' . __('Unsubscribe', 'mgm') . '" onclick="confirm_unsubscribe(this)" class="button" />	
			   </form>';
        // return
        return $html;
    }
/** 
 * post buy button
 *
 * @param int post id
 * @param bool show error message
 * @param bool guest purchase
 * @return string button 
 */
function mgm_get_post_purchase_button($post_id = NULL, $show_message = true, $guest_purchase = false)
{
    // current user
    $current_user = wp_get_current_user();
    // get system
    $system_obj = mgm_get_class('system');
    // guest purchase - issue #1355
    if (!$guest_purchase) {
        $guest_purchase = bool_from_yn(mgm_get_setting('enable_guest_content_purchase'));
    }
    // get current post id
    if (!$post_id) {
        $post_id = get_the_ID();
    }
    // currency
    $currency = $system_obj->get_setting('currency');
    //issue #867
    $css_group = mgm_get_css_group();
    // css
    if ($css_group != 'none') {
        // css link
        $return = '<link rel="stylesheet" href="' . MGM_ASSETS_URL . 'css/' . $css_group . '/mgm.form.fields.css' . '" type="text/css" media="all" />';
    }
    // if user logged in
    if ($current_user->ID > 0 || $guest_purchase === TRUE) {
        // get active payment modules
        $a_payment_modules = $system_obj->get_active_modules('payment');
        // init
        $payment_modules = array();
        // when active
        if ($a_payment_modules) {
            // loop
            foreach ($a_payment_modules as $payment_module) {
                // not trial
                if (in_array($payment_module, array('mgm_free', 'mgm_trial'))) {
                    continue;
                }
                // store
                $payment_modules[] = $payment_module;
            }
        }
        // if show
        if ($show_message) {
            // text
            $private_text_purchasable = mgm_stripslashes_deep($system_obj->get_template('private_text_purchasable', array(), true));
            // def return
            $return .= sprintf('<div class="post_purchase_select_gateway">%s</div>', $private_text_purchasable);
        }
        // some module active
        if (count($payment_modules) > 0) {
            // in transactions url set
            if (!($transactions_url = $system_obj->get_setting('transactions_url'))) {
                // base url
                $transactions_url = mgm_home_url('transactions');
            }
            // post url
            $post_payment_url = add_query_arg(array('method' => 'payment_purchase'), $transactions_url);
            // hook
            add_filter('mgm_payment_gateways_as_custom_field', 'mgm_payment_gateways_as_custom_field_on_postpurchase');
            // custom fields
            $custom_fields = mgm_get_partial_fields(array('on_postpurchase' => true), 'mgm_postpurchase_field');
            // button
            $button_code = sprintf('<input class="button" type="submit" name="btnsubmit" value="%s">', __('Buy Now', 'mgm'));
            // filter
            $button_code = apply_filters('post_purchase_button_html', $button_code);
            // init
            $addon_options_html = '';
            // addons
            if ($addons = mgm_get_post($post_id)->get_addons()) {
                $addon_options_html = mgm_get_post_purchase_addon_options_html($addons);
            }
            // issue #1250
            $button = mgm_subscription_purchase_errors();
            // button
            $button .= '<div class="mgm_custom_filed_table">
						<form name="mgm_buypost_form" id="mgm_buypost_form" class="mgm_form" method="post" action="' . $post_payment_url . '">
							' . $custom_fields . '
							' . $addon_options_html . '
							' . $button_code . '
							<input type="hidden" name="post_id" value="' . $post_id . '">
							<input type="hidden" name="form_action" value="' . post_permalink($post_id) . '">
							<input type="hidden" name="guest_purchase" value="' . $guest_purchase . '">
					    </form>
					    </div>';
            // return
            $return .= $button;
        } else {
            $return .= sprintf('<div class="mgm_no_payment_gateway">%s</div>', __('No Payment Gateway available.', 'mgm'));
        }
    } else {
        // message
        if ($show_message) {
            // text
            $private_text_purchasable_login = mgm_private_text_tags(mgm_stripslashes_deep($system_obj->get_template('private_text_purchasable_login', array(), true)));
            // only when show message
            $return .= sprintf('<div class="post_purchase_select_gateway">%s</div>', $private_text_purchasable_login);
        }
    }
    // return
    return $return;
}
 /**
  * API helper method setup calback urls
  *
  * @param array $setting
  * @return none
  */
 function _setup_callback_urls($setting = array())
 {
     // urls keys
     $url_keys = array('notify_url' => 'payment_notify', 'status_notify_url' => 'payment_status_notify', 'return_url' => 'payment_return', 'cancel_url' => 'payment_cancel', 'processed_url' => 'payment_processed', 'thankyou_url' => 'payment_processed');
     // customizable thankyou url
     // loop
     foreach ($url_keys as $url_key => $callback) {
         // set in POST
         if (isset($setting[$url_key]) && !empty($setting[$url_key])) {
             // set
             $this->setting[$url_key] = $setting[$url_key];
         } else {
             // on key
             switch ($url_key) {
                 case 'notify_url':
                 case 'status_notify_url':
                 case 'return_url':
                     $payments_baseurl = mgm_home_url('payments');
                     break;
                 default:
                     // first check module thankyou
                     if ($transactions_url = $this->_get_transactions_url()) {
                         // thankyou_url url
                         $payments_baseurl = $transactions_url;
                     } else {
                         $payments_baseurl = mgm_home_url('payments');
                     }
                     break;
             }
             // set
             $this->setting[$url_key] = add_query_arg(array('module' => $this->code, 'method' => $callback), $payments_baseurl);
         }
     }
 }
    function get_button_unsubscribe($options = array())
    {
        // if API credentials are given, use curl method to cancel asubscription
        if (isset($this->setting['username']) && !empty($this->setting['username']) && !empty($this->setting['password']) && !empty($this->setting['signature'])) {
            $form_method_action = 'method="post" action="' . add_query_arg(array('module' => $this->code, 'method' => 'payment_unsubscribe'), mgm_home_url('payments')) . '"';
        } else {
            // else send the user to PAYPAL
            $form_method_action = 'method="get" action="' . $this->_get_endpoint() . '?cmd=_subscr-find&alias=' . urlencode($this->setting['business_email']) . '"';
        }
        // message
        $message = sprintf(__('You have subscribed to <b>%s</b> via <b>%s</b>, if you wish to unsubscribe, please click the following link. <br>', 'mgm'), get_option('blogname'), $this->name);
        // html
        $html = '<div class="mgm_margin_bottom_10px">
					<h4>' . __('Unsubscribe', 'mgm') . '</h4>
					<div class="mgm_margin_bottom_10px">' . $message . '</div>
			   </div>
			   <form name="mgm_unsubscribe_form" id="mgm_unsubscribe_form" ' . $form_method_action . ' >			   		
			   		<input type="hidden" name="user_id" value="' . $options['user_id'] . '"/>
					<input type="hidden" name="membership_type" value="' . $options['membership_type'] . '"/>
					<input type="button" name="btn_unsubscribe" value="' . __('Unsubscribe', 'mgm') . '" onclick="confirm_unsubscribe(this)" class="button" />	
			   </form>';
        // return
        return $html;
    }
示例#6
0
 function _default_setting()
 {
     // epoch specific
     $this->setting['reseller'] = 'a';
     $this->setting['co_code'] = '';
     $this->setting['send_userpass'] = '******';
     // dataplus
     $this->setting['dataplus_enable'] = 'no';
     $this->setting['dataplus_data_transfer'] = 'database';
     $this->setting['dataplus_database_server'] = 'local';
     $this->setting['dataplus_http_post_url'] = add_query_arg(array('module' => $this->code, 'method' => 'payment_status_notify'), mgm_home_url('payments'));
     // search api
     $this->setting['searchapi_auth_user'] = '';
     $this->setting['searchapi_auth_pass'] = '';
     // purchase price
     if (in_array('buypost', $this->supported_buttons)) {
         $this->setting['purchase_price'] = 4.0;
     }
     // callback messages
     $this->_setup_callback_messages();
     // callback urls
     $this->_setup_callback_urls();
 }
/**
 * get custom url, return default if not published
 *
 * @param string key/name of page
 * @param bool force default
 * @param array query string
 * @return string url 
 */
function mgm_get_custom_url($name, $load_default = false, $query_arg = array())
{
    // get system
    $system_obj = mgm_get_class('system');
    // is published page
    $is_published = mgm_is_custom_page_published($name == 'purchase_content' ? 'transactions' : $name);
    // on name
    switch ($name) {
        case 'login':
            // custom
            if (!$load_default && $is_published && ($login_url = mgm_get_setting('login_url'))) {
                $url = mgm_site_url($login_url);
            } else {
                // default
                $url = site_url('wp-login.php?action=login', 'login');
            }
            break;
        case 'register':
            // custom
            if (!$load_default && $is_published && ($register_url = mgm_get_setting('register_url'))) {
                $url = mgm_site_url($register_url);
            } elseif (!$load_default) {
                // old
                $url = add_query_arg(array('method' => 'register'), mgm_home_url('purchase_subscription'));
            } else {
                // default
                $url = site_url('wp-login.php?action=register', 'login');
            }
            break;
        case 'lostpassword':
            // custom
            if (!$load_default && $is_published && ($lostpassword_url = mgm_get_setting('lostpassword_url'))) {
                $url = mgm_site_url($lostpassword_url);
            } else {
                // default
                $url = site_url('wp-login.php?action=lostpassword');
            }
            break;
        case 'profile':
            // custom
            if (!$load_default && $is_published && ($profile_url = mgm_get_setting('profile_url'))) {
                $url = mgm_site_url($profile_url);
            } else {
                // default
                $url = admin_url('profile.php');
            }
            break;
        case 'userprofile':
            // custom
            if (!$load_default && $is_published && ($public_profile_url = mgm_get_setting('userprofile_url'))) {
                $url = mgm_site_url($public_profile_url);
            } else {
                // default
                $url = admin_url('profile.php');
            }
            break;
        case 'purchase_content':
            // reuse the same transactions url here: issue#: 756
            // $is_published = mgm_is_custom_page_published('transactions');
        // reuse the same transactions url here: issue#: 756
        // $is_published = mgm_is_custom_page_published('transactions');
        case 'transactions':
            // custom
            if ($is_published && ($transactions_url = mgm_get_setting('transactions_url'))) {
                $url = mgm_site_url($transactions_url, true);
            } else {
                // default
                $url = mgm_home_url($name == 'purchase_content' ? 'purchase_content' : 'purchase_subscription');
            }
            break;
        case 'membership_details':
            // custom
            if ($is_published && !$load_default && !is_super_admin() && ($membership_details_url = mgm_get_setting('membership_details_url'))) {
                $url = mgm_site_url($membership_details_url);
            } else {
                // default
                $url = admin_url(sprintf('%s.php?page=mgm/profile', is_super_admin() ? 'users' : 'profile'));
            }
            break;
        case 'membership_contents':
            // custom
            if ($is_published && !$load_default && !is_super_admin() && ($membership_contents_url = mgm_get_setting('membership_contents_url'))) {
                $url = mgm_site_url($membership_contents_url);
            } else {
                // default
                $url = admin_url(sprintf('%s.php?page=mgm/membership/content', is_super_admin() ? 'users' : 'profile'));
            }
            break;
        default:
            // default
            $url = mgm_home_url('purchase_subscription');
            break;
    }
    // @todo: add_query_arg urlencodes url with page=mgm/ need fix in some servers
    // add query arg
    if (!empty($query_arg)) {
        $url = add_query_arg($query_arg, $url);
    }
    // return
    return $url;
}