当前位置: 首页>>代码示例>>PHP>>正文


PHP mgm_get_post函数代码示例

本文整理汇总了PHP中mgm_get_post函数的典型用法代码示例。如果您正苦于以下问题:PHP mgm_get_post函数的具体用法?PHP mgm_get_post怎么用?PHP mgm_get_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mgm_get_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _buy_post


//.........这里部分代码省略.........
             // backward compatibility
             do_action('mgm_post_purchase_payment_success', $args);
             // new organized name
             break;
         case "ERROR":
         case 'Failure':
             // status
             $status_str = __('Last payment was refunded or denied', 'mgm');
             // purchase status
             $purchase_status = 'Failure';
             // error
             $errors[] = $status_str;
             break;
         case "CANCEL-REBILL":
         case "UNCANCEL-REBILL":
         case 'Pending':
             // status
             $status_str = __('Last payment is pending. Reason: Unnown', 'mgm');
             // purchase status
             $purchase_status = 'Pending';
             // error
             $errors[] = $status_str;
             break;
         default:
             // status
             $status_str = sprintf(__('Last payment status: %s', 'mgm'), $payment_status);
             // purchase status
             $purchase_status = 'Unknown';
             // error
             $errors[] = $status_str;
     }
     // do action
     do_action('mgm_return_post_purchase_payment_' . $this->module, array('post_id' => $post_id));
     // new, individual
     do_action('mgm_return_post_purchase_payment', array('post_id' => $post_id));
     // new, global
     // status
     $status = __('Failed join', 'mgm');
     //overridden on a successful payment
     // check status
     if ($purchase_status == 'Success') {
         // mark as purchased
         if (isset($user->ID)) {
             // purchased by user
             // call coupon action
             do_action('mgm_update_coupon_usage', array('user_id' => $user_id));
             // set as purchased
             $this->_set_purchased($user_id, $post_id, NULL, $alt_tran_id);
         } else {
             // purchased by guest
             if (isset($guest_token)) {
                 // issue #1421, used coupon
                 if (isset($coupon_id) && isset($coupon_code)) {
                     // call coupon action
                     do_action('mgm_update_coupon_usage', array('guest_token' => $guest_token, 'coupon_id' => $coupon_id));
                     // set as purchased
                     $this->_set_purchased(NULL, $post_id, $guest_token, $alt_tran_id, $coupon_code);
                 } else {
                     $this->_set_purchased(NULL, $post_id, $guest_token, $alt_tran_id);
                 }
             }
         }
         // status
         $status = __('The post was purchased successfully', 'mgm');
     }
     // transaction status
     mgm_update_transaction_status($_REQUEST['trans_id'], $status, $status_str);
     // blog
     $blogname = get_option('blogname');
     // post being purchased
     $post = get_post($post_id);
     // notify user and admin, only if gateway emails on
     if (!$dpne) {
         // notify user
         if (isset($user->ID)) {
             // mgm post setup object
             $post_obj = mgm_get_post($post_id);
             // check
             if ($this->send_payment_email($alt_tran_id)) {
                 // check
                 if (mgm_notify_user_post_purchase($blogname, $user, $post, $purchase_status, $system_obj, $post_obj, $status_str)) {
                     // update as email sent
                     $this->update_paymentemail_sent($alt_tran_id);
                 }
             }
         }
     }
     // notify admin, only if gateway emails on
     if (!$dge) {
         // notify admin,
         mgm_notify_admin_post_purchase($blogname, $user, $post, $status);
     }
     // error condition redirect
     if (count($errors) > 0) {
         if ($this->is_webhook_called_by('self')) {
             // only when proxied via payment_return
             mgm_redirect(add_query_arg(array('status' => 'error', 'errors' => implode('|', $errors)), $this->_get_thankyou_url()));
         }
     }
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_ideal.php

示例2: get_option

<?php

$blogname = get_option('blogname');
$tran_success = false;
//getting purchase post title and & price - issue #981
$post_obj = mgm_get_post($post_id);
$purchase_cost = mgm_convert_to_currency($post_obj->purchase_cost);
$post = get_post($post_id);
$post_title = $post->post_title;
//issue #504
if ($user_id) {
    // issue#: 280 (2011 Feb 25)
    // subject
    $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true);
    // body
    $message = $system_obj->get_template('payment_success_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'admin_email' => $system_obj->setting['admin_email']), true);
}
//issue #504
if ($user_id) {
    // issue#: 280 (2011 Feb 25)
    // subject
    $subject = $system_obj->get_template('payment_failed_email_template_subject', array('blogname' => $blogname), true);
    // body
    $message = $system_obj->get_template('payment_failed_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'payment_type' => 'post purchase payment', 'reason' => $status_str, 'admin_email' => $system_obj->setting['admin_email']), true);
}
//issue #504
if ($user_id) {
    // issue#: 280 (2011 Feb 25)
    // subject
    $subject = $system_obj->get_template('payment_pending_email_template_subject', array('blogname' => $blogname), true);
    // body
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:31,代码来源:emails.php

示例3: _get_purchased_contents

 function _get_purchased_contents($post_types, $id, $start, $rows, $gifted = false)
 {
     global $wpdb;
     // array or string
     if (!is_array($post_types)) {
         $post_types = array($post_types);
     }
     // impode
     $post_types_in = mgm_map_for_in($post_types);
     // gifted
     $gifted_sql = $gifted ? "AND is_gift = 'Y'" : "AND is_gift = 'N'";
     // from
     $sql_from = " FROM " . $wpdb->posts . " A JOIN " . TBL_MGM_POST_PURCHASES . " B ON(A.ID = B.post_id) \r\r\n\t\t\t\t\t  WHERE post_status = 'publish' AND post_type IN ( {$post_types_in} ) {$gifted_sql}";
     // sql
     $sql = "SELECT DISTINCT(A.ID), post_type, post_title, post_date, post_content, user_id,guest_token {$sql_from} \r\r\n\t\t        ORDER BY post_date DESC LIMIT {$start},{$rows}";
     // get posts
     $results = $wpdb->get_results($sql);
     // init
     $posts = array();
     // check
     if ($results) {
         // loop
         foreach ($results as $post) {
             // get object
             $post_obj = mgm_get_post($post->ID);
             // check
             if (mgm_post_is_purchasable($post->ID, $post_obj)) {
                 // stip short code
                 $post->post_content = mgm_strip_shortcode($post->post_content);
                 // access type
                 $access_types = $post_obj->get_access_membership_types();
                 // access delay
                 $access_delays = $post_obj->get_access_delay();
                 // init
                 $access_settings = array();
                 // loop
                 foreach ($access_types as $access_type) {
                     // delay
                     $delay = isset($access_delays[$access_type]) ? (int) $access_delays[$access_type] : 0;
                     // set
                     $access_settings[] = array('membership_type' => array('code' => $access_type, 'name' => mgm_get_membership_type_name($access_type)), 'access_delay' => sprintf(__('%d day', 'mgm'), $delay));
                 }
                 // access
                 $post->access_settings = $access_settings;
                 // user
                 if ((int) $post->user_id > 0) {
                     // user
                     $user = get_userdata($post->user_id);
                     $user_info = array('by' => 'user', 'id' => $post->user_id, 'username' => $user->user_login, 'email' => $user->user_email);
                     // gifted
                     if ($gifted) {
                         $post->gift = array_slice($user_info, 1);
                     } else {
                         $post->purchase = $user_info;
                     }
                 } else {
                     $post->purchase = array('by' => 'guest', 'token' => $post->guest_token);
                 }
                 // unset
                 unset($post->guest_token, $post->user_id);
                 // set
                 $posts[] = $post;
             }
         }
     }
     // return
     return $posts;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:68,代码来源:mgm_api_contents.php

示例4: _buy_post

 /**
  * Update buy post response
  *
  */
 function _buy_post()
 {
     global $wpdb;
     //skip updates from IPN: {PPP will be an immediate update}
     if (isset($_POST['ipn_track_id'])) {
         exit;
     }
     // 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 passthrough, stop further process if fails to parse
     $custom = $this->_get_transaction_passthrough($_POST['custom']);
     // local var
     extract($custom);
     // set user
     $user = null;
     // check
     if (isset($user_id) && (int) $user_id > 0) {
         $user = get_userdata($user_id);
     }
     $blogname = get_option('blogname');
     $tran_success = false;
     //getting purchase post title and & price - issue #981
     $post_obj = mgm_get_post($post_id);
     $purchase_cost = mgm_convert_to_currency($post_obj->purchase_cost);
     $post = get_post($post_id);
     $post_title = $post->post_title;
     // errors
     $errors = array();
     // purchase status
     $purchase_status = 'Error';
     // status
     $payment_status = isset($this->response['PAYMENTINFO_0_PAYMENTSTATUS']) ? $this->response['PAYMENTINFO_0_PAYMENTSTATUS'] : $this->response['PAYMENTSTATUS'];
     // status
     if ($this->status == 'test' && strtoupper($payment_status) == 'PENDING') {
         $payment_status = 'Completed';
     }
     // process on response code
     switch ($payment_status) {
         case 'Completed':
         case 'Processed':
             // status
             $status_str = __('Last payment was successful', 'mgm');
             // purchase status
             $purchase_status = 'Success';
             // transaction id
             $transaction_id = $this->_get_transaction_id();
             // hook args
             $args = array('post_id' => $post_id, 'transaction_id' => $transaction_id);
             // user purchase
             if (isset($user_id) && (int) $user_id > 0) {
                 $args['user_id'] = $user_id;
             } else {
                 // guest purchase
                 $args['guest_token'] = $guest_token;
             }
             // after succesful payment hook
             do_action('mgm_buy_post_transaction_success', $args);
             // backward compatibility
             do_action('mgm_post_purchase_payment_success', $args);
             // new organized name
             break;
         case 'Failed':
         case 'Refunded':
         case 'Denied':
         case 'In-Progress':
             // status
             $status_str = __('Last payment was refunded or denied', 'mgm');
             // purchase status
             $purchase_status = 'Failure';
             // error
             $errors[] = $status_str;
             break;
         case 'Pending':
             // reason
             if (isset($this->response['PAYMENTINFO_0_PENDINGREASON'])) {
                 $reason = $this->response['PAYMENTINFO_0_PENDINGREASON'];
             } else {
                 $reason = $payment_status;
             }
             // status
             $status_str = sprintf(__('Last payment is pending. Reason: %s', 'mgm'), $reason);
             // purchase status
             $purchase_status = 'Pending';
             // error
             $errors[] = $status_str;
             break;
         default:
             // status
             $status_str = sprintf(__('Last payment status: %s', 'mgm'), isset($payment_status) ? $payment_status : 'Unknown');
             // purchase status
             $purchase_status = 'Unknown';
             // error
             $errors[] = $status_str;
     }
//.........这里部分代码省略.........
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_paypalexpresscheckout.php

示例5: mgm_post_setup_save

/**
 * post/page meta box data save
 *
 */
function mgm_post_setup_save($post_id)
{
    // donot process ajax
    // if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) return true;
    // update
    if (isset($_POST['mgm_post'])) {
        // check revision
        if ($the_post = wp_is_post_revision($post_id)) {
            $post_id = $the_post;
        }
        // get object
        $post_obj = mgm_get_post($post_id);
        // check object
        if (is_object($post_obj)) {
            // post data
            $post_objdata = $_POST['mgm_post'];
            // access membership types
            if (!isset($post_objdata['access_membership_types'])) {
                $post_objdata['access_membership_types'] = array();
            }
            // access delay
            if (!isset($post_objdata['access_delay'])) {
                $post_objdata['access_delay'] = array();
            }
            // purchase expiry
            if (!empty($post_objdata['purchase_expiry'])) {
                //issue #1424
                $datepickerformat = mgm_get_datepicker_format();
                $post_objdata['purchase_expiry'] = mgm_format_inputdate_to_mysql($post_objdata['purchase_expiry'], $datepickerformat);
            }
            // int
            $post_objdata['access_duration'] = $post_objdata['purchase_duration'] = (int) $post_objdata['access_duration'];
            // int
            $post_objdata['access_view_limit'] = (int) $post_objdata['access_view_limit'];
            // addons
            if (!isset($post_objdata['addons'])) {
                $post_objdata['addons'] = array();
            }
            // allowed_modules
            if (!isset($post_objdata['allowed_modules'])) {
                $post_objdata['allowed_modules'] = array();
            }
            // set new fields
            $post_obj->set_fields($post_objdata);
            // apply filter
            $post_obj = apply_filters('mgm_post_update', $post_obj, $post_id);
            // save meta
            $post_obj->save();
            // log
            // mgm_log($post_obj, __FUNCTION__);
        }
    }
    // return
    return true;
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:59,代码来源:mgm_widget_post_category.php

示例6: mgm_get_post_purchase_options

/**
 * generate guest purchase purchase options
 *
 * @param object post 
 * @patam string message, pre_button|pre_register
 * @return string html
 */
function mgm_get_post_purchase_options($post, $message = 'pre_button')
{
    // post ot post id
    if (!is_object($post) && is_numeric($post)) {
        $post =& get_post($post);
    }
    // get post purchase options
    $post_obj = mgm_get_post($post->ID);
    // membership_types
    $membership_types_obj = mgm_get_class('mgm_membership_types');
    // system
    $system_obj = mgm_get_class('system');
    //Issue #794
    $currency = $system_obj->get_setting('currency');
    // symbol
    if (($currency_symbol = mgm_get_currency_symbols($currency)) != $currency) {
        $purchase_cost = $currency_symbol . mgm_convert_to_currency($post_obj->purchase_cost);
    } else {
        $purchase_cost = mgm_convert_to_currency($post_obj->purchase_cost) . ' ' . $currency;
    }
    // types
    $membership_types = array();
    // acc
    $accessible_membership_types = $post_obj->get_access_membership_types();
    // loop
    foreach ($accessible_membership_types as $membership_type) {
        // url
        $membership_register_url = mgm_get_custom_url('register', false, array('membership' => base64_encode($membership_type), 'post_id' => $post->ID));
        // name
        $membership_name = $membership_types_obj->get_type_name($membership_type);
        // set
        $membership_types[] = sprintf('<li><a href="%s" target="_blank">%s</a></li>', $membership_register_url, $membership_name);
    }
    // template
    $template = mgm_stripslashes_deep($system_obj->get_template('text_guest_purchase_' . $message, array(), true));
    // the template is twice used
    // replace tags
    $html = str_replace('[post_title]', $post->post_title, $template);
    //Issue #794
    $html = str_replace('[purchase_cost]', $purchase_cost, $html);
    // membership_types_options
    $membership_types_options = count($membership_types) > 0 ? sprintf('<ul>%s</ul>', implode('', $membership_types)) : __('None available<br>', 'mgm');
    // set
    $html = str_replace('[membership_types]', $membership_types_options, $html);
    // return
    return $html;
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:54,代码来源:mgm_misc_functions.php

示例7: mgm_get_cached_object

function mgm_get_cached_object($class_name, $type, $id = false)
{
    // on type
    switch ($type) {
        case 'payment':
        case 'autoresponder':
            return mgm_get_module($class_name, $type, true);
            break;
        case 'member':
            return mgm_get_member($id, true);
            // cached from db
            break;
        case 'post':
            return mgm_get_post($id, true);
            // cached from db
            break;
        case 'class':
        default:
            return mgm_get_option($class_name);
            break;
    }
    // error
    return false;
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:24,代码来源:mgm_fixer_functions.php

示例8: mgm_get_membershiptype_access_post

function mgm_get_membershiptype_access_post($post_id = "")
{
    $users = array();
    $post_obj = mgm_get_post($post_id);
    $access_types = $post_obj->get_access_membership_types();
    $users = wp_cache_get('all_user_ids', 'users');
    //if empty read from db:
    if (empty($users)) {
        $users = mgm_get_all_userids(array('ID'), 'get_results');
        //update cache with user ids:
        wp_cache_set('all_user_ids', $users, 'users');
    }
    $members = array();
    // check
    if ($users) {
        // loop
        foreach ($users as $user) {
            // member object
            $member = mgm_get_member($user->ID);
            if (in_array($member->membership_type, $access_types)) {
                if ($member->status == MGM_STATUS_ACTIVE) {
                    $members[] = $member;
                }
            }
        }
    }
    return $members;
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:28,代码来源:mgm_admin_functions.php

示例9: mgm_manage_posts_custom_column

/**
 * add custom colums row to post/page/post type UI
 *
 * @param array $column
 * @param init $post_id
 * @return void
 */
function mgm_manage_posts_custom_column($column, $post_id)
{
    // column
    switch ($column) {
        case 'access_level':
            // post object
            $post_obj = mgm_get_post($post_id);
            // fetch
            $access_levels = $post_obj->get_access_membership_types();
            // check
            echo empty($access_levels) ? __('Public', 'mgm') : implode(', ', $access_levels);
            break;
        case 'purchasable':
            // post object
            $post_obj = mgm_get_post($post_id);
            // check
            echo $post_obj->is_purchasable() ? __('Yes', 'mgm') : __('No', 'mgm');
            break;
    }
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:27,代码来源:mgm_content_hooks.php

示例10: post_settings_delete

 function post_settings_delete()
 {
     global $wpdb;
     extract($_POST);
     // check
     $post_id = $wpdb->get_var($wpdb->prepare("SELECT `post_id` FROM `" . TBL_MGM_POST_PROTECTED_URL . "` WHERE id = %d", $id));
     // if post
     if ((int) $post_id > 0) {
         // update content
         // get content
         $wp_post = wp_get_single_post($post_id);
         // update
         wp_update_post(array('post_content' => preg_replace('/\\[\\/?private\\]/', '', $wp_post->post_content), 'ID' => $wp_post->ID));
         // remove other Issue #922
         // get object
         $post_obj = mgm_get_post($post_id);
         // set
         $post_obj->purchasable = 'N';
         $post_obj->purchase_cost = '0.00';
         $post_obj->access_membership_types = array();
         // save meta
         $post_obj->save();
         // unset
         unset($post_obj);
     }
     // sql
     $sql = $wpdb->prepare("DELETE FROM `" . TBL_MGM_POST_PROTECTED_URL . "` WHERE id = %d", $id);
     // delete
     if ($wpdb->query($sql)) {
         $message = __('Successfully deleted post settings: ', 'mgm');
         $status = 'success';
     } else {
         $message = __('Error while deleting post settings: ', 'mgm');
         $status = 'error';
     }
     // return response
     echo json_encode(array('status' => $status, 'message' => $message));
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:38,代码来源:mgm_admin_settings.php

示例11: _buy_post

 function _buy_post()
 {
     global $wpdb;
     // 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 passthrough, stop further process if fails to parse
     $custom = $this->_get_transaction_passthrough($_REQUEST['custom']);
     // local var
     extract($custom);
     // find user
     if ($user_id) {
         $user = get_userdata($user_id);
     }
     // blog
     $blogname = get_option('blogname');
     //getting purchase post title and & price - issue #981
     $post_obj = mgm_get_post($post_id);
     $purchase_cost = mgm_convert_to_currency($post_obj->purchase_cost);
     $post = get_post($post_id);
     $post_title = $post->post_title;
     // tran
     $tran_success = false;
     // status success
     $tran_success = true;
     // status
     $status_str = __('Last payment was successful', 'mgm');
     // emails not for guest
     if ($user_id) {
         // subject
         $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true);
         // body
         $message = $system_obj->get_template('payment_success_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'admin_email' => $system_obj->setting['admin_email']), true);
         //update coupon usage - issue #1421
         do_action('mgm_update_coupon_usage', array('user_id' => $user_id));
     }
     // transation id
     $transaction_id = $this->_get_transaction_id('custom', $_REQUEST);
     // hook args
     $args = array('post_id' => $post_id, 'transaction_id' => $transaction_id);
     // user purchase
     if (isset($user_id) && (int) $user_id > 0) {
         $args['user_id'] = $user_id;
     } else {
         // guest purchase
         $args['guest_token'] = $guest_token;
     }
     // after succesful payment hook
     do_action('mgm_buy_post_transaction_success', $args);
     // backward compatibility
     do_action('mgm_post_purchase_payment_success', $args);
     // new organized name
     // do action
     do_action('mgm_return_post_purchase_payment_' . $this->module, array('post_id' => $post_id));
     // new, individual
     do_action('mgm_return_post_purchase_payment', array('post_id' => $post_id));
     // new, global
     // notify user
     if (!$dpne) {
         // mail
         if ($user_id && $this->send_payment_email($_REQUEST['custom'])) {
             //issue #862
             $subject = mgm_replace_email_tags($subject, $user_id);
             $message = mgm_replace_email_tags($message, $user_id);
             // mail
             mgm_mail($user->user_email, $subject, $message);
             //send an email to the buyer
             //update as email sent
             $this->update_paymentemail_sent($_REQUEST['custom']);
         }
     }
     // mark as purchased
     if (isset($guest_token)) {
         // issue #1421
         if (isset($coupon_id) && isset($coupon_code)) {
             do_action('mgm_update_coupon_usage', array('guest_token' => $guest_token, 'coupon_id' => $coupon_id));
             $this->_set_purchased(NULL, $post_id, $guest_token, $_REQUEST['custom'], $coupon_code);
         } else {
             $this->_set_purchased(NULL, $post_id, $guest_token, $_REQUEST['custom']);
         }
     } else {
         $this->_set_purchased($user_id, $post_id, NULL, $_REQUEST['custom']);
     }
     // status
     $status = __('The post was purchased successfully', 'mgm');
     // transaction status
     mgm_update_transaction_status($_REQUEST['custom'], $status, $status_str);
     // notify admin, only if gateway emails on
     if (!$dge) {
         // not for guest
         if ($user_id) {
             // subject
             $subject = "[" . $blogname . "] Admin Notification: " . $user->user_email . " purchased post " . $post_id;
             // message
             $message = "User display name: {$user->display_name}<br />\r\r\n\t\t\t\t\t\t\tUser email: {$user->user_email}<br />\r\r\n\t\t\t\t\t\t\tUser ID: {$user->ID}<br />Status: " . $status . "<br />\r\r\n\t\t\t\t\t\t\tAction: Purchase post:" . $subject . "<br /><br />" . $message;
         } else {
             $subject = "[" . $blogname . "] Admin Notification: Guest[IP: " . mgm_get_client_ip_address() . "] purchased post " . $post_id;
             $message = "Guest Purchase";
         }
//.........这里部分代码省略.........
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_free.php

示例12: mgm_get_post_purchase_buttons

/**
 * get post purchase buttons
 * final step for post purchase
 *
 * @param void
 * @return $html
 */
function mgm_get_post_purchase_buttons()
{
    // get current user data - issue #1421
    $user = wp_get_current_user();
    // pack
    $pack = NULL;
    // addon options
    if ($addon_option_ids = mgm_post_var('addon_options')) {
        $addon_options = mgm_get_addon_options_only($addon_option_ids);
        // mgm_pr($addon_options);
    }
    // post purchase
    if (isset($_POST['post_id'])) {
        //issue #1250
        if (isset($_POST['mgm_postpurchase_field']['coupon']) && !empty($_POST['mgm_postpurchase_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_postpurchase_field']['coupon']))) {
                    //redirect back to the form
                    $q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'error_field_value' => $_POST['mgm_postpurchase_field']['coupon']);
                    $redirect = add_query_arg($q_arg, $_POST['form_action']);
                    mgm_redirect($redirect);
                    exit;
                }
            }
        }
        // post id
        $post_id = $_POST['post_id'];
        // gete mgm data
        $post_obj = mgm_get_post($post_id);
        $cost = mgm_convert_to_currency($post_obj->purchase_cost);
        $product = $post_obj->product;
        $allowed_modules = $post_obj->allowed_modules;
        // post data
        $post = get_post($post_id);
        $title = $post->post_title;
        // item name -issue #1380
        $item_name = apply_filters('mgm_post_purchase_itemname', sprintf(__('Purchase Post - %s', 'mgm'), $title));
        // set pack
        $pack = array('duration' => 1, 'item_name' => $item_name, 'buypost' => 1, 'cost' => $cost, 'title' => $title, 'product' => $product, 'post_id' => $post_id, 'allowed_modules' => $allowed_modules);
    } else {
        if (isset($_POST['postpack_id'])) {
            // post pack purchase
            //issue #1250
            if (isset($_POST['mgm_postpurchase_field']['coupon']) && !empty($_POST['mgm_postpurchase_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_postpurchase_field']['coupon']))) {
                        //redirect back to the form
                        $q_arg = array('error_field' => 'Coupon', 'error_type' => 'invalid', 'error_field_value' => $_POST['mgm_postpurchase_field']['coupon']);
                        $redirect = add_query_arg($q_arg, $_POST['form_action']);
                        mgm_redirect($redirect);
                        exit;
                    }
                }
            }
            // post pack purchase
            $postpack_id = $_POST['postpack_id'];
            // pcak id
            $postpack_post_id = $_POST['postpack_post_id'];
            // post id where pack is listed, redirect here
            // get pack
            $postpack = mgm_get_postpack($postpack_id);
            $cost = mgm_convert_to_currency($postpack->cost);
            $product = json_decode($postpack->product, true);
            $modules = json_decode($postpack->modules, true);
            //mgm_pr($postpack);
            // item name -issue #1380
            $item_name = apply_filters('mgm_postpack_purchase_itemname', sprintf(__('Purchase Post Pack - %s', 'mgm'), $postpack->name));
            // post id
            $post_id = mgm_get_postpack_posts_csv($postpack_id);
            // set pack
            $pack = array('duration' => 1, 'item_name' => $item_name, 'buypost' => 1, 'cost' => $cost, 'title' => $postpack->name, 'product' => $product, 'post_id' => $post_id, 'postpack_id' => $postpack_id, 'postpack_post_id' => $postpack_post_id, 'allowed_modules' => $modules);
        }
    }
    // check
    if (!$pack) {
        return __('Error in Payment! No data available ');
        exit;
    }
    // guest token	-issue #1421
    if (isset($_POST['guest_purchase']) && $_POST['guest_purchase'] == TRUE && $user->ID <= 0) {
        $pack['guest_token'] = sanitize_title_for_query(mgm_create_token());
    }
    // addon options
    if (isset($addon_options) && !empty($addon_options)) {
        $pack['addon_options'] = $addon_options;
    }
    // get coupon
    $post_purchase_coupon = mgm_save_partial_fields(array('on_postpurchase' => true), 'mgm_postpurchase_field', $pack['cost'], false, 'postpurchase');
    // alter
//.........这里部分代码省略.........
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_payment_button_functions.php

示例13: mgm_get_posts_for_level

function mgm_get_posts_for_level($membership_type = '', $show_all = true)
{
    global $wpdb, $post;
    if (!empty($membership_type)) {
        if (!is_array($membership_type)) {
            $membership_type = array(0 => $membership_type);
        }
        // get post types
        $post_types_in = mgm_get_post_types(true);
        // id
        $post_id_notin = is_numeric($post->ID) ? $post->ID : 0;
        // sql
        $limit = 50;
        $per_page = 10;
        $sql = "SELECT DISTINCT(ID), post_title, post_date, post_content\r\r\n\t\t\t\tFROM " . $wpdb->posts . " A JOIN " . $wpdb->postmeta . " B ON (A.ID = B.post_id ) \r\r\n\t\t\t\tWHERE post_status = 'publish' AND B.meta_key LIKE '_mgm_post%' \r\r\n\t\t\t\tAND post_type IN ({$post_types_in}) AND A.id NOT IN({$post_id_notin}) \r\r\n\t\t\t\tORDER BY post_date DESC LIMIT 0," . $limit;
        // get posts
        $results = $wpdb->get_results($sql);
        // chk
        if (count($results) > 0) {
            // set counter
            $total = 0;
            // loop
            foreach ($results as $id => $obj) {
                // post
                $post_obj = mgm_get_post($obj->ID);
                $access_types = $post_obj->get_access_membership_types();
                $found = false;
                if (!empty($access_types)) {
                    foreach ($access_types as $type) {
                        if (in_array($type, $membership_type)) {
                            $membership = mgm_get_class('membership_types');
                            $obj->access_membership_type = $membership->get_type_name($type);
                            $found = true;
                            $total++;
                            break;
                        }
                    }
                    if ($found && (isset($_GET['show']) && $_GET['show'] == 'all' || $show_all || $total <= $per_page)) {
                        $posts[] = $obj;
                    }
                }
                // branch
            }
            return array('posts' => $posts, 'total' => $total);
        }
    }
    return array();
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:48,代码来源:mgm_template_functions.php

示例14: membership_type_update


//.........这里部分代码省略.........
             if ($new_type_code != $type_code) {
                 // get object
                 $obj_sp = mgm_get_class('subscription_packs');
                 //update new
                 foreach ($obj_sp->packs as $key => $pack) {
                     if ($obj_sp->packs[$key]['membership_type'] == $type_code) {
                         $obj_sp->packs[$key]['membership_type'] = $new_type_code;
                         $obj_sp->save();
                     }
                 }
                 // loop
                 foreach ($users as $user) {
                     // get
                     $member = mgm_get_member($user->ID);
                     // if users with same membershiptype as that of selected
                     if (isset($member->membership_type) && $member->membership_type == $type_code) {
                         // set
                         $member->membership_type = $new_type_code;
                         // save
                         $member->save();
                     }
                     // check if any multiple levels exist:
                     if (isset($member->other_membership_types) && is_array($member->other_membership_types) && count($member->other_membership_types) > 0) {
                         // loop
                         foreach ($member->other_membership_types as $key => $memtypes) {
                             // make sure its an object:
                             $memtypes = mgm_convert_array_to_memberobj($memtypes, $user->ID);
                             // verify
                             if ($memtypes->membership_type == $type_code) {
                                 // set
                                 $memtypes->membership_type = $new_type_code;
                                 // save
                                 mgm_save_another_membership_fields($memtypes, $user->ID, $key);
                             }
                         }
                     }
                     // unset
                     unset($member);
                 }
                 //issue #1336
                 $membership_posts = mgm_get_posts_for_level($type_code);
                 if (isset($membership_posts['total']) && $membership_posts['total'] > 0) {
                     foreach ($membership_posts['posts'] as $id => $obj) {
                         $post_id = $obj->ID;
                         // get object
                         $post_obj = mgm_get_post($post_id);
                         // if access set
                         if (is_array($post_obj->access_membership_types)) {
                             $access_membership_types = $post_obj->access_membership_types;
                             foreach ($post_obj->access_membership_types as $key => $access_membership_type) {
                                 if ($access_membership_type == $type_code) {
                                     //update rename
                                     $access_membership_types[$key] = $new_type_code;
                                     // set
                                     $post_obj->access_membership_types = $access_membership_types;
                                 }
                             }
                         }
                         // if access delay set
                         if (is_array($post_obj->access_delay)) {
                             $access_delay = $post_obj->access_delay;
                             if (isset($access_delay[$type_code])) {
                                 $access_delay[$new_type_code] = $access_delay[$type_code];
                                 unset($access_delay[$type_code]);
                                 $post_obj->access_delay = $access_delay;
                             }
                         }
                         // apply filter
                         $post_obj = apply_filters('mgm_post_update', $post_obj, $post_id);
                         // save meta
                         $post_obj->save();
                         // unset
                         unset($post_obj);
                     }
                 }
                 //unset
                 $membership_types_obj->unset_membership_type($type_code);
                 // set
                 $membership_types_obj->set_name($membership_type_names[$type_code], $new_type_code);
             } else {
                 // set
                 $membership_types_obj->set_name($membership_type_names[$type_code], $type_code);
             }
         }
         // update
         $updated++;
     }
     // update
     $membership_types_obj->save();
     // notify
     if (empty($message)) {
         // message
         $message = sprintf(__('Successfully updated %d membership type(s).', 'mgm'), $updated);
         // set status
         $status = 'success';
     }
     // return response
     echo json_encode(array('status' => $status, 'message' => $message));
     exit;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_admin_members.php

示例15: _buy_post

 function _buy_post()
 {
     global $wpdb;
     // get system settings
     $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 passthrough, stop further process if fails to parse
     $custom = $this->_get_transaction_passthrough($_POST['M_custom']);
     // local var
     extract($custom);
     // find user
     //issue #504
     if ($user_id) {
         $user = get_userdata($user_id);
     }
     $blogname = get_option('blogname');
     $tran_success = false;
     //getting purchase post title and & price - issue #981
     $post_obj = mgm_get_post($post_id);
     $purchase_cost = mgm_convert_to_currency($post_obj->purchase_cost);
     $post = get_post($post_id);
     $post_title = $post->post_title;
     // errors
     $errors = array();
     // check
     switch ($_POST['transStatus']) {
         case "Y":
             // status success
             $tran_success = true;
             // status str
             $status_str = __('Last payment was successful', 'mgm');
             //issue #504
             if ($user_id) {
                 // subject
                 $subject = $system_obj->get_template('payment_success_email_template_subject', array('blogname' => $blogname), true);
                 // body
                 $message = $system_obj->get_template('payment_success_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'admin_email' => $system_obj->setting['admin_email']), true);
             }
             // transaction id
             $transaction_id = $this->_get_transaction_id('M_custom');
             // hook args
             $args = array('post_id' => $post_id, 'transaction_id' => $transaction_id);
             // user purchase
             if (isset($user_id) && (int) $user_id > 0) {
                 $args['user_id'] = $user_id;
             } else {
                 // guest purchase
                 $args['guest_token'] = $guest_token;
             }
             // after succesful payment hook
             do_action('mgm_buy_post_transaction_success', $args);
             // backward compatibility
             do_action('mgm_post_purchase_payment_success', $args);
             // new organized name
             break;
         case "C":
             // status
             $status_str = __('Last payment was refunded or denied', 'mgm');
             //issue #504
             if ($user_id) {
                 // subject
                 $subject = $system_obj->get_template('payment_failed_email_template_subject', array('blogname' => $blogname), true);
                 // body
                 $message = $system_obj->get_template('payment_failed_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'payment_type' => 'post purchase payment', 'reason' => $status_str, 'admin_email' => $system_obj->setting['admin_email']), true);
             }
             // error
             $errors[] = $status_str;
             break;
         case "F":
             // reason
             $reason = 'Unknown';
             // status
             $status_str = sprintf(__('Last payment is pending. Reason: %s', 'mgm'), $reason);
             //issue #504
             if ($user_id) {
                 // subject
                 $subject = $system_obj->get_template('payment_pending_email_template_subject', array('blogname' => $blogname), true);
                 // body
                 $message = $system_obj->get_template('payment_pending_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'reason' => $status_str, 'admin_email' => $system_obj->setting['admin_email']), true);
             }
             // error
             $errors[] = $status_str;
             break;
         default:
             // status
             $status_str = sprintf(__('Last payment status: %s', 'mgm'), $_POST['rawAuthMessage']);
             //issue #504
             if ($user_id) {
                 // subject
                 $subject = $system_obj->get_template('payment_unknown_email_template_subject', array('blogname' => $blogname), true);
                 // body
                 $message = $system_obj->get_template('payment_unknown_email_template_body', array('blogname' => $blogname, 'name' => $user->display_name, 'post_title' => $post_title, 'purchase_cost' => $purchase_cost, 'email' => $user->user_email, 'reason' => $status_str, 'admin_email' => $system_obj->setting['admin_email']), true);
             }
             // error
             $errors[] = $status_str;
     }
     // do action
     do_action('mgm_return_post_purchase_payment_' . $this->module, array('post_id' => $post_id));
     // new, individual
//.........这里部分代码省略.........
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_worldpay.php


注:本文中的mgm_get_post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。