return false; } function datediffInWeeks($date1, $date2) { $first = DateTime::createFromFormat('m/d/Y', $date1); $second = DateTime::createFromFormat('m/d/Y', $date2); if ($date1 > $date2) { return datediffInWeeks($date2, $date1); } return floor($first->diff($second)->days / 7); } if ($sourcename != "" && $password != "" && $siteID != "" && $fromdate != "" && $todate != "" && $_GET["settings-updated"] == 'true') { // initialize default credentials $creds = new SourceCredentials($sourcename, $password, array($siteID)); //START Enrollments services $classService = new MBClassService(); $classService->SetDefaultCredentials($creds); $StartClassDateTime = new DateTime($fromdate); $EndClassDateTime = new DateTime($todate); $GetCourses = $classService->GetEnrollments(array(), array(), array(), array(), $StartClassDateTime, $EndClassDateTime); $resultget = $GetCourses->GetEnrollmentsResult->Enrollments->ClassSchedule; $resultafter = array(); $completedresults = array(); //END Class services $i = 0; foreach ($resultget as $class) { if ($class->IsAvailable) { $resultafter[$i] = new StdClass(); $resultafter[$i] = $class; $resultafter[$i]->title = $class->ClassDescription->Name; $resultafter[$i]->Level = $class->ClassDescription->Level->Name;
How often should we check the feed and update classes in the near future? How often do we need to update classes that are well in the future (say, 60 days) Will we ever need to change things on past class posts? Should we delete class posts (calendar items) that are well in the past? */ echo '<pre>'; log_it('******** ' . date('Y-m-d H:i:s') . ' ***********'); require_once "includes/classService.php"; // sandbox credentials: $sourcename = 'AccelerantStudiosLLC'; $password = "******"; //$siteID ="-99"; // Mindbody Sandbox $siteID = "38100"; // Casey's ID, now that our keys work there $creds = new SourceCredentials($sourcename, $password, array($siteID)); $classService = new MBClassService(); $classService->SetDefaultCredentials($creds); $d1 = new DateTime(); // defaults to now $d2 = new DateTime("2015-12-31"); // Make this 30, 60 or 365 days ahead, $result = $classService->GetClasses(array(), array(), array(), $d1, $d2, null, 1000, 0); //print_r($result); //The array of class data we want is $result->GetClassesResult->Classes->Class (why 3 deep? dunno. Big sprawling structure. Not my code. MSH) // DEV: look at the structure for ($i = 0; $i < 6; $i++) { //print_r($result->GetClassesResult->Classes->Class[$i]); } // load wordpress so we can get the existing event posts require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-load.php"; //for image processing
return false; } function datediffInWeeks($date1, $date2) { $first = DateTime::createFromFormat('m/d/Y', $date1); $second = DateTime::createFromFormat('m/d/Y', $date2); if ($date1 > $date2) { return datediffInWeeks($date2, $date1); } return floor($first->diff($second)->days / 7); } if ($sourcename != "" && $password != "" && $siteID != "" && $fromdate != "" && $todate != "" && $_GET["settings-updated"] == 'true') { // initialize default credentials $creds = new SourceCredentials($sourcename, $password, array($siteID)); //START Class services $classService = new MBClassService(); $classService->SetDefaultCredentials($creds); $StartClassDateTime = new DateTime($fromdate); $EndClassDateTime = new DateTime($todate); $result = $classService->GetClasses(array(), array(), array(), $StartClassDateTime, $EndClassDateTime, NULL, 1000, 1); $resultget = $result->GetClassesResult->Classes->Class; $resultafter = array(); $completedresults = array(); //END Class services $classids = array(); $i = 0; foreach ($resultget as $class) { if ($class->ClassDescription->Program->ScheduleType == 'DropIn') { $resultafter[$i] = new StdClass(); $resultafter[$i] = $class; $resultafter[$i]->title = $class->ClassDescription->Name;
* * @package mind-body * @author C.J.Churchill <*****@*****.**> * @license GPL-2.0+ * @link http://accruesupport.com * @copyright 4-29-2014 Accrue */ require_once plugin_dir_path(__FILE__) . "../includes/classService.php"; //require_once("../includes/clientService.php"); $no_exists_value = get_option('mind_body_options'); $sourcename = $no_exists_value['sourcename']; $password = $no_exists_value['password']; $siteID = $no_exists_value['siteID']; // initialize default credentials $creds = new SourceCredentials($sourcename, $password, array($siteID)); $classService = new MBClassService(); $classService->SetDefaultCredentials($creds); $result = $classService->GetClassDescriptions(array(), array(), array(), null, null, 150, 0); $resultTest = $result->GetClassDescriptionsResult->ClassDescriptions->ClassDescription; $resultafter = array(); /* * *Traverse array using shortcode level variable if it's set! * * */ if ($level != ' ') { # code... $i = '0'; foreach ($resultTest as $lesson) { if (isset($lesson->Level->Name) && $lesson->Level->Name == $level) {
<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)); // 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; ?>