ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey Class Reference

Class to represent a tool consumer resource link share key. More...

+ Collaboration diagram for IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey:

Public Member Functions

 __construct ($resourceLink, $id=null)
 Class constructor. More...
 
 initialize ()
 Initialise the resource link share key. More...
 
 initialise ()
 Initialise the resource link share key. More...
 
 save ()
 Save the resource link share key to the database. More...
 
 delete ()
 Delete the resource link share key from the database. More...
 
 getId ()
 Get share key value. More...
 

Data Fields

const MAX_SHARE_KEY_LIFE = 168
 Maximum permitted life for a share key value. More...
 
const DEFAULT_SHARE_KEY_LIFE = 24
 Default life for a share key value. More...
 
const MIN_SHARE_KEY_LENGTH = 5
 Minimum length for a share key value. More...
 
const MAX_SHARE_KEY_LENGTH = 32
 Maximum length for a share key value. More...
 
 $resourceLinkId = null
 ID for resource link being shared. More...
 
 $length = null
 Length of share key. More...
 
 $life = null
 Life of share key. More...
 
 $autoApprove = false
 Whether the sharing arrangement should be automatically approved when first used. More...
 
 $expires = null
 Date/time when the share key expires. More...
 

Private Member Functions

 load ()
 Load the resource link share key from the database. More...
 

Private Attributes

 $id = null
 Share key value. More...
 
 $dataConnector = null
 Data connector. More...
 

Detailed Description

Class to represent a tool consumer resource link share key.

Author
Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.2 @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0

Definition at line 16 of file ResourceLinkShareKey.php.

Constructor & Destructor Documentation

◆ __construct()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::__construct (   $resourceLink,
  $id = null 
)

Class constructor.

Parameters
ResourceLink$resourceLinkResource_Link object
string$idValue of share key (optional, default is null)

Definition at line 86 of file ResourceLinkShareKey.php.

87 {
88
89 $this->initialize();
90 $this->dataConnector = $resourceLink->getDataConnector();
91 $this->resourceLinkId = $resourceLink->getRecordId();
92 $this->id = $id;
93 if (!empty($id)) {
94 $this->load();
95 }
96
97 }
load()
Load the resource link share key from the database.
initialize()
Initialise the resource link share key.

References IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\$id, IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\initialize(), and IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\load().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::delete ( )

Delete the resource link share key from the database.

Returns
boolean True if the share key was successfully deleted

Definition at line 156 of file ResourceLinkShareKey.php.

157 {
158
159 return $this->dataConnector->deleteResourceLinkShareKey($this);
160
161 }

◆ getId()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::getId ( )

Get share key value.

Returns
string Share key value

Definition at line 168 of file ResourceLinkShareKey.php.

169 {
170
171 return $this->id;
172
173 }

References IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\$id.

◆ initialise()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::initialise ( )

Initialise the resource link share key.

Pseudonym for initialize().

Definition at line 117 of file ResourceLinkShareKey.php.

118 {
119
120 $this->initialize();
121
122 }

References IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\initialize().

+ Here is the call graph for this function:

◆ initialize()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::initialize ( )

Initialise the resource link share key.

Definition at line 102 of file ResourceLinkShareKey.php.

103 {
104
105 $this->length = null;
106 $this->life = null;
107 $this->autoApprove = false;
108 $this->expires = null;
109
110 }

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\__construct(), IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\initialise(), and IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\load().

+ Here is the caller graph for this function:

◆ load()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::load ( )
private

Load the resource link share key from the database.

Definition at line 182 of file ResourceLinkShareKey.php.

183 {
184
185 $this->initialize();
186 $this->dataConnector->loadResourceLinkShareKey($this);
187 if (!is_null($this->id)) {
188 $this->length = strlen($this->id);
189 }
190 if (!is_null($this->expires)) {
191 $this->life = ($this->expires - time()) / 60 / 60;
192 }
193
194 }

References IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\initialize().

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::save ( )

Save the resource link share key to the database.

Returns
boolean True if the share key was successfully saved

Definition at line 129 of file ResourceLinkShareKey.php.

130 {
131
132 if (empty($this->life)) {
133 $this->life = self::DEFAULT_SHARE_KEY_LIFE;
134 } else {
135 $this->life = max(min($this->life, self::MAX_SHARE_KEY_LIFE), 0);
136 }
137 $this->expires = time() + ($this->life * 60 * 60);
138 if (empty($this->id)) {
139 if (empty($this->length) || !is_numeric($this->length)) {
140 $this->length = self::MAX_SHARE_KEY_LENGTH;
141 } else {
142 $this->length = max(min($this->length, self::MAX_SHARE_KEY_LENGTH), self::MIN_SHARE_KEY_LENGTH);
143 }
144 $this->id = DataConnector::getRandomString($this->length);
145 }
146
147 return $this->dataConnector->saveResourceLinkShareKey($this);
148
149 }
static getRandomString($length=8)
Generate a random string.
const DEFAULT_SHARE_KEY_LIFE
Default life for a share key value.
const MAX_SHARE_KEY_LENGTH
Maximum length for a share key value.

References IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\DEFAULT_SHARE_KEY_LIFE, IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector\getRandomString(), and IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\MAX_SHARE_KEY_LENGTH.

+ Here is the call graph for this function:

Field Documentation

◆ $autoApprove

boolean IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$autoApprove = false

Whether the sharing arrangement should be automatically approved when first used.

Definition at line 59 of file ResourceLinkShareKey.php.

◆ $dataConnector

DataConnector IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$dataConnector = null
private

Data connector.

Definition at line 78 of file ResourceLinkShareKey.php.

◆ $expires

int IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$expires = null

Date/time when the share key expires.

Definition at line 65 of file ResourceLinkShareKey.php.

◆ $id

string IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$id = null
private

◆ $length

int IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$length = null

Length of share key.

Definition at line 47 of file ResourceLinkShareKey.php.

◆ $life

int IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$life = null

Life of share key.

Definition at line 53 of file ResourceLinkShareKey.php.

◆ $resourceLinkId

string IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::$resourceLinkId = null

ID for resource link being shared.

Definition at line 41 of file ResourceLinkShareKey.php.

◆ DEFAULT_SHARE_KEY_LIFE

const IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::DEFAULT_SHARE_KEY_LIFE = 24

Default life for a share key value.

Definition at line 26 of file ResourceLinkShareKey.php.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\save().

◆ MAX_SHARE_KEY_LENGTH

const IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::MAX_SHARE_KEY_LENGTH = 32

Maximum length for a share key value.

Definition at line 34 of file ResourceLinkShareKey.php.

Referenced by IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey\save().

◆ MAX_SHARE_KEY_LIFE

const IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::MAX_SHARE_KEY_LIFE = 168

Maximum permitted life for a share key value.

Definition at line 22 of file ResourceLinkShareKey.php.

◆ MIN_SHARE_KEY_LENGTH

const IMSGlobal\LTI\ToolProvider\ResourceLinkShareKey::MIN_SHARE_KEY_LENGTH = 5

Minimum length for a share key value.

Definition at line 30 of file ResourceLinkShareKey.php.


The documentation for this class was generated from the following file: