84 private $dataConnector =
null;
95 $this->dataConnector = $resourceLink->getDataConnector();
100 $this->resourceLinkId = $resourceLink->getRecordId();
109 $this->length =
null;
111 $this->autoApprove =
false;
112 $this->expires =
null;
132 if (empty($this->life)) {
135 $this->life = max(min($this->life, self::MAX_SHARE_KEY_LIFE), 0);
137 $this->expires = time() + ($this->life * 60 * 60);
138 if (empty($this->
id)) {
139 if (empty($this->length) || !is_numeric($this->length)) {
142 $this->length = max(min($this->length, self::MAX_SHARE_KEY_LENGTH), self::MIN_SHARE_KEY_LENGTH);
147 return $this->dataConnector->saveResourceLinkShareKey($this);
155 public function delete()
157 return $this->dataConnector->deleteResourceLinkShareKey($this);
177 private function load()
180 $this->dataConnector->loadResourceLinkShareKey($this);
181 if (!is_null($this->
id)) {
182 $this->length = strlen(strval($this->
id));
184 if (!is_null($this->expires)) {
185 $this->life = ($this->expires - time()) / 60 / 60;
Class to provide a connection to a persistent store for LTI objects.
Class to represent a platform resource link share key.
$resourceLinkId
ID for resource link being shared.
getId()
Get share key value.
const MAX_SHARE_KEY_LENGTH
Maximum length for a share key value.
const MIN_SHARE_KEY_LENGTH
Minimum length for a share key value.
$expires
Timestamp for when the share key expires.
__construct($resourceLink, $id=null)
Class constructor.
$autoApprove
Whether the sharing arrangement should be automatically approved when first used.
initialize()
Initialise the resource link share key.
const DEFAULT_SHARE_KEY_LIFE
Default life for a share key value.
$length
Length of share key.
const MAX_SHARE_KEY_LIFE
Maximum permitted life for a share key value.
initialise()
Initialise the resource link share key.
save()
Save the resource link share key to the database.
static getRandomString($length=8)
Generate a random string.