/**
 * 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 
}
Пример #2
0
/> <?php 
    _e('Enable confirm e-mail field', 'mgm');
    ?>
</li>
					<?php 
}
?>
		

					<?php 
if (in_array($data['custom_field']['name'], array('birthdate'))) {
    ?>

					<li>
						<input type="checkbox" class="checkbox" name="verify_age" value="1" <?php 
    mgm_check_if_match(1, $data['custom_field']['attributes']['verify_age']);
    ?>
/> <?php 
    _e('Verify age', 'mgm');
    ?>

						<span class="<?php 
    echo $data['custom_field']['attributes']['verify_age'] == 1 ? 'displayinline' : 'displaynone';
    ?>
" id="verify_age_wrap">
							<u><?php 
    _e('More than', 'mgm');
    ?>
</u>:
							<input type="text" size="5" maxlength="10" value="<?php 
    echo stripslashes($data['custom_field']['attributes']['verify_age_unit']);