本文整理汇总了PHP中mgm_get_date_format函数的典型用法代码示例。如果您正苦于以下问题:PHP mgm_get_date_format函数的具体用法?PHP mgm_get_date_format怎么用?PHP mgm_get_date_format使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mgm_get_date_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query_rebill_status
//.........这里部分代码省略.........
//expire date
$member->expire_date = $new_expire_date;*/
// #1736 final fix
// verify txn id exists again
$this->_fetch_merchant_txn_id($member, true);
}
} else {
// set last pay date if greater than expire date
if (strtotime($member->last_pay_date) > strtotime($member->expire_date)) {
$member->expire_date = $member->last_pay_date;
}
}
}
// expire on error
if (isset($tran_response['response_status']) && (int) $tran_response['response_status'] == 5) {
// set as expired
$member->status = $new_status = MGM_STATUS_EXPIRED;
// status string
$member->status_str = sprintf(__('Last payment cycle expired. %s', 'mgm'), $tran_response['message_text']);
//expire date
$member->expire_date = $member->last_pay_date;
}
// set eway txn no
if (isset($tran_response['transId'])) {
$member->payment_info->authorizenet_txn_id = $tran_response['transId'];
}
// set eway txn no
if (isset($tran_response['batchId'])) {
$member->payment_info->authorizenet_batch_id = $tran_response['batchId'];
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// transaction_id
$transaction_id = $member->transaction_id;
// hook args
$args = array('user_id' => $user_id, 'transaction_id' => $transaction_id);
// after succesful payment hook
do_action('mgm_membership_transaction_success', $args);
// backward compatibility
do_action('mgm_subscription_purchase_payment_success', $args);
// new organized name
// }
break;
case 'canceled':
// if expire date in future, let as awaiting
if (!empty($member->expire_date) && strtotime($member->expire_date) > time()) {
// date format
$date_format = mgm_get_date_format('date_format');
// status
$member->status = $new_status = MGM_STATUS_AWAITING_CANCEL;
// status string
$member->status_str = sprintf(__('Subscription awaiting cancellation on %s', 'mgm'), date($date_format, strtotime($member->expire_date)));
// set reset date
$member->status_reset_on = $member->expire_date;
// reset as
$member->status_reset_as = MGM_STATUS_CANCELLED;
} else {
// set cancelled
// status
$member->status = $new_status = MGM_STATUS_CANCELLED;
// status string
$member->status_str = __('Last payment cycle cancelled', 'mgm');
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// after cancellation hook
do_action('mgm_membership_subscription_cancelled', array('user_id' => $user_id));
// }
break;
case 'suspended':
case 'terminated':
case 'expired':
// set new statis
$member->status = $new_status = MGM_STATUS_EXPIRED;
// status string
$member->status_str = __('Last payment cycle expired', 'mgm');
// save
$member->save();
break;
}
// action
if (isset($new_status) && $new_status != $old_status) {
// user status change
do_action('mgm_user_status_change', $user_id, $new_status, $old_status, 'module_' . $this->module, $member->pack_id);
// rebill status change
do_action('mgm_rebill_status_change', $user_id, $new_status, $old_status, 'query');
// query or notify
}
// return as a successful rebill
return true;
}
}
// return
return false;
//default to false to skip normal modules
}
示例2: post_purchase_export
function post_purchase_export()
{
global $wpdb;
// data
$data = array();
// filter
$sql_filter = $data['search_field_name'] = $data['search_field_value'] = '';
$search_field_name = mgm_post_var('search_field_name');
// check
if (!empty($search_field_name)) {
// post
$search_field_value = mgm_post_var('search_field_value');
$search_field_value_two = mgm_post_var('search_field_value_two');
// view data
$data['search_field_name'] = $search_field_name;
// for display
//issue #1281
$data['search_field_value'] = htmlentities($search_field_value, ENT_QUOTES, "UTF-8");
// for display
$data['search_field_value_two'] = htmlentities($search_field_value_two, ENT_QUOTES, "UTF-8");
// for display
//searc value
$search_field_value = esc_sql($search_field_value);
// for sql
// end date value
$search_field_value_two = esc_sql($search_field_value_two);
// for sql
//current date
$curr_date = mgm_get_current_datetime();
$current_date = $curr_date['timestamp'];
// by field
switch ($search_field_name) {
case 'user_login':
$sql_filter = " AND (`user_login` LIKE '%{$search_field_value}%' OR `guest_token` LIKE '%{$search_field_value}%')";
break;
case 'post_title':
$sql_filter = " AND (`post_title` LIKE '%{$search_field_value}%')";
break;
case 'is_gift':
$sql_filter = " AND (`is_gift` = '{$search_field_value}')";
break;
case 'purchase_dt':
// date start
if (empty($search_field_value)) {
$search_field_value = date('Y-m-d', $current_date);
}
// date end
if (empty($search_field_value_two)) {
$search_field_value_two = date('Y-m-d', $current_date);
}
// convert
$search_field_value = mgm_format_inputdate_to_mysql($search_field_value);
$search_field_value_two = mgm_format_inputdate_to_mysql($search_field_value_two);
// set
$sql_filter = " AND (DATE_FORMAT(`pp`.`purchase_dt`,'%Y-%m-%d') BETWEEN '{$search_field_value}' AND '{$search_field_value_two}')";
break;
}
}
// order
$sql_order = " ORDER BY u.user_login, p.post_title";
// sql
$sql = "SELECT SQL_CALC_FOUND_ROWS p.ID AS post_id, p.post_title, pp.purchase_dt, \r\r\n\t\t IF(user_id IS NULL, CONCAT('guest-', guest_token), u.user_login) AS user_login, pp.id,\r\r\n\t\t pp.is_gift,pp.is_expire FROM `" . TBL_MGM_POST_PURCHASES . "` pp \r\r\n\t\t\t\tLEFT JOIN " . $wpdb->posts . " p ON (p.id = pp.post_id) \r\r\n\t\t\t\tLEFT JOIN " . $wpdb->users . " u ON (u.ID = pp.user_id) WHERE 1 \r\r\n\t\t\t\t{$sql_filter} {$sql_order} ";
// log
// mgm_log($sql);
// store
$data['post_purchases'] = $wpdb->get_results($sql);
// date format
$date_format = mgm_get_date_format('date_format');
// init
$purchases = array();
// check
if (count($data['post_purchases']) > 0) {
//purchases
foreach ($data['post_purchases'] as $purchase) {
// int
$row = new stdClass();
// type
$type = $purchase->is_gift == 'Y' ? __('Gift', 'mgm') : __('Purchase', 'mgm');
// check is_expiry
if ($purchase->is_expire == 'N') {
$expiry = __('Indefinite', 'mgm');
} else {
$expiry = mgm_get_post($purchase->post_id)->get_access_duration();
$expiry = !$expiry ? __('Indefinite', 'mgm') : date($date_format, 86400 * $expiry + strtotime($purchase->purchase_dt)) . " (" . $expiry . __(' D', 'mgm') . ")";
}
// member name
if (preg_match('/^guest-/', $purchase->user_login)) {
// guest token
$guest_token = str_replace('guest-', '', $purchase->user_login);
// username
$username = __('Guest', 'mgm') . sprintf(' (%s)', $guest_token);
} else {
// username
$username = $purchase->user_login;
}
//export fields
$row->username = $username;
$row->post = $purchase->post_title;
$row->type = $type;
$row->expire_date = $expiry;
//.........这里部分代码省略.........
示例3: _do_import_users
//.........这里部分代码省略.........
// continue
continue;
}
// set new user
$new_users[$id]['email'] = $email;
$new_users[$id]['user_login'] = $user_login;
// update option
update_user_option($id, 'default_password_nag', true, true);
// flag
$insert_user = true;
} else {
// set id to user
$id = $_user->ID;
}
// unset
unset($_user);
} else {
// login/email not present
// log
// mgm_log(sprintf('step 5: %s, %s ', $user_login, $email), __FUNCTION__);
// continue
continue;
//skip the record
}
} else {
// update
$update_user = true;
}
// get User object:
$user = new WP_user($id);
// log
// mgm_log(sprintf('step 6: %s ', print_r($user,1)), __FUNCTION__);
//issue #700
$format = mgm_get_date_format('date_format_short');
// ------------------------------------------
// user to mgm member
if (isset($user->ID) && $user->ID > 0) {
// get mgm object:
$member = mgm_get_member($user->ID);
// update custom fields:
if (!empty($member)) {
// update pack id if not supplied and already exists
// This is to make pack_id optional: issue#: 807
if (!is_numeric($pack_id) && isset($member->pack_id) && $member->pack_id > 0) {
$pack_id = $member->pack_id;
}
// update misc fields:
if (!isset($member->rss_token) || isset($member->rss_token) && empty($member->rss_token)) {
$member->rss_token = mgm_create_rss_token();
}
// init
$user_password_enc = mgm_encrypt_password($user_password, $user->ID, $member->rss_token);
// mgm_log($user_password_enc, __FUNCTION__);
// check
if ($cf_count > 0) {
// loop custom fields
foreach ($cf_register_page as $field) {
// key
$key = $field['name'];
// mgm_log($key, __FUNCTION__);
// skip unwanted fields
if (in_array($field['name'], $cf_exclude_names) || in_array($field['type'], $cf_exclude_types)) {
// log
// mgm_log(sprintf('step 7: %s ', $field['name']), __FUNCTION__);
// continue
continue;
示例4: _cancel_membership
function _cancel_membership($user_id, $redirect = false)
{
// system
$system_obj = mgm_get_class('system');
$s_packs = mgm_get_class('subscription_packs');
$dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
$dpne = bool_from_yn($system_obj->get_setting('disable_payment_notify_emails'));
//issue #1521
$is_admin = is_super_admin() ? true : false;
// find user
$user = get_userdata($user_id);
$member = mgm_get_member($user_id);
// multiple membesrhip level update:
$multiple_update = false;
// check
if (isset($_POST['membership_type']) && $member->membership_type != $_POST['membership_type']) {
$multiple_update = true;
$member = mgm_get_member_another_purchase($user_id, $_POST['membership_type']);
}
// get pack
if ($member->pack_id) {
$subs_pack = $s_packs->get_pack($member->pack_id);
} else {
$subs_pack = $s_packs->validate_pack($member->amount, $member->duration, $member->duration_type, $member->membership_type);
}
// reset payment info
$member->payment_info->txn_type = 'subscription_cancel';
// types
$duration_exprs = $s_packs->get_duration_exprs();
// default expire date
$expire_date = $member->expire_date;
// if lifetime:
if ($member->duration_type == 'l') {
$expire_date = date('Y-m-d');
}
// if trial on
if ($subs_pack['trial_on'] && isset($duration_exprs[$subs_pack['trial_duration_type']])) {
// if cancel data is before trial end, set cancel on trial expire_date
$trial_expire_date = strtotime("+{$subs_pack['trial_duration']} {$duration_exprs[$subs_pack['trial_duration_type']]}", $member->join_date);
// if lower
if (time() < $trial_expire_date) {
$expire_date = date('Y-m-d', $trial_expire_date);
}
}
// transaction_id
$trans_id = $member->transaction_id;
// if today
if ($expire_date == date('Y-m-d')) {
// status
$new_status = MGM_STATUS_CANCELLED;
$new_status_str = __('Subscription cancelled', 'mgm');
// set
$member->status = $new_status;
$member->status_str = $new_status_str;
$member->expire_date = date('Y-m-d');
// reassign expiry membership pack if exists: issue#: 535
$member = apply_filters('mgm_reassign_member_subscription', $user_id, $member, 'CANCEL', true);
} else {
// date
$date_format = mgm_get_date_format('date_format');
// status
$new_status = MGM_STATUS_AWAITING_CANCEL;
$new_status_str = sprintf(__('Subscription awaiting cancellation on %s', 'mgm'), date($date_format, strtotime($expire_date)));
// set
$member->status = $new_status;
$member->status_str = $new_status_str;
// set reset date
$member->status_reset_on = $expire_date;
$member->status_reset_as = MGM_STATUS_CANCELLED;
}
// multiple memberhip level update:
if ($multiple_update) {
mgm_save_another_membership_fields($member, $user_id);
} else {
$member->save();
}
// transaction status
mgm_update_transaction_status($trans_id, $new_status, $new_status_str);
// send email notification to client
$blogname = get_option('blogname');
// notify user
if (!$dpne) {
// notify user
mgm_notify_user_membership_cancellation($blogname, $user, $member, $system_obj, $new_status, $membership_type);
}
// notify admin
if (!$dge) {
// notify admin
mgm_notify_admin_membership_cancellation($blogname, $user, $member);
}
// after cancellation hook
do_action('mgm_membership_subscription_cancelled', array('user_id' => $user_id));
// redirect only internal
if ($redirect) {
// message
$lformat = mgm_get_date_format('date_format_long');
$message = sprintf(__("You have successfully unsubscribed. Your account has been marked for cancellation on %s", "mgm"), $expire_date == date('Y-m-d') ? 'Today' : date($lformat, strtotime($expire_date)));
//issue #1521
if ($is_admin) {
mgm_redirect(add_query_arg(array('user_id' => $user_id, 'unsubscribe_errors' => urlencode($message)), admin_url('user-edit.php')));
//.........这里部分代码省略.........
示例5: get_pack_desc
/**
* 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;
}
示例6: query_rebill_status
/**
* Specifically check recurring status of each rebill for an expiry date
* ALong with IPN post mechanism for rebills, the module will need to specifically request for the rebill status
* @param int $user_id
* @param object $member
* @return boolean
*/
function query_rebill_status($user_id, $member = NULL)
{
// check
if (isset($member->payment_info->subscr_id) && !empty($member->payment_info->subscr_id)) {
// id
$subscr_id = $member->payment_info->subscr_id;
// check
if ($this->response = $this->_get_api_notify('get_customer', null, $subscr_id)) {
// log
mgm_log($this->response, $this->module . '_' . __FUNCTION__);
// old status
$old_status = $member->status;
// check
$subscription_status = 'not found';
if (isset($this->response->subscription->status) && !empty($this->response->subscription->status)) {
$subscription_status = strtolower($this->response->subscription->status);
}
// log
mgm_log('subscription_status: ' . $subscription_status, $this->module . '_' . __FUNCTION__);
// set status
switch ($subscription_status) {
case 'active':
case 'trialing':
// set new status
$member->status = $new_status = MGM_STATUS_ACTIVE;
// status string
$member->status_str = __('Last payment cycle processed successfully', 'mgm');
// start date
$current_period_start = $this->response->subscription->current_period_start;
// trial fix
if ('trialing' == $subscription_status) {
// expire
if (empty($member->expire_date)) {
$member->expire_date = date('Y-m-d', $this->response->subscription->trial_end);
}
// start date
$current_period_start = $this->response->subscription->trial_start;
// status string
$member->status_str = __('Last trial cycle processed successfully', 'mgm');
}
// last pay date
$member->last_pay_date = isset($current_period_start) && !empty($current_period_start) ? date('Y-m-d', $current_period_start) : date('Y-m-d');
// expire date
if (isset($current_period_start) && !empty($current_period_start) && !empty($member->expire_date)) {
// date to add
$date_add = mgm_get_pack_cycle_date((int) $member->pack_id, $member);
// check
if ($date_add !== false) {
// new expire date should be later than current expire date, #1223
$new_expire_date = date('Y-m-d', strtotime($date_add, strtotime($member->last_pay_date)));
// apply on last pay date so the calc always treat last pay date form gateway,
if (strtotime($new_expire_date) > strtotime($member->expire_date)) {
$member->expire_date = $new_expire_date;
}
} else {
// set last pay date if greater than expire date
if (strtotime($member->last_pay_date) > strtotime($member->expire_date)) {
$member->expire_date = $member->last_pay_date;
}
}
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// transaction_id
$transaction_id = $member->transaction_id;
// hook args
$args = array('user_id' => $user_id, 'transaction_id' => $transaction_id);
// after succesful payment hook
do_action('mgm_membership_transaction_success', $args);
// backward compatibility
do_action('mgm_subscription_purchase_payment_success', $args);
// new organized name
// }
break;
case 'canceled':
// if expire date in future, let as awaiting
if (!empty($member->expire_date) && strtotime($member->expire_date) > time()) {
// date format
$date_format = mgm_get_date_format('date_format');
// status
$member->status = $new_status = MGM_STATUS_AWAITING_CANCEL;
// status string
$member->status_str = sprintf(__('Subscription awaiting cancellation on %s', 'mgm'), date($date_format, strtotime($member->expire_date)));
// set reset date
$member->status_reset_on = $member->expire_date;
// reset as
$member->status_reset_as = MGM_STATUS_CANCELLED;
} else {
// set cancelled
// status
$member->status = $new_status = MGM_STATUS_CANCELLED;
//.........这里部分代码省略.........
示例7: mgm_manage_users_custom_column
/**
* add row to users list
*
* @param mixed $column_data
* @param string $column
* @param int $user_id
* @return void
*/
function mgm_manage_users_custom_column($column_data, $column, $user_id)
{
// column
switch ($column) {
case 'subscription':
// nothing for admin
if (is_super_admin($user_id)) {
return __('n/a', 'mgm');
}
// date format
$date_format = mgm_get_date_format('date_format');
// user object
$user = get_userdata($user_id);
// member
$member = mgm_get_member($user_id);
// packs
$packs = mgm_get_class('subscription_packs');
// pack
if (isset($member->pack_id)) {
$membership = $packs->get_pack_desc($packs->get_pack($member->pack_id));
} else {
$membership = __('Guest', 'mgm');
}
// set
$subscription = sprintf('<div>%s</div>', $membership);
$subscription .= sprintf('<div><span class="overline">%s:</span> %s</div>', __('REGISTER', 'mgm'), date($date_format, strtotime($user->user_registered)));
$subscription .= sprintf('<div><span class="mgm_color_gray">%s:</span> %s</div>', __('EXPIRY', 'mgm'), empty($member->expire_date) ? __('N/A', 'mgm') : date($date_format, strtotime($member->expire_date)));
$subscription .= sprintf('<div><span class="mgm_color_gray">%s:</span> %s</div>', __('PACK JOIN', 'mgm'), empty($member->join_date) ? __('N/A', 'mgm') : date($date_format, $member->join_date));
$subscription .= sprintf('<div><span class="mgm_color_gray">%s:</span> <span class="%s"><b>%s</b></span> %s</div>', __('STATUS', 'mgm'), mgm_get_status_css_class($member->status), esc_html($member->status), !empty($member->status_str) ? '<br />' . esc_html($member->status_str) : '');
$subscription .= sprintf('<div><span class="mgm_color_gray">%s:</span> %s</div>', __('LAST PAY', 'mgm'), empty($member->last_pay_date) ? __('N/A', 'mgm') : date($date_format, strtotime($member->last_pay_date)));
// return
return $subscription;
break;
}
// return
return $column_data;
}
示例8: edit
function edit()
{
global $wpdb;
extract($_POST);
// save
if (isset($save_coupon)) {
// response
$response = array('status' => 'error', 'message' => __('Coupon update failed, Unknown error!', 'mgm'));
// check duplicate
if (mgm_is_duplicate(TBL_MGM_COUPON, array('name'), "id <> '{$id}'")) {
$response['message'] = sprintf(__('Error while updating coupon: %s, same code exists!', 'mgm'), $name);
} else {
// fields
$fields = array('name', 'value', 'description', 'use_limit', 'used_count', 'product', 'expire_dt');
// colums
$column_data = $column_null_data = array();
// create value
$value = $this->_set_value();
// use limit
if (isset($use_limit) && is_numeric($use_limit)) {
$use_limit = (int) $use_limit;
} else {
$use_limit = NULL;
}
// product
if (isset($product)) {
$product = json_encode($product);
} else {
$product = NULL;
}
// expire dt format
if (isset($expire_dt) && !empty($expire_dt)) {
$expire_dt = date('Y-m-d H:i:s', strtotime(mgm_format_inputdate_to_mysql($expire_dt, mgm_get_date_format('date_format_short'))));
} else {
$expire_dt = NULL;
}
// loop
foreach ($fields as $field) {
// check
if (isset(${$field}) && !is_null(${$field})) {
$column_data[$field] = trim(${$field});
} else {
$column_null_data[$field] = 'NULL';
// need string to track
}
}
// affected
$affected = 0;
// update
if ($wpdb->update(TBL_MGM_COUPON, $column_data, array('id' => $id))) {
$affected++;
}
// null
if (!empty($column_null_data)) {
// column_data2
$column_data2_a = mgm_implode_a(',', array_keys($column_null_data), array_values($column_null_data));
// update
if ($wpdb->query("UPDATE `" . TBL_MGM_COUPON . "` SET {$column_data2_a} WHERE id='{$id}' ")) {
$affected++;
}
}
// save
if ($affected) {
$response = array('status' => 'success', 'message' => sprintf(__('Successfully updated coupon: "%s"', 'mgm'), $name));
} else {
$response = array('status' => 'error', 'message' => sprintf(__('Error while updating coupon: "%s"', 'mgm'), $name));
}
}
// return response
echo json_encode($response);
exit;
}
// data
$data = array();
// coupon
$data['coupon'] = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . TBL_MGM_COUPON . "` WHERE id=%d", $id));
// parse
$data['value_is'] = $this->_get_value($data['coupon']->value);
// currency
$data['currency'] = mgm_get_class('system')->setting['currency'];
// load template view
$this->load->template('coupons/edit', array('data' => $data));
}
示例9: query_rebill_status
//.........这里部分代码省略.........
$member->last_pay_date = $last_pay_date;
//date('Y-m-d', strtotime($last_pay_date));
// last pay date
// $member->last_pay_date = (isset($response['LASTPAYMENTDATE'])) ? date('Y-m-d', strtotime($response['LASTPAYMENTDATE'])) : date('Y-m-d');
// expire date
if (isset($response['NEXTPAYMENT']) && !empty($member->expire_date)) {
// date to add
// $date_add = mgm_get_pack_cycle_date((int)$member->pack_id, $member);
// check
if ($date_add !== false) {
// new expire date should be later than current expire date, #1223
$new_expire_date = date('Y-m-d', strtotime($date_add, strtotime($member->last_pay_date)));
// apply on last pay date so the calc always treat last pay date form gateway
if (strtotime($new_expire_date) > strtotime($member->expire_date)) {
$member->expire_date = $new_expire_date;
}
} else {
// set last pay date if greater than expire date
if (strtotime($member->last_pay_date) > strtotime($member->expire_date)) {
$member->expire_date = $member->last_pay_date;
}
}
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// transaction_id
$transaction_id = $member->transaction_id;
// hook args
$args = array('user_id' => $user_id, 'transaction_id' => $transaction_id);
// after succesful payment hook
do_action('mgm_membership_transaction_success', $args);
// backward compatibility
do_action('mgm_subscription_purchase_payment_success', $args);
// new organized name
// }
break;
case 'VENDOR INACTIVE':
case 'DEACTIVATED BY MERCHANT':
// if expire date in future, let as awaiting
if (!empty($member->expire_date) && strtotime($member->expire_date) > time()) {
// date format
$date_format = mgm_get_date_format('date_format');
// set new status
$member->status = $new_status = MGM_STATUS_AWAITING_CANCEL;
// status string
$member->status_str = sprintf(__('Subscription awaiting cancellation on %s', 'mgm'), date($date_format, strtotime($member->expire_date)));
// set reset date
$member->status_reset_on = $member->expire_date;
// reset as
$member->status_reset_as = MGM_STATUS_CANCELLED;
} else {
// set cancelled
// set new status
$member->status = $new_status = MGM_STATUS_CANCELLED;
// status string
$member->status_str = __('Last payment cycle cancelled', 'mgm');
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// after cancellation hook
do_action('mgm_membership_subscription_cancelled', array('user_id' => $user_id));
// }
break;
case 'EXPIRED':
// set new status
$member->status = $new_status = MGM_STATUS_EXPIRED;
// status string
$member->status_str = __('Last payment cycle expired', 'mgm');
// save
$member->save();
break;
case 'TOO MANY FAILURES':
// set new status
$member->status = $new_status = MGM_STATUS_NULL;
// status string
$member->status_str = __('Last payment cycle failed, too many failed transactions.', 'mgm');
// save
$member->save();
break;
}
// action
if (isset($new_status) && $new_status != $old_status) {
// user status change
do_action('mgm_user_status_change', $user_id, $new_status, $old_status, 'module_' . $this->module, $member->pack_id);
// rebill status change
do_action('mgm_rebill_status_change', $user_id, $new_status, $old_status, 'query');
// query or notify
}
// return as a successful rebill
return true;
}
}
// return
return false;
//default to false to skip normal modules
}
示例10: cancel_recurring_subscription
/**
* Cancel Recurring Subscription
* This is not a private function
* @param int/string $trans_ref
* @param int $user_id
* @param int/string $subscr_id
* @return boolean
*/
function cancel_recurring_subscription($trans_ref = null, $user_id = null, $subscr_id = null, $pack_id = null)
{
//if coming form process return after a subscription payment
if (!empty($trans_ref)) {
$transdata = $this->_get_transaction_passthrough($trans_ref);
if ($transdata['payment_type'] != 'subscription_purchase') {
return false;
}
$user_id = $transdata['user_id'];
if (isset($transdata['is_another_membership_purchase']) && $transdata['is_another_membership_purchase'] == 'Y') {
$member = mgm_get_member_another_purchase($user_id, $transdata['membership_type']);
} else {
$member = mgm_get_member($user_id);
}
if (isset($member->payment_info->module) && !empty($member->payment_info->module)) {
$subscr_id = null;
if (!empty($member->payment_info->subscr_id)) {
$subscr_id = $member->payment_info->subscr_id;
} elseif (!empty($member->pack_id)) {
//check the pack is recurring
$s_packs = mgm_get_class('subscription_packs');
$sel_pack = $s_packs->get_pack($member->pack_id);
if ($sel_pack['num_cycles'] != 1) {
$subscr_id = 0;
}
// 0 stands for a lost subscription id
}
//check for same module: if not call the same function of the applicale module.
if (str_replace('mgm_', '', $member->payment_info->module) != str_replace('mgm_', '', $this->code)) {
// mgm_log('RECALLing '. $member->payment_info->module .': cancel_recurring_subscription FROM: ' . $this->code);
return mgm_get_module($member->payment_info->module, 'payment')->cancel_recurring_subscription($trans_ref, null, null, $pack_id);
}
//skip if same pack is updated
if (empty($member->pack_id) || is_numeric($pack_id) && $pack_id == $member->pack_id) {
return false;
}
} else {
return false;
}
}
// when a subscription found
if ($subscr_id) {
$user = get_userdata($user_id);
$date_format = mgm_get_date_format('date_format');
// post data
$post_data = array('USER' => $this->setting['ap_merchant'], 'PASSWORD' => $this->setting['ap_apipassword'], 'SUBSCRIPTIONREFERENCE' => $subscr_id, 'NOTE' => sprintf('Cancellation selected by member: "%s", ID: %d on: %s', $user->user_email, $user->ID, date($date_format)), 'TESTMODE' => $this->status == 'test' ? '1' : '0');
// url
$unsubscribe_url = $this->_get_endpoint('unsubscribe');
// headers
$http_headers = array();
// create curl post
$http_response = mgm_remote_post($unsubscribe_url, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
// parse
@parse_str($http_response, $data);
// verify
if (isset($data['REFERENCENUMBER']) && $data['RETURNCODE'] == 100) {
return true;
} elseif (isset($data['DESCRIPTION'])) {
//error string
return $data['DESCRIPTION'];
}
} elseif (is_null($subscr_id) || $subscr_id === 0) {
//send email to admin if subscription Id is absent
$system_obj = mgm_get_class('system');
$dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
// check
if (!$dge) {
// blog
$blogname = get_option('blogname');
// user
$user = get_userdata($user_id);
// notify admin
mgm_notify_admin_membership_cancellation_manual_removal_required($blogname, $user, $member);
}
// return
return true;
}
// return
return false;
}
示例11: member_export
function member_export()
{
global $wpdb;
// error -- use WP_DEBUG with WP_DEBUG_LOG
// if(!WP_DEBUG) error_reporting(0);
// extract
extract($_POST);
// log
// mgm_log($_POST, __FUNCTION__);
// get format
$sformat = mgm_get_date_format('date_format_short');
// process
if (isset($export_member_info)) {
// init
$success = 0;
// type
$membership_type = isset($bk_membership_type) ? $bk_membership_type : 'all';
// status
$membership_status = isset($bk_membership_status) ? $bk_membership_status : 'all';
// date
$date_start = isset($bk_date_start) ? $bk_date_start : '';
$date_end = isset($bk_date_end) ? $bk_date_end : '';
// query inut
$query = '';
// selected only
if (isset($bk_only_selected)) {
// check
if (isset($bk_selected_members) && is_array($bk_selected_members)) {
$query = " AND `id` IN(" . mgm_map_for_in($bk_selected_members) . ")";
}
}
// start date
if ($date_start) {
// Issue #700
// convert to mysql date
$date_start = strtotime(mgm_format_inputdate_to_mysql($date_start, $sformat));
// end date
if ($date_end) {
// Issue #700
// convert to mysql date
$date_end = mgm_format_inputdate_to_mysql($date_end, $sformat);
$date_end = strtotime($date_end);
// issue#" 492
$query .= " AND UNIX_TIMESTAMP(user_registered) >= '{$date_start}' \r\r\n\t\t\t\t\t AND UNIX_TIMESTAMP(DATE_FORMAT(user_registered, '%Y-%m-%d')) <= '{$date_end}'";
} else {
$query .= " AND UNIX_TIMESTAMP(user_registered) >= '{$date_start}'";
}
} else {
if ($date_end) {
// Issue #700
// convert to mysql date
$date_end = strtotime(mgm_format_inputdate_to_mysql($date_end, $sformat));
// query
$query .= " AND UNIX_TIMESTAMP(DATE_FORMAT(user_registered, '%Y-%m-%d')) <= '{$date_end}' ";
}
}
// all users
$sql = 'SELECT ID, user_login, user_email, user_registered, display_name FROM `' . $wpdb->users . '`
WHERE ID <> 1 ' . $query . ' ORDER BY `user_registered` ASC';
// users
$users = $wpdb->get_results($sql);
// filter
$export_users = array();
// date
$current_date = time();
//issue #844
$skip_fileds = array('subscription_introduction', 'coupon', 'privacy_policy', 'payment_gateways', 'terms_conditions', 'subscription_options', 'autoresponder', 'captcha');
// check - issue #1382
if (isset($bk_users_to_import)) {
$custom_fields = mgm_get_class('member_custom_fields')->get_fields_where(array('display' => array('on_register' => true, 'on_profile' => true)));
$import_user_fileds = array('user_login', 'user_email', 'pack_id', 'membership_type');
foreach ($custom_fields as $field) {
if (!in_array($field['name'], $skip_fileds)) {
$import_user_fileds[] = $field['name'];
}
}
}
// Custom fields
$cf_profile_pg = mgm_get_class('member_custom_fields');
$to_unserialize = array();
foreach (array_unique($cf_profile_pg->sort_orders) as $id) {
foreach ($cf_profile_pg->custom_fields as $field) {
// issue #954: show the field only if it is enabled for profile page
if ($field['id'] == $id && $field['type'] == 'checkbox') {
$to_unserialize[] = $field['name'];
}
}
}
// loop
foreach ($users as $user) {
// user cloned
$user_obj = clone $user;
// member
$member = mgm_get_member($user->ID);
// check
if (!isset($bk_inactive)) {
$bk_inactive = false;
}
// check search parameters:
if ($this->_get_membership_details($member, $bk_msexp_dur_unit, $bk_msexp_dur, $membership_type, $current_date, $bk_inactive, $membership_status)) {
//.........这里部分代码省略.........
示例12: query_rebill_status
//.........这里部分代码省略.........
// status string
$member->status_str = __('Last payment cycle processed successfully', 'mgm');
// last pay date
$member->last_pay_date = isset($response['last_trans_date']) && !empty($response['last_trans_date']) ? $response['last_trans_date'] : date('Y-m-d');
// expire date
if (isset($response['last_trans_date']) && !empty($response['last_trans_date']) && !empty($member->expire_date)) {
// date to add
$date_add = mgm_get_pack_cycle_date((int) $member->pack_id, $member);
// check
if ($date_add !== false) {
// new expire date should be later than current expire date, #1223
$new_expire_date = date('Y-m-d', strtotime($date_add, strtotime($member->last_pay_date)));
// apply on last pay date so the calc always treat last pay date form gateway,
if (strtotime($new_expire_date) > strtotime($member->expire_date)) {
$member->expire_date = $new_expire_date;
}
} else {
// set last pay date if greater than expire date
if (strtotime($member->last_pay_date) > strtotime($member->expire_date)) {
$member->expire_date = $member->last_pay_date;
}
}
}
// set eway txn no
if (isset($response['trans_id'])) {
$member->payment_info->epoch_txn_id = $response['trans_id'];
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// transaction_id
$transaction_id = $member->transaction_id;
// hook args
$args = array('user_id' => $user_id, 'transaction_id' => $transaction_id);
// after succesful payment hook
do_action('mgm_membership_transaction_success', $args);
// backward compatibility
do_action('mgm_subscription_purchase_payment_success', $args);
// new organized name
// }
break;
case 'Canceled':
case 'Cancelled Recurring':
case 'Cancelled Trial':
case 'Cancelled Preview':
// if expire date in future, let as awaiting
if (!empty($member->expire_date) && strtotime($member->expire_date) > time()) {
// date format
$date_format = mgm_get_date_format('date_format');
// status
$member->status = $new_status = MGM_STATUS_AWAITING_CANCEL;
// status string
$member->status_str = sprintf(__('Subscription awaiting cancellation on %s', 'mgm'), date($date_format, strtotime($member->expire_date)));
// set reset date
$member->status_reset_on = $member->expire_date;
// reset as
$member->status_reset_as = MGM_STATUS_CANCELLED;
} else {
// set cancelled
// status
$member->status = $new_status = MGM_STATUS_CANCELLED;
// status string
$member->status_str = __('Last payment cycle cancelled', 'mgm');
}
// save
$member->save();
// only run in cron, other wise too many tracking will be added
// if( defined('DOING_QUERY_REBILL_STATUS') && DOING_QUERY_REBILL_STATUS != 'manual' ){
// after cancellation hook
do_action('mgm_membership_subscription_cancelled', array('user_id' => $user_id));
// }
break;
case 'Suspended':
case 'Terminated':
case 'Expired':
// set new statis
$member->status = $new_status = MGM_STATUS_EXPIRED;
// status string
$member->status_str = __('Last payment cycle expired', 'mgm');
// save
$member->save();
break;
}
// action
if (isset($new_status) && $new_status != $old_status) {
// user status change
do_action('mgm_user_status_change', $user_id, $new_status, $old_status, 'module_' . $this->module, $member->pack_id);
// rebill status change
do_action('mgm_rebill_status_change', $user_id, $new_status, $old_status, 'query');
// query or notify
}
// return as a successful rebill
return true;
}
}
// return
return false;
//default to false to skip normal modules
}
示例13: mgm_expire_member
/**
* expire member: for force expire test
*/
function mgm_expire_member($user_id, $expire_date)
{
// get member
$member = mgm_get_member($user_id);
// if today
if ($expire_date == date('Y-m-d')) {
$new_status = MGM_STATUS_CANCELLED;
$new_status_str = __('Subscription cancelled', 'mgm');
$member->status = $new_status;
$member->status_str = $new_status_str;
$member->expire_date = date('Y-m-d');
} else {
$format = mgm_get_date_format('date_format');
// status
$new_status = MGM_STATUS_AWAITING_CANCEL;
$new_status_str = sprintf(__('Subscription awaiting cancellation on %s', 'mgm'), date($format, strtotime($expire_date)));
// set reset date
$member->status_reset_on = $expire_date;
$member->status_reset_as = MGM_STATUS_CANCELLED;
}
// update user
// update_user_option($user_id, 'mgm_member', $member, true);
$member->save();
}
示例14: _e
<div class="cell theadDivCell width100px">
<b><?php
_e('Purchase/Gift Date', 'mgm');
?>
</b>
</div>
<div class="cell theadDivCell width100px">
<b><?php
_e('Action', 'mgm');
?>
</b>
</div>
</div>
<?php
$date_format = mgm_get_date_format('date_format');
$date_format_time = mgm_get_date_format('date_format_time');
// loop
if ($data['post_purchases']) {
foreach ($data['post_purchases'] as $purchase) {
// check is_expiry
if ($purchase->is_expire == 'N') {
$expiry = __('Indefinite', 'mgm');
} else {
$expiry = mgm_get_post($purchase->post_id)->get_access_duration();
$expiry = !$expiry ? __('Indefinite', 'mgm') : date('d/m/Y', 86400 * $expiry + strtotime($purchase->purchase_dt)) . " (" . $expiry . __(' D', 'mgm') . ")";
}
// member name
if (preg_match('/^guest-/', $purchase->user_login)) {
// guest token
$guest_token = str_replace('guest-', '', $purchase->user_login);
// member
示例15: mgm_get_admin_user_unsubscribe_status_button
/**
* Admin user edit screen unsubscribe staus button
*/
function mgm_get_admin_user_unsubscribe_status_button($member, $user)
{
// init
$html = '';
// object
$packs_obj = mgm_get_class('subscription_packs');
$pack_name = $packs_obj->get($member->pack_id);
// cancelled
if ($member->status == MGM_STATUS_CANCELLED) {
$html .= '<span class="s-active"><b>' . $pack_name['description'] . '</b></span>';
$html .= '<div class="mgm_margin_bottom_10px s-expired">' . '<h4>' . __('Unsubscribed', 'mgm') . '</h4>' . '<div class="mgm_margin_bottom_10px mgm_color_red">' . __('You have unsubscribed.', 'mgm') . '</div>' . '</div>';
$html .= '<hr/>';
} elseif (isset($member->status_reset_on) && isset($member->status_reset_as) && $member->status == MGM_STATUS_AWAITING_CANCEL) {
$lformat = mgm_get_date_format('date_format_long');
$html .= '<span class="s-active"><b>' . $pack_name['description'] . '</b></span>';
$html .= '<div class="mgm_margin_bottom_10px s-expired">' . '<h4>' . __('Unsubscribed', 'mgm') . '</h4>' . '<div class="mgm_margin_bottom_10px mgm_color_red">' . sprintf(__('You have unsubscribed. Your account has been marked for cancellation on <b>%s</b>.', 'mgm'), date($lformat, strtotime($member->status_reset_on))) . '</div>' . '</div>';
$html .= '<hr/>';
} else {
// show unsucscribe button
if (is_super_admin()) {
// check
if ($module = $member->payment_info->module) {
// if a valid module
if ($obj_module = mgm_is_valid_module($module, 'payment', 'object')) {
// output button
$html .= '<span class="s-active"><b>' . $pack_name['description'] . '</b></span>';
$html .= $obj_module->get_button_unsubscribe(array('user_id' => $user->ID, 'membership_type' => $member->membership_type));
$html .= '<script language="javascript">' . 'confirm_unsubscribe=function(element){' . 'if(confirm("' . __('You are about to unsubscribe. Do you want to proceed?', 'mgm') . '")){' . 'jQuery(element).closest("form").submit();' . '}' . '}' . '</script>';
$html .= '<hr/>';
}
}
}
}
return $html;
}