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


PHP bool_from_yn函数代码示例

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


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

示例1: settings_update

 function settings_update()
 {
     // form type
     switch ($_POST['setting_form']) {
         case 'main':
             // form main
             // set fields
             $this->setting['clientid'] = $_POST['setting']['clientid'];
             $this->setting['formid'] = $_POST['setting']['formid'];
             $this->setting['listid'] = $_POST['setting']['listid'];
             $this->setting['specialid'] = $_POST['setting']['specialid'];
             $this->setting['doubleopt'] = $_POST['setting']['doubleopt'];
             // fieldmap
             $this->setting['fieldmap'] = $this->_make_assoc($_POST['setting']['fieldmap']);
             // membershipmap
             $this->setting['membershipmap'] = $this->_make_assoc($_POST['setting']['membershipmap']);
             // update enable/disable
             $this->enabled = $_POST['enabled'];
             // enable/disable method
             $activate_method = bool_from_yn($this->enabled) ? 'activate_module' : 'deactivate_module';
             // update
             $ret = call_user_func_array(array(mgm_get_class('system'), $activate_method), array($this->code, $this->type));
             // save object options
             $this->save();
             // message
             return json_encode(array('status' => 'success', 'message' => sprintf(__('%s settings updated', 'mgm'), $this->name)));
             break;
         case 'box':
         default:
             // from box
             // set fields
             $this->setting['clientid'] = $_POST['setting']['icontact']['clientid'];
             $this->setting['formid'] = $_POST['setting']['icontact']['formid'];
             $this->setting['listid'] = $_POST['setting']['icontact']['listid'];
             $this->setting['specialid'] = $_POST['setting']['icontact']['specialid'];
             $this->setting['doubleopt'] = $_POST['setting']['icontact']['doubleopt'];
             // update object options
             $this->save();
             // message
             return json_encode(array('status' => 'success', 'message' => sprintf(__('%s settings updated', 'mgm'), $this->name)));
             break;
     }
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:43,代码来源:mgm_icontact.php

示例2: _auto_login

 /**
  * API helper method auto login after subscribed
  *
  * @param int $user_id / transaction_id
  * @return bool
  */
 function _auto_login($id)
 {
     // get setting
     $setting = mgm_get_class('system')->get_setting();
     // if autologin not enabled
     if (!isset($setting['enable_autologin']) || isset($setting['enable_autologin']) && !bool_from_yn($setting['enable_autologin'])) {
         return false;
     }
     // check when enabled
     if (is_numeric($id)) {
         // user id
         $user_id = null;
         // get custom param
         $custom = $this->_get_transaction_passthrough($id);
         // verify if not subs purchase
         if ($custom['payment_type'] != 'subscription_purchase' || (!isset($custom['is_registration']) || isset($custom['is_registration']) && !bool_from_yn($custom['is_registration']))) {
             return false;
         }
         // fetch user id
         if (is_numeric($custom['user_id']) && $custom['user_id'] > 0) {
             // return id // #711, autologin is done in background
             mgm_auto_login($id);
             // redirect url for register & purchase
             if (isset($custom['post_id'])) {
                 return get_permalink($custom['post_id']);
             } elseif (isset($custom['postpack_post_id']) && isset($custom['postpack_id'])) {
                 return get_permalink($custom['postpack_post_id']);
             } else {
                 return true;
             }
         }
     }
     // return false
     return false;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:41,代码来源:mgm_payment.php

示例3: sandbox_init

function sandbox_init()
{
    load_theme_textdomain('sandbox');
    if ($GLOBALS['pagenow'] == 'themes.php' && isset($_GET['page']) && $_GET['page'] == 'skins' && isset($_GET['action']) && $_GET['action'] == 'activate' && current_user_can('switch_themes')) {
        check_admin_referer('switch-skin_' . $_GET['skin']);
        $info = sandbox_skin_info($_GET['skin']);
        sandbox_set_options(array('skin' => wp_filter_kses($_GET['skin']), 'globalnav' => bool_from_yn($info['global_navigation'])));
        wp_redirect('themes.php?page=skins&message=updated');
    }
}
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:10,代码来源:functions.php

示例4: test_bool_from_yn

 /**
  * @ticket 35972
  */
 function test_bool_from_yn()
 {
     $this->assertTrue(bool_from_yn('Y'));
     $this->assertTrue(bool_from_yn('y'));
     $this->assertFalse(bool_from_yn('n'));
 }
开发者ID:jaspermdegroot,项目名称:develop.wordpress,代码行数:9,代码来源:functions.php

示例5: get_links_list

function get_links_list($order = 'name', $hide_if_empty = 'obsolete')
{
    global $wpdb;
    $order = strtolower($order);
    // Handle link category sorting
    if (substr($order, 0, 1) == '_') {
        $direction = ' DESC';
        $order = substr($order, 1);
    }
    // if 'name' wasn't specified, assume 'id':
    $cat_order = 'name' == $order ? 'cat_name' : 'cat_id';
    if (!isset($direction)) {
        $direction = '';
    }
    // Fetch the link category data as an array of hashesa
    $cats = $wpdb->get_results("\n\t\tSELECT DISTINCT link_category, cat_name, show_images, \n\t\t\tshow_description, show_rating, show_updated, sort_order, \n\t\t\tsort_desc, list_limit\n\t\tFROM `{$wpdb->links}` \n\t\tLEFT JOIN `{$wpdb->linkcategories}` ON (link_category = cat_id)\n\t\tWHERE link_visible =  'Y'\n\t\t\tAND list_limit <> 0\n\t\tORDER BY {$cat_order} {$direction} ", ARRAY_A);
    // Display each category
    if ($cats) {
        foreach ($cats as $cat) {
            // Handle each category.
            // First, fix the sort_order info
            $orderby = $cat['sort_order'];
            $orderby = (bool_from_yn($cat['sort_desc']) ? '_' : '') . $orderby;
            // Display the category name
            echo '	<li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
            // Call get_links() with all the appropriate params
            get_links($cat['link_category'], '<li>', "</li>", "\n", bool_from_yn($cat['show_images']), $orderby, bool_from_yn($cat['show_description']), bool_from_yn($cat['show_rating']), $cat['list_limit'], bool_from_yn($cat['show_updated']));
            // Close the last category
            echo "\n\t</ul>\n</li>\n";
        }
    }
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:32,代码来源:links.php

示例6: _e

?>
</div>
				</div>				
			</div>
			<div class="row">
				<div class="cell width120px">
					<b><?php 
_e('Amazon S3 Settings', 'mgm');
?>
:</b> 
				</div>
			</div>
			<div class="row">		
				<div class="cell textalignleft ">
					<input type="checkbox" name="is_s3_torrent" id="is_s3_torrent" <?php 
echo bool_from_yn($data['download']->is_s3_torrent) ? "checked='checked'" : '';
?>
 /> <?php 
_e('Is Torrent', 'mgm');
?>

					<div class="tips"><?php 
printf(__('Allow Torrent for Amazon S3 larger files ( rquires public ACL ). Please read <a href="%s">here</a>.', 'mgm'), ' http://docs.amazonwebservices.com/AmazonS3/latest/dev/S3TorrentRetrieve.html');
?>
</div>
				</div>
			</div>
			<div class="row brBottom">
				<div class="cell">
					<div class="tips">
						<b><?php 
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:31,代码来源:edit.php

示例7: _e

    		<div class="cell">
				<p><input type="checkbox" name="enable_facebook" id="enable_facebook" value="Y" <?php 
if (bool_from_yn($data['system_obj']->get_setting('enable_facebook'))) {
    echo "checked='checked'";
}
?>
>&nbsp;<b><?php 
_e('Enable Facebook login/registration?', 'mgm');
?>
</b></p>				
			</div>
		</div>
  		<div class="row">
    		<div class="cell">
				<div id="enable_facebook_setting" class="<?php 
echo bool_from_yn($data['system_obj']->get_setting('enable_facebook')) ? 'displayblock' : 'displaynone';
?>
 paddingtop10px">
					<p><b><?php 
_e('Facebook API ID');
?>
:</b></p>
					<input type="text" name="facebook_id" value="<?php 
echo esc_html($data['system_obj']->get_setting('facebook_id'));
?>
" size="50" />
					<p><b><?php 
_e('Facebook API Key');
?>
:</b></p>
					<input type="text" name="facebook_key" value="<?php 
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:31,代码来源:general.php

示例8: 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	
  * @param int $pack_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)) {
             if (isset($member->payment_info->subscr_id)) {
                 $subscr_id = $member->payment_info->subscr_id;
             } else {
                 //check pack is recurring:
                 $pid = $pack_id ? $pack_id : $member->pack_id;
                 if ($pid) {
                     $s_packs = mgm_get_class('subscription_packs');
                     $sel_pack = $s_packs->get_pack($pid);
                     if ($sel_pack['num_cycles'] != 1) {
                         $subscr_id = 0;
                     }
                 }
             }
             //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;
         }
     }
     //send email only if setting enabled
     if (!empty($subscr_id) || $subscr_id === 0) {
         $system_obj = mgm_get_class('system');
         $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
         //send email only if setting enabled
         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 true;
     }
     return false;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:67,代码来源:mgm_clickbank.php

示例9: get_template

 function get_template($name, $data = array(), $parse = false)
 {
     // by name
     switch ($name) {
         case 'tos':
         case 'subs_intro':
         case 'text_guest_purchase_pre_button':
         case 'text_guest_purchase_pre_register':
             return mgm_get_template($name, NULL, 'messages');
             break;
         case 'private_text':
         case 'private_text_no_access':
         case 'private_text_purchasable':
         case 'private_text_purchasable_login':
         case 'private_text_purchasable_pack_login':
         case 'private_text_postdelay_no_access':
             // parse enabled
             if ($parse) {
                 // parse
                 $message_content = mgm_get_template($name, $data, 'messages');
                 // set template
                 $template = mgm_get_template('private_text_template', NULL, 'templates');
                 // return
                 return str_replace('[message]', $message_content, $template);
             } else {
                 // parse disabled
                 return mgm_get_template($name, NULL, 'messages');
             }
             break;
         case 'login_errmsg_null':
         case 'login_errmsg_expired':
         case 'login_errmsg_trial_expired':
         case 'login_errmsg_pending':
         case 'login_errmsg_cancelled':
         case 'login_errmsg_default':
         case 'login_errmsg_date_range':
         case 'login_errmsg_multiple_logins':
             // parse enabled
             if ($parse) {
                 // argas
                 $q_args = array('action' => '[[ACTION]]');
                 //
                 if (bool_from_yn($this->setting['enable_email_as_username'])) {
                     $q_args = array_merge($q_args, array('user_id' => '[[USERID]]'));
                 } else {
                     $q_args = array_merge($q_args, array('username' => '[[USERNAME]]'));
                 }
                 // set url data
                 $data['subscription_url'] = add_query_arg($q_args, mgm_get_custom_url('transactions'));
                 // return
                 return mgm_get_template($name, $data, 'messages');
             } else {
                 // parse disabled
                 return mgm_get_template($name, NULL, 'messages');
             }
             break;
         case 'pack_desc_template':
         case 'pack_desc_lifetime_template':
         case 'pack_desc_date_range_template':
         case 'ppp_pack_template':
         case 'register_form_row_template':
         case 'profile_form_row_template':
         case 'register_form_row_autoresponder_template':
             // separate
             // parse enabled
             if ($parse) {
                 // return
                 return mgm_get_template($name, $data, 'templates');
             } else {
                 // parse disabled
                 return mgm_get_template($name, NULL, 'templates');
             }
             break;
         case 'reminder_email_template_subject':
         case 'reminder_email_template_body':
         case 'registration_email_template_subject':
         case 'registration_email_template_body':
         case 'new_user_notification_email_template_subject':
         case 'new_user_notification_email_template_body':
         case 'user_upgrade_notification_email_template_subject':
         case 'user_upgrade_notification_email_template_body':
         case 'payment_success_email_template_subject':
         case 'payment_success_email_template_body':
         case 'payment_success_subscription_email_template_body':
         case 'payment_failed_email_template_subject':
         case 'payment_failed_email_template_body':
         case 'payment_active_email_template_subject':
         case 'payment_active_email_template_body':
         case 'payment_pending_email_template_subject':
         case 'payment_pending_email_template_body':
         case 'payment_error_email_template_subject':
         case 'payment_error_email_template_body':
         case 'payment_unknown_email_template_subject':
         case 'payment_unknown_email_template_body':
         case 'subscription_cancelled_email_template_subject':
         case 'subscription_cancelled_email_template_body':
         case 'retrieve_password_email_template_subject':
         case 'retrieve_password_email_template_body':
         case 'lost_password_email_template_subject':
         case 'lost_password_email_template_body':
//.........这里部分代码省略.........
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_system.php

示例10: enqueue_scripts

 /**
  * enqueue scripts
  *
  * @since 1.1
  *
  */
 public function enqueue_scripts()
 {
     global $stt2extat_settings;
     $set = $stt2extat_settings;
     $is_single = apply_filters('stt2extat_is_single', true);
     if (!$is_single && !is_search()) {
         return false;
     }
     $post_ids = stt2extat_post_ids_query();
     if (!$post_ids) {
         return false;
     }
     $settings = array('post_ID' => $post_ids, 'showList' => isset($set['auto']) ? bool_from_yn($set['auto']) : (bool) 0, 'single' => is_single());
     $heartbeat_set = wp_heartbeat_settings($settings);
     $localize_script = wp_parse_args($heartbeat_set, $settings);
     wp_register_script('jquery-stt2extat-res', plugin_dir_url(__FILE__) . 'assets/js/jquery-stt2extat-res.js', array('jquery-core'), STT2EXTAT_VER, true);
     wp_enqueue_script('jquery-stt2extat-res');
     wp_localize_script('jquery-stt2extat-res', 'stt2extatJs', $localize_script);
 }
开发者ID:Jevuska,项目名称:stt2-extension-add-terms,代码行数:25,代码来源:class-stt2extat-load.php

示例11: mgm_template_include

/**
 * override default template
 *
 * @param array $column
 * @param init $post_id
 * @return void
 */
function mgm_template_include($template)
{
    // check override
    if (bool_from_yn(mgm_get_setting('override_theme_for_custom_pages'))) {
        // name
        $name = mgm_get_query_var('name');
        // switch
        switch ($name) {
            case 'register':
            case 'profile':
            case 'lost_password':
            case 'login':
                $content = mgm_get_query_post_content();
                // @todo check #BUG_PENDING
                // check
                if (mgm_is_custom_page_published($name, $content)) {
                    // if template exists in theme only
                    if ($c_template = mgm_get_page_template($name, false, true)) {
                        $template = $c_template;
                    }
                }
                break;
        }
    }
    // return
    return $template;
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:34,代码来源:mgm_content_hooks.php

示例12: mgm_notify_admin_passthrough_verification_failed

/**
 * Send Email Notification to Admin on passthrough verification failed
 *
 * @uses mgm_notify_admin()
 * @param string $passthrough
 * @param string $module
 * @return bool @send
 */
function mgm_notify_admin_passthrough_verification_failed($passthrough, $module)
{
    // system
    $system_obj = mgm_get_class('system');
    $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
    // notify admin, only if gateway emails on
    if (!$dge) {
        // subject
        $subject = sprintf('Error in %s custom passthrough verification', ucwords($module));
        // message
        $message = sprintf('Could not read custom passthrough:<br />passthrough: %s;<br>request: %s', $passthrough, print_r($_REQUEST, true));
        // mail
        return @mgm_notify_admin(null, $subject, $message);
    }
    // error
    return false;
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:25,代码来源:mgm_email_functions.php

示例13: cancel_recurring_subscription


//.........这里部分代码省略.........
             }
             //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;
         }
     }
     //if valid rebill data is found and settings are set
     if (!empty($rebill['rebill_id']) && !empty($rebill['rebill_customer_id']) && !empty($this->setting['customer_id']) && !empty($this->setting['username']) && !empty($this->setting['password'])) {
         $gateway_method = 'webservice';
         $secure = array('CustomerID' => $this->setting['customer_id'], 'Username' => $this->setting['username'], 'Password' => $this->setting['password']);
         //data to post
         //Delete Rebill Event
         $post_data = array('webservice_action' => 'DeleteRebillEvent', 'RebillCustomerID' => $rebill['rebill_customer_id'], 'RebillID' => $rebill['rebill_id']);
         $post_data = array_merge($post_data, $secure);
         // filter post data and create soap xml
         $post_string = $this->_filter_postdata($gateway_method, $post_data);
         // endpoint
         $endpoint = $this->_get_endpoint($this->status . '_' . $gateway_method);
         // test_webservice / live_webservice
         // headers
         $http_headers = $this->_get_http_headers($gateway_method, $post_data['webservice_action']);
         // log
         mgm_log('Request Headers [' . $post_data['webservice_action'] . ']' . mgm_pr($http_headers, true), __FUNCTION__);
         // log
         mgm_log('Request [' . $post_data['webservice_action'] . ']' . $post_string, __FUNCTION__);
         // create curl post
         $http_response = mgm_remote_post($endpoint, $post_string, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
         // log
         mgm_log('Response [' . $post_data['webservice_action'] . ']' . $http_response, __FUNCTION__);
         /*$http_header = array('User-Agent: NuSOAP/0.9.5 (1.123)', 'Content-Type: text/xml; charset=ISO-8859-1', 
           sprintf('SOAPAction: "http://www.eway.com.au/gateway/rebill/manageRebill/%s"', $post_data['webservice_action']));*/
         // post soap data
         // $buffer = $this->_curl_post($endpoint, $post_string, $http_header);
         // parse response
         $this->_process_response($gateway_method, $http_response, $post_data['webservice_action']);
         // log
         mgm_log('Response Parsed [' . $post_data['webservice_action'] . ']' . mgm_pr($this->response, true), __FUNCTION__);
         //if rebill event is deleted, delete rebill customer
         if (isset($this->response['response_status']) && $this->response['response_status'] == 1) {
             //delete rebill customer:
             $post_data['webservice_action'] = 'DeleteRebillCustomer';
             // filter post data and create soap xml
             $post_string = $this->_filter_postdata($gateway_method, $post_data);
             // soap_action
             $soap_action = sprintf('http://www.eway.com.au/gateway/rebill/manageRebill/%s', $post_data['webservice_action']);
             // http_headers
             $http_headers = array_merge($http_headers, array('SOAPAction' => $soap_action));
             // log
             mgm_log('Request Headers [' . $post_data['webservice_action'] . ']' . mgm_pr($http_headers, true), __FUNCTION__);
             // log
             mgm_log('Request [' . $post_data['webservice_action'] . ']' . $post_string, __FUNCTION__);
             // create curl post
             $http_response = mgm_remote_post($endpoint, $post_string, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
             // log
             mgm_log('Response [' . $post_data['webservice_action'] . ']' . $http_response, __FUNCTION__);
             /*$http_header = array('User-Agent: NuSOAP/0.9.5 (1.123)', 'Content-Type: text/xml; charset=ISO-8859-1', 
               sprintf('SOAPAction: "http://www.eway.com.au/gateway/rebill/manageRebill/%s"', $post_data['webservice_action']));*/
             // post soap data
             // $buffer = $this->_curl_post($endpoint, $post_string, $http_header);
             // parse response
             $this->_process_response($gateway_method, $http_response, $post_data['webservice_action']);
             // log
             mgm_log('Response Parsed [' . $post_data['webservice_action'] . ']' . mgm_pr($this->response, true), __FUNCTION__);
             // check
             if (isset($this->response['response_status']) && $this->response['response_status'] == 1) {
                 //done
                 return true;
             }
         }
     } elseif ($rebill['rebill_id'] === 0) {
         $system_obj = mgm_get_class('system');
         $dge = bool_from_yn($system_obj->get_setting('disable_gateway_emails'));
         //send email only if setting enabled
         if (!$dge) {
             $user = get_userdata($user_id);
             //send notification email to admin:
             $message = __('The User: ', 'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm');
             $message .= "<br/>" . __('Please unsubscribe the user from Gateway Merchant panel.', 'mgm');
             if (!empty($rebill['rebill_customer_id'])) {
                 $message .= "<br/><br/>" . __('Customer Rebill Id: ', 'mgm') . $rebill['rebill_customer_id'];
             }
             if (!empty($rebill['rebill_id'])) {
                 $message .= "<br/><br/>" . __('Rebill Id: ', 'mgm') . $rebill['rebill_id'];
             }
             if (isset($member->transaction_id)) {
                 $message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id;
             }
             //admin email:
             if (!empty($system_obj->setting['admin_email'])) {
                 @mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message);
             }
         }
         //treat as done
         return true;
     }
     return false;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:101,代码来源:mgm_eway.php

示例14: 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)) {
             if (isset($member->payment_info->subscr_id)) {
                 $subscr_id = $member->payment_info->subscr_id;
             } else {
                 //check pack is recurring:
                 $pid = $pack_id ? $pack_id : $member->pack_id;
                 if ($pid) {
                     $s_packs = mgm_get_class('subscription_packs');
                     $sel_pack = $s_packs->get_pack($pid);
                     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;
         }
     }
     //ony for subscription_purchase
     if ($subscr_id) {
         // end  point
         $endpoint = $this->_get_endpoint('unsubscribe');
         // base
         // add query
         $url = add_query_arg(array('SUBSCRIPTION_ID' => urlencode($subscr_id), 'MERCHANT_ID' => urlencode($this->setting['merchant_id']), 'ZombaioGWPass' => urlencode($this->setting['gw_pass']), 'ReasonCode' => urlencode(11)), $endpoint);
         // create curl post
         //$buffer = $this->_curl_post($url);
         // headers
         $http_headers = array();
         // fetch
         $http_response = mgm_remote_post($url, $post_data, array('headers' => $http_headers, 'timeout' => 30, 'sslverify' => false));
         // verify
         if ($http_response == 1) {
             return true;
         } else {
             // message
             return $this->_get_cancel_error($http_response);
         }
     } elseif ($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'));
         //send email only if setting enabled
         if (!$dge) {
             $user = get_userdata($user_id);
             //send notification email to admin:
             $message = __('The User: ', 'mgm') . $user->user_email . ' (' . $user_id . ') ' . __('has upgraded/cancelled subscription.', 'mgm');
             $message .= "<br/>" . __('Please unsubscribe the user subscription from Gateway Merchant panel.', 'mgm');
             if (!empty($member->transaction_id)) {
                 $message .= "<br/>" . __('MGM Transaction Id:', 'mgm') . $member->transaction_id;
             }
             //admin email:
             if (!empty($system_obj->setting['admin_email'])) {
                 @mgm_mail($system_obj->setting['admin_email'], sprintf(__('[%s] User Subscription Cancellation', 'mgm'), get_option('blogname')), $message);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:92,代码来源:mgm_zombaio.php

示例15: mgm_is_mgm_menu_enabled

/**
 * Check secondary menu is enabled for the logged in user
 * @param string $primary_menu
 * @param string $secondary_menu
 * @return boolean
 */
function mgm_is_mgm_menu_enabled($type = 'primary', $primary_menu, $secondary_menu = null)
{
    $user_id = get_current_user_id();
    $obj_roles = new mgm_roles();
    // for the firsttime load
    if (!get_option('rolebasedmenu_init')) {
        // update administrator role with capabilities
        $custom_caps = $obj_roles->get_custom_capabilities();
        foreach ($custom_caps as $cap) {
            $obj_roles->update_capability_role('administrator', $cap, true);
        }
        // set init value
        update_option('rolebasedmenu_init', 1);
    }
    $capabilities = $obj_roles->get_loggedinuser_custom_capabilities($user_id);
    $system_obj = mgm_get_class('system');
    // common setting
    $dml = $system_obj->setting['enable_role_based_menu_loading'];
    // if dynamic menu loading is disabled/priamry and secondary menus are enabled
    return is_super_admin() && !bool_from_yn($dml) || (bool_from_yn($dml) && ($type == 'primary' && in_array($primary_menu, $capabilities)) || $type == 'secondary' && in_array($primary_menu, $capabilities) && in_array($secondary_menu, $capabilities));
    // check secondary menu capability is loaded
}
开发者ID:jervy-ez,项目名称:magic-members-test,代码行数:28,代码来源:mgm_admin_functions.php


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