コード例 #1
0
    $time = $times[0]->StartDateTime;
    ?>
	
		<h2>Time List</h2>
		<?php 
    echo $timeHtml;
    ?>
		
		<p>Pick a time to book a client into: <?php 
    echo $time;
    ?>
</p>
		
<?php 
    // validate the current user's MB login information to identify the client
    $result = $clientService->ValidateLogin("miketyson", "test1234");
    $clientHtml = '<table><tr><td>ID</td><td>Name</td><td>GUID</td></tr>';
    $client = $result->ValidateLoginResult->Client;
    $guid = $result->ValidateLoginResult->GUID;
    if ($client != null) {
        $clientHtml .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', $client->ID, $client->FirstName . " " . $client->LastName, $guid);
    }
    $clientHtml .= '</table>';
    ?>
		<h2>Selected Client</h2>
		<?php 
    echo $clientHtml;
    // find out if they have a service to pay for this appointment
    $result = $clientService->GetClientServices($client->ID, array(), array(23));
    $serviceHtml = '<table><tr><td>ID</td><td>Name</td></tr>';
    if ($result->GetClientServicesResult->ResultCount > 0) {
コード例 #2
0
    $classID = $classes[0]->ID;
    ?>
	
		<h2>Class List</h2>
		<?php 
    echo $classHtml;
    ?>
		
		<p>Pick a classID to sign a client into: <?php 
    echo $classID;
    ?>
</p>
		
<?php 
    // validate the current user's MB login information to identify the client
    $result = $clientService->ValidateLogin("foxmccloud", "foxmccloud1");
    $clientHtml = '<table><tr><td>ID</td><td>Name</td><td>GUID</td></tr>';
    $client = $result->ValidateLoginResult->Client;
    $guid = $result->ValidateLoginResult->GUID;
    if ($client != null) {
        $clientHtml .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', $client->ID, $client->FirstName . " " . $client->LastName, $guid);
    }
    $clientHtml .= '</table>';
    ?>
		<h2>Selected Client</h2>
		<?php 
    echo $clientHtml;
    // try to sign them up for the class
    $result = $classService->AddClientsToClasses(array($client->ID), array($classID));
    /*
    
コード例 #3
0
/**
 * The login-redirect page is marked with a special custom attribute.
 * This function hooks the get_header action, where it will have the
 * option to try a redirect. If the user doesn't have MindBody credentials
 * in their profile, this will redirect them to their user profile.
 * See http://codex.wordpress.org/Plugin_API/Action_Reference/get_header
 */
function pkv_mindbody_redirect_page()
{
    global $post;
    global $pkv_error;
    // If they've submitted the login form, save their credentials. This might not be the right action.
    // If this succeeds, it should just go right on to the redirect.
    if (is_user_logged_in() && $_POST['pkv_mindbody_action'] == 'save' && wp_verify_nonce($_POST['_pkv_mindbody_nonce'], 'pkv_mindbody_save')) {
        pkv_mindbody_update_user_profile();
    }
    if (is_page() || is_object($post)) {
        // The login page is identified by the presence of the 'mindbody-login' Custom Field
        if (get_post_meta($post->ID, 'mindbody-login', true)) {
            if (is_user_logged_in() === true) {
                global $user_ID;
                // load user info
                $iv = pkv_mindbody_retrieve_iv($user_ID);
                $mindbody_username = pkv_mindbody_decrypt(get_user_meta($user_ID, 'mindbody_username', true), $iv);
                $mindbody_password = pkv_mindbody_decrypt(get_user_meta($user_ID, 'mindbody_password', true), $iv);
                // No username/password set! Forget it.
                if (empty($mindbody_username) || empty($mindbody_password)) {
                    return;
                }
                require_once dirname(__FILE__) . '/mindbody-api/clientService.php';
                $sourcename = PKV_MINDBODY_SOURCE_NAME;
                $password = PKV_MINDBODY_PASSWORD;
                $siteID = PKV_MINDBODY_SITE_ID;
                // initialize default credentials
                $creds = new SourceCredentials($sourcename, $password, array($siteID));
                $clientService = new MBClientService();
                $clientService->SetDefaultCredentials($creds);
                // TODO: need some exception handling here
                $result = $clientService->ValidateLogin($mindbody_username, $mindbody_password);
                if ($result == NULL || $result->ValidateLoginResult->Status == "InvalidParameters") {
                    $pkv_error = "The MindBody login information we have for you isn't correct. Please re-enter it.";
                    // Clear their username and password
                    delete_user_meta($user_ID, 'mindbody_username');
                    delete_user_meta($user_ID, 'mindbody_password');
                    return;
                }
                $guid = $result->ValidateLoginResult->GUID;
                // Redirect to MindBody, pre-authenticated via the GUID
                $mb_url = "https://clients.mindbodyonline.com/ASP/ws.asp?studioid=" . $siteID . "&guid=" . $guid;
                header('Location: ' . $mb_url);
            } else {
                // We'll show a log-in form
                $pkv_error = 'Not logged in';
            }
        }
    }
}