/** * get subscription options html */ function _get_field_subscription_options_html($subs_enc, $opt_id, $selected, $checked, $pack, $dispaly_as_selectbox, $pack_desc, &$options, &$html) { //issue #1234 if ($dispaly_as_selectbox) { $options .= '<option value="' . $subs_enc . '" id="' . $opt_id . '" ' . $selected . '>' . $pack_desc . '</option>'; } else { // html //NOTE: Do not change the mgm_subs_wrapper class. It is being used in payment_gateways Custom field $input = sprintf('<input type="radio" %s class="mgm_subs_radio" name="mgm_subscription" id="mgm_subscription_%d" value="%s" rel="mgm_subscription_options"/>', $checked, $pack['id'], $subs_enc); //Refer to : function field_payment_gateways_callback() $html .= '<div class="mgm_subs_wrapper ' . $pack['membership_type'] . ' "> <div class="mgm_subs_option ' . $pack['membership_type'] . '"> ' . $input . ' </div> <div class="mgm_subs_pack_desc ' . $pack['membership_type'] . '"> ' . $pack_desc . ' </div> <div class="clearfix ' . $pack['membership_type'] . '"></div> <div class="mgm_subs_desc ' . $pack['membership_type'] . '"> ' . mgm_stripslashes_deep($pack['description']) . ' </div> </div>'; } }
</div> <div class="row"> <div class="cell"> <p><b><?php _e('Description', 'mgm'); ?> :</b></p> </div> </div> <div class="row"> <div class="cell"> <textarea name="description" id="setting_description_<?php echo $data['module']->code; ?> " rows='4' cols='75' class="width750px height100px"><?php echo mgm_stripslashes_deep(esc_html($data['module']->description)); ?> </textarea> <div class="clearfix"></div> <p><div class="tips"><?php _e('Description shown on payment page.', 'mgm'); ?> </div></p> </div> </div> <div class="row"> <div class="cell"> <p><b><?php _e('Test/Live Switch', 'mgm'); ?> :</b></p>
function _get_button_code($pack, $tran_id = NULL) { // get data $data = $this->_get_button_data($pack, $tran_id); // log // mgm_log($data, $this->module . '_' .__FUNCTION__); // strip $data = mgm_stripslashes_deep($data); // init $return = ''; // create return foreach ($data as $key => $value) { $return .= '<input type="hidden" name="' . $key . '" value="' . esc_html($value) . '" />' . "\n"; } // return return $return; }
?> </div></p> </div> </div> <div class="row"> <div class="cell"> <p><b><?php _e('Worldpay Gateway Transaction Failed Page Contents', 'mgm'); ?> :</b></p> </div> </div> <div class="row"> <div class="cell"> <textarea name="gateway_failedpage" id="setting_gateway_errorpage" rows='4' cols='75' class="width750px height100px"><?php echo mgm_stripslashes_deep(esc_html($data['module']->setting['gateway_failedpage'])); ?> </textarea> <div class="clearfix"></div> <p><div class="tips"><?php _e('Contents to be displayed on Wordlpay Gateway failed page.<br/>The default thankyou page on Merchant gateway needs to be replaced by this html.<br/>Copy and paste the html into <strong>resultC.html</strong> on Merchant Gateway', 'mgm'); ?> </div></p> </div> </div> <div class="row"> <div class="cell"> <p><b><?php _e('Test/Live Switch', 'mgm'); ?>
} $temp = array(); foreach ($subscription_packs as $i => $pack) { if ($pack['membership_type'] != $type_code) { continue; } $temp[] = $pack; } $cost = $temp[0]['cost']; if (trim($cost) > 0) { if (isset($data[0]['member_type'])) { if ($data[0]['member_type'] == $type_code) { $strTypes .= '<option value="' . $type_code . '" SELECTED>' . __(mgm_stripslashes_deep($type_name), 'mgm') . '</option>'; } } $strTypes .= '<option value="' . $type_code . '">' . __(mgm_stripslashes_deep($type_name), 'mgm') . '</option>'; } } echo $strTypes; ?> </select> <input type="button" name="reload" class="button" value="<?php _e('Generate Report', 'mgm'); ?> " onclick="search_earnings()" /> </div>
/** * Button code wrapper * * @param unknown_type $pack * @param unknown_type $tran_id * @return unknown */ function _get_button_code($pack, $tran_id = NULL) { // get data $data = $this->_get_button_data($pack, $tran_id); // strip $data = mgm_stripslashes_deep($data); // log mgm_log($data, __FUNCTION__); // return return mgm_http_build_query($data); }
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; }
/** * find members with selected custom filed critera * @param string $field * @return mixed array|int */ function mgm_get_members_with_customfiled($field, $value) { global $wpdb; $start = 0; $limit = 1000; //user meta fields $fields = array('user_id', 'meta_value'); // sql $sql = "SELECT count(*) FROM `{$wpdb->usermeta}` WHERE `meta_key` = 'mgm_member_options' AND `user_id` <> 1"; $count = $wpdb->get_var($sql); // init $members = array(); //count if ($count) { //for for ($i = $start; $i < $count; $i = $i + $limit) { //users $users = mgm_patch_partial_user_member_options($i, $limit, $fields); // check if ($users) { // loop foreach ($users as $user) { // vlid $valid = false; //name $name = ''; $user_id = $user->user_id; $member = unserialize($user->meta_value); // convert $member = mgm_convert_array_to_memberobj($member, $user_id); // check if (!empty($value) && isset($member->status) && $member->status == 'Active') { // from custom field if (isset($member->custom_fields->{$field}) && !empty($member->custom_fields->{$field})) { $name = $member->custom_fields->{$field}; } // clean $value = mgm_stripslashes_deep($value); // if there is a match if (!empty($name) && strpos(strtolower($name), strtolower($value)) !== false) { $valid = true; } else { $valid = false; } } // store if ($valid) { $members[] = $user_id; } // unset object unset($member); unset($user); } } } } // return return $members; }
?> " class="width25;"> <?php $arr_options = $data['roles']; if ($data['role_type'] == 'others') { $arr_options = array_merge($data['default_roles'], $arr_options); } foreach ($arr_options as $rn => $arr_role) { if (!in_array($arr_role['role'], array($role['role'], $data['admin_role']))) { ?> <option value="<?php echo mgm_stripslashes_deep($arr_role['role']); ?> "> <?php echo mgm_stripslashes_deep($arr_role['name']); ?> </option> <?php } } ?> </select> <input class="button" type="button" id="move_users" onclick="move_users_<?php echo $data['role_type']; ?> ('<?php echo $role['role']; ?>
/** * create purchase another button * * @param array userdata * @retun string html output */ function mgm_get_purchase_another_subscription_button($args = array()) { global $wpdb; //ceck settings $settings = mgm_get_class('system')->get_setting(); // check if (!isset($settings['enable_multiple_level_purchase']) || isset($settings['enable_multiple_level_purchase']) && !bool_from_yn($settings['enable_multiple_level_purchase'])) { return; } // current user $user = wp_get_current_user(); // validate if (!$user->ID) { // query string $user = mgm_get_user_from_querystring(); } // validate if (!$user->ID) { return __('No such user', 'mgm'); } // userdata $username = $user->user_login; $mgm_home = get_option('siteurl'); $member = mgm_get_member($user->ID); $system_obj = mgm_get_class('system'); $membership_type = mgm_get_user_membership_type($user->ID, 'code'); $packs_obj = mgm_get_class('subscription_packs'); $packs = $packs_obj->get_packs('upgrade'); $duration_str = $packs_obj->duration_str; $trial_taken = $member->trial_taken; // pack_ids $pack_ids = mgm_get_members_packids($member); $pack_membership_types = mgm_get_subscribed_membershiptypes($user->ID, $member); // query_arg $form_action = mgm_get_custom_url('transactions', false, array('action' => 'purchase_another', 'username' => $username)); //issue 1009 if (isset($settings['membership_details_url'])) { $membership_details_url = $settings['membership_details_url']; } else { $membership_details_url = get_admin_url() . 'profile.php?page=mgm/profile'; } // cancel $cancel_url = $membership_details_url; // $cancel_url = mgm_get_custom_url('membership_details'); // active modules $a_payment_modules = $system_obj->get_active_modules('payment'); // selected_subscription $selected_subs = mgm_get_selected_subscription($args); // second step, after post if (isset($_POST['submit'])) { // verify selected if (!isset($_POST['subs_opt'])) { // die return sprintf(__('Package not selected, <a href="%s">go back</a>.', 'mgm'), $_POST['form_action']); exit; } // get subs data $subs_opt_pack = mgm_decode_package($_POST['subs_opt']); extract($subs_opt_pack); // check $valid = false; // loop packs foreach ($packs as $pack) { // check //check pack id as well: issue#: 580 if ($pack['cost'] == $cost && $pack['duration'] == $duration && $pack['duration_type'] == $duration_type && $membership_type == $pack['membership_type'] && $pack_id == $pack['id']) { $valid = true; break; } } // error if (!$valid) { return __('Invalid data passed', 'mgm'); exit; } // get object $member = new mgm_member($user->ID); $temp_membership = $member->_default_fields(); $temp_membership['membership_type'] = $membership_type; $temp_membership['pack_id'] = $pack_id; //issue #860 //if (isset($_POST['mgm_upgrade_field']['autoresponder']) && ($_POST['mgm_upgrade_field']['autoresponder'])=='Y') { if (isset($_POST['mgm_upgrade_field']['autoresponder']) && substr($_POST['mgm_upgrade_field']['autoresponder'], 0, 1) == 'Y') { $temp_membership['subscribed'] = 'Y'; $temp_membership['autoresponder'] = $system_obj->active_modules['autoresponder']; } //issue #1236 if (isset($_POST['mgm_upgrade_field']['coupon']) && !empty($_POST['mgm_upgrade_field']['coupon'])) { //issue #1250 - Coupon validation if (!empty($_POST['form_action'])) { // check if its a valid coupon if (!($coupon = mgm_get_coupon_data($_POST['mgm_upgrade_field']['coupon']))) { //redirect back to the form $q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'error_field_value' => $_POST['mgm_upgrade_field']['coupon']); $redirect = add_query_arg($q_arg, $_POST['form_action']); // redirect mgm_redirect($redirect); exit; } else { // membership type check // get subs if ($subs_pack = mgm_decode_package(mgm_post_var('subs_opt'))) { // values $coupon_values = mgm_get_coupon_values(NULL, $coupon['value'], true); // check if (isset($coupon_values['new_membership_type']) && $coupon_values['new_membership_type'] != $subs_pack['membership_type']) { $new_membership_type = mgm_get_membership_type_name($coupon_values['new_membership_type']); $q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'membership_type' => $coupon_values['new_membership_type'], 'error_field_value' => $_POST['mgm_upgrade_field']['coupon']); $redirect = add_query_arg($q_arg, $_POST['form_action']); // redirect mgm_redirect($redirect); exit; } } } } } //inserted an incomplete entry for the selected subscription type mgm_save_another_membership_fields($temp_membership, $user->ID); // save coupon fields and update member object $member = mgm_save_partial_fields_purchase_more($user->ID, $membership_type, $cost); // coupon $purchase_another_coupon = false; // array if (isset($member->upgrade)) { if (is_array($member->upgrade) && isset($member->upgrade['coupon']['id'])) { $purchase_another_coupon = $member->upgrade['coupon']; } elseif (is_object($member->upgrade) && isset($member->upgrade->coupon->id)) { $purchase_another_coupon = mgm_object2array($member->upgrade->coupon); } // coupon mgm_get_purchase_another_coupon_pack($purchase_another_coupon, $pack); } //save custom fields -issue #1285 if (isset($_POST['mgm_upgrade_field']) && !empty($_POST['mgm_upgrade_field'])) { //member $cf_member = mgm_get_member($user->ID); //upgrade custom fileds $cfu_fileds = mgm_get_class('member_custom_fields')->get_fields_where(array('display' => array('on_multiple_membership_level_purchase' => true))); //loop fields foreach ($cfu_fileds as $cf_filed) { //skip coupon and autoresponder if (in_array($cf_filed['name'], array('coupon', 'autoresponder'))) { continue; } //check if (isset($_POST['mgm_upgrade_field'][$cf_filed['name']])) { // check upgrae and required if ((bool) $cf_filed['attributes']['required'] === true) { if (empty($_POST['mgm_upgrade_field'][$cf_filed['name']])) { //redirect back to the form $q_arg = array('error_field' => $cf_filed['label'], 'error_type' => 'empty', 'error_field_value' => $_POST['mgm_upgrade_field'][$cf_filed['name']]); $redirect = add_query_arg($q_arg, $_POST['form_action']); mgm_redirect($redirect); exit; } } //appending custom fields if (isset($cf_member->custom_fields->{$cf_filed}['name'])) { $cf_member->custom_fields->{$cf_filed}['name'] = $_POST['mgm_upgrade_field'][$cf_filed['name']]; } else { $cf_member->custom_fields->{$cf_filed}['name'] = $_POST['mgm_upgrade_field'][$cf_filed['name']]; } } } $cf_member->save(); } // start html $html = '<div>'; // free if (($pack['cost'] == 0 || $membership_type == 'free') && in_array('mgm_free', $a_payment_modules) && mgm_get_module('mgm_free')->is_enabled()) { $html .= sprintf('<div>%s - %s</div>', __('Create a free account ', 'mgm'), ucwords($membership_type)); $module = 'mgm_free'; // payments url $payments_url = mgm_get_custom_url('transactions'); // if tril module selected and cost is 0 and free moduleis not active if ($membership_type == 'trial') { if (in_array('mgm_trial', $a_payment_modules)) { $module = 'mgm_trial'; } } //Purchase Another Membership Level problem : issue #: 752 $redirect = add_query_arg(array('method' => 'payment_return', 'module' => $module, 'custom' => $user->ID . '_' . $duration . '_' . $duration_type . '_' . $pack_id . '_Y', 'redirector' => $redirector), $payments_url); // redirect if (!headers_sent()) { @header('location: ' . $redirect); exit; } // js redirect $html .= sprintf('<script type="text/javascript">window.location = "%s";</script><div>%s</div>', $redirect, $packs_obj->get_pack_desc($pack)); } else { $html .= sprintf('<div class="mgm_get_subs_btn">%s</div>', $packs_obj->get_pack_desc($pack)); // coupon if (isset($purchase_another_coupon['id'])) { $html .= sprintf('<div class="mgm_get_subs_btn">%s</div>', sprintf(__('Using Coupon "%s" - %s', 'mgm'), $purchase_another_coupon['name'], $purchase_another_coupon['description'])); } $html .= sprintf('<div class="mgm_get_subs_btn">%s</div>', __('Please Select from Available Payment Gateways', 'mgm')); } //bypass if payment gateway field is selected -issue #1764 if ((double) $pack['cost'] > 0 && isset($_POST['mgm_payment_gateways']) && !empty($_POST['mgm_payment_gateways'])) { //init $tran_id = 0; if (!$tran_id) { $tran_id = mgm_add_transaction($pack, array('is_another_membership_purchase' => true, 'user_id' => $user->ID)); } // module $mod_obj = mgm_get_module($_POST['mgm_payment_gateways'], 'payment'); // module end point $redirect = $mod_obj->_get_endpoint('html_redirect', false); // encode id: //encode transaction id $encode_tran_id = mgm_encode_id($tran_id); //args $redirect = add_query_arg(array('tran_id' => $encode_tran_id), $redirect); // do the redirect to payment mgm_redirect($redirect); } // init $payment_modules = array(); // when active if ($a_payment_modules) { // loop foreach ($a_payment_modules as $payment_module) { // not trial if (in_array($payment_module, array('mgm_free', 'mgm_trial'))) { continue; } //consider only the modules assigned to pack if (isset($pack['modules']) && !in_array($payment_module, (array) $pack['modules'])) { continue; } // store $payment_modules[] = $payment_module; } } // loop payment mods if not free if (count($payment_modules) && $cost) { // transaction $tran_id = 0; // loop foreach ($payment_modules as $module) { // module $mod_obj = mgm_get_module($module, 'payment'); // create transaction // if(!$tran_id) $tran_id = $mod_obj->_create_transaction($pack, array('is_another_membership_purchase' => true, 'user_id' => $user->ID)); if (!$tran_id) { $tran_id = mgm_add_transaction($pack, array('is_another_membership_purchase' => true, 'user_id' => $user->ID)); } // button $html .= sprintf('<div class="mgm_get_subs_btn">%s</div>', $mod_obj->get_button_subscribe(array('pack' => $pack, 'tran_id' => $tran_id))); } } else { if ($cost) { $html .= sprintf('<div class="mgm_get_subs_btn">%s</div>', __('There are no payment gateways available at this time.', 'mgm')); } } // html $html .= '</div>'; } else { // first step show upgrade options // html $html = sprintf('<p class="message register">%s</p>', __('Please Select from Available Membership Packages', 'mgm')); // upgrade_packages $upgrade_packages = ''; // pack to modules $pack_modules = array(); // loop foreach ($packs as $pack) { // default $checked = ''; // skip already purchased packs if (in_array($pack['id'], $pack_ids)) { continue; } //skip same membership level subscriptions if (in_array($pack['membership_type'], $pack_membership_types)) { continue; } // do not show trial or free as upgradre if ($pack['membership_type'] == 'trial' || $pack['membership_type'] == 'free') { continue; } // reset $checked = mgm_select_subscription($pack, $selected_subs); // skip other when a package sent as selected if ($selected_subs !== false) { if (empty($checked)) { continue; } } // checked if (!$checked) { $checked = (int) $pack['default'] == 1 ? ' checked="checked"' : ''; } // duration if ($pack['duration'] == 1) { $dur_str = rtrim($duration_str[$pack['duration_type']], 's'); } else { $dur_str = $duration_str[$pack['duration_type']]; } $css_group = mgm_get_css_group(); // encode pack $subs_opt_enc = mgm_encode_package($pack); // set $pack_modules[$subs_opt_enc] = $pack['modules']; //issue #867 if ($css_group != 'none') { //expand this if needed $css_link_format = '<link rel="stylesheet" href="%s" type="text/css" media="all" />'; $css_file = MGM_ASSETS_URL . 'css/' . $css_group . '/mgm.form.fields.css'; $upgrade_packages .= sprintf($css_link_format, $css_file); } // free if (($pack['cost'] == 0 || strtolower($pack['membership_type']) == 'free') && in_array('mgm_free', $a_payment_modules) && mgm_get_module('mgm_free')->enabled == 'Y') { // input $input = sprintf('<input type="radio" %s class="checkbox" name="subs_opt" value="%s" rel="mgm_subscription_options"/>', $checked, $subs_opt_enc); // html $upgrade_packages .= ' <div class="mgm_subs_wrapper ' . $pack['membership_type'] . '"> <div class="mgm_subs_option ' . $pack['membership_type'] . '"> ' . $input . ' </div> <div class="mgm_subs_pack_desc ' . $pack['membership_type'] . '"> ' . $packs_obj->get_pack_desc($pack) . ' </div> <div class="clearfix"></div> <div class="mgm_subs_desc ' . $pack['membership_type'] . '"> ' . mgm_stripslashes_deep($pack['description']) . ' </div> </div>'; } else { // input $input = sprintf('<input type="radio" %s class="checkbox" name="subs_opt" value="%s" rel="mgm_subscription_options"/>', $checked, $subs_opt_enc); // html $upgrade_packages .= ' <div class="mgm_subs_wrapper ' . $pack['membership_type'] . '"> <div class="mgm_subs_option ' . $pack['membership_type'] . '"> ' . $input . ' </div> <div class="mgm_subs_pack_desc ' . $pack['membership_type'] . '"> ' . $packs_obj->get_pack_desc($pack) . ' </div> <div class="clearfix"></div> <div class="mgm_subs_desc ' . $pack['membership_type'] . '"> ' . mgm_stripslashes_deep($pack['description']) . ' </div> </div>'; } } // add pack_modules as json data, may consider jquery data later if (!empty($pack_modules)) { $html .= sprintf('<script language="javascript">var mgm_pack_modules = %s</script>', json_encode($pack_modules)); } // show error if (!$upgrade_packages) { // html $html .= '<div class="mgm_subs_wrapper"> <div class="mgm_subs_pack_desc"> ' . __('Sorry, no packages available.', 'mgm') . ' </div> </div> <p> <input type="button" name="cancel" onclick="window.location=\'' . $cancel_url . '\'" value="' . __('Cancel', 'mgm') . '" class="button-primary" /> </p>'; } else { /* $error_field = mgm_request_var('error_field'); if(!empty($error_field)) { $errors = new WP_Error(); switch (mgm_request_var('error_type')) { case 'empty': $error_string = 'You must provide a '; break; case 'invalid': $error_string = 'Invalid '; break; } //issue #703 $errors->add( $error_field, __( '<strong>ERROR</strong>: '.$error_string, 'mgm' ).$error_field ); $html .= mgm_set_errors($errors, true); }*/ // check errors if any: $html .= mgm_subscription_purchase_errors(); // form $html .= '<form action="' . $form_action . '" method="post" class="mgm_form"><div class="mgm_get_pack_form_container">'; $html .= '<input type="hidden" name="form_action" value="' . $form_action . '" />'; $html .= $upgrade_packages; //issue #1285 $html .= mgm_get_custom_fields($user->ID, array('on_multiple_membership_level_purchase' => true), 'mgm_upgrade_field'); // html $html .= '<input type="hidden" name="ref" value="' . md5($member->amount . '_' . $member->duration . '_' . $member->duration_type . '_' . $member->membership_type) . '" />'; // set $html .= '<p> <input class="button" type="submit" name="submit" value="' . __('Next', 'mgm') . '" /> <input class="button" type="button" name="cancel" onclick="window.location=\'' . $cancel_url . '\'" value="' . __('Cancel', 'mgm') . '"/> </p>'; // html $html .= '</div></form>'; } } // return return $html; }
function posts() { global $wpdb; // local extract($_POST); // update if (isset($post_setup_save) && !empty($post_setup_save)) { // init updatd $updated = 0; // get system object $system_obj = mgm_get_class('system'); //$setting['enable_facebook']= $system_obj->setting['enable_facebook']; // content protection $content_protection = $system_obj->setting['content_protection']; //Issue #720 if (isset($add_private_tags)) { if ($add_private_tags == 'Y') { $system_obj->setting['add_private_tags'] = 'Y'; $system_obj->save(); } } else { $system_obj->setting['add_private_tags'] = 'N'; $system_obj->save(); } // membership types if (is_array($access_membership_types)) { $membership_types = json_encode($access_membership_types); } else { $membership_types = json_encode(array()); } // init posts $wp_posts = array(); // posts if (isset($posts)) { $wp_posts = array_merge($wp_posts, $posts); } // pages if (isset($pages)) { $wp_posts = array_merge($wp_posts, $pages); } // custom post types if (isset($custom_post_types)) { $wp_posts = array_merge($wp_posts, $custom_post_types); } // add direct urls if ($direct_urls) { // loop foreach ($direct_urls as $direct_url_id => $direct_url) { // affected $affected = false; // insert if (!empty($direct_url)) { // check duplicate if (!mgm_is_duplicate(TBL_MGM_POST_PROTECTED_URL, array('url'), '', array('url' => $direct_url))) { // add $affected = $wpdb->insert(TBL_MGM_POST_PROTECTED_URL, array('url' => $direct_url, 'membership_types' => $membership_types)); } } // update counter if ($affected) { $updated++; } } } // check if ($wp_posts) { // loop foreach ($wp_posts as $post_id) { // get object $post_obj = mgm_get_post($post_id); //Issue #838 if (isset($purchasable) == 'Y') { // set $post_obj->purchasable = $purchasable; } // check if (isset($purchase_cost) && isset($purchasable) == 'Y') { // check if (!empty($purchase_cost) && $purchase_cost > 0) { // set $post_obj->purchase_cost = $purchase_cost; } } // apply filter $post_obj = apply_filters('mgm_post_update', $post_obj, $post_id); // save meta $post_obj->save(); // if access set if (is_array($access_membership_types)) { // set $post_obj->access_membership_types = $access_membership_types; // apply filter $post_obj = apply_filters('mgm_post_update', $post_obj, $post_id); // save meta $post_obj->save(); // unset unset($post_obj); // check duplicate if (!mgm_is_duplicate(TBL_MGM_POST_PROTECTED_URL, array('post_id'), '', array('post_id' => $post_id))) { // add $affected = $wpdb->insert(TBL_MGM_POST_PROTECTED_URL, array('url' => get_permalink($post_id), 'post_id' => $post_id, 'membership_types' => $membership_types)); } else { $affected = $wpdb->update(TBL_MGM_POST_PROTECTED_URL, array('membership_types' => $membership_types), array('post_id' => $post_id)); } } // make private, add [private] tag if (mgm_protect_content($content_protection)) { // get post $wp_post = wp_get_single_post($post_id); // Check private tag on/off Issue #720 if (bool_from_yn($system_obj->setting['add_private_tags'])) { // double check, not already added if (preg_match('/\\[private\\](.*)\\[\\/private\\]/', $wp_post->post_content) == FALSE) { // make content private $post_content = sprintf('[private]%s[/private]', $wp_post->post_content); // update wp_update_post(array('post_content' => $post_content, 'ID' => $wp_post->ID)); } } } // update counter $updated++; } } // response if ($updated) { $response = array('status' => 'success', 'message' => sprintf(__('Post protection successfully updated. %d Post/Page(s) updated.', 'mgm'), $updated)); } else { $response = array('status' => 'error', 'message' => sprintf(__('Post protection failed. %d Post/Page(s) selected.', 'mgm'), $updated)); } // print echo json_encode($response); // return return; } // data $data = array(); // member types $arr_membershiptypes = array(); // loop foreach (mgm_get_class('membership_types')->membership_types as $code => $name) { $arr_membershiptypes[$code] = mgm_stripslashes_deep($name); } // set $data['membership_types'] = $arr_membershiptypes; // posts $data['posts'] = mgm_field_values($wpdb->posts, 'ID', 'post_title', "AND (post_content NOT LIKE '%[private]%' OR post_content LIKE '[private]%') AND post_type = 'post' AND post_status = 'publish'"); // pages $data['pages'] = mgm_field_values($wpdb->posts, 'ID', 'post_title', "AND (post_content NOT LIKE '%[private]%' OR post_content LIKE '[private]%') AND post_type = 'page' AND post_status = 'publish'"); // custom post types if ($post_types = mgm_get_post_types(true, array('page', 'post'))) { $data['custom_post_types'] = mgm_field_values($wpdb->posts, 'ID', "CONCAT(post_title, ' ( ', post_type, ' )') AS post_title", "AND (post_content NOT LIKE '%[private]%' OR post_content LIKE '[private]%') AND post_type IN ({$post_types}) AND post_status = 'publish'", 'post_title'); } else { $data['custom_post_types'] = array(); } // posts access $data['posts_access'] = $wpdb->get_results(sprintf("SELECT * FROM %s WHERE `post_id` IS NOT NULL ORDER BY id ASC", TBL_MGM_POST_PROTECTED_URL)); // direct urls access $data['direct_urls_access'] = $wpdb->get_results(sprintf("SELECT * FROM %s WHERE `post_id` IS NULL ORDER BY id ASC", TBL_MGM_POST_PROTECTED_URL)); // load template view $this->load->template('settings/posts', array('data' => $data)); }
function _get_button_data($pack, $tran_id = NULL) { // system setting $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); // item $item = $this->get_pack_item($pack); //pack currency over rides genral setting currency - issue #1602 if (!isset($pack['currency']) || empty($pack['currency'])) { $pack['currency'] = $this->setting['currency']; } // setup data array $data = array('invnum' => $tran_id, 'description' => $item['name'], 'currencycode' => $pack['currency'], 'notifyurl' => $this->setting['notify_url'], 'email' => $user->user_email, 'amount' => $pack['cost']); // additional fields $this->_set_address_fields($user, $data); // subscription purchase with ongoing/limited if (!isset($pack['buypost']) && isset($pack['duration_type']) && $pack['num_cycles'] != 1) { // does not support one-time recurring // if ($pack['num_cycles'] != 1 && $pack['duration_type']) { // old style // recurring $data['recurring_billing'] = 'TRUE'; // types $bp_types = array('d' => 'Day', 'm' => 'Month', 'y' => 'Year'); // start date $data['start_date'] = date(DATE_ATOM); // Mon, 15 Aug 2005 15:12:46 UTC // billing period $data['billing_period'] = $bp_types[$pack['duration_type']]; // Day|Month|Year $data['billing_frequency'] = $pack['duration']; // 3|12 etc. // greater than 0, limited if ((int) $pack['num_cycles'] > 0) { $data['total_billing_cycles'] = $pack['num_cycles']; } // trial if ($pack['trial_on']) { $data['trial_billing_period'] = $bp_types[$pack['trial_duration_type']]; $data['trial_billing_frequency'] = $pack['trial_duration']; // greated than 0, limited cycle if ((int) $pack['trial_num_cycles'] > 0) { // need this checked $data['trial_total_billing_cycles'] = $pack['trial_num_cycles']; } // cost $data['trial_amt'] = $pack['trial_cost']; } } else { // post purchase/one time billing $data['recurring_billing'] = 'FALSE'; } // custom passthrough $data['custom'] = $tran_id; // update currency - issue #1602 /* if($pack['currency'] != $this->setting['currency']){ $pack['currency'] = $this->setting['currency']; }*/ // strip $data = mgm_stripslashes_deep($data); // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }
/** * recursively check each member object of a user * * @param object $user * @param object $member * @param array $packs * @param array $data * @return bool $has_sent */ function mgm_check_expiring_member($user, $member, $spacks_obj, $data, $system_obj) { // only check for Active members if ($member->status != MGM_STATUS_ACTIVE) { return; } // flag $has_sent = false; // check pack $subs_pack = null; // get pack if ($member->pack_id) { $subs_pack = $spacks_obj->get_pack($member->pack_id); } /*else{ $subs_pack = $spacks_obj->validate_pack($member->amount, $member->duration, $member->duration_type, $member->membership_type); }*/ // check empty if (empty($subs_pack)) { $subs_pack = $spacks_obj->validate_pack($member->amount, $member->duration, $member->duration_type, $member->membership_type); } // log // mgm_log('subs_pack'. mgm_pr($subs_pack, true), ($user->ID.'_'.__FUNCTION__)); // check on going if (isset($subs_pack['id'])) { // issue#: 478 $num_cycles = isset($member->active_num_cycles) && !empty($member->active_num_cycles) ? $member->active_num_cycles : $subs_pack['num_cycles']; // ongoing / lifetime if ($num_cycles == 0) { // never send mail return false; } elseif ($num_cycles > 1 || $member->duration_type == 'l') { // why lifetime included here? // allow onetime subscriptions // if already unsubscribed if (isset($member->status_reset_as) && in_array($member->status_reset_as, array(MGM_STATUS_AWAITING_CANCEL, MGM_STATUS_CANCELLED))) { // set expire date if (empty($member->expire_date)) { $member->expire_date = $member->status_reset_on; } // fishy @todo check // let it send } elseif ($member->duration_type == 'l' || (!isset($member->rebilled) || $member->rebilled <= $num_cycles - 1)) { // send email at the end of the subscription return false; } } } // expire date $expire_date = $member->expire_date; $date_diff = strtotime($expire_date) - $data['current_timestamp']; $days_to_expire = floor($date_diff / (60 * 60 * 24)); // log /*mgm_log(sprintf('reminder email: user: %d, days_to_expire: %d, expire_date: %s, current_date: %s', $user->ID, $days_to_expire, $expire_date, date('Y-m-d H:i:s', $data['current_timestamp'])), __FUNCTION__);*/ $email_data = array(); $email_data['expire_date'] = $expire_date; $email_data['subscription_type'] = mgm_stripslashes_deep($data['subscription_types'][$member->membership_type]); $email_data['template_subject'] = $data['template_subject']; $email_data['template_body'] = $data['template_body']; // days match if ($days_to_expire == $data['days_to_start']) { // send mail $has_sent = mgm_send_reminder_mail($user, $email_data, $system_obj); } else { // incremental if (bool_from_yn($data['days_incremental']) && is_array($data['days_incremental_ranges'])) { // loop foreach ($data['days_incremental_ranges'] as $range) { // get int $range = (int) $range; // if days match if ($range > 0) { // match if ($days_to_expire == $range) { // send mail $has_sent = mgm_send_reminder_mail($user, $email_data, $system_obj); } } } } } // return return $has_sent; }
][<?php echo $member_oth->membership_type; ?> ]" id="user_mem_index_<?php echo $user->ID; ?> _<?php echo $key; ?> " value="<?php echo $key; ?> " /> </td> <td width="15%"><?php echo mgm_stripslashes_deep($m_types->get_type_name($member_oth->membership_type)); ?> </td> <td width="15%"><?php echo $pack_desc_oth; ?> </td> <td width="15%"><?php echo $register_date_oth; ?> </td> <td width="15%"><?php echo $expire_date_oth; ?> </td> <td width="25%"><?php
/** * API helper method get membership types, used in field mapping * * @param none * @return array $membership_types */ function _get_membership_types() { // member types $membership_types = array(); // loop foreach (mgm_get_class('membership_types')->membership_types as $code => $name) { $membership_types[$code] = mgm_stripslashes_deep($name); } // set return $membership_types; }
function _process_response($gateway_method, $content, $action = null) { // reset $this->response = array(); // gateway method switch ($gateway_method) { case 'recurring': // xml if ($xml = @simplexml_load_string($content)) { $this->response['response_status'] = (string) $xml->Result == 'Success' ? 1 : 3; // 1 success, 3 error //$this->response['message_code'] = (string)$xml->messages->message->code ; if (isset($xml->ErrorDetails)) { $this->response['message_text'] = $xml->ErrorDetails; } if (isset($_POST['Option1'])) { $this->response['subscription_id'] = $_POST['Option1']; } //check here as eway doesn't return subscription id:(important) } else { $this->response['response_status'] = 3; $this->response['message_text'] = 'Error parsing XML'; } break; case 'xml_cvn': // xml if ($xml = @simplexml_load_string($content)) { $this->response['response_status'] = (string) $xml->ewayTrxnStatus == 'True' ? 1 : 3; // 1 success, 3 error //$this->response['message_code'] = (string)$xml->messages->message->code ; $this->response['message_text'] = (string) $xml->ewayTrxnError; if (isset($_POST['Option1'])) { $this->response['transaction_id'] = $_POST['Option1']; } } else { $this->response['response_status'] = 3; $this->response['message_text'] = 'Error parsing XML'; } break; case 'xmlauth': case 'xmlauthco': case 'xmlauthvoid': // xml if ($xml = @simplexml_load_string($content)) { $this->response['response_status'] = (string) $xml->ewayTrxnStatus == 'True' ? 1 : 3; // 1 success, 3 error $this->response['message_text'] = $this->_get_error_code((string) $xml->ewayTrxnError); $this->response['txn_no'] = (string) $xml->ewayTrxnNumber; $this->response['auth_code'] = (string) $xml->ewayAuthCode; $this->response['txn_ref'] = (string) $xml->ewayTrxnReference; } else { $this->response['response_status'] = 3; $this->response['message_text'] = 'Error parsing XML'; } break; // parse webservice sml string // parse webservice sml string case 'webservice': if (!empty($content)) { $arr_resp_fields = array('result' => null, 'errordetails' => null); //result: Success switch ($action) { case 'CreateRebillCustomer': $arr_resp_fields['rebillcustomerid'] = null; $arr_resp_fields['transaction_type'] = 'subscription'; break; case 'CreateRebillEvent': $arr_resp_fields['rebillcustomerid'] = null; $arr_resp_fields['rebillid'] = null; $arr_resp_fields['transaction_type'] = 'subscription'; break; case 'UpdateRebillEvent': $arr_resp_fields['rebillcustomerid'] = null; $arr_resp_fields['rebillid'] = null; $arr_resp_fields['transaction_type'] = 'subscription'; break; case 'QueryRebillEvent': $arr_resp_fields['rebillstartdate'] = null; $arr_resp_fields['rebillenddate'] = null; break; case 'DeleteRebillEvent': $arr_resp_fields['rebillcustomerid'] = null; $arr_resp_fields['rebillid'] = null; $arr_resp_fields['transaction_type'] = 'ubsubscribe'; break; case 'DeleteRebillCustomer': $arr_resp_fields['customerref'] = null; //mgm user id break; case 'QueryTransactions': $arr_resp_fields['transactiondate'] = null; $arr_resp_fields['status'] = null; $arr_resp_fields['transactionerror'] = null; $arr_resp_fields['transaction_type'] = 'rebill'; $arr_resp_fields['transactionnumber'] = ''; break; } //parse soap xml $parser = xml_parser_create(); xml_parse_into_struct($parser, $content, $response); xml_parser_free($parser); //loop through tags and get the action related vars if (!empty($response)) { foreach ($response as $resp) { $tag = strtolower($resp['tag']); if (array_key_exists($tag, $arr_resp_fields)) { $arr_resp_fields[$tag] = isset($resp['value']) ? $resp['value'] : ''; } } } //assign to response: $this->response = $arr_resp_fields; //set response_status switch ($action) { case 'CreateRebillCustomer': case 'CreateRebillEvent': case 'DeleteRebillEvent': case 'DeleteRebillCustomer': case 'QueryRebillEvent': $this->response['response_status'] = (string) $arr_resp_fields['result'] == 'Success' ? 1 : 3; // 1 success, 3 error break; case 'QueryTransactions': // statsu set if (isset($arr_resp_fields['status']) && !empty($arr_resp_fields['status'])) { // success if ($arr_resp_fields['status'] == 'Successful') { $this->response['response_status'] = 1; // 1 success, 3 error } else { // other, Failed, Future, $this->response['response_status'] = 3; // error } } else { $this->response['response_status'] = 5; // expired } // message if (isset($arr_resp_fields['transactionnumber']) && !empty($arr_resp_fields['transactionnumber'])) { $this->response['message_text'] = sprintf('%s %s: %s', $arr_resp_fields['transactionerror'], __(' EWAY Transaction No', 'mgm'), $arr_resp_fields['transactionnumber']); } else { $this->response['message_text'] = __('Eway Transaction not found', 'mgm'); } break; } // unset unset($this->response['result']); //errors if (!empty($arr_resp_fields['errordetails'])) { $this->response['message_text'] = mgm_stripslashes_deep($arr_resp_fields['errordetails']); } unset($this->response['errordetails']); //set trans id if (isset($_POST['Option1'])) { $this->response['transaction_id'] = $_POST['Option1']; } //check here as eway doesn't return subscription id:(important) } break; } }
/** * 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; }
echo $id; ?> " <?php echo $active === TRUE ? 'checked' : ''; ?> > </div> <div class="cell width35"> <?php echo mgm_ellipsize(mgm_stripslashes_deep($field['label']), 50); ?> </div> <div class="cell width35"> <?php echo mgm_ellipsize(mgm_stripslashes_deep($field['name']), 50); ?> </div> <div class="cell width10"> <?php echo $field['type']; ?> </div> <div class="cell width20"> <!--<a href="javascript://" rel="#custom_field_settings_overlay_<?php echo $id; ?> " title="<?php _e('Settings', 'mgm');
function _get_button_data($pack, $tran_id = NULL) { // system $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); // item $item = $this->get_pack_item($pack); // set data $data = array('invoice_num' => $tran_id, 'description' => $item['name'], 'email' => $user->user_email, 'currency' => strtolower($this->setting['currency'])); // additional fields,see parent for all fields, only different given here $this->_set_address_fields($user, $data); // product based if (isset($pack['product']['stripe_plan_id'])) { $data['plan'] = $pack['product']['stripe_plan_id']; $data['quantity'] = 1; } else { // use total $data['amount'] = mgm_convert_to_cents($pack['cost']); } // custom passthrough $data['custom'] = $tran_id; // update currency if ($pack['currency'] != $this->setting['currency']) { $pack['currency'] = $this->setting['currency']; } // strip $data = mgm_stripslashes_deep($data); // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }
/** * get subscription packages * * @param int optional subscription id * @return subscription packages * @verb GET * @action list * @url <site>/mgmapi/subscription_packages.<format> * @url <site>/mgmapi/subscription_packages/:id.<format> * @since 1.0 */ public function members_get($id = NULL) { global $wpdb; // init $subscription_packages = array(); $total_rows = 0; $status = 'success'; // loop if ($packs = mgm_get_all_subscription_package()) { // loop foreach ($packs as $pack) { // id flter if ($id) { if ($id != $pack['id']) { continue; } } // membership type $membership_type = $pack['membership_type']; // description $description = mgm_stripslashes_deep($pack['description']); $members = mgm_get_members_with('membership_type', $pack['membership_type'], array('pack_id' => $pack['id']), 'count'); // set $subscription_packages[] = array('id' => $pack['id'], 'membership_type' => $membership_type, 'description' => $description, 'members' => $members); } // total $total_rows = count($subscription_packages); } // base $data = array('total_rows' => $total_rows); // data if ((int) $id > 0) { // message $message = sprintf(__('Get members of subscription package by id#%d response', 'mgm'), $id); // data if ($total_rows > 0) { $data = $data + array('subscription_packages' => array_shift($subscription_packages)); } } else { // message $message = sprintf(__('Get members of subscription packages response - %d subscription package(s) found', 'mgm'), $total_rows); // data if ($total_rows > 0) { $data = $data + array('subscription_packages' => $subscription_packages); } } // response $response = array('status' => 'success', 'message' => $message, 'data' => $data); // return return array($response, 200); }
/** * 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); }
/** * validate and save profile data * * @param int user id * @return int user id */ function mgm_user_profile_update($user_id) { global $wpdb; // get user if ($user_id > 0) { $user_data = get_userdata($user_id); } // error if (!$user_data->ID) { return $user_id; } // flag to control callback re calling via hooks clash, iss#705 define('MGM_DOING_USERS_PROFILE_UPDATE', TRUE); // set aside member object $member = mgm_get_member($user_id); // create empty user $user = new stdClass(); // set id $user->ID = $user_data->ID; // sanitize user login if (isset($_POST['user_login'])) { $user->user_login = sanitize_user($_POST['user_login'], true); } // asnitize email and copy if (isset($_POST['user_email'])) { $user->user_email = sanitize_text_field($_POST['user_email']); } // urls if (isset($_POST['mgm_profile_field']['url'])) { if (empty($_POST['mgm_profile_field']['url']) || $_POST['mgm_profile_field']['url'] == 'http://') { $user->user_url = ''; } else { $user->user_url = esc_url_raw($_POST['mgm_profile_field']['url']); $user->user_url = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $user->user_url) ? $user->user_url : 'http://' . $user->user_url; } } if (isset($_POST['mgm_profile_field']['first_name'])) { $user->first_name = sanitize_text_field($_POST['mgm_profile_field']['first_name']); } if (isset($_POST['mgm_profile_field']['last_name'])) { $user->last_name = sanitize_text_field($_POST['mgm_profile_field']['last_name']); } if (isset($_POST['mgm_profile_field']['nickname'])) { $user->nickname = sanitize_text_field($_POST['mgm_profile_field']['nickname']); } if (isset($_POST['mgm_profile_field']['display_name'])) { $user->display_name = sanitize_text_field($_POST['mgm_profile_field']['display_name']); } if (isset($_POST['mgm_profile_field']['description'])) { $user->description = trim($_POST['mgm_profile_field']['description']); } // init errors $errors = new WP_Error(); // check user login if (isset($_POST['user_login']) && !validate_username($_POST['user_login'])) { $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.', 'mgm')); } // user login duplicate if (($owner_id = username_exists($user->user_login)) && $owner_id != $user->ID) { $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered. Please choose another one.', 'mgm')); } // nickname //!isset( $_POST['mgm_profile_field']['nickname'] ) || - issue #1207 if (isset($_POST['mgm_profile_field']['nickname']) && empty($_POST['mgm_profile_field']['nickname'])) { $errors->add('nickname', __('<strong>ERROR</strong>: You must provide a Nick Name.', 'mgm')); } // email - issue #1207 if (isset($_POST['user_email']) && empty($user->user_email)) { $errors->add('empty_email', __('<strong>ERROR</strong>: Please enter an e-mail address.', 'mgm'), array('form-field' => 'email')); } elseif (isset($_POST['user_email']) && !is_email($user->user_email)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: The e-mail address isn’t correct.', 'mgm'), array('form-field' => 'email')); } elseif (isset($_POST['user_email']) && ($owner_id = email_exists($user->user_email)) && $owner_id != $user->ID) { $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'mgm'), array('form-field' => 'email')); } // password: $pass1 = $pass2 = ''; if (isset($_POST['user_password'])) { $pass1 = sanitize_text_field($_POST['user_password']); } if (isset($_POST['user_password_conf'])) { $pass2 = sanitize_text_field($_POST['user_password_conf']); } /* checking the password has been typed twice */ do_action_ref_array('check_passwords', array($user->user_login, &$pass1, &$pass2)); //issue #1207 if (isset($_POST['user_password']) && isset($_POST['user_password_conf'])) { if (empty($pass1) && !empty($pass2)) { $errors->add('pass', __('<strong>ERROR</strong>: You entered your new password only once.', 'mgm'), array('form-field' => 'pass1')); } elseif (!empty($pass1) && empty($pass2)) { $errors->add('pass', __('<strong>ERROR</strong>: You entered your new password only once.', 'mgm'), array('form-field' => 'pass2')); } } /* Check for "\" in password */ //issue #1207 if (isset($_POST['user_password']) && isset($_POST['user_password_conf'])) { if (false !== strpos(stripslashes($pass1), "\\")) { $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".', 'mgm'), array('form-field' => 'pass1')); } } // get default fields $profile_fields = mgm_get_config('default_profile_fields', array()); // get active custom fields on profile page $cf_profile_page = mgm_get_class('member_custom_fields')->get_fields_where(array('display' => array('on_profile' => true))); //init - issue #1573 $show_membership_fields_arr = array(); if (isset($_REQUEST['membership']) && !empty($_REQUEST['membership'])) { // membership $membership = $_REQUEST['membership']; // get active custom fields on register $cf_profile_by_membership_types = mgm_get_class('member_custom_fields')->get_fields_where(array('attributes' => array('profile_by_membership_types' => true))); //mgm_pr($cf_profile_by_membership_types); //check if (!empty($cf_profile_by_membership_types)) { //loop foreach ($cf_profile_by_membership_types as $cf_profile_by_membership_type) { //membership_type $membership_types_string = $cf_profile_by_membership_type['attributes']['profile_membership_types_field_alias']; //check if (preg_match('/\\b' . $membership . '\\b/', $membership_types_string)) { $show_fields_arr[] = $cf_profile_by_membership_type['name']; $show_membership_fields_arr[] = $cf_profile_by_membership_type; if ($cf_profile_by_membership_type['name'] == 'password') { foreach ($cf_profile_by_membership_types as $cf_profile_by_membership) { if ($cf_profile_by_membership['name'] == 'password_conf') { $show_membership_fields_arr[] = $cf_profile_by_membership; } } } } } } } //merge - issue #1573 if (isset($show_membership_fields_arr) && is_array($show_membership_fields_arr) && !empty($show_membership_fields_arr)) { $cf_profile_page = array_merge($cf_profile_page, $show_membership_fields_arr); } //Profile page password filed is default .#issue 799 $falg = 0; $pass_field = ''; foreach ($cf_profile_page as $field) { if ($field['name'] == 'password') { $falg = 1; //issue #973 $pass_field = $field; } } if ($falg == 0) { $cf_profile_page[] = array('name' => 'password', 'label' => 'Password', 'type' => 'password', 'system' => 1); } //issue #973 & issue #1207 if (isset($_POST['user_password']) && isset($_POST['user_password_conf']) && !empty($pass1) && !empty($pass2) && (isset($pass_field['attributes']['password_min_length']) && $pass_field['attributes']['password_min_length'] == true) || isset($pass_field['attributes']['password_max_length']) && $pass_field['attributes']['password_max_length'] == true) { if (strlen($pass1) < $pass_field['attributes']['password_min_length_field_alias'] || strlen($pass2) < $pass_field['attributes']['password_min_length_field_alias']) { $errors->add('pass', sprintf(__('<strong>ERROR</strong>:Password is too short, minimum %d characters.', 'mgm'), $pass_field['attributes']['password_min_length_field_alias']), array('form-field' => 'pass1')); } elseif (strlen($pass1) > $pass_field['attributes']['password_max_length_field_alias'] || strlen($pass2) > $pass_field['attributes']['password_max_length_field_alias']) { $errors->add('pass', sprintf(__('<strong>ERROR</strong>:Password is too long, minimum %d characters.', 'mgm'), $pass_field['attributes']['password_max_length_field_alias']), array('form-field' => 'pass1')); } elseif ($pass1 != $pass2) { $errors->add('pass', __('<strong>ERROR</strong>: Please enter the same password in the two password fields.', 'mgm'), array('form-field' => 'pass1')); } } elseif (isset($_POST['user_password']) && isset($_POST['user_password_conf']) && $pass1 != $pass2) { $errors->add('pass', __('<strong>ERROR</strong>: Please enter the same password in the two password fields.', 'mgm'), array('form-field' => 'pass1')); } // confirm email - issue #1315 if (isset($_POST['user_email_conf']) && empty($_POST['user_email_conf'])) { $errors->add($field['name'], __('<strong>ERROR</strong>: Please type your confirm e-mail address.', 'mgm')); } elseif (isset($_POST['user_email_conf']) && !is_email($_POST['user_email_conf'])) { $errors->add('invalid_email_conf', __('<strong>ERROR</strong>: The confirm email address isn’t correct.', 'mgm')); } elseif (isset($_POST['user_email_conf']) && is_email($_POST['user_email']) && $_POST['user_email_conf'] != $_POST['user_email']) { $errors->add($field['name'], __('<strong>ERROR</strong>: E-mail does not match. Please re-type.', 'mgm')); } //issue #1207 $m_pass = ''; // set if (!empty($pass1) || !empty($pass2)) { if (!empty($pass1) && !empty($pass2)) { $user->user_pass = wp_hash_password($pass1); $m_pass = $pass1; } elseif (!empty($pass1)) { $user->user_pass = wp_hash_password($pass1); $m_pass = $pass1; } else { $user->user_pass = wp_hash_password($pass2); $m_pass = $pass2; } //issue #703 //$user->user_pass = $pass1; $member->user_password = mgm_encrypt_password($m_pass, $user->ID); } // loop foreach ($cf_profile_page as $field) { // skip default fields, validated already if (in_array($field['name'], array('username', 'email', 'password', 'password_conf', 'email_conf'))) { continue; } // skip html if ($field['type'] == 'html' || $field['type'] == 'label') { continue; } // check register and required if ((bool) $field['attributes']['required'] === true) { // error $error_codes = $errors->get_error_codes(); // validate other if (!isset($_POST['mgm_profile_field'][$field['name']]) || empty($_POST['mgm_profile_field'][$field['name']])) { //issue #703 $errors->add($field['name'], __('<strong>ERROR</strong>: You must provide a ', 'mgm') . mgm_stripslashes_deep($field['label']) . '.'); } } } // Allow plugins to return their own errors. do_action_ref_array('user_profile_update_errors', array(&$errors, $update, &$user)); // error if ($errors->get_error_codes()) { return $errors; } // init pass $user_password = ''; // system - issue #1237 $system_obj = mgm_get_class('system'); $short_format = !empty($system_obj->setting['date_format_short']) ? $system_obj->setting['date_format_short'] : MGM_DATE_FORMAT_SHORT; // update custom fields values: if (isset($_POST['mgm_profile_field'])) { // loop fields foreach ($cf_profile_page as $field) { // skip html if ($field['type'] == 'html' || $field['type'] == 'label' || $field['name'] == 'password_conf') { continue; } // set if (isset($_POST['mgm_profile_field'][$field['name']])) { // value $value = $_POST['mgm_profile_field'][$field['name']]; // birthdate if ($field['name'] == 'birthdate') { //convert to mysql date format(to standardise the date format) -issue #1237 $value = mgm_format_inputdate_to_mysql($value, $short_format); } elseif ($field['name'] == 'password') { // pass iss#705 $user_password = $value; // issue#: 672 $value = mgm_encrypt_password($value, $user_id); } elseif ($field['type'] == 'checkbox' && is_array($value)) { //$value = implode(" ", $value); //issue #1070 $value = serialize($value); } // set $member->custom_fields->{$field}['name'] = $value; } elseif (isset($_POST[$field['name']])) { // value $value = $_POST[$field['name']]; // birthdate if ($field['name'] == 'birthdate') { // convert to mysql date format(to standardise the date format) - issue #1237 $value = mgm_format_inputdate_to_mysql($value, $short_format); } elseif ($field['name'] == 'password') { // pass iss#705 $user_password = $value; //issue#: 672 $value = mgm_encrypt_password($value, $user_id); } elseif ($field['type'] == 'checkbox' && is_array($value)) { //issue #1070 $value = serialize($value); //$value = implode(" ", $value); } // set $member->custom_fields->{$field}['name'] = $value; } elseif ($field['name'] == 'password' && !empty($pass1)) { // pass iss#705 $user_password = $pass1; // value $value = mgm_encrypt_password($pass1, $user_id); // set $member->custom_fields->{$field}['name'] = $value; } elseif ($field['type'] == 'checkbox' && isset($member->custom_fields->{$field}['name'])) { // If no value selected $member->custom_fields->{$field}['name'] = ''; } } } // update $member->save(); //issue #1207 if (!empty($m_pass)) { // pass iss#705 $user_password = $m_pass; } // iss#705 // userdata to update, leave password here $userdata = get_object_vars($user); // unset encoded password from userdata unset($userdata['user_pass']); // update password if (!empty($user_password)) { // set $userdata['user_pass'] = $user_password; } // save main user data & return user id return $user_id = wp_update_user($userdata); }
')">Change Logo</a><br /> <div id="change_logo_<?php echo $data['module']->code; ?> " class="displaynone"> <input type="file" name="logo_<?php echo $data['module']->code; ?> " id="box_logo_<?php echo $data['module']->code; ?> " ><!--keep id name box_ to track by uploader--> </div> </div> <div class="description"><?php echo mgm_stripslashes_deep($data['module']->description); ?> </div> <div class="links"> <input type="checkbox" name="payment[enable]" value="Y" <?php echo $data['module']->is_enabled() ? 'checked' : ''; ?> /> <span id="status_label_<?php echo $data['module']->code; ?> " class="<?php echo $data['module']->is_enabled() ? 's-enabled' : 's-disabled'; ?> "><?php echo $data['module']->is_enabled() ? __('Enabled', 'mgm') : __('Disabled', 'mgm'); ?>
_e('Members\' Contents', 'mgm'); ?> </h2> <div id="poststuff"> <?php $section = isset($_GET['section']) ? strip_tags($_GET['section']) : 'all'; ?> <?php if (in_array($section, array('all', 'accessible'))) { ?> <div class="postbox margin10px0px"> <h3><?php echo sprintf(__('Your Membership Level "%s" Accessible Contents', 'mgm'), mgm_stripslashes_deep($data['membership_level'])); ?> </h3> <div class="inside"> <?php echo mgm_member_accessible_contents('admin'); ?> </div> </div> <?php } ?> <?php
/** * get members by membership type * * @param none * @return members * @verb GET * @action list * @url <site>/mgmapi/membership_types/:membership_type/members.<format> * @since 1.0 */ public function members_get($code = NULL) { // init $status = 'success'; $total_rows = 0; $membership_types = array(); // loop if ($types = mgm_get_all_membership_type()) { // loop foreach ($types as $type) { // code check if ($code) { if ($code != $type['code']) { continue; } } // name $name = mgm_stripslashes_deep($type['name']); $members = mgm_get_members_with('membership_type', $type['code'], NULL, 'count'); // set $membership_types[] = array('code' => $type['code'], 'name' => $name, 'members' => $members); } // total $total_rows = count($membership_types); } // base $data = array('total_rows' => $total_rows); // data if (!empty($code)) { // message $message = sprintf(__('Get members by membership type - %s response', 'mgm'), $code, count($membership_types)); // data if ($total_rows > 0) { $data = $data + array('membership_type' => array_shift($membership_types)); } } else { // message $message = sprintf(__('Get members by membership types response - %d membership type(s) found', 'mgm'), $total_rows); // data if ($total_rows > 0) { $data = $data + array('membership_types' => $membership_types); } } // response $response = array('status' => $status, 'message' => $message, 'data' => $data); // return return array($response, 200); }
/** * url content protection */ function mgm_url_content_protection($content) { // return 'Protected'; $system_obj = mgm_get_class('system'); // check $current_user = wp_get_current_user(); // message code if ($current_user->ID) { // logged in user $message_code = mgm_post_is_purchasable() ? 'private_text_purchasable' : 'private_text_no_access'; } else { // logged out user $message_code = mgm_post_is_purchasable() ? 'private_text_purchasable_login' : 'private_text'; } // protected_message $protected_message = sprintf('<div class="mgm_private_no_access">%s</div>', mgm_private_text_tags(mgm_stripslashes_deep($system_obj->get_template($message_code, array(), true)))); // filter message $protected_message = mgm_replace_message_tags($protected_message); // return return $content = $protected_message; }
function _get_button_code($pack, $tran_id = NULL) { // data $data = $this->_get_button_data($pack, $tran_id); // strip $data = mgm_stripslashes_deep($data); // return $return = ''; // loop foreach ($data as $key => $value) { $return .= ' <input type="hidden" name="' . $key . '" value="' . esc_html($value) . '" />' . "\n"; } // return return $return; }
<div class="row"> <div class="cell"> <div id="upd_elements_membership_type"> <select name="upd_membership_type" id="upd_membership_type" disabled="disabled" class="width200px"> <option value="-"><?php _e('Select', 'mgm'); ?> </option> <?php foreach (mgm_get_class('membership_types')->membership_types as $type_code => $type_name) { // check if ($type_code == 'guest') { continue; } // prin printf('<option value="%s">%s</option>', $type_code, __(mgm_stripslashes_deep($type_name), 'mgm')); } ?> </select> </div> </div> </div> <div class="row"> <div class="cell width150px"> <input type="checkbox" class="checkbox" name="update_opt[]" value="expire_date" /> <b><?php _e('Expiration Date', 'mgm'); ?> </b> </div> </div>
function _get_button_data($pack, $tran_id = NULL) { // system $system_obj = mgm_get_class('system'); $user_id = $pack['user_id']; $user = get_userdata($user_id); // item $item = $this->get_pack_item($pack); // set data $data = array('x_invoice_num' => $tran_id, 'x_description' => $item['name'], 'x_email' => $user->user_email, 'x_amount' => $pack['cost']); // additional fields,see parent for all fields, only different given here $this->_set_address_fields($user, $data); // subscription purchase with ongoing/limited if (!isset($pack['buypost']) && isset($pack['duration_type']) && $pack['num_cycles'] != 1) { // does not support one-time recurring // if ( isset($pack['num_cycles']) && $pack['num_cycles'] != 1 && isset($pack['duration_type'])) { // old style // recurring $data['x_recurring_billing'] = 'TRUE'; // cust id $data['x_cust_id'] = $user_id; // types $unit_types = array('d' => 'days', 'w' => 'days', 'm' => 'months', 'y' => 'months'); // treat year a 12 x months also treat 7 x weeks // interval $data['x_interval_unit'] = $unit_types[strtolower($pack['duration_type'])]; // days|months //$data['x_interval_length'] = ($pack['duration_type']=='y') ? ((int)$pack['duration'] * 12) : $pack['duration']; // 3|12|365 etc. //issue #1768 if (strtolower($pack['duration_type']) == 'y') { $data['x_interval_length'] = (int) $pack['duration'] * 12; } elseif (strtolower($pack['duration_type']) == 'w') { $data['x_interval_length'] = (int) $pack['duration'] * 7; } else { $data['x_interval_length'] = $pack['duration']; } // start date // $data['x_start_date'] = date('Y-m-d') ; // issue#: 581 changes: calculate billing date for 2nd cycle as first cycle will be billed through AIM $add_by = str_replace('s', '', $data['x_interval_unit']); // DAY|MONTH $data['x_start_date'] = date('Y-m-d', strtotime("+{$data['x_interval_length']} {$add_by}", strtotime(date('Y-m-d')))); // trial if (isset($pack['trial_on']) && (bool) $pack['trial_on'] == true) { $data['x_trial_occurrences'] = $pack['trial_num_cycles']; $data['x_trial_amount'] = $pack['trial_cost']; //rewrite start date: $trial_interval_unit = $unit_types[$pack['trial_duration_type']]; // days|months //$trial_interval_length = ($pack['trial_duration_type']=='y') ? ((int)$pack['trial_duration'] * 12) : $pack['trial_duration']; // 3|12|365 etc. //issue #1768 if (strtolower($pack['trial_duration_type']) == 'y') { $trial_interval_length = (int) $pack['trial_duration'] * 12; } elseif (strtolower($pack['trial_duration_type']) == 'w') { $trial_interval_length = (int) $pack['trial_duration'] * 7; } else { $trial_interval_length = $pack['trial_duration']; } $trial_add_by = str_replace('s', '', $trial_interval_unit); $data['x_start_date'] = date('Y-m-d', strtotime("+{$trial_interval_length} {$trial_add_by}", strtotime(date('Y-m-d')))); } // arb ongoing =0 must be set as 9999, or integer 1-99 // occurrences: greater than 0 if ((int) $pack['num_cycles'] > 0) { // $data['x_total_occurrences'] = $pack['num_cycles']; // issue#: 581 changes: reduce total cycles by one as first cycle will be billed through AIM $data['x_total_occurrences'] = $pack['num_cycles']; } else { $data['x_total_occurrences'] = 9999; // ongoing for ARB } } else { // post purchase/ one time billing // recurring $data['x_recurring_billing'] = 'FALSE'; // apply addons $this->_apply_addons($pack, $data, array('amount' => 'x_amount', 'description' => 'x_description')); } // custom passthrough $data['x_custom'] = $tran_id; // strip $data = mgm_stripslashes_deep($data); // add filter @todo test $data = apply_filters('mgm_payment_button_data', $data, $tran_id, $this->module, $pack); // update pack/transaction mgm_update_transaction(array('data' => json_encode($pack), 'module' => $this->module), $tran_id); // return data return $data; }
</div> <div class="cell width5px">:</div> <div class="cell textalignleft"> <select name="packs[<?php echo $data['pack_ctr'] - 1; ?> ][membership_type]" id="packs_membership_type_<?php echo $data['pack_ctr'] - 1; ?> " class="width250px"> <option value="<?php echo $data['pack']['membership_type']; ?> "><?php echo mgm_stripslashes_deep(mgm_get_class('membership_types')->get_type_name($data['pack']['membership_type'])); ?> </option> </select> </div> </div> <div class="row "> <div class="cell width125px"> <?php _e('Duration', 'mgm'); ?> </div> <div class="cell width5px">:</div> <div class="cell textalignleft"> <input type="text" name="packs[<?php