Exemplo n.º 1
0
		<input type="password" size="25" name="password"/><br/>
		SiteID:
		<input type="text" size="5" name="siteID" value="-99"/><br/>
		<input type="submit" value="submit" name="submit"/>
	</form>
<?php 
} else {
    $sourcename = $_POST["sName"];
    $password = $_POST["password"];
    $siteID = $_POST["siteID"];
    // initialize default credentials
    $creds = new SourceCredentials($sourcename, $password, array($siteID));
    // initialize the services you are going to use
    $classService = new MBClassService(true);
    $classService->SetDefaultCredentials($creds);
    $clientService = new MBClientService(true);
    $clientService->SetDefaultCredentials($creds);
    // get a list of upcoming classes
    $result = $classService->GetClasses(array(), array(), array(), new DateTime("2010-11-28"), new DateTime("2010-12-04"), null, 10, 0);
    $classHtml = '<table><tr><td>ID</td><td>Name</td><td>Start Time</td></tr>';
    $classes = toArray($result->GetClassesResult->Classes->Class);
    foreach ($classes as $class) {
        $classHtml .= sprintf('<tr><td>%d</td><td>%s</td><td>%s</td></tr>', $class->ID, $class->ClassDescription->Name, $class->StartDateTime);
    }
    $classHtml .= '</table>';
    // pick a classID to sign a client into
    $classID = $classes[0]->ID;
    ?>
	
		<h2>Class List</h2>
		<?php 
Exemplo n.º 2
0
    <form method="post" action=".">
        Source Name:
        <input type="text" size="25" name="sName"/><br/>
        Password:
        <input type="password" size="25" name="password"/><br/>
        SiteID:
        <input type="text" size="5" name="siteID" value="-99"/><br/>
        <input type="submit" value="submit" name="submit"/>
    </form>
<?php 
} else {
    $sourcename = $_POST["sName"];
    $password = $_POST["password"];
    $siteID = $_POST["siteID"];
    // initialize default credentials
    $creds = new SourceCredentials($sourcename, $password, array($siteID));
    $clientService = new MBClientService();
    $clientService->SetDefaultCredentials($creds);
    $result = $clientService->GetClients(array());
    $cdsHtml = '<table><tr><td>ID</td><td>Name</td></tr>';
    $cds = toArray($result->GetClassDescriptionsResult->ClassDescriptions->ClassDescription);
    foreach ($cds as $cd) {
        $cdsHtml .= sprintf('<tr><td>%d</td><td>%s</td></tr>', $cd->ID, $cd->Name);
    }
    $cdsHtml .= '</table>';
    echo $cdsHtml;
}
?>
    </body>
</html>
		<input type="password" size="25" name="password"/><br/>
		SiteID:
		<input type="text" size="5" name="siteID" value="-99"/><br/>
		<input type="submit" value="submit" name="submit"/>
	</form>
<?php 
} else {
    $sourcename = $_POST["sName"];
    $password = $_POST["password"];
    $siteID = $_POST["siteID"];
    // initialize default credentials
    $creds = new SourceCredentials($sourcename, $password, array($siteID));
    // initialize the services you are going to use
    $appointmentService = new MBAppointmentService();
    $appointmentService->SetDefaultCredentials($creds);
    $clientService = new MBClientService();
    $clientService->SetDefaultCredentials($creds);
    $saleService = new MBSaleService();
    $saleService->SetDefaultCredentials($creds);
    // get a list of upcoming classes
    $result = $appointmentService->GetBookableItems(array(23), array(), array(), null, null);
    $timeHtml = '<table><tr><td>Location Name</td><td>Staff Name</td><td>Start Time</td></tr>';
    $times = toArray($result->GetBookableItemsResult->ScheduleItems->ScheduleItem);
    foreach ($times as $time) {
        $timeHtml .= sprintf('<tr><td>%s</td><td>%s</td><td>%s</td></tr>', $time->Location->Name, $time->Staff->FirstName, $time->StartDateTime);
    }
    $timeHtml .= '</table>';
    // pick a time to sign a client into
    $time = $times[0]->StartDateTime;
    ?>
	
Exemplo n.º 4
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';
            }
        }
    }
}