25# NB This class assumes that a PostgreSQL connection has already been opened to the appropriate schema
45 $allowMultiple =
false;
46 if (!is_null($platform->getRecordId())) {
47 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
48 'platform_id, client_id, deployment_id, public_key, ' .
49 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
50 'profile, tool_proxy, settings, protected, enabled, ' .
51 'enable_from, enable_until, last_access, created, updated ' .
52 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
53 'WHERE consumer_pk = %d', $platform->getRecordId());
54 } elseif (!empty($platform->platformId)) {
55 if (empty($platform->clientId)) {
56 $allowMultiple =
true;
57 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
58 'platform_id, client_id, deployment_id, public_key, ' .
59 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
60 'profile, tool_proxy, settings, protected, enabled, ' .
61 'enable_from, enable_until, last_access, created, updated ' .
62 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
63 'WHERE (platform_id = %s) ', $this->
escape($platform->platformId));
64 } elseif (empty($platform->deploymentId)) {
65 $allowMultiple =
true;
66 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
67 'platform_id, client_id, deployment_id, public_key, ' .
68 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
69 'profile, tool_proxy, settings, protected, enabled, ' .
70 'enable_from, enable_until, last_access, created, updated ' .
71 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
72 'WHERE (platform_id = %s) AND (client_id = %s)', $this->
escape($platform->platformId),
73 $this->escape($platform->clientId));
75 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
76 'platform_id, client_id, deployment_id, public_key, ' .
77 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
78 'profile, tool_proxy, settings, protected, enabled, ' .
79 'enable_from, enable_until, last_access, created, updated ' .
80 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
81 'WHERE (platform_id = %s) AND (client_id = %s) AND (deployment_id = %s)', $this->
escape($platform->platformId),
82 $this->escape($platform->clientId), $this->escape($platform->deploymentId));
85 $sql = sprintf(
'SELECT consumer_pk, name, consumer_key, secret, ' .
86 'platform_id, client_id, deployment_id, public_key, ' .
87 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
88 'profile, tool_proxy, settings, protected, enabled, ' .
89 'enable_from, enable_until, last_access, created, updated ' .
90 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
91 "WHERE consumer_key = %s", $this->
escape($platform->getKey()));
93 $rsConsumer = $this->executeQuery($sql);
95 $row = pg_fetch_object($rsConsumer);
96 if ($row && ($allowMultiple || !pg_fetch_object($rsConsumer))) {
97 $platform->setRecordId(intval($row->consumer_pk));
98 $platform->name = $row->name;
99 $platform->setkey($row->consumer_key);
100 $platform->secret = $row->secret;
101 $platform->platformId = $row->platform_id;
102 $platform->clientId = $row->client_id;
103 $platform->deploymentId = $row->deployment_id;
104 $platform->rsaKey = $row->public_key;
105 $platform->ltiVersion = $row->lti_version;
106 $platform->signatureMethod = $row->signature_method;
107 $platform->consumerName = $row->consumer_name;
108 $platform->consumerVersion = $row->consumer_version;
109 $platform->consumerGuid = $row->consumer_guid;
111 $platform->toolProxy = $row->tool_proxy;
113 if (!is_array($settings)) {
114 $settings = @unserialize($row->settings);
116 if (!is_array($settings)) {
119 $platform->setSettings($settings);
120 $platform->protected = ($row->protected ===
't');
121 $platform->enabled = ($row->enabled ===
't');
122 $platform->enableFrom =
null;
123 if (!is_null($row->enable_from)) {
124 $platform->enableFrom = strtotime($row->enable_from);
126 $platform->enableUntil =
null;
127 if (!is_null($row->enable_until)) {
128 $platform->enableUntil = strtotime($row->enable_until);
130 $platform->lastAccess =
null;
131 if (!is_null($row->last_access)) {
132 $platform->lastAccess = strtotime($row->last_access);
134 $platform->created = strtotime($row->created);
135 $platform->updated = strtotime($row->updated);
153 $id = $platform->getRecordId();
154 $protected = ($platform->protected) ?
'true' :
'false';
155 $enabled = ($platform->enabled) ?
'true' :
'false';
156 $profile = (!empty($platform->profile)) ? json_encode($platform->profile) :
null;
158 $settingsValue = json_encode($platform->getSettings());
161 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
163 if (!is_null($platform->enableFrom)) {
164 $from = date(
"{$this->dateFormat} {$this->timeFormat}", $platform->enableFrom);
167 if (!is_null($platform->enableUntil)) {
168 $until = date(
"{$this->dateFormat} {$this->timeFormat}", $platform->enableUntil);
171 if (!is_null($platform->lastAccess)) {
172 $last = date($this->dateFormat, $platform->lastAccess);
175 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' (consumer_key, name, secret, ' .
176 'platform_id, client_id, deployment_id, public_key, ' .
177 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
178 'profile, tool_proxy, settings, protected, enabled, ' .
179 'enable_from, enable_until, last_access, created, updated) ' .
180 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
181 $this->
escape($platform->getKey()), $this->escape($platform->name), $this->escape($platform->secret),
182 $this->escape($platform->platformId), $this->escape($platform->clientId), $this->escape($platform->deploymentId),
183 $this->escape($platform->rsaKey), $this->escape($platform->ltiVersion), $this->escape($platform->signatureMethod),
184 $this->escape($platform->consumerName), $this->escape($platform->consumerVersion),
185 $this->escape($platform->consumerGuid), $this->escape($profile), $this->escape($platform->toolProxy),
186 $this->escape($settingsValue), $protected, $enabled, $this->escape($from), $this->escape($until),
187 $this->escape($last), $this->escape($now), $this->escape($now));
189 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' SET ' .
190 'consumer_key = %s, name = %s, secret = %s, ' .
191 'platform_id = %s, client_id = %s, deployment_id = %s, public_key = %s, ' .
192 'lti_version = %s, signature_method = %s, ' .
193 'consumer_name = %s, consumer_version = %s, consumer_guid = %s, ' .
194 'profile = %s, tool_proxy = %s, settings = %s, ' .
195 'protected = %s, enabled = %s, enable_from = %s, enable_until = %s, last_access = %s, updated = %s ' .
196 'WHERE consumer_pk = %d', $this->
escape($platform->getKey()), $this->escape($platform->name),
197 $this->escape($platform->secret), $this->escape($platform->platformId), $this->escape($platform->clientId),
198 $this->escape($platform->deploymentId), $this->escape($platform->rsaKey), $this->escape($platform->ltiVersion),
199 $this->escape($platform->signatureMethod), $this->escape($platform->consumerName),
200 $this->escape($platform->consumerVersion), $this->escape($platform->consumerGuid), $this->escape($profile),
201 $this->escape($platform->toolProxy), $this->escape($settingsValue), $protected, $enabled, $this->escape($from),
202 $this->escape($until), $this->escape($last), $this->escape($now), $platform->getRecordId());
204 $ok = $this->executeQuery($sql);
207 $platform->setRecordId($this->insert_id());
208 $platform->created = $time;
210 $platform->updated = $time;
226 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::ACCESS_TOKEN_TABLE_NAME .
' WHERE consumer_pk = %d',
227 $platform->getRecordId());
228 $this->executeQuery($sql);
231 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
' WHERE consumer_pk = %d',
232 $platform->getRecordId());
233 $this->executeQuery($sql);
236 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
237 "WHERE resource_link_pk IN (SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
238 'WHERE consumer_pk = %d)', $platform->getRecordId());
239 $this->executeQuery($sql);
242 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
243 "WHERE resource_link_pk IN (SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ' .
244 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk WHERE c.consumer_pk = %d)',
245 $platform->getRecordId());
246 $this->executeQuery($sql);
249 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
250 "WHERE resource_link_pk IN (SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
251 'WHERE consumer_pk = %d)', $platform->getRecordId());
252 $this->executeQuery($sql);
255 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
256 "WHERE resource_link_pk IN (SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ' .
257 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk WHERE c.consumer_pk = %d)',
258 $platform->getRecordId());
259 $this->executeQuery($sql);
262 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
263 'SET primary_resource_link_pk = NULL, share_approved = NULL ' .
264 'WHERE primary_resource_link_pk IN ' .
265 "(SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
266 'WHERE consumer_pk = %d)', $platform->getRecordId());
267 $ok = $this->executeQuery($sql);
270 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
271 'SET primary_resource_link_pk = NULL, share_approved = NULL ' .
272 'WHERE primary_resource_link_pk IN ' .
273 "(SELECT rl.resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' rl ' .
274 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ON rl.context_pk = c.context_pk ' .
275 'WHERE c.consumer_pk = %d)', $platform->getRecordId());
276 $ok = $this->executeQuery($sql);
279 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
280 'WHERE consumer_pk = %d', $platform->getRecordId());
281 $this->executeQuery($sql);
284 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
285 'WHERE context_pk IN (' .
286 "SELECT context_pk FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ' .
'WHERE consumer_pk = %d)',
287 $platform->getRecordId());
288 $this->executeQuery($sql);
291 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ' .
292 'WHERE consumer_pk = %d', $platform->getRecordId());
293 $this->executeQuery($sql);
296 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
297 'WHERE consumer_pk = %d', $platform->getRecordId());
298 $ok = $this->executeQuery($sql);
301 $platform->initialize();
314 $platforms = array();
316 $sql =
'SELECT consumer_pk, consumer_key, name, secret, ' .
317 'platform_id, client_id, deployment_id, public_key, ' .
318 'lti_version, signature_method, consumer_name, consumer_version, consumer_guid, ' .
319 'profile, tool_proxy, settings, protected, enabled, ' .
320 'enable_from, enable_until, last_access, created, updated ' .
321 "FROM {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' ' .
323 $rsConsumers = $this->executeQuery($sql);
325 while ($row = pg_fetch_object($rsConsumers)) {
327 $platform->setRecordId(intval($row->consumer_pk));
328 $platform->name = $row->name;
329 $platform->setKey($row->consumer_key);
330 $platform->secret = $row->secret;
331 $platform->platformId = $row->platform_id;
332 $platform->clientId = $row->client_id;
333 $platform->deploymentId = $row->deployment_id;
334 $platform->rsaKey = $row->public_key;
335 $platform->ltiVersion = $row->lti_version;
336 $platform->signatureMethod = $row->signature_method;
337 $platform->consumerName = $row->consumer_name;
338 $platform->consumerVersion = $row->consumer_version;
339 $platform->consumerGuid = $row->consumer_guid;
341 $platform->toolProxy = $row->tool_proxy;
343 if (!is_array($settings)) {
344 $settings = @unserialize($row->settings);
346 if (!is_array($settings)) {
349 $platform->setSettings($settings);
350 $platform->protected = ($row->protected ===
't');
351 $platform->enabled = ($row->enabled ===
't');
352 $platform->enableFrom =
null;
353 if (!is_null($row->enable_from)) {
354 $platform->enableFrom = strtotime($row->enable_from);
356 $platform->enableUntil =
null;
357 if (!is_null($row->enable_until)) {
358 $platform->enableUntil = strtotime($row->enable_until);
360 $platform->lastAccess =
null;
361 if (!is_null($row->last_access)) {
362 $platform->lastAccess = strtotime($row->last_access);
364 $platform->created = strtotime($row->created);
365 $platform->updated = strtotime($row->updated);
367 $platforms[] = $platform;
369 pg_free_result($rsConsumers);
389 if (!is_null($context->getRecordId())) {
390 $sql = sprintf(
'SELECT context_pk, consumer_pk, title, lti_context_id, type, settings, created, updated ' .
391 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ' .
392 'WHERE (context_pk = %d)', $context->getRecordId());
394 $sql = sprintf(
'SELECT context_pk, consumer_pk, title, lti_context_id, type, settings, created, updated ' .
395 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ' .
396 'WHERE (consumer_pk = %d) AND (lti_context_id = %s)', $context->getPlatform()->getRecordId(),
397 $this->escape($context->ltiContextId));
399 $rsContext = $this->executeQuery($sql);
401 $row = pg_fetch_object($rsContext);
403 $context->setRecordId(intval($row->context_pk));
404 $context->setPlatformId(intval($row->consumer_pk));
405 $context->title = $row->title;
406 $context->ltiContextId = $row->lti_context_id;
407 $context->type = $row->type;
409 if (!is_array($settings)) {
410 $settings = @unserialize($row->settings);
412 if (!is_array($settings)) {
415 $context->setSettings($settings);
416 $context->created = strtotime($row->created);
417 $context->updated = strtotime($row->updated);
435 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
436 $settingsValue = json_encode($context->getSettings());
437 $id = $context->getRecordId();
438 $consumer_pk = $context->getPlatform()->getRecordId();
440 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' (consumer_pk, title, ' .
441 'lti_context_id, type, settings, created, updated) ' .
442 'VALUES (%d, %s, %s, %s, %s, %s, %s)', $consumer_pk, $this->
escape($context->title),
443 $this->escape($context->ltiContextId), $this->escape($context->type), $this->escape($settingsValue),
444 $this->escape($now), $this->escape($now));
446 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' SET ' .
447 'title = %s, lti_context_id = %s, type = %s, settings = %s, ' .
449 'WHERE (consumer_pk = %d) AND (context_pk = %d)', $this->
escape($context->title),
450 $this->escape($context->ltiContextId), $this->escape($context->type), $this->escape($settingsValue),
451 $this->escape($now), $consumer_pk, $id);
453 $ok = $this->executeQuery($sql);
456 $context->setRecordId($this->insert_id());
457 $context->created = $time;
459 $context->updated = $time;
475 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
476 "WHERE resource_link_pk IN (SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
477 'WHERE context_pk = %d)', $context->getRecordId());
478 $this->executeQuery($sql);
481 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
482 "WHERE resource_link_pk IN (SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
483 'WHERE context_pk = %d)', $context->getRecordId());
484 $this->executeQuery($sql);
487 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
488 'SET primary_resource_link_pk = null, share_approved = null ' .
489 'WHERE primary_resource_link_pk IN ' .
490 "(SELECT resource_link_pk FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' WHERE context_pk = %d)',
491 $context->getRecordId());
492 $ok = $this->executeQuery($sql);
495 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
496 'WHERE context_pk = %d', $context->getRecordId());
497 $this->executeQuery($sql);
500 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' ',
'WHERE context_pk = %d',
501 $context->getRecordId());
502 $ok = $this->executeQuery($sql);
504 $context->initialize();
511### ResourceLink methods
524 if (!is_null($resourceLink->getRecordId())) {
525 $sql = sprintf(
'SELECT resource_link_pk, context_pk, consumer_pk, title, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated ' .
526 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
527 'WHERE (resource_link_pk = %d)', $resourceLink->getRecordId());
528 } elseif (!is_null($resourceLink->getContext())) {
529 $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 ' .
530 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' r ' .
531 'WHERE (r.lti_resource_link_id = %s) AND ((r.context_pk = %d) OR (r.consumer_pk IN (' .
532 'SELECT c.consumer_pk ' .
533 "FROM {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' c ' .
534 'WHERE (c.context_pk = %d))))', $this->
escape($resourceLink->getId()), $resourceLink->getContext()->getRecordId(),
535 $resourceLink->getContext()->getRecordId());
537 $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 ' .
538 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' r LEFT OUTER JOIN ' .
539 $this->dbTableNamePrefix . static::CONTEXT_TABLE_NAME .
' c ON r.context_pk = c.context_pk ' .
540 ' WHERE ((r.consumer_pk = %d) OR (c.consumer_pk = %d)) AND (lti_resource_link_id = %s)',
541 $resourceLink->getPlatform()->getRecordId(), $resourceLink->getPlatform()->getRecordId(),
542 $this->escape($resourceLink->getId()));
544 $rsResourceLink = $this->executeQuery($sql);
545 if ($rsResourceLink) {
546 $row = pg_fetch_object($rsResourceLink);
548 $resourceLink->setRecordId(intval($row->resource_link_pk));
549 if (!is_null($row->context_pk)) {
550 $resourceLink->setContextId(intval($row->context_pk));
552 $resourceLink->setContextId(
null);
554 if (!is_null($row->consumer_pk)) {
555 $resourceLink->setPlatformId(intval($row->consumer_pk));
557 $resourceLink->setPlatformId(
null);
559 $resourceLink->title = $row->title;
560 $resourceLink->ltiResourceLinkId = $row->lti_resource_link_id;
562 if (!is_array($settings)) {
563 $settings = @unserialize($row->settings);
565 if (!is_array($settings)) {
568 $resourceLink->setSettings($settings);
569 if (!is_null($row->primary_resource_link_pk)) {
570 $resourceLink->primaryResourceLinkId = intval($row->primary_resource_link_pk);
572 $resourceLink->primaryResourceLinkId =
null;
574 $resourceLink->shareApproved = (is_null($row->share_approved)) ?
null : (intval($row->share_approved) === 1);
575 $resourceLink->created = strtotime($row->created);
576 $resourceLink->updated = strtotime($row->updated);
593 if (is_null($resourceLink->shareApproved)) {
595 } elseif ($resourceLink->shareApproved) {
600 if (empty($resourceLink->primaryResourceLinkId)) {
601 $primaryResourceLinkId =
'NULL';
603 $primaryResourceLinkId = strval($resourceLink->primaryResourceLinkId);
606 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
607 $settingsValue = json_encode($resourceLink->getSettings());
608 if (!is_null($resourceLink->getContext())) {
609 $consumerId =
'NULL';
610 $contextId = strval($resourceLink->getContext()->getRecordId());
611 } elseif (!is_null($resourceLink->getContextId())) {
612 $consumerId =
'NULL';
613 $contextId = strval($resourceLink->getContextId());
615 $consumerId = strval($resourceLink->getPlatform()->getRecordId());
618 $id = $resourceLink->getRecordId();
620 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' (consumer_pk, context_pk, ' .
621 'title, lti_resource_link_id, settings, primary_resource_link_pk, share_approved, created, updated) ' .
622 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)', $consumerId, $contextId, $this->
escape($resourceLink->title),
623 $this->escape($resourceLink->getId()), $this->escape($settingsValue), $primaryResourceLinkId, $approved,
624 $this->escape($now), $this->escape($now));
625 } elseif ($contextId !==
'NULL') {
626 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' SET ' .
627 'consumer_pk = %s, title = %s, lti_resource_link_id = %s, settings = %s, ' .
628 'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
629 'WHERE (context_pk = %s) AND (resource_link_pk = %d)', $consumerId, $this->
escape($resourceLink->title),
630 $this->escape($resourceLink->getId()), $this->escape($settingsValue), $primaryResourceLinkId, $approved,
631 $this->escape($now), $contextId, $id);
633 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' SET ' .
634 'context_pk = NULL, title = %s, lti_resource_link_id = %s, settings = %s, ' .
635 'primary_resource_link_pk = %s, share_approved = %s, updated = %s ' .
636 'WHERE (consumer_pk = %s) AND (resource_link_pk = %d)', $this->
escape($resourceLink->title),
637 $this->escape($resourceLink->getId()), $this->escape($settingsValue), $primaryResourceLinkId, $approved,
638 $this->escape($now), $consumerId, $id);
640 $ok = $this->executeQuery($sql);
643 $resourceLink->setRecordId($this->insert_id());
644 $resourceLink->created = $time;
646 $resourceLink->updated = $time;
662 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
663 'WHERE (resource_link_pk = %d)', $resourceLink->getRecordId());
664 $ok = $this->executeQuery($sql);
668 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
669 'WHERE (resource_link_pk = %d)', $resourceLink->getRecordId());
670 $ok = $this->executeQuery($sql);
675 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
676 'SET primary_resource_link_pk = NULL ' .
677 'WHERE (primary_resource_link_pk = %d)', $resourceLink->getRecordId());
678 $ok = $this->executeQuery($sql);
683 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' ' .
684 'WHERE (resource_link_pk = %s)', $resourceLink->getRecordId());
685 $ok = $this->executeQuery($sql);
689 $resourceLink->initialize();
709 $userResults = array();
712 $sql = sprintf(
'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
713 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' AS u ' .
714 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS rl ' .
715 'ON u.resource_link_pk = rl.resource_link_pk ' .
716 "WHERE (rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)", $resourceLink->getRecordId());
718 $sql = sprintf(
'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
719 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' AS u ' .
720 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS rl ' .
721 'ON u.resource_link_pk = rl.resource_link_pk ' .
722 'WHERE ((rl.resource_link_pk = %d) AND (rl.primary_resource_link_pk IS NULL)) OR ' .
723 '((rl.primary_resource_link_pk = %d) AND share_approved)', $resourceLink->getRecordId(),
724 $resourceLink->getRecordId());
726 $rsUser = $this->executeQuery($sql);
728 while ($row = pg_fetch_object($rsUser)) {
729 $userresult = LTI\UserResult::fromResourceLink($resourceLink, $row->lti_user_id);
730 if (is_null($idScope)) {
731 $userResults[] = $userresult;
733 $userResults[$userresult->getId($idScope)] = $userresult;
752 $sql = sprintf(
'SELECT c.consumer_name, r.resource_link_pk, r.title, r.share_approved ' .
753 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS r ' .
754 "INNER JOIN {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' AS c ON r.consumer_pk = c.consumer_pk ' .
755 'WHERE (r.primary_resource_link_pk = %d) ' .
757 'SELECT c2.consumer_name, r2.resource_link_pk, r2.title, r2.share_approved ' .
758 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS r2 ' .
759 "INNER JOIN {$this->dbTableNamePrefix}" . static::CONTEXT_TABLE_NAME .
' AS x ON r2.context_pk = x.context_pk ' .
760 "INNER JOIN {$this->dbTableNamePrefix}" . static::PLATFORM_TABLE_NAME .
' AS c2 ON x.consumer_pk = c2.consumer_pk ' .
761 'WHERE (r2.primary_resource_link_pk = %d) ' .
762 'ORDER BY consumer_name, title', $resourceLink->getRecordId(), $resourceLink->getRecordId());
763 $rsShare = $this->executeQuery($sql);
765 while ($row = pg_fetch_object($rsShare)) {
767 $share->consumerName = $row->consumer_name;
768 $share->resourceLinkId = intval($row->resource_link_pk);
769 $share->title = $row->title;
770 $share->approved = (intval($row->share_approved) === 1);
779### PlatformNonce methods
791 if (parent::useMemcache()) {
792 $ok = parent::loadPlatformNonce($nonce);
797 $now = date(
"{$this->dateFormat} {$this->timeFormat}", time());
798 $sql =
"DELETE FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
" WHERE expires <= '{$now}'";
799 $this->executeQuery($sql);
802 $sql = sprintf(
"SELECT value AS T FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
' WHERE (consumer_pk = %d) AND (value = %s)',
803 $nonce->getPlatform()->getRecordId(), $this->escape($nonce->getValue()));
804 $rsNonce = $this->executeQuery($sql,
false);
806 if (pg_fetch_object($rsNonce)) {
824 if (parent::useMemcache()) {
825 $ok = parent::savePlatformNonce($nonce);
827 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $nonce->expires);
828 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
" (consumer_pk, value, expires) VALUES (%d, %s, %s)",
829 $nonce->getPlatform()->getRecordId(), $this->escape($nonce->getValue()), $this->escape($expires));
830 $ok = $this->executeQuery($sql);
845 if (parent::useMemcache()) {
846 $ok = parent::deletePlatformNonce($nonce);
848 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::NONCE_TABLE_NAME .
' WHERE (consumer_pk = %d) AND (value = %s)',
849 $nonce->getPlatform()->getRecordId(), $this->escape($nonce->getValue()));
850 $ok = $this->executeQuery($sql);
857### AccessToken methods
869 if (parent::useMemcache()) {
870 $ok = parent::loadAccessToken($accessToken);
873 $consumer_pk = $accessToken->getPlatform()->getRecordId();
874 $sql = sprintf(
'SELECT scopes, token, expires, created, updated ' .
875 "FROM {$this->dbTableNamePrefix}" . static::ACCESS_TOKEN_TABLE_NAME .
' ' .
876 'WHERE (consumer_pk = %d)', $consumer_pk);
877 $rsAccessToken = $this->executeQuery($sql,
false);
878 if ($rsAccessToken) {
879 $row = pg_fetch_object($rsAccessToken);
882 if (!is_array($scopes)) {
885 $accessToken->scopes = $scopes;
886 $accessToken->token = $row->token;
887 $accessToken->expires = strtotime($row->expires);
888 $accessToken->created = strtotime($row->created);
889 $accessToken->updated = strtotime($row->updated);
907 if (parent::useMemcache()) {
908 $ok = parent::saveAccessToken($accessToken);
910 $consumer_pk = $accessToken->getPlatform()->getRecordId();
911 $scopes = json_encode($accessToken->scopes, JSON_UNESCAPED_SLASHES);
912 $token = $accessToken->token;
913 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $accessToken->expires);
915 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
916 if (empty($accessToken->created)) {
917 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::ACCESS_TOKEN_TABLE_NAME .
' ' .
918 '(consumer_pk, scopes, token, expires, created, updated) ' .
919 'VALUES (%d, %s, %s, %s, %s, %s)', $consumer_pk, $this->
escape($scopes), $this->
escape($token),
922 $sql = sprintf(
'UPDATE ' . $this->dbTableNamePrefix . static::ACCESS_TOKEN_TABLE_NAME .
' ' .
923 'SET scopes = %s, token = %s, expires = %s, updated = %s WHERE consumer_pk = %d', $this->
escape($scopes),
926 $ok = $this->executeQuery($sql);
933### ResourceLinkShareKey methods
948 $now = date(
"{$this->dateFormat} {$this->timeFormat}", time());
949 $sql =
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
" WHERE expires <= '{$now}'";
950 $this->executeQuery($sql);
953 $id = pg_escape_string($this->db, $shareKey->getId());
954 $sql =
'SELECT resource_link_pk, auto_approve, expires ' .
955 "FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
956 "WHERE share_key_id = '{$id}'";
957 $rsShareKey = $this->executeQuery($sql);
959 $row = pg_fetch_object($rsShareKey);
961 $shareKey->resourceLinkId = intval($row->resource_link_pk);
962 $shareKey->autoApprove = (intval($row->auto_approve) === 1);
963 $shareKey->expires = strtotime($row->expires);
980 if ($shareKey->autoApprove) {
985 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
986 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
987 '(share_key_id, resource_link_pk, auto_approve, expires) ' .
988 "VALUES (%s, %d, {$approve}, '{$expires}')", $this->
escape($shareKey->getId()), $shareKey->resourceLinkId);
989 $ok = $this->executeQuery($sql);
1003 $sql =
"DELETE FROM {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
" WHERE share_key_id = '{$shareKey->getId()}'";
1005 $ok = $this->executeQuery($sql);
1008 $shareKey->initialize();
1015### UserResult methods
1028 if (!is_null($userresult->getRecordId())) {
1029 $sql = sprintf(
'SELECT user_result_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1030 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1031 'WHERE (user_result_pk = %d)', $userresult->getRecordId());
1033 $sql = sprintf(
'SELECT user_result_pk, resource_link_pk, lti_user_id, lti_result_sourcedid, created, updated ' .
1034 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1035 'WHERE (resource_link_pk = %d) AND (lti_user_id = %s)', $userresult->getResourceLink()->getRecordId(),
1038 $rsUserResult = $this->executeQuery($sql);
1039 if ($rsUserResult) {
1040 $row = pg_fetch_object($rsUserResult);
1042 $userresult->setRecordId(intval($row->user_result_pk));
1043 $userresult->setResourceLinkId(intval($row->resource_link_pk));
1044 $userresult->ltiUserId = $row->lti_user_id;
1045 $userresult->ltiResultSourcedId = $row->lti_result_sourcedid;
1046 $userresult->created = strtotime($row->created);
1047 $userresult->updated = strtotime($row->updated);
1065 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
1066 if (is_null($userresult->created)) {
1067 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' (resource_link_pk, ' .
1068 'lti_user_id, lti_result_sourcedid, created, updated) ' .
1069 'VALUES (%d, %s, %s, %s, %s)', $userresult->getResourceLink()->getRecordId(),
1070 $this->escape($userresult->getId(LTI\
Tool::ID_SCOPE_ID_ONLY)), $this->escape($userresult->ltiResultSourcedId),
1071 $this->escape($now), $this->escape($now));
1073 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1074 'SET lti_result_sourcedid = %s, updated = %s ' .
1075 'WHERE (user_result_pk = %d)', $this->
escape($userresult->ltiResultSourcedId), $this->escape($now),
1076 $userresult->getRecordId());
1078 $ok = $this->executeQuery($sql);
1080 if (is_null($userresult->created)) {
1081 $userresult->setRecordId($this->insert_id());
1082 $userresult->created = $time;
1084 $userresult->updated = $time;
1099 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' ' .
1100 'WHERE (user_result_pk = %d)', $userresult->getRecordId());
1101 $ok = $this->executeQuery($sql);
1104 $userresult->initialize();
1124 if (!is_null($tool->getRecordId())) {
1125 $sql = sprintf(
'SELECT tool_pk, name, consumer_key, secret, ' .
1126 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1127 'lti_version, signature_method, settings, enabled, ' .
1128 'enable_from, enable_until, last_access, created, updated ' .
1129 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1130 'WHERE tool_pk = %d', $tool->getRecordId());
1131 } elseif (!empty($tool->initiateLoginUrl)) {
1132 $sql = sprintf(
'SELECT tool_pk, name, consumer_key, secret, ' .
1133 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1134 'lti_version, signature_method, settings, enabled, ' .
1135 'enable_from, enable_until, last_access, created, updated ' .
1136 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1137 'WHERE initiate_login_url = %s', $this->
escape($tool->initiateLoginUrl));
1139 $sql = sprintf(
'SELECT tool_pk, name, consumer_key, secret, ' .
1140 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1141 'lti_version, signature_method, settings, enabled, ' .
1142 'enable_from, enable_until, last_access, created, updated ' .
1143 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1144 'WHERE consumer_key = %s', $this->
escape($tool->getKey()));
1146 $rsTool = $this->executeQuery($sql);
1148 $row = pg_fetch_object($rsTool);
1150 $tool->setRecordId(intval($row->tool_pk));
1151 $tool->name = $row->name;
1152 $tool->setkey($row->consumer_key);
1153 $tool->secret = $row->secret;
1154 $tool->messageUrl = $row->message_url;
1155 $tool->initiateLoginUrl = $row->initiate_login_url;
1157 if (!is_array($tool->redirectionUris)) {
1158 $tool->redirectionUris = array();
1160 $tool->rsaKey = $row->public_key;
1161 $tool->ltiVersion = $row->lti_version;
1162 $tool->signatureMethod = $row->signature_method;
1164 if (!is_array($settings)) {
1165 $settings = array();
1167 $tool->setSettings($settings);
1168 $tool->enabled = ($row->enabled ===
't');
1169 $tool->enableFrom =
null;
1170 if (!is_null($row->enable_from)) {
1171 $tool->enableFrom = strtotime($row->enable_from);
1173 $tool->enableUntil =
null;
1174 if (!is_null($row->enable_until)) {
1175 $tool->enableUntil = strtotime($row->enable_until);
1177 $tool->lastAccess =
null;
1178 if (!is_null($row->last_access)) {
1179 $tool->lastAccess = strtotime($row->last_access);
1181 $tool->created = strtotime($row->created);
1182 $tool->updated = strtotime($row->updated);
1200 $id = $tool->getRecordId();
1201 $enabled = ($tool->enabled) ?
'true' :
'false';
1202 $redirectionUrisValue = json_encode($tool->redirectionUris);
1204 $settingsValue = json_encode($tool->getSettings());
1207 $now = date(
"{$this->dateFormat} {$this->timeFormat}", $time);
1209 if (!is_null($tool->enableFrom)) {
1210 $from = date(
"{$this->dateFormat} {$this->timeFormat}", $tool->enableFrom);
1213 if (!is_null($tool->enableUntil)) {
1214 $until = date(
"{$this->dateFormat} {$this->timeFormat}", $tool->enableUntil);
1217 if (!is_null($tool->lastAccess)) {
1218 $last = date($this->dateFormat, $tool->lastAccess);
1221 $sql = sprintf(
"INSERT INTO {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' (name, consumer_key, secret, ' .
1222 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1223 'lti_version, signature_method, settings, enabled, enable_from, enable_until, ' .
1224 'last_access, created, updated) ' .
1225 'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', $this->
escape($tool->name),
1226 $this->escape($tool->getKey()), $this->escape($tool->secret), $this->escape($tool->messageUrl),
1227 $this->escape($tool->initiateLoginUrl), $this->escape($redirectionUrisValue), $this->escape($tool->rsaKey),
1228 $this->escape($tool->ltiVersion), $this->escape($tool->signatureMethod), $this->escape($settingsValue), $enabled,
1229 $this->escape($from), $this->escape($until), $this->escape($last), $this->escape($now), $this->escape($now));
1231 $sql = sprintf(
"UPDATE {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' SET ' .
1232 'name = %s, consumer_key = %s, secret = %s, ' .
1233 'message_url = %s, initiate_login_url = %s, redirection_uris = %s, public_key = %s, ' .
1234 'lti_version = %s, signature_method = %s, settings = %s, enabled = %s, enable_from = %s, enable_until = %s, ' .
1235 'last_access = %s, updated = %s ' .
1236 'WHERE tool_pk = %d', $this->
escape($tool->name), $this->escape($tool->getKey()), $this->escape($tool->secret),
1237 $this->escape($tool->messageUrl), $this->escape($tool->initiateLoginUrl), $this->escape($redirectionUrisValue),
1238 $this->escape($tool->rsaKey), $this->escape($tool->ltiVersion), $this->escape($tool->signatureMethod),
1239 $this->escape($settingsValue), $enabled, $this->escape($from), $this->escape($until), $this->escape($last),
1240 $this->escape($now), $tool->getRecordId());
1242 $ok = $this->executeQuery($sql);
1245 $tool->setRecordId($this->insert_id());
1246 $tool->created = $time;
1248 $tool->updated = $time;
1263 $sql = sprintf(
"DELETE FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1264 'WHERE tool_pk = %d', $tool->getRecordId());
1265 $ok = $this->executeQuery($sql);
1268 $tool->initialize();
1283 $sql =
'SELECT tool_pk, name, consumer_key, secret, ' .
1284 'message_url, initiate_login_url, redirection_uris, public_key, ' .
1285 'lti_version, signature_method, settings, enabled, ' .
1286 'enable_from, enable_until, last_access, created, updated ' .
1287 "FROM {$this->dbTableNamePrefix}" . static::TOOL_TABLE_NAME .
' ' .
1289 $rsTools = $this->executeQuery($sql);
1291 while ($row = pg_fetch_object($rsTools)) {
1292 $tool =
new Tool($this);
1293 $tool->setRecordId(intval($row->tool_pk));
1294 $tool->name = $row->name;
1295 $tool->setkey($row->consumer_key);
1296 $tool->secret = $row->secret;
1297 $tool->messageUrl = $row->message_url;
1298 $tool->initiateLoginUrl = $row->initiate_login_url;
1300 if (!is_array($tool->redirectionUris)) {
1301 $tool->redirectionUris = array();
1303 $tool->rsaKey = $row->public_key;
1304 $tool->ltiVersion = $row->lti_version;
1305 $tool->signatureMethod = $row->signature_method;
1307 if (!is_array($settings)) {
1308 $settings = array();
1310 $tool->setSettings($settings);
1311 $tool->enabled = ($row->enabled ===
't');
1312 $tool->enableFrom =
null;
1313 if (!is_null($row->enable_from)) {
1314 $tool->enableFrom = strtotime($row->enable_from);
1316 $tool->enableUntil =
null;
1317 if (!is_null($row->enable_until)) {
1318 $tool->enableUntil = strtotime($row->enable_until);
1320 $tool->lastAccess =
null;
1321 if (!is_null($row->last_access)) {
1322 $tool->lastAccess = strtotime($row->last_access);
1324 $tool->created = strtotime($row->created);
1325 $tool->updated = strtotime($row->updated);
1329 pg_free_result($rsTools);
1344 private function insert_id()
1346 $rsId = $this->executeQuery(
'SELECT lastval();');
1347 $row = pg_fetch_row($rsId);
1348 return intval($row[0]);
1362 public function escape($value, $addQuotes =
true)
1364 if (is_null($value)) {
1367 $value = pg_escape_string($this->db, $value);
1369 $value =
"'{$value}'";
1386 private function executeQuery($sql, $reportError =
true)
1388 $res = pg_query($this->db, $sql);
1389 if (($res ===
false) && $reportError) {
1390 Util::logError($sql . PHP_EOL .
'Error: ' . pg_last_error($this->db));
Class to represent an HTTP message.
Class to represent a platform context.
Class to represent an LTI Data Connector for PostgreSQL.
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.
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.
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.