28# NB This class assumes that a MySQL connection has already been opened to the appropriate schema
44 Util::logDebug(
'Class ceLTIc\LTI\DataConnector\DataConnector_mysql has been deprecated; please use ceLTIc\LTI\DataConnector\DataConnector_mysqli instead.',
62 $allowMultiple =
false;
63 if (!is_null($platform->getRecordId())) {
64 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
65 'platform_id, client_id, deployment_id, public_key, ' .
66 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
67 'profile, tool_proxy, settings, protected, enabled, ' .
68 'enable_from, enable_until, last_access, created, updated ' .
69 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
70 'WHERE consumer_pk = %d', $platform->getRecordId());
71 } elseif (!empty($platform->platformId)) {
72 if (empty($platform->clientId)) {
73 $allowMultiple =
true;
74 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
75 'platform_id, client_id, deployment_id, public_key, ' .
76 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
77 'profile, tool_proxy, settings, protected, enabled, ' .
78 'enable_from, enable_until, last_access, created, updated ' .
79 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
80 'WHERE (platform_id = %s) ', $this->
escape($platform->platformId));
81 } elseif (empty($platform->deploymentId)) {
82 $allowMultiple =
true;
83 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
84 'platform_id, client_id, deployment_id, public_key, ' .
85 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
86 'profile, tool_proxy, settings, protected, enabled, ' .
87 'enable_from, enable_until, last_access, created, updated ' .
88 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
89 'WHERE (platform_id = %s) AND (client_id = %s)', $this->
escape($platform->platformId),
90 $this->escape($platform->clientId));
92 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
93 'platform_id, client_id, deployment_id, public_key, ' .
94 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
95 'profile, tool_proxy, settings, protected, enabled, ' .
96 'enable_from, enable_until, last_access, created, updated ' .
97 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
98 'WHERE (platform_id = %s) AND (client_id = %s) AND (deployment_id = %s)', $this->
escape($platform->platformId),
99 $this->escape($platform->clientId), $this->escape($platform->deploymentId));
102 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
103 'platform_id, client_id, deployment_id, public_key, ' .
104 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
105 'profile, tool_proxy, settings, protected, enabled, ' .
106 'enable_from, enable_until, last_access, created, updated ' .
107 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
108 'WHERE consumer_key = %s', $this->
escape($platform->getKey()));
110 $rsConsumer = $this->executeQuery($sql);
112 $row = mysql_fetch_object($rsConsumer);
113 if ($row && ($allowMultiple || !mysql_fetch_object($rsConsumer))) {
114 $platform->setRecordId(intval($row->consumer_pk));
115 $platform->name = $row->name;
116 $platform->setkey($row->consumer_key);
117 $platform->secret = $row->secret;
118 $platform->platformId = $row->platform_id;
119 $platform->clientId = $row->client_id;
120 $platform->deploymentId = $row->deployment_id;
121 $platform->rsaKey = $row->public_key;
122 $platform->ltiVersion = $row->lti_version;
123 $platform->signatureMethod = $row->signature_method;
124 $platform->consumerName = $row->consumer_name;
125 $platform->consumerVersion = $row->consumer_version;
126 $platform->consumerGuid = $row->consumer_guid;
128 $platform->toolProxy = $row->tool_proxy;
130 if (!is_array($settings)) {
131 $settings = @unserialize($row->settings);
133 if (!is_array($settings)) {
136 $platform->setSettings($settings);
137 $platform->protected = (intval($row->protected) === 1);
138 $platform->enabled = (intval($row->enabled) === 1);
139 $platform->enableFrom =
null;
140 if (!is_null($row->enable_from)) {
141 $platform->enableFrom = strtotime($row->enable_from);
143 $platform->enableUntil =
null;
144 if (!is_null($row->enable_until)) {
145 $platform->enableUntil = strtotime($row->enable_until);
147 $platform->lastAccess =
null;
148 if (!is_null($row->last_access)) {
149 $platform->lastAccess = strtotime($row->last_access);
151 $platform->created = strtotime($row->created);
152 $platform->updated = strtotime($row->updated);
170 $id = $platform->getRecordId();
171 $protected = ($platform->protected) ? 1 : 0;
172 $enabled = ($platform->enabled) ? 1 : 0;
173 $profile = (!empty($platform->profile)) ? json_encode($platform->profile) :
null;
175 $settingsValue = json_encode($platform->getSettings());
178 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
180 if (!is_null($platform->enableFrom)) {
181 $from = date(
"{$this->dateFormat} {$this->timeFormat}", $platform->enableFrom);
184 if (!is_null($platform->enableUntil)) {
185 $until = date(
"{$this->dateFormat} {$this->timeFormat}", $platform->enableUntil);
188 if (!is_null($platform->lastAccess)) {
189 $last = date($this->dateFormat, $platform->lastAccess);
192 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' (consumer_key, name, secret, ' .
193 'platform_id, client_id, deployment_id, public_key, ' .
194 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
195 'profile, tool_proxy, settings, protected, enabled, ' .
196 'enable_from, enable_until, last_access, created, updated) ' .
197 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %d, %s, %s, %s, %s, %s)',
198 $this->
escape($platform->getKey()), $this->escape($platform->name), $this->escape($platform->secret),
199 $this->escape($platform->platformId), $this->escape($platform->clientId), $this->escape($platform->deploymentId),
200 $this->escape($platform->rsaKey), $this->escape($platform->ltiVersion), $this->escape($platform->signatureMethod),
201 $this->escape($platform->consumerName), $this->escape($platform->consumerVersion),
202 $this->escape($platform->consumerGuid), $this->escape($profile), $this->escape($platform->toolProxy),
203 $this->escape($settingsValue), $protected, $enabled, $this->escape($from), $this->escape($until),
204 $this->escape($last), $this->escape($now), $this->escape($now));
206 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' SET ' .
207 'consumer_key = %s, name = %s, secret= %s, ' .
208 'platform_id = %s, client_id = %s, deployment_id = %s, public_key = %s, ' .
209 'lti_version = %s, signature_method = %s, ' .
210 'consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
211 'profile = %s, tool_proxy = %s, settings = %s, ' .
212 'protected = %d, enabled = %d, enable_from = %s, enable_until = %s, last_access = %s, updated = %s ' .
213 'WHERE consumer_pk = %d', $this->
escape($platform->getKey()), $this->escape($platform->name),
214 $this->escape($platform->secret), $this->escape($platform->platformId), $this->escape($platform->clientId),
215 $this->escape($platform->deploymentId), $this->escape($platform->rsaKey), $this->escape($platform->ltiVersion),
216 $this->escape($platform->signatureMethod), $this->escape($platform->consumerName),
217 $this->escape($platform->consumerVersion), $this->escape($platform->consumerGuid), $this->escape($profile),
218 $this->escape($platform->toolProxy), $this->escape($settingsValue), $protected, $enabled, $this->escape($from),
219 $this->escape($until), $this->escape($last), $this->escape($now), $platform->getRecordId());
221 $ok = $this->executeQuery($sql);
224 $platform->setRecordId(mysql_insert_id());
225 $platform->created = $time;
227 $platform->updated = $time;
243 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::ACCESS_TOKEN_TABLE_NAME .
' WHERE consumer_pk = %d',
244 $platform->getRecordId());
245 $this->executeQuery($sql);
248 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
' WHERE consumer_pk = %d',
249 $platform->getRecordId());
250 $this->executeQuery($sql);
253 $sql = sprintf(
'DELETE sk ' .
254 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' sk ' .
255 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
256 'WHERE rl.consumer_pk = %d', $platform->getRecordId());
257 $this->executeQuery($sql);
260 $sql = sprintf(
'DELETE sk ' .
261 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' sk ' .
262 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
263 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk ' .
264 'WHERE c.consumer_pk = %d', $platform->getRecordId());
265 $this->executeQuery($sql);
268 $sql = sprintf(
'DELETE u ' .
269 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' u ' .
270 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON u.resource_link_pk = rl.resource_link_pk ' .
271 'WHERE rl.consumer_pk = %d', $platform->getRecordId());
272 $this->executeQuery($sql);
275 $sql = sprintf(
'DELETE u ' .
276 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' u ' .
277 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON u.resource_link_pk = rl.resource_link_pk ' .
278 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk ' .
279 'WHERE c.consumer_pk = %d', $platform->getRecordId());
280 $this->executeQuery($sql);
283 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' prl ' .
284 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
285 'SET prl.primary_resource_link_pk = NULL, prl.share_approved = NULL ' .
286 'WHERE rl.consumer_pk = %d', $platform->getRecordId());
287 $ok = $this->executeQuery($sql);
290 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' prl ' .
291 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
292 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk ' .
293 'SET prl.primary_resource_link_pk = NULL, prl.share_approved = NULL ' .
294 'WHERE c.consumer_pk = %d', $platform->getRecordId());
295 $ok = $this->executeQuery($sql);
298 $sql = sprintf(
'DELETE rl ' .
299 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ' .
300 'WHERE rl.consumer_pk = %d', $platform->getRecordId());
301 $this->executeQuery($sql);
304 $sql = sprintf(
'DELETE rl ' .
305 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ' .
306 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk ' .
307 'WHERE c.consumer_pk = %d', $platform->getRecordId());
308 $this->executeQuery($sql);
311 $sql = sprintf(
'DELETE c ' .
312 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ' .
313 'WHERE c.consumer_pk = %d', $platform->getRecordId());
314 $this->executeQuery($sql);
317 $sql = sprintf(
'DELETE c ' .
318 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' c ' .
319 'WHERE c.consumer_pk = %d', $platform->getRecordId());
320 $ok = $this->executeQuery($sql);
323 $platform->initialize();
336 $platforms = array();
338 $sql =
'SELECT consumer_pk, consumer_key, name, secret, ' .
339 'platform_id, client_id, deployment_id, public_key, ' .
340 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
341 'profile, tool_proxy, settings, ' .
342 'protected, enabled, enable_from, enable_until, last_access, created, updated ' .
343 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
345 $rsConsumers = $this->executeQuery($sql);
347 while ($row = mysql_fetch_object($rsConsumers)) {
349 $platform->setRecordId(intval($row->consumer_pk));
350 $platform->name = $row->name;
351 $platform->setKey($row->consumer_key);
352 $platform->secret = $row->secret;
353 $platform->platformId = $row->platform_id;
354 $platform->clientId = $row->client_id;
355 $platform->deploymentId = $row->deployment_id;
356 $platform->rsaKey = $row->public_key;
357 $platform->ltiVersion = $row->lti_version;
358 $platform->signatureMethod = $row->signature_method;
359 $platform->consumerName = $row->consumer_name;
360 $platform->consumerVersion = $row->consumer_version;
361 $platform->consumerGuid = $row->consumer_guid;
363 $platform->toolProxy = $row->tool_proxy;
365 if (!is_array($settings)) {
366 $settings = @unserialize($row->settings);
368 if (!is_array($settings)) {
371 $platform->setSettings($settings);
372 $platform->protected = (intval($row->protected) === 1);
373 $platform->enabled = (intval($row->enabled) === 1);
374 $platform->enableFrom =
null;
375 if (!is_null($row->enable_from)) {
376 $platform->enableFrom = strtotime($row->enable_from);
378 $platform->enableUntil =
null;
379 if (!is_null($row->enable_until)) {
380 $platform->enableUntil = strtotime($row->enable_until);
382 $platform->lastAccess =
null;
383 if (!is_null($row->last_access)) {
384 $platform->lastAccess = strtotime($row->last_access);
386 $platform->created = strtotime($row->created);
387 $platform->updated = strtotime($row->updated);
389 $platforms[] = $platform;
391 mysql_free_result($rsConsumers);
411 if (!is_null($context->getRecordId())) {
412 $sql = sprintf(
'SELECT context_pk, consumer_pk, title, lti_context_id, type, settings, created, updated ' .
413 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ' .
414 'WHERE (context_pk = %d)', $context->getRecordId());
416 $sql = sprintf(
'SELECT context_pk, consumer_pk, title, lti_context_id, type, settings, created, updated ' .
417 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ' .
418 'WHERE (consumer_pk = %d) AND (lti_context_id = %s)', $context->getPlatform()->getRecordId(),
419 $this->escape($context->ltiContextId));
421 $rsContext = $this->executeQuery($sql);
423 $row = mysql_fetch_object($rsContext);
425 $context->setRecordId(intval($row->context_pk));
426 $context->setPlatformId(intval($row->consumer_pk));
427 $context->title = $row->title;
428 $context->ltiContextId = $row->lti_context_id;
429 $context->type = $row->type;
431 if (!is_array($settings)) {
432 $settings = @unserialize($row->settings);
434 if (!is_array($settings)) {
437 $context->setSettings($settings);
438 $context->created = strtotime($row->created);
439 $context->updated = strtotime($row->updated);
457 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
458 $settingsValue = json_encode($context->getSettings());
459 $id = $context->getRecordId();
460 $consumer_pk = $context->getPlatform()->getRecordId();
462 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' (consumer_pk, title, ' .
463 'lti_context_id, type, settings, created, updated) ' .
464 'VALUES (%d, %s, %s, %s, %s, %s, %s)', $consumer_pk, $this->
escape($context->title),
465 $this->escape($context->ltiContextId), $this->escape($context->type), $this->escape($settingsValue),
466 $this->escape($now), $this->escape($now));
468 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' SET ' .
469 'title = %s, lti_context_id = %s, type = %s, settings = %s, ' .
471 'WHERE (consumer_pk = %d) AND (context_pk = %d)', $this->
escape($context->title),
472 $this->escape($context->ltiContextId), $this->escape($context->type), $this->escape($settingsValue),
473 $this->escape($now), $consumer_pk, $id);
475 $ok = $this->executeQuery($sql);
478 $context->setRecordId(mysql_insert_id());
479 $context->created = $time;
481 $context->updated = $time;
497 $sql = sprintf(
'DELETE sk ' .
498 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' sk ' .
499 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON sk.resource_link_pk = rl.resource_link_pk ' .
500 'WHERE rl.context_pk = %d', $context->getRecordId());
501 $this->executeQuery($sql);
504 $sql = sprintf(
'DELETE u ' .
505 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' u ' .
506 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON u.resource_link_pk = rl.resource_link_pk ' .
507 'WHERE rl.context_pk = %d', $context->getRecordId());
508 $this->executeQuery($sql);
511 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' prl ' .
512 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ON prl.primary_resource_link_pk = rl.resource_link_pk ' .
513 'SET prl.primary_resource_link_pk = null, prl.share_approved = null ' .
514 'WHERE rl.context_pk = %d', $context->getRecordId());
515 $ok = $this->executeQuery($sql);
518 $sql = sprintf(
'DELETE rl ' .
519 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ' .
520 'WHERE rl.context_pk = %d', $context->getRecordId());
521 $this->executeQuery($sql);
524 $sql = sprintf(
'DELETE c ' .
525 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ',
'WHERE c.context_pk = %d',
526 $context->getRecordId());
527 $ok = $this->executeQuery($sql);
529 $context->initialize();
536### ResourceLink methods
549 if (!is_null($resourceLink->getRecordId())) {
550 $sql = sprintf(
'SELECT resource_link_pk, context_pk, consumer_pk, title, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated ' .
551 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
552 'WHERE (resource_link_pk = %d)', $resourceLink->getRecordId());
553 } elseif (!is_null($resourceLink->getContext())) {
554 $sql = sprintf(
'SELECT r.resource_link_pk, r.context_pk, r.consumer_pk, r.title, r.lti_resource_link_id, r.settings, r.primary_resource_link_pk, r.share_approved, r.created, r.updated ' .
555 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' r ' .
556 'WHERE (r.lti_resource_link_id = %s) AND ((r.context_pk = %d) OR (r.consumer_pk IN (' .
557 'SELECT c.consumer_pk ' .
558 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ' .
559 'WHERE (c.context_pk = %d))))', $this->
escape($resourceLink->getId()), $resourceLink->getContext()->getRecordId(),
560 $resourceLink->getContext()->getRecordId());
562 $sql = sprintf(
'SELECT r.resource_link_pk, r.context_pk, r.consumer_pk, r.title, r.lti_resource_link_id, r.settings, r.primary_resource_link_pk, r.share_approved, r.created, r.updated ' .
563 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' r LEFT OUTER JOIN ' .
564 $this->dbTableNamePrefix . static::CONTEXT_TABLE_NAME .
' c ON r.context_pk = c.context_pk ' .
565 ' WHERE ((r.consumer_pk = %d) OR (c.consumer_pk = %d)) AND (lti_resource_link_id = %s)',
566 $resourceLink->getPlatform()->getRecordId(), $resourceLink->getPlatform()->getRecordId(),
567 $this->escape($resourceLink->getId()));
569 $rsResourceLink = $this->executeQuery($sql);
570 if ($rsResourceLink) {
571 $row = mysql_fetch_object($rsResourceLink);
573 $resourceLink->setRecordId(intval($row->resource_link_pk));
574 if (!is_null($row->context_pk)) {
575 $resourceLink->setContextId(intval($row->context_pk));
577 $resourceLink->setContextId(
null);
579 if (!is_null($row->consumer_pk)) {
580 $resourceLink->setPlatformId(intval($row->consumer_pk));
582 $resourceLink->setPlatformId(
null);
584 $resourceLink->title = $row->title;
585 $resourceLink->ltiResourceLinkId = $row->lti_resource_link_id;
587 if (!is_array($settings)) {
588 $settings = @unserialize($row->settings);
590 if (!is_array($settings)) {
593 $resourceLink->setSettings($settings);
594 if (!is_null($row->primary_resource_link_pk)) {
595 $resourceLink->primaryResourceLinkId = intval($row->primary_resource_link_pk);
597 $resourceLink->primaryResourceLinkId =
null;
599 $resourceLink->shareApproved = (is_null($row->share_approved)) ?
null : (intval($row->share_approved) === 1);
600 $resourceLink->created = strtotime($row->created);
601 $resourceLink->updated = strtotime($row->updated);
618 if (is_null($resourceLink->shareApproved)) {
620 } elseif ($resourceLink->shareApproved) {
625 if (empty($resourceLink->primaryResourceLinkId)) {
626 $primaryResourceLinkId =
'NULL';
628 $primaryResourceLinkId = strval($resourceLink->primaryResourceLinkId);
631 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
632 $settingsValue = json_encode($resourceLink->getSettings());
633 if (!is_null($resourceLink->getContext())) {
634 $consumerId =
'NULL';
635 $contextId = strval($resourceLink->getContext()->getRecordId());
636 } elseif (!is_null($resourceLink->getContextId())) {
637 $consumerId =
'NULL';
638 $contextId = strval($resourceLink->getContextId());
640 $consumerId = strval($resourceLink->getPlatform()->getRecordId());
643 $id = $resourceLink->getRecordId();
645 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' (consumer_pk, context_pk, ' .
646 'title, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated) ' .
647 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)', $consumerId, $contextId, $this->
escape($resourceLink->title),
648 $this->escape($resourceLink->getId()), $this->escape($settingsValue), $primaryResourceLinkId, $approved,
649 $this->escape($now), $this->escape($now));
650 } elseif ($contextId !==
'NULL') {
651 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' SET ' .
652 'consumer_pk = %s, title = %s, lti_resource_link_id = %s, settings = %s, ' .
653 'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
654 'WHERE (context_pk = %s) AND (resource_link_pk = %d)', $consumerId, $this->
escape($resourceLink->title),
655 $this->escape($resourceLink->getId()), $this->escape($settingsValue), $primaryResourceLinkId, $approved,
656 $this->escape($now), $contextId, $id);
658 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' SET ' .
659 'context_pk = NULL, title = %s, lti_resource_link_id = %s, settings = %s, ' .
660 'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
661 'WHERE (consumer_pk = %s) AND (resource_link_pk = %d)', $this->
escape($resourceLink->title),
662 $this->escape($resourceLink->getId()), $this->escape($settingsValue), $primaryResourceLinkId, $approved,
663 $this->escape($now), $consumerId, $id);
665 $ok = $this->executeQuery($sql);
668 $resourceLink->setRecordId(mysql_insert_id());
669 $resourceLink->created = $time;
671 $resourceLink->updated = $time;
687 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
688 'WHERE (resource_link_pk = %d)', $resourceLink->getRecordId());
689 $ok = $this->executeQuery($sql);
693 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
694 'WHERE (resource_link_pk = %d)', $resourceLink->getRecordId());
695 $ok = $this->executeQuery($sql);
700 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
701 'SET primary_resource_link_pk = NULL ' .
702 'WHERE (primary_resource_link_pk = %d)', $resourceLink->getRecordId());
703 $ok = $this->executeQuery($sql);
708 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
709 'WHERE (resource_link_pk = %s)', $resourceLink->getRecordId());
710 $ok = $this->executeQuery($sql);
714 $resourceLink->initialize();
734 $userResults = array();
737 $sql = sprintf(
'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
738 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' AS u ' .
739 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS rl ' .
740 'ON u.resource_link_pk = rl.resource_link_pk ' .
741 "WHERE (rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)", $resourceLink->getRecordId());
743 $sql = sprintf(
'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
744 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' AS u ' .
745 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS rl ' .
746 'ON u.resource_link_pk = rl.resource_link_pk ' .
747 'WHERE ((rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)) OR ' .
748 '((rl.primary_resource_link_pk = %d) AND (share_approved = 1))', $resourceLink->getRecordId(),
749 $resourceLink->getRecordId());
751 $rsUser = $this->executeQuery($sql);
753 while ($row = mysql_fetch_object($rsUser)) {
754 $userresult = LTI\UserResult::fromResourceLink($resourceLink, $row->lti_user_id);
755 if (is_null($idScope)) {
756 $userResults[] = $userresult;
758 $userResults[$userresult->getId($idScope)] = $userresult;
777 $sql = sprintf(
'SELECT c.consumer_name, r.resource_link_pk, r.title, r.share_approved ' .
778 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS r ' .
779 "INNER JOIN {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' AS c ON r.consumer_pk = c.consumer_pk ' .
780 'WHERE (r.primary_resource_link_pk = %d) ' .
782 'SELECT c2.consumer_name, r2.resource_link_pk, r2.title, r2.share_approved ' .
783 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS r2 ' .
784 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' AS x ON r2.context_pk = x.context_pk ' .
785 "INNER JOIN {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' AS c2 ON x.consumer_pk = c2.consumer_pk ' .
786 'WHERE (r2.primary_resource_link_pk = %d) ' .
787 'ORDER BY consumer_name, title', $resourceLink->getRecordId(), $resourceLink->getRecordId());
788 $rsShare = $this->executeQuery($sql);
790 while ($row = mysql_fetch_object($rsShare)) {
792 $share->consumerName = $row->consumer_name;
793 $share->resourceLinkId = intval($row->resource_link_pk);
794 $share->title = $row->title;
795 $share->approved = (intval($row->share_approved) === 1);
804### PlatformNonce methods
816 if (parent::useMemcache()) {
817 $ok = parent::loadPlatformNonce($nonce);
822 $now = date(
"{$this->dateFormat} {$this->timeFormat}", time());
823 $sql =
"DELETE FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
" WHERE expires <= '{$now}'";
824 $this->executeQuery($sql);
827 $sql = sprintf(
"SELECT value AS T FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
' WHERE (consumer_pk = %d) AND (value = %s)',
828 $nonce->getPlatform()->getRecordId(), $this->escape($nonce->getValue()));
829 $rsNonce = $this->executeQuery($sql,
false);
831 $row = mysql_fetch_object($rsNonce);
832 if ($row !==
false) {
850 if (parent::useMemcache()) {
851 $ok = parent::savePlatformNonce($nonce);
853 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $nonce->expires);
854 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
" (consumer_pk, value, expires) VALUES (%d, %s, %s)",
855 $nonce->getPlatform()->getRecordId(), $this->escape($nonce->getValue()), $this->escape($expires));
856 $ok = $this->executeQuery($sql);
871 if (parent::useMemcache()) {
872 $ok = parent::deletePlatformNonce($nonce);
874 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
' ' .
875 'WHERE (consumer_pk = %d) AND (value = %s)', $nonce->getPlatform()->getRecordId(), $this->escape($nonce->getValue()));
876 $ok = $this->executeQuery($sql);
883### AccessToken methods
895 if (parent::useMemcache()) {
896 $ok = parent::loadAccessToken($accessToken);
899 $consumer_pk = $accessToken->getPlatform()->getRecordId();
900 $sql = sprintf(
'SELECT scopes, token, expires, created, updated ' .
901 "FROM {$this->dbTableNamePrefix}" . static::ACCESS_TOKEN_TABLE_NAME .
' ' .
902 'WHERE (consumer_pk = %d)', $consumer_pk);
903 $rsAccessToken = $this->executeQuery($sql,
false);
904 if ($rsAccessToken) {
905 $row = mysql_fetch_object($rsAccessToken);
908 if (!is_array($scopes)) {
911 $accessToken->scopes = $scopes;
912 $accessToken->token = $row->token;
913 $accessToken->expires = strtotime($row->expires);
914 $accessToken->created = strtotime($row->created);
915 $accessToken->updated = strtotime($row->updated);
933 if (parent::useMemcache()) {
934 $ok = parent::saveAccessToken($accessToken);
936 $consumer_pk = $accessToken->getPlatform()->getRecordId();
937 $scopes = json_encode($accessToken->scopes, JSON_UNESCAPED_SLASHES);
938 $token = $accessToken->token;
939 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $accessToken->expires);
941 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
942 if (empty($accessToken->created)) {
943 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::ACCESS_TOKEN_TABLE_NAME .
' ' .
944 '(consumer_pk, scopes, token, expires, created, updated) ' .
945 'VALUES (%d, %s, %s, %s, %s, %s)', $consumer_pk, $this->
escape($scopes), $this->
escape($token),
948 $sql = sprintf(
'UPDATE ' . $this->dbTableNamePrefix . static::ACCESS_TOKEN_TABLE_NAME .
' ' .
949 'SET scopes = %s, token = %s, expires = %s, updated = %s WHERE consumer_pk = %d', $this->
escape($scopes),
952 $ok = $this->executeQuery($sql);
959### ResourceLinkShareKey methods
974 $now = date(
"{$this->dateFormat} {$this->timeFormat}", time());
975 $sql =
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
" WHERE expires <= '{$now}'";
976 $this->executeQuery($sql);
979 $id = mysql_real_escape_string($shareKey->getId());
980 $sql =
'SELECT resource_link_pk, auto_approve, expires ' .
981 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
982 "WHERE share_key_id = '{$id}'";
983 $rsShareKey = $this->executeQuery($sql);
985 $row = mysql_fetch_object($rsShareKey);
987 $shareKey->resourceLinkId = intval($row->resource_link_pk);
988 $shareKey->autoApprove = (intval($row->auto_approve) === 1);
989 $shareKey->expires = strtotime($row->expires);
1006 if ($shareKey->autoApprove) {
1011 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
1012 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
1013 '(share_key_id, resource_link_pk, auto_approve, expires) ' .
1014 "VALUES (%s, %d, {$approve}, '{$expires}')", $this->
escape($shareKey->getId()), $shareKey->resourceLinkId);
1015 $ok = $this->executeQuery($sql);
1029 $sql =
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
" WHERE share_key_id = '{$shareKey->getId()}'";
1031 $ok = $this->executeQuery($sql);
1034 $shareKey->initialize();
1041### UserResult methods
1054 if (!is_null($userresult->getRecordId())) {
1055 $sql = sprintf(
'SELECT user_result_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1056 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1057 'WHERE (user_result_pk = %d)', $userresult->getRecordId());
1059 $sql = sprintf(
'SELECT user_result_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1060 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1061 'WHERE (resource_link_pk = %d) AND (lti_user_id = %s)', $userresult->getResourceLink()->getRecordId(),
1064 $rsUserResult = $this->executeQuery($sql);
1065 if ($rsUserResult) {
1066 $row = mysql_fetch_object($rsUserResult);
1068 $userresult->setRecordId(intval($row->user_result_pk));
1069 $userresult->setResourceLinkId(intval($row->resource_link_pk));
1070 $userresult->ltiUserId = $row->lti_user_id;
1071 $userresult->ltiResultSourcedId = $row->lti_result_sourcedid;
1072 $userresult->created = strtotime($row->created);
1073 $userresult->updated = strtotime($row->updated);
1091 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
1092 if (is_null($userresult->created)) {
1093 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' (resource_link_pk, ' .
1094 'lti_user_id, lti_result_sourcedid, created, updated) ' .
1095 'VALUES (%d, %s, %s, %s, %s)', $userresult->getResourceLink()->getRecordId(),
1096 $this->escape($userresult->getId(LTI\
Tool::ID_SCOPE_ID_ONLY)), $this->escape($userresult->ltiResultSourcedId),
1097 $this->escape($now), $this->escape($now));
1099 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1100 'SET lti_user_id = %s, lti_result_sourcedid = %s, updated = %s ' .
1102 $this->escape($userresult->ltiResultSourcedId), $this->escape($now), $userresult->getRecordId());
1104 $ok = $this->executeQuery($sql);
1106 if (is_null($userresult->created)) {
1107 $userresult->setRecordId(mysql_insert_id());
1108 $userresult->created = $time;
1110 $userresult->updated = $time;
1125 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1126 'WHERE (user_result_pk = %d)', $userresult->getRecordId());
1127 $ok = $this->executeQuery($sql);
1130 $userresult->initialize();
1150 if (!is_null($tool->getRecordId())) {
1151 $sql = sprintf(
'SELECT tool_pk, name, consumer_key, secret, ' .
1152 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1153 'lti_version, signature_method, settings, enabled, ' .
1154 'enable_from, enable_until, last_access, created, updated ' .
1155 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1156 'WHERE tool_pk = %d', $tool->getRecordId());
1157 } elseif (!empty($tool->initiateLoginUrl)) {
1158 $sql = sprintf(
'SELECT tool_pk, name, consumer_key, secret, ' .
1159 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1160 'lti_version, signature_method, settings, enabled, ' .
1161 'enable_from, enable_until, last_access, created, updated ' .
1162 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1163 'WHERE initiate_login_url = %s', $this->
escape($tool->initiateLoginUrl));
1165 $sql = sprintf(
'SELECT tool_pk, name, consumer_key, secret, ' .
1166 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1167 'lti_version, signature_method, settings, enabled, ' .
1168 'enable_from, enable_until, last_access, created, updated ' .
1169 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1170 'WHERE consumer_key = %s', $this->
escape($tool->getKey()));
1172 $rsTool = $this->executeQuery($sql);
1174 $row = mysql_fetch_object($rsTool);
1176 $tool->setRecordId(intval($row->tool_pk));
1177 $tool->name = $row->name;
1178 $tool->setkey($row->consumer_key);
1179 $tool->secret = $row->secret;
1180 $tool->messageUrl = $row->message_url;
1181 $tool->initiateLoginUrl = $row->initiate_login_url;
1183 if (!is_array($tool->redirectionUris)) {
1184 $tool->redirectionUris = array();
1186 $tool->rsaKey = $row->public_key;
1187 $tool->ltiVersion = $row->lti_version;
1188 $tool->signatureMethod = $row->signature_method;
1190 if (!is_array($settings)) {
1191 $settings = array();
1193 $tool->setSettings($settings);
1194 $tool->enabled = (intval($row->enabled) === 1);
1195 $tool->enableFrom =
null;
1196 if (!is_null($row->enable_from)) {
1197 $tool->enableFrom = strtotime($row->enable_from);
1199 $tool->enableUntil =
null;
1200 if (!is_null($row->enable_until)) {
1201 $tool->enableUntil = strtotime($row->enable_until);
1203 $tool->lastAccess =
null;
1204 if (!is_null($row->last_access)) {
1205 $tool->lastAccess = strtotime($row->last_access);
1207 $tool->created = strtotime($row->created);
1208 $tool->updated = strtotime($row->updated);
1226 $id = $tool->getRecordId();
1227 $enabled = ($tool->enabled) ? 1 : 0;
1228 $redirectionUrisValue = json_encode($tool->redirectionUris);
1230 $settingsValue = json_encode($tool->getSettings());
1233 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
1235 if (!is_null($tool->enableFrom)) {
1236 $from = date(
"{$this->dateFormat} {$this->timeFormat}", $tool->enableFrom);
1239 if (!is_null($tool->enableUntil)) {
1240 $until = date(
"{$this->dateFormat} {$this->timeFormat}", $tool->enableUntil);
1243 if (!is_null($tool->lastAccess)) {
1244 $last = date($this->dateFormat, $tool->lastAccess);
1247 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' (name, consumer_key, secret, ' .
1248 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1249 'lti_version, signature_method, settings, enabled, enable_from, enable_until, ' .
1250 'last_access, created, updated) ' .
1251 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s)', $this->
escape($tool->name),
1252 $this->escape($tool->getKey()), $this->escape($tool->secret), $this->escape($tool->messageUrl),
1253 $this->escape($tool->initiateLoginUrl), $this->escape($redirectionUrisValue), $this->escape($tool->rsaKey),
1254 $this->escape($tool->ltiVersion), $this->escape($tool->signatureMethod), $this->escape($settingsValue), $enabled,
1255 $this->escape($from), $this->escape($until), $this->escape($last), $this->escape($now), $this->escape($now));
1257 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' SET ' .
1258 'name = %s, consumer_key = %s, secret= %s, ' .
1259 'message_url = %s, initiate_login_url = %s, redirection_uris = %s, public_key = %s, ' .
1260 'lti_version = %s, signature_method = %s, settings = %s, enabled = %d, enable_from = %s, enable_until = %s, ' .
1261 'last_access = %s, updated = %s ' .
1262 'WHERE tool_pk = %d', $this->
escape($tool->name), $this->escape($tool->getKey()), $this->escape($tool->secret),
1263 $this->escape($tool->messageUrl), $this->escape($tool->initiateLoginUrl), $this->escape($redirectionUrisValue),
1264 $this->escape($tool->rsaKey), $this->escape($tool->ltiVersion), $this->escape($tool->signatureMethod),
1265 $this->escape($settingsValue), $enabled, $this->escape($from), $this->escape($until), $this->escape($last),
1266 $this->escape($now), $tool->getRecordId());
1268 $ok = $this->executeQuery($sql);
1271 $tool->setRecordId(mysql_insert_id($this->db));
1272 $tool->created = $time;
1274 $tool->updated = $time;
1289 $sql = sprintf(
'DELETE t ' .
1290 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' t ' .
1291 'WHERE t.tool_pk = %d', $tool->getRecordId());
1292 $ok = $this->executeQuery($sql);
1295 $tool->initialize();
1310 $sql =
'SELECT tool_pk, name, consumer_key, secret, ' .
1311 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1312 'lti_version, signature_method, settings, enabled, ' .
1313 'enable_from, enable_until, last_access, created, updated ' .
1314 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1316 $rsTools = $this->executeQuery($sql);
1318 while ($row = mysql_fetch_object($rsTools)) {
1319 $tool =
new Tool($this);
1320 $tool->setRecordId(intval($row->tool_pk));
1321 $tool->name = $row->name;
1322 $tool->setkey($row->consumer_key);
1323 $tool->secret = $row->secret;
1324 $tool->messageUrl = $row->message_url;
1325 $tool->initiateLoginUrl = $row->initiate_login_url;
1327 if (!is_array($tool->redirectionUris)) {
1328 $tool->redirectionUris = array();
1330 $tool->rsaKey = $row->public_key;
1331 $tool->ltiVersion = $row->lti_version;
1332 $tool->signatureMethod = $row->signature_method;
1334 if (!is_array($settings)) {
1335 $settings = array();
1337 $tool->setSettings($settings);
1338 $tool->enabled = (intval($row->enabled) === 1);
1339 $tool->enableFrom =
null;
1340 if (!is_null($row->enable_from)) {
1341 $tool->enableFrom = strtotime($row->enable_from);
1343 $tool->enableUntil =
null;
1344 if (!is_null($row->enable_until)) {
1345 $tool->enableUntil = strtotime($row->enable_until);
1347 $tool->lastAccess =
null;
1348 if (!is_null($row->last_access)) {
1349 $tool->lastAccess = strtotime($row->last_access);
1351 $tool->created = strtotime($row->created);
1352 $tool->updated = strtotime($row->updated);
1356 mysql_free_result($rsTools);
1377 public function escape($value, $addQuotes =
true)
1379 if (is_null($value)) {
1382 $value = mysql_real_escape_string($value);
1384 $value =
"'{$value}'";
1401 private function executeQuery($sql, $reportError =
true)
1403 $res = mysql_query($sql);
1404 $info = mysql_info();
1406 $info = PHP_EOL . $info;
1410 if (($res ===
false) && $reportError) {
1411 Util::logError($sql . $info . PHP_EOL .
'Error ' . mysql_errno() .
': ' . mysql_error());
Class to represent an HTTP message.
Class to represent a platform context.
Class to represent an LTI Data Connector for MySQL.
loadResourceLinkShareKey($shareKey)
Load resource link share key object.
escape($value, $addQuotes=true)
Escape a string for use in a database query.
saveUserResult($userresult)
Save user object.
loadContext($context)
Load context object.
deleteTool($tool)
Delete tool object.
savePlatform($platform)
Save platform object.
deletePlatform($platform)
Delete platform object.
saveAccessToken($accessToken)
Save access token object.
deletePlatformNonce($nonce)
Delete nonce object.
saveResourceLinkShareKey($shareKey)
Save resource link share key object.
saveContext($context)
Save context object.
loadPlatformNonce($nonce)
Load nonce object.
loadAccessToken($accessToken)
Load access token object.
loadTool($tool)
Load tool object.
getTools()
Load tool objects.
loadPlatform($platform)
Load platform object.
getUserResultSourcedIDsResourceLink($resourceLink, $localOnly, $idScope)
Get array of user objects.
__construct($db, $dbTableNamePrefix='')
Class constructor.
getPlatforms()
Load all platforms from the database.
getSharesResourceLink($resourceLink)
Get array of shares defined for this resource link.
loadResourceLink($resourceLink)
Load resource link object.
savePlatformNonce($nonce)
Save nonce object.
saveResourceLink($resourceLink)
Save resource link object.
deleteContext($context)
Delete context object.
loadUserResult($userresult)
Load user object.
deleteUserResult($userresult)
Delete user object.
deleteResourceLinkShareKey($shareKey)
Delete resource link share key object.
saveTool($tool)
Save tool object.
deleteResourceLink($resourceLink)
Delete resource link object.
Class to provide a connection to a persistent store for LTI objects.
$dbTableNamePrefix
Prefix for database table names.
fixToolSettings($tool, $isSave)
Adjust the settings for any tool properties being stored as a setting value.
fixPlatformSettings($platform, $isSave)
Adjust the settings for any platform properties being stored as a setting value.
Class to represent a platform resource link share key.
Class to represent a platform resource link share.
Class to represent a platform resource link.
Class to represent a platform user association with a resource link.
Class to implement utility methods.
static logError($message, $showSource=true)
Log an error message.
static jsonDecode($str, $associative=false)
Decode a JSON string.
static logDebug($message, $showSource=false)
Log a debug message.