21 ### ResourceLink methods 38 $id = $resourceLink->getRecordId();
39 $userResults = array();
42 $sql =
'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
43 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' AS u ' .
44 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS rl ' .
45 'ON u.resource_link_pk = rl.resource_link_pk ' .
46 'WHERE (rl.resource_link_pk = :id) AND (rl.primary_resource_link_pk IS NULL)';
47 $query = $this->db->prepare($sql);
48 $query->bindValue(
'id', $id, \PDO::PARAM_INT);
50 $sql =
'SELECT u.user_result_pk, u.lti_result_sourcedid, u.lti_user_id, u.created, u.updated ' .
51 "FROM {$this->dbTableNamePrefix}" . static::USER_RESULT_TABLE_NAME .
' AS u ' .
52 "INNER JOIN {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_TABLE_NAME .
' AS rl ' .
53 'ON u.resource_link_pk = rl.resource_link_pk ' .
54 'WHERE ((rl.resource_link_pk = :id) AND (rl.primary_resource_link_pk IS NULL)) OR ' .
55 '((rl.primary_resource_link_pk = :pid) AND share_approved)';
56 $query = $this->db->prepare($sql);
57 $query->bindValue(
'id', $id, \PDO::PARAM_INT);
58 $query->bindValue(
'pid', $id, \PDO::PARAM_INT);
60 if ($query->execute()) {
61 while ($row = $query->fetch(\PDO::FETCH_ASSOC)) {
62 $row = array_change_key_case($row);
64 $userresult->setRecordId(intval($row[
'user_result_pk']));
65 $userresult->ltiResultSourcedId = $row[
'lti_result_sourcedid'];
66 $userresult->created = strtotime($row[
'created']);
67 $userresult->updated = strtotime($row[
'updated']);
68 if (is_null($idScope)) {
69 $userResults[] = $userresult;
71 $userResults[$userresult->getId($idScope)] = $userresult;
80 ### ResourceLinkShareKey methods 92 $id = $shareKey->getId();
93 $expires = date(
"{$this->dateFormat} {$this->timeFormat}", $shareKey->expires);
94 $sql =
"INSERT INTO {$this->dbTableNamePrefix}" . static::RESOURCE_LINK_SHARE_KEY_TABLE_NAME .
' ' .
95 '(share_key_id, resource_link_pk, auto_approve, expires) ' .
96 'VALUES (:id, :prlid, :approve, :expires)';
97 $query = $this->db->prepare($sql);
98 $query->bindValue(
'id', $id, \PDO::PARAM_STR);
99 $query->bindValue(
'prlid', $shareKey->resourceLinkId, \PDO::PARAM_INT);
100 $query->bindValue(
'approve', $shareKey->autoApprove, \PDO::PARAM_INT);
101 $query->bindValue(
'expires', $expires, \PDO::PARAM_STR);
102 $ok = $query->execute();
getUserResultSourcedIDsResourceLink($resourceLink, $localOnly, $idScope)
Get array of user objects.
saveResourceLinkShareKey($shareKey)
Save resource link share key object.
Class to represent a tool consumer context.
Class to represent an LTI Data Connector for PDO connections.
Class to represent an LTI Data Connector for PDO variations for PostgreSQL connections.
static fromRecordId($id, $dataConnector)
Load the user from the database.