function autoresponder_modules()
 {
     // data
     $data = array();
     // get modules
     $data['autoresponder_modules'] = mgm_get_modules('autoresponder');
     // autoresponders
     foreach ($data['autoresponder_modules'] as $module) {
         // get module
         $module_object = mgm_get_module('mgm_' . $module, 'autoresponder');
         // check
         if (is_object($module_object)) {
             // get html
             $data['modules'][$module]['html'] = $module_object->settings();
             // get code
             $data['modules'][$module]['code'] = $module_object->code;
             // get name
             $data['modules'][$module]['name'] = $module_object->name;
         }
     }
     // membership types
     $data['membership_types'] = mgm_get_class('membership_types')->membership_types;
     // active
     $data['active_module'] = mgm_get_class('system')->active_modules['autoresponder'];
     // load template view
     $this->load->template('autoresponders/modules', array('data' => $data));
 }
 function activation_activate()
 {
     global $wpdb;
     // 	local
     extract($_POST);
     // post
     if (isset($btn_activate)) {
         // default
         $status = 'error';
         // check
         if (!empty($email)) {
             // validate
             $message = mgm_get_class('auth')->validate_subscription($email);
             // check
             if ($message === true) {
                 $status = 'success';
                 $message = __('Your account has been activated.', 'mgm');
             }
         } else {
             $message = __('Email is not provided.', 'mgm');
         }
         // return response
         echo json_encode(array('status' => $status, 'message' => $message));
         exit;
     }
     // data
     $data = array();
     // load template view
     $this->load->template('admin/activation/activate', array('data' => $data));
 }
 function index()
 {
     // data
     $data = array();
     // get active modules
     $data['payment_modules'] = mgm_get_class('system')->get_active_modules('payment');
     // mgm_log($data['payment_modules'], __FUNCTION__);
     // load template view
     $this->load->template('payments/index', array('data' => $data));
 }
 function disable($deactivate = false)
 {
     // deactivate
     if ($deactivate) {
         mgm_get_class('system')->deactivate_plugin($this->code);
     }
     // update state
     $this->enabled = 'N';
     // update option
     $this->save();
 }
 function settings_update()
 {
     // form type
     switch ($_POST['setting_form']) {
         case 'main':
             // form main
             // set fields
             $this->setting['clientid'] = $_POST['setting']['clientid'];
             $this->setting['formid'] = $_POST['setting']['formid'];
             $this->setting['listid'] = $_POST['setting']['listid'];
             $this->setting['specialid'] = $_POST['setting']['specialid'];
             $this->setting['doubleopt'] = $_POST['setting']['doubleopt'];
             // fieldmap
             $this->setting['fieldmap'] = $this->_make_assoc($_POST['setting']['fieldmap']);
             // membershipmap
             $this->setting['membershipmap'] = $this->_make_assoc($_POST['setting']['membershipmap']);
             // update enable/disable
             $this->enabled = $_POST['enabled'];
             // enable/disable method
             $activate_method = bool_from_yn($this->enabled) ? 'activate_module' : 'deactivate_module';
             // update
             $ret = call_user_func_array(array(mgm_get_class('system'), $activate_method), array($this->code, $this->type));
             // save object options
             $this->save();
             // message
             return json_encode(array('status' => 'success', 'message' => sprintf(__('%s settings updated', 'mgm'), $this->name)));
             break;
         case 'box':
         default:
             // from box
             // set fields
             $this->setting['clientid'] = $_POST['setting']['icontact']['clientid'];
             $this->setting['formid'] = $_POST['setting']['icontact']['formid'];
             $this->setting['listid'] = $_POST['setting']['icontact']['listid'];
             $this->setting['specialid'] = $_POST['setting']['icontact']['specialid'];
             $this->setting['doubleopt'] = $_POST['setting']['icontact']['doubleopt'];
             // update object options
             $this->save();
             // message
             return json_encode(array('status' => 'success', 'message' => sprintf(__('%s settings updated', 'mgm'), $this->name)));
             break;
     }
 }
Example #6
0
?>
</div></p>				
    		</div>
		</div>
	</div>	
	<?php 
mgm_box_bottom();
?>

	
	<?php 
mgm_box_top('Captcha Settings');
?>
	
	<?php 
$recaptcha = mgm_get_class('recaptcha');
?>

	<div class="table">
  		<div class="row">
    		<div class="cell width25">
				<p><b><?php 
_e('reCaptcha Public Key', 'mgm');
?>
:</b></p>
    		</div>
		</div>
  		<div class="row">
    		<div class="cell width75">
				<p><input type="text" name="recaptcha_public_key" value="<?php 
echo esc_html($data['system_obj']->get_setting('recaptcha_public_key'));
?>
';
			// bind	search field change		
			jQuery("select[name='search_field_name']").bind('change',function() {	
				// remove old		
				jQuery(":input[name='search_field_value']").remove();		
				// reset val
				if(onchange_count > 0) search_val = search_val2 = '';	
				// on val
				switch(jQuery(this).val()){
					case 'membership_type':
						jQuery('#fld_wrapper_two').html('');
						var s=document.createElement('select');
							s.name='search_field_value';						
						<?php 
foreach (mgm_get_class('membership_types')->membership_types as $membership_type_value => $membership_type_text) {
    ?>

							s.options[s.options.length]=new Option('<?php 
    echo $membership_type_text;
    ?>
','<?php 
    echo $membership_type_value;
    ?>
',false,<?php 
    echo $data['search_field_value'] == $membership_type_value ? 'true' : 'false';
    ?>
);
						<?php 
}
?>
    /** 
     * get pack description
     *	
     * @param array $pack
     * @return string $desc
     */
    function get_pack_desc($pack)
    {
        // system
        $system_obj = mgm_get_class('system');
        // format
        $date_fmt = mgm_get_date_format('date_format_short');
        // tpl data
        $tpl_data = array();
        // tpl vars
        $tpl_vars = array('membership_type', 'cost', 'currency', 'duration', 'duration_period', 'num_cycles', 'trial_cost', 'trial_duration', 'trial_duration_period', 'description', 'currency_sign', 'pack_start_date', 'pack_end_date');
        // get template
        if (!($pack_desc_template = $system_obj->get_template('pack_desc_template', array(), true))) {
            $pack_desc_template = sprintf('[membership_type] - [cost] [currency] %s [duration] [duration_period] [num_cycles].<br/> 
										   [if_trial_on] %s [trial_cost] [currency] %s [trial_duration] [trial_duration_period] [/if_trial_on]', __('per', 'mgm'), __('This pack includes a special, limited trial-offer:', 'mgm'), __('for', 'mgm'));
        }
        // lifetime template:
        if ($pack['duration_type'] == 'l') {
            // template	-issue #988
            if (!($pack_desc_template = $system_obj->get_template('pack_desc_lifetime_template', array(), true))) {
                $pack_desc_template = sprintf('[membership_type] - [cost] [currency] %s', __('for Lifetime', 'mgm'));
            }
        } elseif ($pack['duration_type'] == 'dr') {
            $date_range = '';
            // check
            if (mgm_is_valid_date($pack['duration_range_start_dt'], '-') && mgm_is_valid_date($pack['duration_range_end_dt'], '-')) {
                $tpl_data['pack_start_date'] = date($date_fmt, strtotime($pack['duration_range_start_dt']));
                $tpl_data['pack_end_date'] = date($date_fmt, strtotime($pack['duration_range_end_dt']));
            }
            if (!($pack_desc_template = $system_obj->get_template('pack_desc_date_range_template', array(), true))) {
                $pack_desc_template = sprintf('[membership_type] - [cost] [currency] starts from [pack_start_date]  to [pack_end_date]');
            }
        }
        // currency - issue #1602
        if (!isset($pack['currency']) || empty($pack['currency'])) {
            $tpl_data['currency'] = $system_obj->get_setting('currency');
        } else {
            $tpl_data['currency'] = $pack['currency'];
        }
        // issue #1177
        $tpl_data['currency_sign'] = mgm_get_currency_symbols($tpl_data['currency']);
        // type
        $tpl_data['membership_type'] = mgm_stripslashes_deep(mgm_get_class('membership_types')->get_type_name($pack['membership_type']));
        $tpl_data['duration_period'] = strtolower($this->get_pack_duration($pack));
        // transalation issue #950
        $tpl_data['text_for'] = __('for', 'mgm');
        $tpl_data['num_cycles'] = $pack['num_cycles'] == 0 ? __(' - Ongoing', 'mgm') : sprintf(' - %s %d %s', $tpl_data['text_for'], (int) $pack['num_cycles'], $pack['num_cycles'] == 1 ? __('time', 'mgm') : __('times', 'mgm'));
        $tpl_data['trial_duration_period'] = strtolower($this->get_pack_duration($pack, true));
        // merge rest, overwrite tpl_data
        if (is_array($pack)) {
            $tpl_data = array_merge($pack, $tpl_data);
        }
        // remove next lines as preg_replace will fail
        $pack_desc_template = str_replace(array("\r\n", "\n", "\r"), '', $pack_desc_template);
        // copy template
        $pack_desc = $pack_desc_template;
        // replace 0 cost
        if (isset($tpl_data['cost']) && $tpl_data['cost'] == 0.0) {
            $pack_desc = str_replace('[cost] [currency]', __('free', 'mgm'), $pack_desc);
        }
        // replace 0 trial_cost
        if (isset($tpl_data['trial_cost']) && $tpl_data['trial_cost'] == 0.0) {
            $pack_desc = str_replace('[trial_cost] [currency]', __('free', 'mgm'), $pack_desc);
        }
        // replace
        foreach ($tpl_vars as $var) {
            if (isset($tpl_data[$var])) {
                $pack_desc = str_replace('[' . $var . ']', $tpl_data[$var], $pack_desc);
            }
        }
        // num cycles
        if ($pack['num_cycles']) {
            $pack_desc = preg_replace("'\\[/?\\s?if_num_cycles\\s?\\]'i", '', $pack_desc);
        } else {
            $pack_desc = preg_replace("'\\[if_num_cycles\\s?\\](.*)\\[/if_num_cycles\\s?\\]'i", '', $pack_desc);
        }
        // trial on
        if (isset($pack['trial_on']) && (int) $pack['trial_on'] == 1) {
            $pack_desc = preg_replace("'\\[/?\\s?if_trial_on\\s?\\]'i", '', $pack_desc);
        } else {
            $pack_desc = preg_replace("'\\[if_trial_on\\s?\\](.*)\\[/if_trial_on\\s?\\]'i", '', $pack_desc);
        }
        // send
        return $pack_desc;
    }
/**
 * get payment processed page html
 *
 * @param void
 * @return string
 * @since 1.5
 */
function mgm_get_payment_processed_page_html()
{
    // home url
    $home_url = trailingslashit(get_option('siteurl'));
    // current module
    $module = mgm_request_var('module', '', true);
    // check
    if (!mgm_is_valid_module($module) || empty($module)) {
        // redirect
        mgm_redirect($home_url);
    }
    // init
    $html = '';
    // refresh wait time
    $refresh_wait_time = 5;
    //in seconds
    // redirect url
    $redirect_url = '';
    // redirect
    $do_redirect = true;
    // refresh header for post redirecr
    if (isset($_GET['post_redirect'])) {
        // redirect url
        $redirect_url = strip_tags($_GET['post_redirect']);
    } elseif (isset($_GET['register_redirect'])) {
        // redirect url, if 1/true, redirect to profile, else its register & redirect url
        if ($_GET['register_redirect'] != 1) {
            $redirect_url = strip_tags($_GET['register_redirect']);
        } else {
            // auto login
            $system_obj = mgm_get_class('system');
            //issue# 1392
            $current_user_id = get_current_user_id();
            // check if set
            if ($autologin_redirect_url = $system_obj->get_setting('autologin_redirect_url')) {
                $page_title = '';
                $redirect_url = $autologin_redirect_url;
                //short code support
                if (!empty($current_user_id)) {
                    $user = get_userdata($current_user_id);
                    $redirect_url = str_replace('[username]', $user->user_login, $redirect_url);
                }
            } elseif (mgm_get_user_package_redirect_url($current_user_id) && $current_user_id) {
                $page_title = '';
                $redirect_url = mgm_get_user_package_redirect_url($current_user_id);
            } else {
                $page_title = 'Profile';
                $redirect_url = mgm_get_custom_url('profile');
            }
        }
        // check not logged in, #948 paypal fails to redirect
        if (!is_user_logged_in()) {
            // user login
            if (isset($_GET['trans_ref'])) {
                // re construct redirect url
                $redirect_url = mgm_get_custom_url('login', false, array('trans_ref' => strip_tags($_GET['trans_ref']), 'auto_login' => true, 'redirect_to' => $redirect_url));
            }
        }
    }
    // check and set
    if (!empty($redirect_url) && $do_redirect) {
        // alter
        $redirect_url = apply_filters('mgm_register_redirect', $redirect_url);
        // no headers
        if (!headers_sent()) {
            @header(sprintf('Refresh: %d;url=%s', $refresh_wait_time, $redirect_url));
        } else {
            $html .= sprintf('<script language="javascript">window.setTimeout(function(){window.location.href="%s";}, %d)</script>', $redirect_url, (int) $refresh_wait_time * 5);
        }
    }
    // module object
    $module_object = mgm_get_module($module, 'payment');
    // [domain]/subscribe/?method=payment_processed&module=mgm_paypal&status=success
    // [domain]/subscribe/?method=payment_processed&module=mgm_paypal&status=cancel
    // status and message
    $arr_shortcodes = array('transaction_amount' => '');
    // check
    if (!isset($_GET['status']) || $_GET['status'] == 'success') {
        // mgm_replace_oldlinks_with_tag is a patch for replacing the old link
        $message = $module_object->setting['success_message'] ? mgm_replace_oldlinks_with_tag($module_object->setting['success_message'], 'payment_success_message') : $system_obj->get_template('payment_success_message', array(), true);
        // get price
        if (isset($_GET['trans_ref'])) {
            // tarns
            $_GET['trans_ref'] = mgm_decode_id(strip_tags($_GET['trans_ref']));
            // get transaction data
            $trans = mgm_get_transaction($_GET['trans_ref']);
            // set amount
            if ($trans['module'] == 'manualpay') {
                $arr_shortcodes['transaction_amount'] = $trans['data']['cost'] . ' ' . $trans['data']['currency'];
            }
            // update googe analytics:
            $html .= apply_filters('mgm_payment_processed_page_analytics', $trans);
            // @todo, callback in template function
            // mgm_update_google_analytics($trans);	deprecated, use hook
        }
    } else {
        if (!isset($_GET['status']) || $_GET['status'] == 'cancel') {
            // set message
            $message = __('You have cancelled the transaction.', 'mgm');
        } else {
            // mgm_replace_oldlinks_with_tag is a patch for replacing the old link
            $message = $module_object->setting['failed_message'] ? mgm_replace_oldlinks_with_tag($module_object->setting['failed_message'], 'payment_failed_message') : $system_obj->get_template('payment_failed_message', array(), true);
        }
    }
    // parse short codes:
    // [transaction_amount] = amount paid
    foreach ($arr_shortcodes as $code => $value) {
        $message = str_replace('[' . $code . ']', $value, $message);
    }
    // html
    $html .= mgm_stripslashes_deep(mgm_get_message_template($message));
    // get error
    if (isset($_GET['errors'])) {
        // get errors
        $errors = explode('|', strip_tags($_GET['errors']));
        // html
        $html .= sprintf('<h3> %s </h3><div><ul>', __('Messages', 'mgm'));
        // loop
        foreach ($errors as $error) {
            $html .= sprintf('<li> %s </li>', $error);
        }
        // end
        $html .= '</ul></div>';
    }
    // auto redirect to post purchased
    if (isset($_GET['post_redirect'])) {
        // message
        $m = sprintf(__('You will be automatically redirected to the post you purchased within %d seconds. Please <a href="%s"> click here </a> to go to the page. ', 'mgm'), $refresh_wait_time, strip_tags($_GET['post_redirect']));
        // set
        $html .= sprintf('<b>%s</b>', $m);
    } elseif (isset($_GET['register_redirect'])) {
        // auto login redirect
        // message
        $m = sprintf(__('You will be automatically redirected to your %s page within %d seconds. Please <a href="%s"> click here </a> to go to the page. ', 'mgm'), $_GET['register_redirect'] == 1 ? __($page_title, 'mgm') : __('Post', 'mgm'), $refresh_wait_time, $redirect_url);
        // set
        $html .= sprintf('<b>%s</b>', $m);
    }
    // return
    return apply_filters('mgm_payment_processed_page_html', $html);
}
<?php

/** 
 * Objects merge/update
 * Add New content protection setting: using_the_excerpt_in_theme
 * This is to prevent executing content protection callback if the_excerpt is being used in themes
 */
// read
$system_obj = mgm_get_class('system');
// check
if (!isset($system_obj->setting['using_the_excerpt_in_theme'])) {
    // default to 'NO'
    $system_obj->setting['using_the_excerpt_in_theme'] = 'N';
    // save
    $system_obj->save();
}
Example #11
0
 function _default_setting()
 {
     // ideal specific
     $this->setting['aquirer'] = '';
     $this->setting['merchant_id'] = '';
     $this->setting['secret_key'] = '';
     $this->setting['key_version'] = '1';
     $this->setting['sub_id'] = '';
     $this->setting['language'] = 'nl';
     $this->setting['currency'] = mgm_get_class('system')->setting['currency'];
     $this->setting['payment_mean_brand'] = '';
     // 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();
 }
 /**
  * Cancel Recurring Subscription
  * This is not a private function
  * @param int/string $trans_ref	
  * @param int $user_id	
  * @param int/string $subscr_id	
  * @param int $pack_id	
  * @return boolean
  */
 function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
 {
     //if coming form process return after a subscription payment
     if (!empty($trans_ref)) {
         $transdata = $this->_get_transaction_passthrough($trans_ref);
         if ($transdata['payment_type'] != 'subscription_purchase') {
             return false;
         }
         $user_id = $transdata['user_id'];
         if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
             $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
         } else {
             $member = mgm_get_member($user_id);
         }
         if (isset($member->payment_info->module)) {
             if (isset($member->payment_info->subscr_id)) {
                 $subscr_id = $member->payment_info->subscr_id;
             } else {
                 //check pack is recurring:
                 $pid = $pack_id ? $pack_id : $member->pack_id;
                 if ($pid) {
                     $s_packs = mgm_get_class('subscription_packs');
                     $sel_pack = $s_packs->get_pack($pid);
                     if ($sel_pack['num_cycles'] != 1) {
                         $subscr_id = 0;
                     }
                 }
             }
             //check for same module: if not call the same function of the applicale module.
             if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
                 mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->code);
                 return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
             }
             //skip if same pack is updated
             if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
                 return false;
             }
         } else {
             return false;
         }
     }
     //send email only if setting enabled
     if (!empty($subscr_id) || $subscr_id === 0) {
         $system_obj = mgm_get_class('system');
         $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
         //send email only if setting enabled
         if (!$dge) {
             // blog
             $blogname = get_option('blogname');
             // user
             $user = get_userdata($user_id);
             // notify admin
             mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member);
         }
         return true;
     }
     return false;
 }
 /**
  * Calls an HTTP POST function to verify if the user's guess was correct
  * @param string $privkey
  * @param string $remoteip
  * @param string $challenge
  * @param string $response
  * @param array $extra_params an array of extra variables to post to the server
  * @return ReCaptchaResponse
  */
 function recaptcha_check_answer($challenge, $response, $extra_params = array())
 {
     //system settings
     $recaptcha_response = new stdClass();
     $recaptcha_response->error = null;
     $setting = mgm_get_class('system')->get_setting();
     $use_ssl = isset($_SERVER['https']) ? true : false;
     $remoteip = mgm_get_client_ip_address();
     if (empty($setting['recaptcha_private_key']) || empty($setting['recaptcha_public_key'])) {
         $recaptcha_response->is_valid = false;
         $recaptcha_response->error = __("reCAPTCHA API keys are blank. ", 'mgm');
         return $recaptcha_response;
     }
     if ($remoteip == null || $remoteip == '') {
         $recaptcha_response->is_valid = false;
         $recaptcha_response->error = __("For security reasons, you must pass the remote IP to reCAPTCHA", 'mgm');
         return $recaptcha_response;
     }
     //discard spam submissions
     if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
         $recaptcha_response->is_valid = false;
         $recaptcha_response->error = __('The Captcha String isn\'t correct', 'mgm');
         return $recaptcha_response;
     }
     $response = $this->_recaptcha_http_post($setting['recaptcha_verify_server'], "/recaptcha/api/verify", array('privatekey' => $setting['recaptcha_private_key'], 'remoteip' => $remoteip, 'challenge' => $challenge, 'response' => $response) + $extra_params);
     $recaptcha_response->is_valid = $response['status'];
     if (isset($response['error'])) {
         $recaptcha_response->error = __('The Captcha String isn\'t correct', 'mgm');
     }
     return $recaptcha_response;
 }
 function _default_setting()
 {
     // authorize.net specific
     $this->setting['secretkey'] = '';
     $this->setting['publishable_key'] = '';
     $this->setting['currency'] = mgm_get_class('system')->setting['currency'];
     // 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();
 }
Example #15
0
			<div class="cell height10px">
				<div class="information"><?php 
    echo sprintf(__('<a href="%s">Content Protection</a> is <b>%s</b>. Make sure its enabled to Protect Post/Page(s).', 'mgm'), 'javascript:mgm_set_tab_url(2,0)', mgm_protect_content() ? 'enabled' : 'disabled');
    ?>
</div>	
			</div>
		</div>			
		<?php 
}
?>

		<div class="row">&nbsp;</div>
		<div class="row">
			<div class="cell height10px">
				<input type="checkbox" name="add_private_tags" 	value="Y" <?php 
if (mgm_get_class('system')->setting['add_private_tags'] == "Y") {
    echo "checked='checked'";
}
?>
/>
				&nbsp;<b><?php 
_e('Add Private Tags', 'mgm');
?>
</b>
			</div>
		</div>			
		<div class="row">
			<div class="cell">
				<div class="tips"><?php 
_e('Will wrap full page content with [private] [/private] tags', 'mgm');
?>
 function editor()
 {
     global $wpdb;
     // init
     $data = array();
     // hook
     $data['download_hook'] = mgm_get_class('system')->get_setting('download_hook', 'download');
     // downloads
     $data['downloads'] = $wpdb->get_results("SELECT  * FROM `" . TBL_MGM_DOWNLOAD . "`");
     // load template view
     $this->load->template('downloads/editor_list', array('data' => $data));
 }
 /**	
  * add
  *
  * @param array $data pack data
  * @param array $options
  */
 public function add($data, $options = NULL)
 {
     global $wpdb;
     // init
     $columns = $tran_data = array();
     // payment type
     $columns['payment_type'] = isset($data['buypost']) ? 'post_purchase' : 'subscription_purchase';
     // user
     // IMPORTANT: user_id has to be passed alogn with pack details, otherwise logged in user id
     $tran_data['user_id'] = isset($options['user_id']) ? $options['user_id'] : mgm_get_user_id();
     // register and purchase, capture post id
     if (isset($options['post_id'])) {
         $tran_data['post_id'] = (int) $options['post_id'];
     }
     // register and purchase postpack, capture postpack id & postpack post id
     if (isset($options['postpack_id'])) {
         $tran_data['postpack_id'] = (int) $options['postpack_id'];
     }
     if (isset($options['postpack_post_id'])) {
         $tran_data['postpack_post_id'] = (int) $options['postpack_post_id'];
     }
     // subscription option : create|upgrade|downgrade|extend
     if ($columns['payment_type'] == 'subscription_purchase') {
         // registration flag, @ToDo will use "subscription_option" next onwards
         // subscription option
         $tran_data['subscription_option'] = isset($options['subscription_option']) ? $options['subscription_option'] : 'create';
         // new registration @todo @depracate
         $tran_data['is_registration'] = isset($options['is_registration']) ? 'Y' : 'N';
         // another subscription purchase flag @todo @depracate
         $tran_data['is_another_membership_purchase'] = isset($options['is_another_membership_purchase']) ? 'Y' : 'N';
         // another subscription purchase - if upgrade from prev pack
         // value should be reset once upgrade member object is replaced @todo @depracate
         $tran_data['multiple_upgrade_prev_packid'] = isset($options['multiple_upgrade_prev_packid']) ? $options['multiple_upgrade_prev_packid'] : '';
         // registration user email notification flag after user is active - issue #1468
         $tran_data['notify_user'] = isset($options['notify_user']) ? $options['notify_user'] : false;
     }
     // others
     // set system currency, will update at module level after module selection
     //issue #1602
     if (!isset($data['currency']) || empty($data['currency'])) {
         $tran_data['currency'] = mgm_get_class('system')->get_setting('currency');
     } else {
         $tran_data['currency'] = $data['currency'];
     }
     // ip
     $tran_data['client_ip'] = mgm_get_client_ip_address();
     // payment email sent flag
     $tran_data['payment_email'] = 0;
     // merge with data
     $tran_data = array_merge($data, $tran_data);
     // set data
     $columns['data'] = json_encode($tran_data);
     // date
     $columns['transaction_dt'] = date('Y-m-d H:i:s');
     // user id
     if (isset($tran_data['user_id']) && (int) $tran_data['user_id'] > 0) {
         // add
         $columns['user_id'] = $tran_data['user_id'];
     }
     // insert
     $wpdb->insert(TBL_MGM_TRANSACTION, $columns);
     // transaction id
     $id = $wpdb->insert_id;
     // run actions
     do_action('mgm_transaction_item_add', $id, $columns['payment_type']);
     // global
     do_action('mgm_transaction_item_add_' . $columns['payment_type'], $id);
     // individual
     // return
     return $id;
 }
 /**
  * set default settings
  *
  */
 function _default_setting()
 {
     // paypalexpress specific
     $this->setting['username'] = '';
     $this->setting['password'] = '';
     $this->setting['signature'] = '';
     $this->setting['locale'] = 'US';
     $this->setting['currency'] = mgm_get_class('system')->setting['currency'];
     //issue #974
     $this->setting['max_failed_payments'] = 3;
     // 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();
 }
/**
 * taxonomy/category delete
 *
 * @param int term_id
 * @param int term taxonomy id
 * @param string taxonomy
 * @return none
 */
function mgm_term_delete($term_id, $tt_id, $taxonomy)
{
    // term
    switch ($taxonomy) {
        case 'category':
            // class
            $post_category = mgm_get_class('post_category');
            // set
            $post_category->access_membership_types[$term_id] = $_POST['mgm_category_access'];
            // save
            $post_category->save();
            break;
        case 'post_tag':
            // nothing for tags
            break;
        default:
            // class
            $post_taxonomy = mgm_get_class('post_taxonomy');
            // set
            $post_taxonomy->access_membership_types[$term_id] = $_POST['mgm_taxonomy_access'];
            // save
            $post_taxonomy->save();
            break;
    }
}
/**
 * text widget : multiple instance
 * admin instance
 *
 * @param array $widget_args
 * @return void
 * @since 1.0
 */
function mgm_sidebar_widget_text_admin($widget_args = 1)
{
    global $wp_registered_widgets, $mgm_sidebar_widget;
    static $updated = false;
    if (is_numeric($widget_args)) {
        $widget_args = array('number' => $widget_args);
    }
    $widget_args = wp_parse_args($widget_args, array('number' => -1));
    extract($widget_args, EXTR_SKIP);
    $options = $mgm_sidebar_widget->text_widget;
    if (!is_array($options)) {
        $options = array();
    }
    // m_sidebar
    $m_sidebar = mgm_post_var('sidebar');
    // updated
    if (!$updated && !empty($m_sidebar)) {
        $sidebar = (string) $m_sidebar;
        $sidebars_widgets = wp_get_sidebars_widgets();
        if (isset($sidebars_widgets[$sidebar])) {
            $this_sidebar =& $sidebars_widgets[$sidebar];
        } else {
            $this_sidebar = array();
        }
        foreach ($this_sidebar as $_widget_id) {
            // check
            if (isset($wp_registered_widgets[$_widget_id]['callback']) && isset($wp_registered_widgets[$_widget_id]['params'][0]['number'])) {
                if ('mgm_widget_text' == $wp_registered_widgets[$_widget_id]['callback']) {
                    $widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
                    if (!in_array("text-{$widget_number}", mgm_post_var('widget-id'))) {
                        // the widget has been removed.
                        unset($options[$widget_number]);
                    }
                }
            }
        }
        foreach ((array) mgm_post_var('mgm_widget_text') as $widget_number => $mgm_widget_text) {
            if (!isset($mgm_widget_text['text']) && isset($options[$widget_number])) {
                // user clicked cancel
                continue;
            }
            // title
            $title = isset($mgm_widget_text['title']) ? strip_tags(stripslashes($mgm_widget_text['title'])) : '';
            // text
            if (current_user_can('unfiltered_html')) {
                $text = isset($mgm_widget_text['text']) ? stripslashes($mgm_widget_text['text']) : '';
            } else {
                $text = isset($mgm_widget_text['text']) ? stripslashes(wp_filter_post_kses($mgm_widget_text['text'])) : '';
            }
            // types
            $access_membership_types = isset($mgm_widget_text['access_membership_types']) ? implode('|', $mgm_widget_text['access_membership_types']) : '';
            // set
            $options[$widget_number] = compact('title', 'text', 'access_membership_types');
        }
        // set
        $mgm_sidebar_widget->text_widget = $options;
        // update_option('mgm_sidebar_widget', $mgm_sidebar_widget);
        $mgm_sidebar_widget->save();
        // updated
        $updated = true;
    }
    // get available membership types
    $membership_types = mgm_get_class('membership_types')->membership_types;
    // selected
    $selected_membership_types = array();
    // get selected
    if (-1 == $number) {
        $number = '%i%';
        $title = '';
        $text = '';
        $selected_membership_types = implode(';', $membership_types);
    } else {
        $title = esc_attr($options[$number]['title']);
        $text = format_to_edit($options[$number]['text']);
        if (isset($options[$number]['access_membership_types'])) {
            $selected_membership_types = explode('|', $options[$number]['access_membership_types']);
        }
    }
    echo '<p>' . __('Available to', 'mgm') . ':<br />';
    foreach ((array) $membership_types as $type_code => $type_name) {
        if (is_array($selected_membership_types)) {
            $c = in_array($type_code, $selected_membership_types) ? 'checked="checked"' : '';
        } else {
            $c = '';
        }
        echo '<input type="checkbox" id="mgm_widget_text_' . $number . '" class="checkbox" name="mgm_widget_text[' . $number . '][access_membership_types][]" value="' . $type_code . '" ' . $c . ' />
			  &nbsp;&nbsp;<label class="mgm_font_italic" for="' . __($type_code, 'mgm') . '">' . __($type_name, 'mgm') . '</label>&nbsp;&nbsp;';
    }
    echo '</p>';
    ?>

	<p>
		<label><?php 
    _e('Title', 'mgm');
    ?>
:</label> 		
		<input class="widefat" id="mgm_widget_text_<?php 
    echo $number;
    ?>
" name="mgm_widget_text[<?php 
    echo $number;
    ?>
][title]" type="text" value="<?php 
    echo $title;
    ?>
" />
	</p>
	<p>
		<label><?php 
    _e('Text', 'mgm');
    ?>
: </label>
		<textarea class="widefat" rows="16" cols="20" id="mgm_widget_text_<?php 
    echo $number;
    ?>
" name="mgm_widget_text[<?php 
    echo $number;
    ?>
][text]"><?php 
    echo $text;
    ?>
</textarea>
		<input type="hidden" name="mgm_widget_text[<?php 
    echo $number;
    ?>
][submit]" value="1" />
	</p>
	<?php 
}
 function _do_export()
 {
     global $wpdb;
     // local
     extract($_POST);
     // create
     $migrate =& new mgm_migrate();
     // version
     $version = mgm_get_class('auth')->get_product_info('product_version');
     // file
     $filepath = MGM_FILES_EXPORT_DIR . 'export-' . $version . '-' . time() . '.xml';
     // create
     $status = $migrate->create($filepath, $export_sections);
     // return
     return $filepath;
 }
    /**
     * Cancel Recurring Subscription
     * This is not a private function
     * @param int/string $trans_ref	
     * @param int $user_id	
     * @param int/string $subscr_id	
     * @return boolean
     */
    function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
    {
        //if coming form process return after a subscription payment
        if (!empty($trans_ref)) {
            $transdata = $this->_get_transaction_passthrough($trans_ref);
            if ($transdata['payment_type'] != 'subscription_purchase') {
                return false;
            }
            $user_id = $transdata['user_id'];
            if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
                $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
            } else {
                $member = mgm_get_member($user_id);
            }
            if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
                if (isset($member->payment_info->subscr_id)) {
                    $subscr_id = $member->payment_info->subscr_id;
                } else {
                    //check pack is recurring:
                    $pid = $pack_id ? $pack_id : $member->pack_id;
                    if ($pid) {
                        $s_packs = mgm_get_class('subscription_packs');
                        $sel_pack = $s_packs->get_pack($pid);
                        if ($sel_pack['num_cycles'] != 1) {
                            $subscr_id = 0;
                        }
                    }
                }
                //check for same module: if not call the same function of the applicale module.
                if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
                    // log
                    // mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code);
                    // return
                    return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
                }
                //skip if same pack is updated
                if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
                    return false;
                }
            } else {
                return false;
            }
        }
        //only for subscription_purchase
        if ($subscr_id) {
            // set xml content
            $post_data = '<ARBCancelSubscriptionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
							<merchantAuthentication>
								<name>' . $this->setting['loginid'] . '</name>
								<transactionKey>' . $this->setting['tran_key'] . '</transactionKey>
							</merchantAuthentication>
							<refId>' . $user_id . '</refId>
							<subscriptionId>' . $subscr_id . '</subscriptionId>
						</ARBCancelSubscriptionRequest>';
            // end  point
            $endpoint = $this->_get_endpoint($this->status . '_arb');
            // test_arb, live_aim etc.
            // headers
            $http_headers = array('Content-Type' => 'text/xml');
            // create curl post
            $http_response = mgm_remote_post($endpoint, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
            // parse response and store into a different array:
            // do not use $this->response here as this will overwrite previous theprevious values in one scenario
            $arb_response = $this->_process_response('arb', $http_response, false);
            // check
            if (isset($arb_response['response_status']) && $arb_response['response_status'] == 1) {
                return true;
            }
        } elseif (is_null($subscr_id) || $subscr_id === 0) {
            //send email to admin if subscription Id is absent
            $system_obj = mgm_get_class('system');
            $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
            //send email only if setting enabled
            if (!$dge) {
                // blog
                $blogname = get_option('blogname');
                // user
                $user = get_userdata($user_id);
                // notify admin
                mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member);
            }
            // return
            return true;
        }
        // return
        return false;
    }
 private function _get_protected_taxonimies($taxonomies)
 {
     global $wpdb;
     // array or string
     if (!is_array($taxonomies)) {
         $taxonomies = array($taxonomies);
     }
     // membership types
     $access_membership_types['category'] = mgm_get_class('post_category')->get_access_membership_types();
     // membership types
     $access_membership_types['taxonomy'] = mgm_get_class('post_taxonomy')->get_access_membership_types();
     // init
     $membership_types = array();
     // taxonomies
     $terms = get_terms($taxonomies, array('hide_empty' => 0));
     // taxonomies
     $taxonomies = array();
     // loop
     foreach ($terms as $term) {
         // $access_settings
         $access_settings = array();
         // check
         if (isset($access_membership_types[$term->taxonomy][$term->term_id])) {
             // loop
             if ($membership_types = $access_membership_types[$term->taxonomy][$term->term_id]) {
                 // loop
                 foreach ($membership_types as $membership_type) {
                     $access_settings[] = array('membership_type' => array('code' => $membership_type, 'name' => mgm_get_membership_type_name($membership_type)));
                 }
             }
         } else {
             $access_settings = 'public';
         }
         // access_settings
         $term->access_settings = $access_settings;
         // store
         $taxonomies[] = $term;
     }
     // return
     return $taxonomies;
 }
 function edit()
 {
     global $wpdb;
     extract($_POST);
     // save
     if (isset($save_coupon)) {
         // response
         $response = array('status' => 'error', 'message' => __('Coupon update failed, Unknown error!', 'mgm'));
         // check duplicate
         if (mgm_is_duplicate(TBL_MGM_COUPON, array('name'), "id <> '{$id}'")) {
             $response['message'] = sprintf(__('Error while updating coupon: %s, same code exists!', 'mgm'), $name);
         } else {
             // fields
             $fields = array('name', 'value', 'description', 'use_limit', 'used_count', 'product', 'expire_dt');
             // colums
             $column_data = $column_null_data = array();
             // create value
             $value = $this->_set_value();
             // use limit
             if (isset($use_limit) && is_numeric($use_limit)) {
                 $use_limit = (int) $use_limit;
             } else {
                 $use_limit = NULL;
             }
             // product
             if (isset($product)) {
                 $product = json_encode($product);
             } else {
                 $product = NULL;
             }
             // expire dt format
             if (isset($expire_dt) && !empty($expire_dt)) {
                 $expire_dt = date('Y-m-d H:i:s', strtotime(mgm_format_inputdate_to_mysql($expire_dt, mgm_get_date_format('date_format_short'))));
             } else {
                 $expire_dt = NULL;
             }
             // loop
             foreach ($fields as $field) {
                 // check
                 if (isset(${$field}) && !is_null(${$field})) {
                     $column_data[$field] = trim(${$field});
                 } else {
                     $column_null_data[$field] = 'NULL';
                     // need string to track
                 }
             }
             // affected
             $affected = 0;
             // update
             if ($wpdb->update(TBL_MGM_COUPON, $column_data, array('id' => $id))) {
                 $affected++;
             }
             // null
             if (!empty($column_null_data)) {
                 // column_data2
                 $column_data2_a = mgm_implode_a(',', array_keys($column_null_data), array_values($column_null_data));
                 // update
                 if ($wpdb->query("UPDATE `" . TBL_MGM_COUPON . "` SET {$column_data2_a} WHERE id='{$id}' ")) {
                     $affected++;
                 }
             }
             // save
             if ($affected) {
                 $response = array('status' => 'success', 'message' => sprintf(__('Successfully updated coupon: "%s"', 'mgm'), $name));
             } else {
                 $response = array('status' => 'error', 'message' => sprintf(__('Error while updating coupon: "%s"', 'mgm'), $name));
             }
         }
         // return response
         echo json_encode($response);
         exit;
     }
     // data
     $data = array();
     // coupon
     $data['coupon'] = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . TBL_MGM_COUPON . "` WHERE id=%d", $id));
     // parse
     $data['value_is'] = $this->_get_value($data['coupon']->value);
     // currency
     $data['currency'] = mgm_get_class('system')->setting['currency'];
     // load template view
     $this->load->template('coupons/edit', array('data' => $data));
 }
 private function _filter_verbs()
 {
     // get verbs
     $rest_input_methods = mgm_get_class('system')->get_setting('rest_input_methods');
     // check
     if (is_array($rest_input_methods)) {
         // only matching
         $this->_supported_verbs = array_intersect($rest_input_methods, $this->_supported_verbs);
     }
 }
Example #26
0
<?php

/** 
 * Patch for Membership Level's rename
 */
// get object
$membership_types_obj = mgm_get_class('membership_types');
// ge all users
$users = mgm_get_all_userids(array('ID'), 'get_results');
// loop types
foreach ($membership_types_obj->get_membership_types() as $type_code => $type_name) {
    $new_type_code = $membership_types_obj->get_type_code($type_name);
    //check
    if ($new_type_code != $type_code) {
        // get object
        $obj_sp = mgm_get_class('subscription_packs');
        //update new
        foreach ($obj_sp->packs as $key => $pack) {
            if ($obj_sp->packs[$key]['membership_type'] == $type_code) {
                $obj_sp->packs[$key]['membership_type'] = $new_type_code;
                $obj_sp->save();
            }
        }
        // loop
        foreach ($users as $user) {
            // get
            $member = mgm_get_member($user->ID);
            // if users with same membershiptype as that of selected
            if (isset($member->membership_type) && $member->membership_type == $type_code) {
                // set
                $member->membership_type = $new_type_code;
 /**
  * Cancel Recurring Subscription
  * This is not a private function
  * @param int/string $trans_ref	
  * @param int $user_id	
  * @param int/string $subscr_id	
  * @param int $pack_id	
  * @return boolean
  */
 function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
 {
     //if coming form process return after a subscription payment
     if (!empty($trans_ref)) {
         $transdata = $this->_get_transaction_passthrough($trans_ref);
         if ($transdata['payment_type'] != 'subscription_purchase') {
             return false;
         }
         $user_id = $transdata['user_id'];
         if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
             $member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
         } else {
             $member = mgm_get_member($user_id);
         }
         if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
             if (isset($member->payment_info->subscr_id)) {
                 $subscr_id = $member->payment_info->subscr_id;
             } else {
                 //check pack is recurring:
                 $pid = $pack_id ? $pack_id : $member->pack_id;
                 if ($pid) {
                     $s_packs = mgm_get_class('subscription_packs');
                     $sel_pack = $s_packs->get_pack($pid);
                     if ($sel_pack['num_cycles'] != 1) {
                         $subscr_id = 0;
                     }
                     // 0 stands for a lost subscription id
                 }
             }
             //check for same module: if not call the same function of the applicale module.
             if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
                 mgm_log('RECALLing ' . $member->payment_info->module . ': cancel_recurring_subscription FROM: ' . $this->code);
                 return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
             }
             //skip if same pack is updated
             if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
                 return false;
             }
         } else {
             return false;
         }
     }
     $system_obj = mgm_get_class('system');
     $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
     //send email only if setting enabled
     if ((!empty($subscr_id) || $subscr_id === 0) && !$dge) {
         $user = get_userdata($user_id);
         //send notification email to admin:
         $message = __('The User: '******'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm');
         $message .= "<br/>" . __('Please unsubscribe the user from Gateway Merchant panel.', 'mgm');
         if ($subscr_id) {
             $message .= "<br/><br/>" . __('Pay Id: ', 'mgm') . $subscr_id;
         }
         if (isset($member->transaction_id)) {
             $message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id;
         }
         //admin email:
         if (!empty($system_obj->setting['admin_email'])) {
             @mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message);
         }
     }
     return true;
 }
 function _default_setting()
 {
     // ccbill specific
     $this->setting['client_acccnum'] = '';
     $this->setting['client_subacc'] = '';
     $this->setting['formname'] = '';
     $this->setting['upgrade_api'] = 'signup';
     $this->setting['upgrade_enc_key'] = '';
     $this->setting['send_userpass'] = '******';
     $this->setting['dynamic_pricing'] = 'disabled';
     $this->setting['md5_hashsalt'] = '';
     $this->setting['datalink_username'] = '';
     $this->setting['datalink_password'] = '';
     $this->setting['rebill_status_query'] = 'enabled';
     $this->setting['currency'] = mgm_get_class('system')->get_setting('currency');
     // 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();
 }
/**
 * status widget : multiple instance
 * front end instance
 *
 * @param array $args
 * @param array $widget_args
 * @return void
 * @since 1.0
 */
function mgm_sidebar_widget_status($args, $widget_args = 1)
{
    global $wpdb, $user_ID, $current_user, $mgm_sidebar_widget;
    extract($args, EXTR_SKIP);
    if (is_numeric($widget_args)) {
        $widget_args = array('number' => $widget_args);
    }
    $widget_args = wp_parse_args($widget_args, array('number' => -1));
    extract($widget_args, EXTR_SKIP);
    $options = $mgm_sidebar_widget->status_widget;
    if (!isset($options[$number])) {
        return;
    }
    $title = isset($options[$number]['title']) ? $options[$number]['title'] : __('Magic Members', 'mgm');
    $logged_out_intro = isset($options[$number]['logged_out_intro']) ? stripslashes($options[$number]['logged_out_intro']) : $mgm_sidebar_widget->default_text['logged_out_intro'];
    $hide_logged_out = isset($options[$number]['hide_logged_out']) ? stripslashes($options[$number]['hide_logged_out']) : false;
    // packs -issue#: 714
    $packs = mgm_get_class('subscription_packs');
    if ($user_ID) {
        echo $before_widget;
        if (trim($title)) {
            echo $before_title . $title . $after_title;
        }
        //issue#: 539
        $member = mgm_get_member($user_ID);
        // check pack - issue#: 714
        $subs_pack = null;
        if ($member->pack_id) {
            $subs_pack = $packs->get_pack($member->pack_id);
        }
        $uat = $member->membership_type;
        if (!$uat) {
            $uat = 'free';
        }
        $user_status = $member->status;
        if ($user_status != MGM_STATUS_ACTIVE || strtolower($uat) == 'free') {
            $inactive_intro = isset($options[$number]['inactive_intro']) ? $options[$number]['inactive_intro'] : $mgm_sidebar_widget->default_text['inactive_intro'];
            echo $inactive_intro;
            mgm_sidebar_register_links();
        } else {
            if ($expiry = $member->expire_date) {
                //issue#: 692
                $sformat = mgm_get_date_format('date_format_short');
                $expiry = date($sformat, strtotime($expiry));
                //$date = explode('-', $expiry);
                //$expiry = date(get_option('date_format'), mktime(0,0,0,$date[1], $date[2], $date[0]));
            } else {
                $expiry = __('None', 'mgm');
            }
            $active_intro = $mgm_sidebar_widget->default_text['active_intro'];
            if (isset($options[$number]['active_intro'])) {
                $active_intro = $options[$number]['active_intro'];
            }
            $active_intro = str_replace('[membership_type]', mgm_get_class('membership_types')->get_type_name($uat), $active_intro);
            $active_intro = str_replace('[expiry_date]', $expiry, $active_intro);
            // check hidden subscription pack - issue#: 714
            if (isset($subs_pack['hidden']) && $subs_pack['hidden'] != 1 || !isset($subs_pack['hidden'])) {
                echo $active_intro;
            }
            mgm_render_my_purchased_posts($user_ID);
        }
        echo $after_widget;
    } else {
        if (!$hide_logged_out) {
            echo $before_widget;
            if (trim($title)) {
                echo $before_title . $title . $after_title;
            }
            echo $logged_out_intro;
            echo mgm_get_login_register_links();
            echo $after_widget;
        }
    }
}
 function delete()
 {
     extract($_POST);
     // object
     $cf_obj = mgm_get_class('member_custom_fields');
     // label
     $label = $cf_obj->get_field_attr($id, 'label');
     // set sort
     $success = $cf_obj->unset_custom_field($id);
     // success
     if ($success) {
         // update on success
         $cf_obj->save();
         // message
         $message = sprintf(__('Successfully removed custom field: <b>%s</b>', 'mgm'), mgm_stripslashes_deep($label));
         $status = 'success';
     } else {
         // message
         $message = sprintf(__('Error while removing custom field: <b>%s</b>', 'mgm'), mgm_stripslashes_deep($label));
         $status = 'error';
     }
     // return response
     echo json_encode(array('status' => $status, 'message' => $message));
     exit;
 }