Changeset 435356 for scormcloud
- Timestamp:
- 09/08/2011 06:27:50 PM (14 years ago)
- Location:
- scormcloud/trunk
- Files:
-
- 32 added
- 1 deleted
- 9 edited
-
SCORMAPI (deleted)
-
SCORMCloud_PHPLibrary (added)
-
SCORMCloud_PHPLibrary/AccountService.php (added)
-
SCORMCloud_PHPLibrary/Configuration.php (added)
-
SCORMCloud_PHPLibrary/CourseData.php (added)
-
SCORMCloud_PHPLibrary/CourseService.php (added)
-
SCORMCloud_PHPLibrary/DebugLogger.php (added)
-
SCORMCloud_PHPLibrary/DebugService.php (added)
-
SCORMCloud_PHPLibrary/Enums.php (added)
-
SCORMCloud_PHPLibrary/ImportResult.php (added)
-
SCORMCloud_PHPLibrary/LaunchInfo.php (added)
-
SCORMCloud_PHPLibrary/README.txt (added)
-
SCORMCloud_PHPLibrary/RegistrationData.php (added)
-
SCORMCloud_PHPLibrary/RegistrationService.php (added)
-
SCORMCloud_PHPLibrary/RegistrationSummary.php (added)
-
SCORMCloud_PHPLibrary/ReportingService.php (added)
-
SCORMCloud_PHPLibrary/ScormEngineService.php (added)
-
SCORMCloud_PHPLibrary/ScormEngineUtilities.php (added)
-
SCORMCloud_PHPLibrary/ServiceRequest.php (added)
-
SCORMCloud_PHPLibrary/TaggingService.php (added)
-
SCORMCloud_PHPLibrary/UploadService.php (added)
-
SCORMCloud_PHPLibrary/UploadToken.php (added)
-
SCORMCloud_PHPLibrary/samples (added)
-
SCORMCloud_PHPLibrary/samples/CourseListSample.php (added)
-
SCORMCloud_PHPLibrary/samples/CourseMetadataSample.php (added)
-
SCORMCloud_PHPLibrary/samples/CoursePropertiesSample.php (added)
-
SCORMCloud_PHPLibrary/samples/CreateRegistrationSample.php (added)
-
SCORMCloud_PHPLibrary/samples/DeletePackageSample.php (added)
-
SCORMCloud_PHPLibrary/samples/ImportFinish.php (added)
-
SCORMCloud_PHPLibrary/samples/ImportSample.php (added)
-
SCORMCloud_PHPLibrary/samples/LaunchHistorySample.php (added)
-
SCORMCloud_PHPLibrary/samples/RegistrationListSample.php (added)
-
SCORMCloud_PHPLibrary/samples/config.php (added)
-
ajax.php (modified) (19 diffs)
-
readme.txt (modified) (3 diffs)
-
scormcloud.catalogwidget.php (modified) (1 diff)
-
scormcloud.php (modified) (2 diffs)
-
scormcloud.widget.php (modified) (1 diff)
-
scormcloud.wp.php (modified) (4 diffs)
-
scormcloud_makeBlogEntry.php (modified) (3 diffs)
-
scormcloud_manage_training.php (modified) (1 diff)
-
scormcloud_training_details.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scormcloud/trunk/ajax.php
r383309 r435356 31 31 $require_login = 1; 32 32 $show_course_info = 0; 33 34 $wpdb->query($wpdb->prepare( " 35 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitations 36 (invite_id, blog_id, app_id, post_id, course_id, course_title, header, description, require_login, show_course_info) 37 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %d, %d)", 38 $inviteId, $GLOBALS['blog_id'], $appId, $postId, $courseId, $courseTitle, $header, $description, $require_login, $show_course_info)); 33 34 $wpdb->insert(scormcloud_getTableName('scormcloudinvitations'), 35 array('invite_id' => $inviteId, 36 'blog_id' => $GLOBALS['blog_id'], 37 'app_id' => $appId, 38 'post_id' => $postId, 39 'course_id' => $courseId, 40 'course_title' => $courseTitle, 41 'header' => $header, 42 'description' => $description, 43 'require_login' => $require_login, 44 'show_course_info' => $show_course_info), 45 array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d')); 39 46 40 47 //create the cloud registration(s) … … 75 82 $xml = simplexml_load_string($response); 76 83 if (isset($xml->success)){ 77 $wpdb->query($wpdb->prepare( " 78 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitationregs 79 (invite_id, reg_id, user_id, user_email) 80 VALUES (%s, %s, %d, %s)", 81 $inviteId, $regid, $userData->ID, $userData->user_email)); 84 $wpdb->insert(scormcloud_getTableName('scormcloudinvitationregs'), 85 array('invite_id' => $inviteId, 86 'reg_id' => $regid, 87 'user_id' => $userData->ID, 88 'user_email' => $userData->user_email), 89 array('%s', '%s', '%d', '%s')); 82 90 83 91 } else if ($xml->err['code'] == '4') { … … 103 111 $show_course_info = $_POST['showcourseinfo']; 104 112 105 $wpdb->query($wpdb->prepare( " 106 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitations 107 (invite_id, blog_id, app_id, course_id, course_title, header, description, require_login, show_course_info) 108 VALUES (%s, %s, %s, %s, %s, %s, %s, %d, %d)", 109 $inviteId, $GLOBALS['blog_id'], $appId, $courseId, $courseTitle, $header, $description, (int)$require_login, (int)$show_course_info)); 110 113 $wpdb->insert(scormcloud_getTableName('scormcloudinvitations'), 114 array('invite_id' => $inviteId, 115 'blog_id' => $GLOBALS['blog_id'], 116 'app_id' => $appId, 117 'course_id' => $courseId, 118 'course_title' => $courseTitle, 119 'header' => $header, 120 'description' => $description, 121 'require_login' => $require_login, 122 'show_course_info' => $show_course_info), 123 array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d')); 111 124 112 125 echo $inviteId; … … 123 136 $show_course_info = $_POST['showcourseinfo']; 124 137 125 $ querystr = "UPDATE ".scormcloud_getDBPrefix()."scormcloudinvitations SET126 header = '$header',127 description = '$description',128 require_login = ".(int)$require_login.",129 show_course_info = ".(int)$show_course_info."130 WHERE invite_id = '$inviteId'";131 $wpdb->query($querystr);138 $wpdb->update(scormcloud_getTableName('scormcloudinvitations'), 139 array('header' => $header, 140 'description' => $description, 141 'require_login' => (int)$require_login, 142 'show_course_info' => (int)$show_course_info), 143 array('invite_id' => $inviteId), 144 array('%s', '%s', '%d', '%d')); 132 145 133 146 break; … … 140 153 $returnUrl = $_POST['returnurl']; 141 154 142 $querystr = "SELECT * FROM ".scormcloud_getDBPrefix()."scormcloudinvitations WHERE invite_id = '$inviteId'"; 143 $invites = $wpdb->get_results($querystr, OBJECT); 144 $invite = $invites[0]; 155 $invite = scormcloud_getInvitation($inviteId); 145 156 146 157 $appId = $invite->app_id; … … 175 186 $regService = $ScormService->getRegistrationService(); 176 187 177 $querystr = "SELECT reg_id FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs WHERE invite_id = '$inviteId' AND user_email = '$user_email'"; 178 $inviteRegs = $wpdb->get_results($querystr, OBJECT); 179 if (count($inviteRegs) > 0) { 180 $inviteReg = $inviteRegs[0]; 188 $inviteReg = scormcloud_getInvitationReg(array('invite_id' => $inviteId, 'user_email' => $user_email)); 189 if ($inviteReg != null) { 181 190 $regid = (string)$inviteReg->reg_id; 182 191 } else { … … 186 195 $regService->CreateRegistration($regid, $courseId, $user_email, $user_first_name, $user_last_name,$user_email); 187 196 188 $wpdb->query($wpdb->prepare( " 189 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitationregs 190 (invite_id, reg_id, user_email) 191 VALUES (%s, %s, %s)", 192 $inviteId, $regid, $user_email)); 193 197 $wpdb->insert(scormcloud_getTableName('scormcloudinvitationregs'), 198 array('invite_id' => $inviteId, 199 'reg_id' => $regid, 200 'user_email' => $user_email)); 194 201 } 195 202 … … 250 257 } 251 258 252 $querystr = "SELECT * FROM ".scormcloud_getDBPrefix()."scormcloudinvitations WHERE invite_id = '$inviteId'"; 253 $invites = $wpdb->get_results($querystr, OBJECT); 254 $invite = $invites[0]; 259 $invite = scormcloud_getInvitation($inviteId); 255 260 256 261 $courseId = $invite->course_id; … … 287 292 $regService->CreateRegistration($regid, $courseId, $user_email, $user_first_name, $user_last_name,$user_email); 288 293 289 $wpdb->query($wpdb->prepare( " 290 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitationregs 291 (invite_id, reg_id, user_id, user_email) 292 VALUES (%s, %s, %d, %s)", 293 $inviteId, $regid, $current_user->ID, $user_email)); 294 $wpdb->insert(scormcloud_getTableName('scormcloudinvitationregs'), 295 array('invite_id' => $inviteId, 296 'reg_id' => $regid, 297 'user_id' => $current_user->ID, 298 'user_email' => $user_email), 299 array('%s', '%s', '%d', '%s')); 294 300 295 301 if (function_exists("bp_activity_add")){ … … 341 347 $widgetName = isset($_POST['widgetname']) ? $_POST['widgetname'] : null; 342 348 343 $querystr = "SELECT invite_id FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs WHERE reg_id = '$regid'"; 344 $inviteRegs = $wpdb->get_results($querystr, OBJECT); 345 $inviteReg = $inviteRegs[0]; 349 $inviteReg = scormcloud_getInvitationReg($regid); 346 350 347 351 $regTags = $GLOBALS['blog_id'].','.(string)$inviteReg->invite_id; … … 353 357 if (function_exists("bp_activity_add")){ 354 358 global $bp; 355 $querystr = "SELECT * FROM ".scormcloud_getDBPrefix()."scormcloudinvitations WHERE invite_id = '".$inviteReg->invite_id."'"; 356 $invites = $wpdb->get_results($querystr, OBJECT); 357 $invite = $invites[0]; 359 $invite = scormcloud_getInvitation($inviteReg->invite_id); 358 360 359 361 … … 419 421 $courseId = $_POST['courseid']; 420 422 421 //$querystr = "UPDATE ".scormcloud_getDBPrefix()."scormcloudinvitations SET active = 2 WHERE course_id = '$courseId'";422 423 $query str = "DELETE r FROM wp_scormcloudinvitations AS i LEFT JOIN wp_scormcloudinvitationregs AS r ON i.invite_id=r.invite_id424 WHERE course_id = '$courseId'";425 $wpdb->query($query str);426 $querystr = "DELETE FROM ".scormcloud_getDBPrefix()."scormcloudinvitations WHERE course_id = '$courseId'";427 428 $wpdb->query($query str);423 $invTable = scormcloud_getTableName('scormcloudinvitations'); 424 $regTable = scormcloud_getTableName('scormcloudinvitationregs'); 425 $query = $wpdb->prepare('DELETE r FROM '.$invTable.' AS i LEFT JOIN '.$regTable.' AS r ON i.invite_id = r.invite_id WHERE course_id = %s', 426 array($courseId)); 427 $wpdb->query($query); 428 429 $query = $wpdb->prepare('DELETE FROM '.$invTable.' WHERE course_id = %s', array($courseId)); 430 $wpdb->query($query); 429 431 430 432 $courseService = $ScormService->getCourseService(); … … 445 447 $regId = $_POST['regid']; 446 448 447 $querystr = "SELECT inv.course_id, reg.user_email FROM ".scormcloud_getDBPrefix()."scormcloudinvitations inv 448 JOIN ".scormcloud_getDBPrefix()."scormcloudinvitationregs reg ON inv.invite_id = reg.invite_id 449 WHERE reg.invite_id = '$inviteId' AND reg.reg_id= '$regId'"; 450 $invites = $wpdb->get_results($querystr, OBJECT); 451 $invite = $invites[0]; 449 $query = $wpdb->prepare('SELECT inv.course_id, reg.user_email FROM '.scormcloud_getTableName('scormcloudinvitations').' inv 450 JOIN '.scormcloud_getTableName('scormcloudinvitationregs').' reg ON inv.invite_id = reg.invite_id 451 WHERE reg.invite_id = %s AND reg.reg_id = %s', array($inviteId, $regId)); 452 $invite = $wpdb->get_row($query, OBJECT); 452 453 453 454 $courseId = $invite->course_id; … … 485 486 $inviteId = $_POST['inviteid']; 486 487 487 //$invites = $wpdb->get_results("SELECT * FROM ".scormcloud_getDBPrefix()."scormcloudinvitations WHERE invite_id = '$inviteId'", OBJECT); 488 //$invite = $invites[0]; 489 490 $querystr = "SELECT reg.*, inv.course_id FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs reg JOIN ".scormcloud_getDBPrefix()."scormcloudinvitations inv 491 ON reg.invite_id = inv.invite_id 492 WHERE reg.invite_id = '$inviteId' ORDER BY reg.update_date DESC"; 493 $inviteRegs = $wpdb->get_results($querystr, OBJECT); 488 $invTable = scormcloud_getTableName('scormcloudinvitations'); 489 $regTable = scormcloud_getTableName('scormcloudinvitationregs'); 490 $query = $wpdb->prepare('SELECT reg.*, inv.course_id FROM '.$regTable.' reg JOIN '.$invTable.' inv 491 ON reg.invite_id = inv.invite_id 492 WHERE reg.invite_id = %s ORDER BY reg.update_date DESC', array($inviteId)); 493 $inviteRegs = $wpdb->get_results($query, OBJECT); 494 494 495 495 $regService = $ScormService->getRegistrationService(); … … 553 553 $active = $_POST['active']; 554 554 555 $ querystr = "UPDATE ".scormcloud_getDBPrefix()."scormcloudinvitations SET active = $active WHERE invite_id = '$inviteId'";556 $wpdb->query($querystr);555 $wpdb->update(scormcloud_getTableName('scormcloudinvitations'), 556 array('active' => $active, 'invite_id' => $inviteId)); 557 557 558 558 break; … … 586 586 $show_course_info = 0; 587 587 588 $wpdb->query($wpdb->prepare( " 589 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitations 590 (invite_id, blog_id, app_id, post_id, course_id, course_title, header, description, require_login, show_course_info) 591 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %d, %d)", 592 $inviteId, $GLOBALS['blog_id'], $appId, $postId, $courseId, $courseTitle, $header, $description, $require_login, $show_course_info)); 593 588 $wpdb->insert(scormcloud_getTableName('scormcloudinvitations'), 589 array('invite_id' => $inviteId, 590 'blog_id' => $GLOBALS['blog_id'], 591 'app_id' => $appId, 592 'post_id' => $postId, 593 'course_id' => $courseId, 594 'course_title' => $courseTitle, 595 'header' => $header, 596 'description' => $description, 597 'require_login' => $require_login, 598 'show_course_info' => $show_course_info), 599 array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d')); 594 600 595 601 $courseTags = 'catalog_widget'; … … 601 607 $regService = $ScormService->getRegistrationService(); 602 608 $regService->CreateRegistration($regid, $courseId, $user_email, $user_first_name, $user_last_name,$user_email); 603 604 $wpdb->query($wpdb->prepare( " 605 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitationregs 606 (invite_id, reg_id, user_id, user_email) 607 VALUES (%s, %s, %d, %s)", 608 $inviteId, $regid, $current_user->ID, $user_email)); 609 610 $wpdb->insert(scormcloud_getTableName('scormcloudinvitationregs'), 611 array('invite_id' => $inviteId, 612 'reg_id' => $regid, 613 'user_id' => $current_user->ID, 614 'user_email' => $user_email), 615 array('%s', '%s', '%d', '%s')); 609 616 610 617 if (function_exists("bp_activity_add")){ … … 659 666 $regService = $ScormService->getRegistrationService(); 660 667 661 $querystr = "select r.reg_id, r.invite_id from ".scormcloud_getDBPrefix()."scormcloudinvitations i 662 JOIN ".scormcloud_getDBPrefix()."scormcloudinvitationregs r on i.invite_id = r.invite_id 663 WHERE r.user_email = '$user_email' and i.course_id = '$courseId'"; 664 $inviteRegs = $wpdb->get_results($querystr, OBJECT); 665 if (count($inviteRegs) > 0) { 666 $inviteReg = $inviteRegs[0]; 668 $query = $wpdb->prepare('SELECT r.reg_id, r.invite_id FROM '.scormcloud_getTableName('scormcloudinvitations').' i 669 JOIN '.scormcloud_getTableName('scormcloudinvitationregs').' r ON i.invite_id = r.invite_id 670 WHERE r.user_email = %s AND i.course_id = %s', array($user_email, $courseId)); 671 $inviteReg = $wpdb->get_row($query, OBJECT); 672 if ($inviteReg != null) { 667 673 $regid = (string)$inviteReg->reg_id; 668 674 $inviteId = (string)$inviteReg->invite_id; … … 674 680 $show_course_info = 0; 675 681 //error_log(scormcloud_getDBPrefix()); 676 $wpdb->query($wpdb->prepare( " 677 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitations 678 (invite_id, blog_id, app_id, post_id, course_id, course_title, header, description, require_login, show_course_info) 679 VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %d, %d)", 680 $inviteId, $GLOBALS['blog_id'], $appId, $postId, $courseId, $courseTitle, $header, $description, $require_login, $show_course_info)); 682 $wpdb->insert(scormcloud_getTableName('scormcloudinvitations'), 683 array('invite_id' => $inviteId, 684 'blog_id' => $GLOBALS['blog_id'], 685 'app_id' => $appId, 686 'post_id' => $postId, 687 'course_id' => $courseId, 688 'course_title' => $courseTitle, 689 'header' => $header, 690 'description' => $description, 691 'require_login' => $require_login, 692 'show_course_info' => $show_course_info), 693 array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d')); 681 694 682 695 //create the cloud registration 683 696 $regService->CreateRegistration($regid, $courseId, $user_email, $user_first_name, $user_last_name, $user_email); 684 697 685 $wpdb->query($wpdb->prepare( " 686 INSERT INTO ".scormcloud_getDBPrefix()."scormcloudinvitationregs 687 (invite_id, reg_id, user_email) 688 VALUES (%s, %s, %s)", 689 $inviteId, $regid, $user_email));698 $wpdb->insert(scormcloud_getTableName('scormcloudinvitationregs'), 699 array('invite_id' => $inviteId, 700 'reg_id' => $regid, 701 'user_email' => $user_email), 702 array('%s', '%s', '%s')); 690 703 } 691 704 -
scormcloud/trunk/readme.txt
r411704 r435356 1 1 === Plugin Name === 2 Contributors: troyef 2 Contributors: troyef, stuartchilds 3 3 Tags: elearning, learning, scorm, aicc, education, training, cloud 4 4 Requires at least: 2.9 5 5 Tested up to: 3.2.1 6 Stable tag: 1.0. 6.66 Stable tag: 1.0.7 7 7 8 8 Tap the power of SCORM to deliver and track training right from your WordPress-powered site. … … 49 49 50 50 == Changelog == 51 52 = 1.0.7 = 53 * Fixes some security vulnerabilities. 51 54 52 55 = 1.0.6.6 = … … 95 98 == Upgrade Notice == 96 99 100 = 1.0.7 = 101 * Critical security vulnerability fixes. Upgrade immediately. 102 97 103 = 1.0.6.6 = 98 104 * Small update to fix a potentially troublesome php tag. Not needed if you are embedding trainings in posts without issue. -
scormcloud/trunk/scormcloud.catalogwidget.php
r382844 r435356 77 77 78 78 if(isset($current_user->user_login) && $current_user->user_login != '') { 79 $regs = $wpdb->get_results("SELECT reg.reg_id,inv.course_title,inv.course_id, inv.active, reg.update_date FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs reg 80 JOIN ".scormcloud_getDBPrefix()."scormcloudinvitations inv ON reg.invite_id = inv.invite_id 81 WHERE reg.user_id = '".$current_user->ID."' AND inv.course_id = '".$courseId."' 82 ORDER BY reg.update_date DESC"); 79 $invTable = scormcloud_getTableName('scormcloudinvitations'); 80 $regTable = scormcloud_getTableName('scormcloudinvitationregs'); 81 $query = $wpdb->prepare('SELECT reg.reg_id, inv.course_title, inv.course_id, inv.active, reg.update_date FROM '.$regTable.' reg 82 JOIN '.$invTable.' inv ON reg.invite_id = inv.invite_id 83 WHERE reg.user_id = %s AND inv.course_id = %s ORDER BY reg.update_date DESC', 84 array($current_user->ID, $courseId)); 85 $reg = $wpdb->get_row($query, OBJECT); 83 86 84 if (count($regs) > 0){ 85 86 $reg = $regs[0]; 87 if ($reg != null) { 87 88 $regId = $reg->reg_id; 88 89 $regResultsXmlStr = $regService->GetRegistrationResult($regId,0,0); -
scormcloud/trunk/scormcloud.php
r411704 r435356 5 5 Description: Tap the power of SCORM to deliver and track training right from your WordPress-powered site. Just add the SCORM Cloud widget to the sidebar or use the SCORM Cloud button to add a link directly in a post or page. 6 6 Author: Rustici Software 7 Version: 1.0. 6.67 Version: 1.0.7 8 8 Author URI: http://www.scorm.com 9 9 */ … … 187 187 global $wpdb; 188 188 require_once('scormcloud.wp.php'); 189 require_once('SCORM API/DebugLogger.php');189 require_once('SCORMCloud_PHPLibrary/DebugLogger.php'); 190 190 $ScormService = scormcloud_getScormEngineService(); 191 191 $regService = $ScormService->getRegistrationService(); -
scormcloud/trunk/scormcloud.widget.php
r386359 r435356 48 48 $regService = $ScormService->getRegistrationService(); 49 49 50 $regs = $wpdb->get_results("SELECT reg.reg_id,inv.course_title,inv.course_id, inv.active, reg.update_date FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs reg 51 JOIN ".scormcloud_getDBPrefix()."scormcloudinvitations inv ON reg.invite_id = inv.invite_id 52 WHERE user_id = '".$current_user->ID."' AND inv.blog_id = '".$GLOBALS['blog_id']."' 53 ORDER BY reg.update_date DESC"); 54 50 $invTable = scormcloud_getTableName('scormcloudinvitations'); 51 $regTable = scormcloud_getTableName('scormcloudinvitationregs'); 52 $query = $wpdb->prepare('SELECT reg.reg_id, inv.course_title, inv.course_id, inv.active, reg.update_date FROM '.$regTable.' reg 53 JOIN '.$invTable.' inv ON reg.invite_id = inv.invite_id 54 WHERE user_id = %s AND inv.blog_id = %s ORDER BY reg.update_date DESC', 55 array($current_user->ID, $GLOBALS['blog_id'])); 56 $regs = $wpdb->get_results($query, OBJECT); 55 57 //echo count($regs); 56 58 -
scormcloud/trunk/scormcloud.wp.php
r283699 r435356 2 2 3 3 function scormcloud_getScormEngineService(){ 4 require_once('SCORMAPI/ScormEngineService.php'); 4 require_once('SCORMCloud_PHPLibrary/ScormEngineService.php'); 5 require_once('SCORMCloud_PHPLibrary/ScormEngineUtilities.php'); 5 6 6 7 if (scormcloud_isScormCloudNetworkManaged()){ … … 15 16 } 16 17 18 $origin = ScormEngineUtilities::getCanonicalOriginString('Rustici Software', 'WordPress', '1.0.6.6'); 19 17 20 //arbitrary number 17 is the length of 'EngineWebServices' 18 21 if (strlen($engine_url) < 17){ … … 20 23 } 21 24 22 return new ScormEngineService($engine_url,$appid,$secretkey );25 return new ScormEngineService($engine_url,$appid,$secretkey,$origin); 23 26 } 24 27 … … 60 63 } 61 64 65 function scormcloud_getTableName($table) { 66 return scormcloud_getDBPrefix().$table; 67 } 68 69 /** 70 * Works similarly to $wpdb->insert/update to select a single row. 71 * 72 * First arg is always table name, e.g. 'scormcloudinvitations' 73 * Second arg is an associative array of column/value pairs for the WHERE clause in the query, 74 * e.g. array('invite_id' => $inviteId) 75 * If a third arg is provided, it must be an array of the same dimensions as the second arg and 76 * provide a list of format specifiers, e.g. array('%s', '%s', '%d') 77 * 78 * Returns the resulting row in OBJECT format, or null if no row was found or the call was invalid 79 * 80 */ 81 function scormcloud_getRow() { 82 global $wpdb; 83 $numargs = func_num_args(); 84 if ($numargs < 2 || $numargs > 3) { 85 return null; 86 } 87 88 $table = func_get_arg(0); 89 90 $wheres = null; 91 $formats = null; 92 if ($numargs == 2) { 93 $arg = func_get_arg(1); 94 if (!is_array($arg)) { 95 // Must be array 96 return null; 97 } else { 98 $wheres = $arg; 99 } 100 } else if ($numargs == 3) { 101 $arg = func_get_arg(1); 102 $arg2 = func_get_arg(2); 103 if (!(is_array($arg) && is_array($arg2))) { 104 // In the 2-arg call format, the args must be arrays 105 return null; 106 } 107 108 if (empty($arg) || (count($arg) != count($arg2))) { 109 // Arrays must not be empty and must contain same number of args 110 return null; 111 } 112 113 $wheres = $arg; 114 $formats = $arg2; 115 } 116 117 $i = 0; 118 $first = true; 119 $whereClause = ' WHERE '; 120 $whereValues = array(); 121 foreach ($wheres as $col => $val) { 122 $format = '%s'; 123 if ($formats !== null) { 124 $format = $formats[$i]; 125 $i++; 126 } 127 128 $comma = ', '; 129 if ($first) { 130 $comma = ''; 131 $first = false; 132 } 133 134 $whereClause .= $comma.$col.' = '.$format; 135 $whereValues[] = $val; 136 } 137 138 $query = $wpdb->prepare('SELECT * FROM '.scormcloud_getTableName($table).$whereClause, $whereValues); 139 return $wpdb->get_row($query, OBJECT); 140 } 141 142 function scormcloud_ensureArray($default, $val) { 143 if (!is_array($val)) { 144 return array($default => $val); 145 } 146 147 return $val; 148 } 149 150 /** 151 * Convenience wrapper for scormcloud_getRow to select a single invitation 152 * 153 * If the first arg is an array, it is assumed to be an associative array of column/value pairs to pass on to scormcloud_getRow. If it 154 * is not an array, the arg is used as the value for the invite_id column, allowing for a simple scormcloud_getInvitation($inviteId) 155 * If a second arg is provided, it should be an array of format specifiers for the first arg 156 */ 157 function scormcloud_getInvitation() { 158 $callArgs = array('scormcloudinvitations'); // Table name 159 $args = func_get_args(); 160 $args[0] = scormcloud_ensureArray('invite_id', $args[0]); 161 array_push($callArgs, $args); 162 return call_user_func_array('scormcloud_getRow', $callArgs); 163 } 164 165 /** 166 * Convenience wrapper for scormcloud_getRow to select a single invitation registration 167 * 168 * If the first arg is an array, it is assumed to be an associative array of column/value pairs to pass on to scormcloud_getRow. If it 169 * is not an array, the arg is used as the value for the reg_id column, allowing for a simple scormcloud_getInvitationReg($regId) 170 * If a second arg is provided, it should be an array of format specifiers for the first arg 171 */ 172 function scormcloud_getInvitationReg() { 173 $callArgs = array('scormcloudinvitationregs'); // Table name 174 $args = func_get_args(); 175 $args[0] = scormcloud_ensureArray('reg_id', $args[0]); 176 array_push($callArgs, $args); 177 return call_user_func_array('scormcloud_getRow', $args); 178 } 179 62 180 function scormcloud_regsRemaining(){ 63 181 $ScormService = scormcloud_getScormEngineService(); -
scormcloud/trunk/scormcloud_makeBlogEntry.php
r368807 r435356 17 17 $inviteId = substr($tagString,21,strlen($tagString) - 22); 18 18 19 $querystr = "SELECT * FROM ".scormcloud_getDBPrefix()."scormcloudinvitations WHERE invite_id = '".$inviteId."'"; 20 $invites = $wpdb->get_results($querystr, OBJECT); 21 if (count($invites) == 0){ 19 $invite = scormcloud_getInvitation($inviteId); 20 if ($invite == null) { 22 21 $content = str_replace($tagString,'',$content); 23 22 } 24 25 $invite = $invites[0];26 23 27 24 $inviteHtml = "<div class='scormCloudInvitation' key='$inviteId'>"; … … 84 81 } else { 85 82 $userId = $current_user->ID; 86 $querystr = "SELECT reg_id FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs WHERE invite_id = '$inviteId' AND user_id = '$userId' ORDER BY update_date DESC"; 87 $regs = $wpdb->get_results($querystr, OBJECT); 88 if (count($regs) > 0){ 89 $regId = $regs[0]->reg_id; 83 $query = $wpdb->prepare('SELECT reg_id FROM '.scormcloud_getTableName('scormcloudinvitationregs').' WHERE invite_id = %s AND 84 user_id = %s ORDER BY update_date DESC', array($inviteId, $userId)); 85 $reg = $wpdb->get_row($query, OBJECT); 86 if ($reg != null){ 87 $regId = $reg->reg_id; 90 88 91 89 $regService = $ScormService->getRegistrationService(); … … 157 155 $inviteId = substr($tagString,21,strlen($tagString) - 22); 158 156 159 $querystr = "UPDATE ".scormcloud_getDBPrefix()."scormcloudinvitations SET post_id = '$postId' WHERE invite_id = '$inviteId'"; 160 $wpdb->query($querystr); 161 162 163 164 157 $wpdb->update(scormcloud_getTableName('scormcloudinvitations'), 158 array('post_id' => $postId, 'invite_id' => $inviteId)); 165 159 } 166 160 -
scormcloud/trunk/scormcloud_manage_training.php
r361868 r435356 217 217 <?php 218 218 219 $querystr = "SELECT inv.*, count(reg.reg_id) as reg_count FROM ".scormcloud_getDBPrefix()."scormcloudinvitations inv 220 LEFT OUTER JOIN ".scormcloud_getDBPrefix()."scormcloudinvitationregs reg ON inv.invite_id = reg.invite_id 221 WHERE inv.blog_id = '".$GLOBALS['blog_id']."' 222 GROUP BY inv.invite_id 223 ORDER BY inv.create_date DESC"; 224 225 $invites = $wpdb->get_results($querystr, OBJECT); 219 $invTable = scormcloud_getTableName('scormcloudinvitations'); 220 $regTable = scormcloud_getTableName('scormcloudinvitationregs'); 221 $query = $wpdb->prepare('SELECT inv.*, count(reg.reg_id) as reg_count FROM '.$invTable.' inv 222 LEFT OUTER JOIN '.$regTable.' reg ON inv.invite_id = reg.invite_id 223 WHERE inv.blog_id = %s GROUP BY inv.invite_id ORDER BY inv.create_date DESC', array($GLOBALS['blog_id'])); 224 $invites = $wpdb->get_results($query, OBJECT); 226 225 227 226 echo '<table class="widefat" cellspacing="0" id="InvitationListTable" >'; -
scormcloud/trunk/scormcloud_training_details.php
r361868 r435356 3 3 $inviteId = $_GET['inviteid']; 4 4 5 $querystr = "SELECT inv.*, count(reg.reg_id) as reg_count FROM ".scormcloud_getDBPrefix()."scormcloudinvitations inv 6 LEFT OUTER JOIN ".scormcloud_getDBPrefix()."scormcloudinvitationregs reg ON inv.invite_id = reg.invite_id 7 WHERE inv.invite_id = '$inviteId' 8 GROUP BY inv.invite_id"; 9 10 $invites = $wpdb->get_results($querystr, OBJECT); 11 $invite = $invites[0]; 5 $invTable = scormcloud_getTableName('scormcloudinvitations'); 6 $regTable = scormcloud_getTableName('scormcloudinvitationregs'); 7 $query = $wpdb->prepare('SELECT inv.*, count(reg.reg_id) as reg_count FROM '.$invTable.' inv 8 LEFT OUTER JOIN '.$regTable.' reg ON inv.invite_id = reg.invite_id 9 WHERE inv.invite_id = %s GROUP BY inv.invite_id', array($inviteId)); 10 $invite = $wpdb->get_row($query, OBJECT); 12 11 13 12 … … 210 209 <?php 211 210 212 $query str = "SELECT * FROM ".scormcloud_getDBPrefix()."scormcloudinvitationregs WHERE invite_id = '$inviteId' ORDER BY update_date DESC";213 $inviteRegs = $wpdb->get_results($query str, OBJECT);211 $query = $wpdb->prepare('SELECT * FROM '.$regTable.' WHERE invite_id = %s ORDER BY update_date DESC', array($inviteId)); 212 $inviteRegs = $wpdb->get_results($query, OBJECT); 214 213 215 214 $regService = $ScormService->getRegistrationService();
Note: See TracChangeset
for help on using the changeset viewer.