/**
 * the meta box for post/page purchase
 *
 */
function mgm_post_setup_meta_box_form($post)
{
    // get object
    $post_obj = mgm_get_post($post->ID);
    $datepickerformat = mgm_get_datepicker_format();
    // set default price
    if ($post_obj->purchase_cost == 0) {
        if (mgm_get_module('mgm_paypal', 'payment')->setting['purchase_price']) {
            $post_obj->purchase_cost = mgm_get_module('mgm_paypal', 'payment')->setting['purchase_price'];
        } else {
            $post_obj->purchase_cost = mgm_get_class('system')->setting['post_purchase_price'];
        }
    }
    // protect
    $protect_content = mgm_protect_content();
    //issue#: 414(changed id submitpost => submitpost_member for the below div )
    ?>

	<div class="submitbox" id="submitpost_member">	
		<div class="misc-pub-section">
			<p id="howto">
				<?php 
    _e('Select which membership types will have access to read this post/page.', 'mgm');
    ?>

				<?php 
    _e('Note: The private parts of the post should be inside the following tags: <strong>[private]</strong> <em>your text</em> <strong>[/private]</strong>', 'mgm');
    ?>

			</p>
			<p>
				<div class="mgm_post_setup_meta_box_div">
					<input type="checkbox" name="check_all" value="mgm_post[access_membership_types][]" /> <span><?php 
    _e('Select all', 'mgm');
    ?>
</span>
				</div>
			</p>
			<p>
				<?php 
    echo mgm_make_checkbox_group('mgm_post[access_membership_types][]', mgm_get_class('membership_types')->get_membership_types(), $post_obj->access_membership_types, MGM_KEY_VALUE);
    ?>
				
			</p>
			<?php 
    if ($protect_content == false) {
        ?>

			<div class="information mgm_width_230px"><?php 
        echo sprintf(__('<a href="%s">Content Protection</a> is <b>%s</b>. Make sure its enabled to Protect Post/Page.', 'mgm'), 'admin.php?page=mgm/admin', $protect_content ? 'enabled' : 'disabled');
        ?>
</div>			
			<?php 
    }
    ?>

		</div>	
		
		<div class="misc-pub-section">
			<b><?php 
    _e('Pay Per Post', 'mgm');
    ?>
:</b>
			<a href="#payperpost" class="mgm-toggle"><?php 
    _e('Edit');
    ?>
</a>
			<div id="payperpostdiv" class="hide-if-js">
				<div class="mgm_padding_5px">				
					<p class="postpurhase-heading"><?php 
    _e('Purchasable Settings', 'mgm');
    ?>
:</p>
					<ul class="mgm_post_setup_meta_box_ul">
						<li>
							<label><?php 
    _e('If the user doesn\'t have access, is this post/page available to buy?', 'mgm');
    ?>
</label><br/>	
							<input type="radio" class="radio" name="mgm_post[purchasable]" value='N' <?php 
    mgm_check_if_match('N', $post_obj->purchasable);
    ?>
/>
							<label><?php 
    _e('No', 'mgm');
    ?>
</label>
							<input type="radio" class="radio" name="mgm_post[purchasable]" value='Y' <?php 
    mgm_check_if_match('Y', $post_obj->purchasable);
    ?>
/> 
							<label><?php 
    _e('Yes', 'mgm');
    ?>
</label>
						</li>
						<li>
							<label><?php 
    _e('Cost of Post?', 'mgm');
    ?>
 </label><br>
							<input type="text" name="mgm_post[purchase_cost]" class="mgm_width_55px" value="<?php 
    echo $post_obj->purchase_cost;
    ?>
"/> <?php 
    echo mgm_get_setting('currency');
    ?>
							
						</li>
						<li>
							<label><?php 
    _e('The date that the ability to buy this page/post expires (Leave blank for indefinate).', 'mgm');
    ?>
</label><br />
							<input type="text" name="mgm_post[purchase_expiry]" class="date_input mgm_width_100px" value="<?php 
    echo intval($post_obj->purchase_expiry) > 0 ? date(MGM_DATE_FORMAT_INPUT, strtotime($post_obj->purchase_expiry)) : '';
    ?>
"/>
							<span class="mgm_font_size_8px">(<?php 
    echo $datepickerformat;
    ?>
)</span>							
						</li>
						<li>
							<label><?php 
    _e('The number of days that the buyer will have access for (0 for indefinate).', 'mgm');
    ?>
</label><br />
							<input type="text" name="mgm_post[access_duration]" class="mgm_width_50px" value="<?php 
    echo $post_obj->get_access_duration();
    ?>
"/>
						</li>
						<li>
							<label><?php 
    _e('The number of times that the buyer will have access for, "PAY PER VIEW" (0 for unlimited views).', 'mgm');
    ?>
</label><br />
							<input type="text" name="mgm_post[access_view_limit]" class="mgm_width_50px" value="<?php 
    echo $post_obj->get_access_view_limit();
    ?>
"/>
						</li>	
					</ul>
					
					<?php 
    if ($addons = mgm_get_all_addon_combo()) {
        ?>

					<p class="postpurhase-heading"><?php 
        _e('Addon Settings', 'mgm');
        ?>
:</p>
					<ul class="mgm_post_setup_meta_box_ul">		
						<li>
							<label><?php 
        _e('Allow Addons?', 'mgm');
        ?>
</label>	<br />
							<select name="mgm_post[addons][]" class="mgm_width_50px">
								<option value="">-</option>
								<?php 
        echo mgm_make_combo_options($addons, $post_obj->get_addons(), MGM_KEY_VALUE);
        ?>

							</select>							
						</li>					
					</ul>	
					<?php 
    }
    ?>


					<p class="postpurhase-heading"><?php 
    _e('Payment Settings', 'mgm');
    ?>
:</p>	
					<p class="fontweightbold"><?php 
    _e('Allow Modules', 'mgm');
    ?>
:</p>
					<?php 
    if ($payment_modules = mgm_get_class('system')->get_active_modules('payment')) {
        $modue_i = 0;
        foreach ($payment_modules as $payment_module) {
            if (!in_array($payment_module, array('mgm_trial'))) {
                ?>

					<input type="checkbox" name="mgm_post[allowed_modules][<?php 
                echo $modue_i;
                ?>
]" value="<?php 
                echo $payment_module;
                ?>
" <?php 
                echo in_array($payment_module, $post_obj->get_allowed_modules()) ? 'checked' : '';
                ?>
/> 
					<label><?php 
                echo mgm_get_module($payment_module)->name;
                ?>
</label><br/>
					<?php 
                $modue_i++;
            }
        }
    } else {
        ?>
				
					<b class="mgm_color_red"><?php 
        _e('No payment module is active.', 'mgm');
        ?>
</b>		
					<?php 
    }
    ?>

					<?php 
    // init
    $payment_settings = '';
    // product id mapping
    if ($payment_modules) {
        foreach ($payment_modules as $payment_module) {
            if ($module = mgm_is_valid_module($payment_module, 'payment', 'object')) {
                if ($module->has_product_map()) {
                    $payment_settings .= $module->settings_post_purchase($post_obj);
                }
            }
        }
    }
    // print
    if (!empty($payment_settings)) {
        echo $payment_settings;
    }
    ?>

					
					<?php 
    do_action('mgm_widget_payperpost_options', $post->ID);
    ?>
												
				</div>	
			</div>
		</div>			
		<div class="misc-pub-section misc-pub-section-last">
			<b><?php 
    _e('Post Delay (sequential posts)', 'mgm');
    ?>
:</b>
			<a href="#postdelay" class="mgm-toggle"><?php 
    _e('Edit');
    ?>
</a>
			<div id="postdelaydiv" class="hide-if-js">
				<div class="mgm_padding_5px">				
					<p id="howto"><?php 
    _e('How long should the user have been a member to see this content?', 'mgm');
    ?>
</p>
					<div class="div_table mgm_width_100pr">
					<?php 
    foreach (mgm_get_class('membership_types')->membership_types as $type_code => $type_name) {
        $val = isset($post_obj->access_delay[$type_code]) ? (int) $post_obj->access_delay[$type_code] : 0;
        ?>

						<div class="row">
							<div class="cell mgm_width_100px mgm_font_size_11px"><?php 
        echo $type_name;
        ?>
</div>
							<div class="cell mgm_font_size_11px">
								<input type="text" name="mgm_post[access_delay][<?php 
        echo $type_code;
        ?>
]" value="<?php 
        echo $val;
        ?>
" class="mgm_width_50px"/> Day(s)
							</div>
						</div>
					<?php 
    }
    ?>

					</div>		
				</div>	
			</div>
		</div>				
	</div>	
	
	<script language="javascript">
		jQuery(document).ready(function(){			
			jQuery('.mgm-toggle').bind('click', function(){
				if(jQuery(this).html() == '<?php 
    _e('Edit', 'mgm');
    ?>
'){
					jQuery(jQuery(this).attr('href')+'div').slideDown();
					jQuery(this).html('<?php 
    _e('Close', 'mgm');
    ?>
')
				}else{
					jQuery(jQuery(this).attr('href')+'div').slideUp();
					jQuery(this).html('<?php 
    _e('Edit', 'mgm');
    ?>
')
				}
			});
			// check bind
			jQuery("#submitpost_member :checkbox[name='check_all']").bind('click',function(){
				// check
				jQuery("#submitpost_member :checkbox[name='"+jQuery(this).val()+"']").attr('checked', (jQuery(this).attr('checked')=='checked') );
				// label
				if(jQuery(this).attr('checked')){
					jQuery(this).next().html('<?php 
    _e('Deselect all', 'mgm');
    ?>
');
				}else{
					jQuery(this).next().html('<?php 
    _e('Select all', 'mgm');
    ?>
');
				}
			});	

			// bind module allow
			jQuery(":checkbox[name^='mgm_post[allowed_modules]']").bind('click',function() {		
				var _m = jQuery(this).val().replace('mgm_', '');
				
				if(jQuery(this).attr('checked')){				
					jQuery('#settings_postpurchase_package_' + _m).slideDown('slow');
				}else{				
					jQuery('#settings_postpurchase_package_' + _m).slideUp('slow');
				}
			});
			// date		
			try{	
				mgm_date_picker('.date_input', false, {yearRange:"<?php 
    echo mgm_get_calendar_year_range();
    ?>
", dateFormat: "<?php 
    echo $datepickerformat;
    ?>
"});
			}catch(ex){}	
		});
	</script>
	<?php 
}
/**
 * get transaction page html
 *
 * @param bool $return
 * @return string
 * @since 1.5
 */
function mgm_get_transaction_page_html($return = false, $method = NULL)
{
    // get method
    if (!$method) {
        $method = mgm_request_var('method', '', true);
    }
    // switch $method
    switch ($method) {
        case 'payment_return':
            // after payment return with get/post values and process
        // after payment return with get/post values and process
        case 'payment_notify':
            // silent post back, IPN, just after first payment
        // silent post back, IPN, just after first payment
        case 'payment_status_notify':
            // INS, post back, at each payment cycle,i.e, 2CO INS, PayPal IPN
        // INS, post back, at each payment cycle,i.e, 2CO INS, PayPal IPN
        case 'payment_cancel':
            // cancelled
        // cancelled
        case 'payment_unsubscribe':
            // unsubscribe tracking
        // unsubscribe tracking
        case 'payment_html_redirect':
            // proxy for html redirect
        // proxy for html redirect
        case 'payment_credit_card':
            // proxy for credit_card processing
            // get module
            $module = mgm_request_var('module', '', true);
            // validate module
            if ($module_obj = mgm_is_valid_module($module, 'payment', 'object')) {
                // process, invoke process_return,process_notify,process_cancel,process_unsubscribe
                $output = $module_obj->invoke(str_replace(array('payment_'), 'process_', $method));
                // html redirect
                if ($method == 'payment_html_redirect') {
                    // set in globals
                    $GLOBALS['mgm_html_outout'] = $output;
                    // if template exists
                    if ($return) {
                        $template_file = MGM_CORE_DIR . 'html/payment_processing_return.php';
                    } else {
                        if (file_exists(TEMPLATEPATH . '/payment_processing.php')) {
                            $template_file = TEMPLATEPATH . '/payment_processing.php';
                        } else {
                            $template_file = MGM_CORE_DIR . 'html/payment_processing.php';
                        }
                    }
                    // apply template filter
                    $template_file = apply_filters('mgm_page_template', $template_file, $method);
                    // return template
                    if ($return) {
                        return mgm_get_include($template_file);
                    }
                    // @todo check payment
                    // include template
                    @(include $template_file);
                }
            } else {
                // not a valiud module, call default for unsubscribe
                if ($method == 'payment_unsubscribe') {
                    // default unsubscribe
                    return mgm_member_unsubscribe();
                } else {
                    // error
                    return __('Invalid module supplied', 'mgm');
                }
            }
            break;
        case 'payment_processed':
            // processed
            // get module
            $module = mgm_request_var('module', '', true);
            // validate module
            if ($module_obj = mgm_is_valid_module($module, 'payment', 'object')) {
                // redirect logic moved, in all cases same page is loaded
                // if template exists
                if ($return) {
                    $template_file = MGM_CORE_DIR . 'html/payment_processed_return.php';
                } else {
                    if (file_exists(TEMPLATEPATH . '/payment_processed.php')) {
                        $template_file = TEMPLATEPATH . '/payment_processed.php';
                    } else {
                        $template_file = MGM_CORE_DIR . 'html/payment_processed.php';
                    }
                }
                // apply template filter
                $template_file = apply_filters('mgm_page_template', $template_file, $method);
                // return template
                if ($return) {
                    return mgm_get_include($template_file);
                }
                // include template
                @(include $template_file);
            } else {
                return __('Invalid module supplied', 'mgm');
            }
            break;
        case 'payment_purchase':
            // post purchase
            // if template exists
            if ($return) {
                $template_file = MGM_CORE_DIR . 'html/payment_post_purchase_return.php';
            } else {
                if (file_exists(TEMPLATEPATH . '/payment_post_purchase.php')) {
                    $template_file = TEMPLATEPATH . '/payment_post_purchase.php';
                } else {
                    $template_file = MGM_CORE_DIR . 'html/payment_post_purchase.php';
                }
            }
            // apply template filter
            $template_file = apply_filters('mgm_page_template', $template_file, $method);
            // return template
            if ($return) {
                return mgm_get_include($template_file);
            }
            // include template
            @(include $template_file);
            break;
        case 'guest_purchase':
            // form
            // if template exists
            if ($return) {
                $template_file = MGM_CORE_DIR . 'html/guest_purchase_return.php';
            } else {
                if (file_exists(TEMPLATEPATH . '/guest_purchase.php')) {
                    $template_file = TEMPLATEPATH . '/guest_purchase.php';
                } else {
                    $template_file = MGM_CORE_DIR . 'html/guest_purchase.php';
                }
            }
            // apply template filter
            $template_file = apply_filters('mgm_page_template', $template_file, $method);
            // return template
            if ($return) {
                return mgm_get_include($template_file);
            }
            // include template
            @(include $template_file);
            break;
        case 'register':
            // if template exists
            $template = mgm_get_page_template($method, $return);
            // return template
            if ($return) {
                return mgm_get_include($template);
            }
            // include template
            @(include $template);
            break;
        case 'profile':
            //user profile page
            // if template exists
            $template = mgm_get_page_template($method, $return);
            // return template
            if ($return) {
                return mgm_get_include($template);
            }
            // include template
            @(include $template);
            break;
        case 'lost_password':
            // if template exists
            $template = mgm_get_page_template($method, $return);
            // return template
            if ($return) {
                return mgm_get_include($template);
            }
            // include template
            @(include $template);
            break;
        case 'user_login':
        case 'login':
            // if template exists
            $template = mgm_get_page_template('login', $return);
            // return template
            if ($return) {
                return mgm_get_include($template);
            }
            // include template
            @(include $template);
            break;
        case 'payment_subscribe':
            // form
        // form
        case 'payment':
            // form
        // form
        default:
            // if template exists
            if ($return) {
                $template_file = MGM_CORE_DIR . 'html/payment_subscribe_return.php';
            } elseif (file_exists(TEMPLATEPATH . '/payment_subscribe.php')) {
                $template_file = TEMPLATEPATH . '/payment_subscribe.php';
            } else {
                $template_file = MGM_CORE_DIR . 'html/payment_subscribe.php';
            }
            // apply template filter
            $template_file = apply_filters('mgm_page_template', $template_file, $method);
            // return template
            if ($return) {
                return mgm_get_include($template_file);
            }
            // include template
            @(include $template_file);
            break;
    }
}
示例#3
0
<!--payments-->
<div id="wrap-admin-payments" class="content-div">
	<ul class="tabs">		
		<li><a href="admin-ajax.php?action=mgm_admin_ajax_action&page=mgm/admin/payments&method=payment_modules"><span class="pngfix"><?php 
_e('Payment Modules', 'mgm');
?>
</span></a></li>			
		<?php 
foreach ($data['payment_modules'] as $payment_module) {
    if ($module = mgm_is_valid_module($payment_module, 'payment', 'object')) {
        if ($module->is_enabled()) {
            ?>
	
		<li><a href="admin-ajax.php?action=mgm_admin_ajax_action&page=mgm/admin/payments&method=module_settings&module=<?php 
            echo $module->code;
            ?>
"><span class="pngfix"><?php 
            echo sprintf(__('%s', 'mgm'), $module->name);
            ?>
</span></a></li>
		<?php 
        }
    }
}
?>
					
	</ul>										
</div>
示例#4
0
                    // expire
                    $expire_date_oth = sprintf('<div><b>%s:</b> %s</div>', __('EXPIRY', 'mgm'), empty($member_oth->expire_date) ? __('N/A', 'mgm') : date($date_format_time, strtotime($member_oth->expire_date)));
                    // build status value
                    $subs_status_oth = sprintf('<span class="%s"><b>%s</b></span>', mgm_get_status_css_class($member_oth->status), esc_html($member_oth->status));
                    // status_str
                    if (!empty($member_oth->status_str)) {
                        $subs_status_oth .= '<br />' . esc_html($member_oth->status_str);
                    }
                    // last pay
                    $subs_status_oth .= sprintf('<div class="overline"><span class="mgm_color_gray">%s:</span> %s</div>', __('LAST PAY', 'mgm'), empty($member_oth->last_pay_date) ? __('N/A', 'mgm') : date($date_format, strtotime($member_oth->last_pay_date)));
                    // last transaction
                    if (isset($member_oth->transaction_id) && (int) $member_oth->transaction_id > 0) {
                        $subs_status_oth .= sprintf('<div class="overline"><span class="mgm_color_gray">%s#</span> %d</div>', __('TRANSACTION', 'mgm'), (int) $member_oth->transaction_id);
                    }
                    // module transaction info
                    if (isset($member_oth->payment_info->module) && ($module_object = mgm_is_valid_module($member_oth->payment_info->module, 'payment', 'object'))) {
                        $subs_status_oth .= $module_object->get_transaction_info($member_oth, $date_format);
                    }
                    ?>

						<li>
							<table width="100%" cellpadding="1" cellspacing="0" border="0" class="nested-table">
								<tr class="<?php 
                    echo $alt;
                    ?>
">								
									<td width="10%">
										<!-- <input onclick="mgm_uncheck_other_memberships(this,'<?php 
                    //echo $user->ID;
                    ?>
');" type="checkbox" name="ps_mem[<?php 
/**
 *  Admin user edit screen unsubscribe staus button	 
 */
function mgm_get_admin_user_unsubscribe_status_button($member, $user)
{
    // init
    $html = '';
    // object
    $packs_obj = mgm_get_class('subscription_packs');
    $pack_name = $packs_obj->get($member->pack_id);
    // cancelled
    if ($member->status == MGM_STATUS_CANCELLED) {
        $html .= '<span class="s-active"><b>' . $pack_name['description'] . '</b></span>';
        $html .= '<div class="mgm_margin_bottom_10px s-expired">' . '<h4>' . __('Unsubscribed', 'mgm') . '</h4>' . '<div class="mgm_margin_bottom_10px mgm_color_red">' . __('You have unsubscribed.', 'mgm') . '</div>' . '</div>';
        $html .= '<hr/>';
    } elseif (isset($member->status_reset_on) && isset($member->status_reset_as) && $member->status == MGM_STATUS_AWAITING_CANCEL) {
        $lformat = mgm_get_date_format('date_format_long');
        $html .= '<span class="s-active"><b>' . $pack_name['description'] . '</b></span>';
        $html .= '<div class="mgm_margin_bottom_10px s-expired">' . '<h4>' . __('Unsubscribed', 'mgm') . '</h4>' . '<div class="mgm_margin_bottom_10px mgm_color_red">' . sprintf(__('You have unsubscribed. Your account has been marked for cancellation on <b>%s</b>.', 'mgm'), date($lformat, strtotime($member->status_reset_on))) . '</div>' . '</div>';
        $html .= '<hr/>';
    } else {
        // show unsucscribe button
        if (is_super_admin()) {
            // check
            if ($module = $member->payment_info->module) {
                // if a valid module
                if ($obj_module = mgm_is_valid_module($module, 'payment', 'object')) {
                    // output button
                    $html .= '<span class="s-active"><b>' . $pack_name['description'] . '</b></span>';
                    $html .= $obj_module->get_button_unsubscribe(array('user_id' => $user->ID, 'membership_type' => $member->membership_type));
                    $html .= '<script language="javascript">' . 'confirm_unsubscribe=function(element){' . 'if(confirm("' . __('You are about to unsubscribe. Do you want to proceed?', 'mgm') . '")){' . 'jQuery(element).closest("form").submit();' . '}' . '}' . '</script>';
                    $html .= '<hr/>';
                }
            }
        }
    }
    return $html;
}
/** 
 * rebill notify on rebill status change
 * 
 * @param array $options saved in usermeta
 * @param int user_id
 * @return void	
 * @since 2.7
 */
function mgm_notify_on_rebill_status_change($user_id, $new_status, $old_status, $context)
{
    // system
    $system_obj = mgm_get_class('system');
    $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
    $dpne = bool_from_yn($system_obj->get_setting('disable_payment_notify_emails'));
    // get member
    $member = mgm_get_member($user_id);
    // log
    // mgm_log($member, __FUNCTION__);
    // notify
    $notify = false;
    // @todo check by last_pay_date
    // check
    if (!($last_email_notify_date = get_user_option('_mgm_last_email_notify_date', $user_id))) {
        // check
        $notify = true;
        // log
        // mgm_log('Block1: ' . $last_email_notify_date . ' - ' . $member->last_pay_date . ' ' . $notify, __FUNCTION__);
    } else {
        // check
        if (!empty($member->last_pay_date) && $last_email_notify_date != $member->last_pay_date) {
            $notify = true;
        }
        // log
        // mgm_log('Block2: ' . $last_email_notify_date . ' - ' . $member->last_pay_date . ' ' . $notify, __FUNCTION__);
    }
    // notify user
    if ($notify) {
        // packs
        $s_packs = mgm_get_class('subscription_packs');
        // get user
        $user = get_userdata($user_id);
        // blog
        $blogname = get_option('blogname');
        // notify user
        if (!$dpne) {
            // get pack
            if ($member->pack_id) {
                $subs_pack = $s_packs->get_pack($member->pack_id);
            } else {
                $subs_pack = $s_packs->validate_pack($member->amount, $member->duration, $member->duration_type, $member->membership_type);
            }
            // custom
            $custom = mgm_get_transaction($member->transaction_id);
            // notify
            if (mgm_notify_user_membership_purchase($blogname, $user, $member, $custom, $subs_pack, $s_packs, $system_obj)) {
                // tracking
                update_user_option($user_id, '_mgm_last_email_notify_date', $member->last_pay_date, true);
                // log
                // mgm_log('mgm_last_email_notify_date updated: ' . $member->last_pay_date, __FUNCTION__);
                // update as email sent
                /*				
                				if( $module = mgm_is_valid_module($member->payment_info->module) ){
                					$module->update_paymentemail_sent( $member->transaction_id );	
                				}*/
                // check
                if ($module = $member->payment_info->module) {
                    // if a valid module
                    if ($obj_module = mgm_is_valid_module($module, 'payment', 'object')) {
                        $obj_module->update_paymentemail_sent($member->transaction_id);
                    }
                }
            }
        }
        // notify admin
        if (!$dge) {
            // pack duration
            $pack_duration = $s_packs->get_pack_duration($subs_pack);
            // notify admin,
            mgm_notify_admin_membership_purchase($blogname, $user, $member, $pack_duration);
        }
    }
}
 function subscription_packages_list()
 {
     // data
     $data = array();
     // roles
     $wproles = new WP_Roles();
     $roles = array_reverse($wproles->role_names);
     $system_obj = mgm_get_class('system');
     $payment_modules = $system_obj->get_active_modules('payment');
     $currency = $system_obj->get_setting('currency');
     // check if any module supports trial setup i.e. paypal authorizenet
     $supports_trial = false;
     // log
     // mgm_log($payment_modules, __FUNCTION__);
     // loop
     foreach ($payment_modules as $payment_module) {
         // check
         if ($module_obj = mgm_is_valid_module($payment_module, 'payment', 'object')) {
             // check
             if ($module_obj->is_trial_supported()) {
                 // set
                 $supports_trial = true;
                 break;
             }
         }
     }
     // membership_types
     $obj_mt = mgm_get_class('membership_types');
     $obj_sp = mgm_get_class('subscription_packs');
     // membership_types
     $membership_types = $obj_mt->get_membership_types();
     // subscription_packs
     $subscription_packs = $obj_sp->get_packs();
     //remove
     $arr_packdta = $free_packs = array();
     // packages
     foreach ($membership_types as $type_code => $type) {
         // package
         $membership_package = '';
         // pack data
         $pack_data = array();
         // roles
         $pack_data['roles'] = $roles;
         // supports_trial
         $pack_data['supports_trial'] = $supports_trial;
         // payment_modules
         $pack_data['payment_modules'] = $payment_modules;
         // loop
         foreach ($subscription_packs as $i => $pack) {
             // show when match type
             if ($pack['membership_type'] != $type_code) {
                 continue;
             }
             // get free packs
             if ($pack['membership_type'] == 'free') {
                 $free_packs[$pack['id']] = true;
             }
             // remove
             $arr_packdta[] = $pack['membership_type'] . "[" . $pack['id'] . "]" . $pack['description'];
             // set
             $pack_data['pack_ctr'] = $i + 1;
             // default values
             $pack['num_cycles'] = isset($pack['num_cycles']) ? $pack['num_cycles'] : 1;
             $pack['role'] = isset($pack['role']) ? $pack['role'] : 'subscriber';
             $pack['default'] = (int) (isset($pack['default']) ? $pack['default'] : 0);
             // currency
             if (!isset($pack['currency'])) {
                 $pack['currency'] = $currency;
             }
             // set pack
             $pack_data['pack'] = $pack;
             // objects
             $pack_data['obj_sp'] = $obj_sp;
             // packs
             $pack_data['packages'] = mgm_get_subscription_packages($obj_sp, NULL, array($pack['id']));
             // get html
             $membership_package .= $this->load->template('members/subscription/package', array('data' => $pack_data), true);
         }
         // get html
         $data['membership'][$type_code] = $membership_package;
     }
     // membership types
     $data['membership_types'] = $membership_types;
     // active modules
     $data['payment_modules'] = $payment_modules;
     //check free module is enabled
     $data['free_module_enabled'] = in_array('mgm_free', $payment_modules) && mgm_get_module('mgm_free')->is_enabled() ? 1 : 0;
     $data['enable_multiple_level_purchase'] = $system_obj->setting['enable_multiple_level_purchase'];
     $data['free_packs'] = $free_packs;
     // load template view
     $this->load->template('members/subscription/packages_list', array('data' => $data));
 }
示例#8
0
<?php

/** 
 * Patch for updating ccbill last payment date & expiration date from gateway (issue #1520)
 */
$arr_users = mgm_get_all_userids();
if (!empty($arr_users)) {
    foreach ($arr_users as $user_id) {
        //member
        $member = mgm_get_member($user_id);
        if (!isset($member->last_payment_check) || isset($member->last_payment_check) && $member->last_payment_check != 'disabled') {
            // check
            if (!empty($member->payment_info->module) && ($module_obj = mgm_is_valid_module($member->payment_info->module, 'payment', 'object')) && trim($member->payment_info->module) == 'mgm_ccbill') {
                // check is supported
                if ($module_obj->is_rebill_status_check_supported()) {
                    //call
                    if ($module_obj->query_rebill_status($user_id, $member)) {
                        // return
                        $return = true;
                    }
                }
            }
        }
    }
}
// end file