ILIAS  release_8 Revision v8.24
ILIAS\LTI\ToolProvider\ResourceLinkShareKey Class Reference

Class to represent a platform resource link share key. More...

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

Public Member Functions

 __construct (ResourceLink $resourceLink, string $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...
 
int $resourceLinkId = null
 ID for resource link being shared. More...
 
int $length = null
 Length of share key. More...
 
int $life = null
 Life of share key. More...
 
bool $autoApprove = false
 Whether the sharing arrangement should be automatically approved when first used. More...
 
int $expires = null
 Timestamp for when the share key expires. More...
 

Private Member Functions

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

Private Attributes

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

Detailed Description

Class to represent a platform resource link share key.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com

Definition at line 30 of file ResourceLinkShareKey.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LTI\ToolProvider\ResourceLinkShareKey::__construct ( ResourceLink  $resourceLink,
string  $id = null 
)

Class constructor.

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

Definition at line 106 of file ResourceLinkShareKey.php.

107 {
108 $this->initialize();
109 $this->dataConnector = $resourceLink->getDataConnector();
110 $this->id = $id;
111 if (!empty($id)) {
112 $this->load();
113 } else {
114 $this->resourceLinkId = $resourceLink->getRecordId();
115 }
116 }
load()
Load the resource link share key from the database.
initialize()
Initialise the resource link share key.

References ILIAS\LTI\ToolProvider\ResourceLinkShareKey\$id, ILIAS\LTI\ToolProvider\ResourceLink\getDataConnector(), ILIAS\LTI\ToolProvider\ResourceLink\getRecordId(), ILIAS\LTI\ToolProvider\ResourceLinkShareKey\initialize(), and ILIAS\LTI\ToolProvider\ResourceLinkShareKey\load().

+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

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

Delete the resource link share key from the database.

Returns
bool True if the share key was successfully deleted

Definition at line 169 of file ResourceLinkShareKey.php.

169 : bool
170 {
171 return $this->dataConnector->deleteResourceLinkShareKey($this);
172 }

◆ getId()

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

Get share key value.

Returns
string Share key value

Definition at line 179 of file ResourceLinkShareKey.php.

179 : ?string
180 {
181 return $this->id;
182 }

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

Referenced by ilLTIDataConnector\deleteResourceLinkShareKey(), ilLTIDataConnector\loadResourceLinkShareKey(), and ilLTIDataConnector\saveResourceLinkShareKey().

+ Here is the caller graph for this function:

◆ initialise()

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

Initialise the resource link share key.

Synonym for initialize().

Definition at line 134 of file ResourceLinkShareKey.php.

135 {
136 $this->initialize();
137 }

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

+ Here is the call graph for this function:

◆ initialize()

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

Initialise the resource link share key.

Definition at line 121 of file ResourceLinkShareKey.php.

122 {
123 $this->length = null;
124 $this->life = null;
125 $this->autoApprove = false;
126 $this->expires = null;
127 }

Referenced by ILIAS\LTI\ToolProvider\ResourceLinkShareKey\__construct(), ilLTIDataConnector\deleteResourceLinkShareKey(), ILIAS\LTI\ToolProvider\ResourceLinkShareKey\initialise(), and ILIAS\LTI\ToolProvider\ResourceLinkShareKey\load().

+ Here is the caller graph for this function:

◆ load()

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

Load the resource link share key from the database.

Definition at line 191 of file ResourceLinkShareKey.php.

192 {
193 $this->initialize();
194 $this->dataConnector->loadResourceLinkShareKey($this);
195 if (!is_null($this->id)) {
196 $this->length = strlen(strval($this->id));
197 }
198 if (!is_null($this->expires)) {
199 $this->life = ($this->expires - time()) / 60 / 60;
200 }
201 }

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

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

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

◆ save()

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

Save the resource link share key to the database.

Returns
bool True if the share key was successfully saved

Definition at line 144 of file ResourceLinkShareKey.php.

144 : bool
145 {
146 if (empty($this->life)) {
147 $this->life = self::DEFAULT_SHARE_KEY_LIFE;
148 } else {
149 $this->life = max(min($this->life, self::MAX_SHARE_KEY_LIFE), 0);
150 }
151 $this->expires = time() + ($this->life * 60 * 60);
152 if (empty($this->id)) {
153 if (empty($this->length) || !is_numeric($this->length)) {
154 $this->length = self::MAX_SHARE_KEY_LENGTH;
155 } else {
156 $this->length = max(min($this->length, self::MAX_SHARE_KEY_LENGTH), self::MIN_SHARE_KEY_LENGTH);
157 }
158 $this->id = Util::getRandomString($this->length);
159 }
160
161 return $this->dataConnector->saveResourceLinkShareKey($this);
162 }
const DEFAULT_SHARE_KEY_LIFE
Default life for a share key value.
const MAX_SHARE_KEY_LENGTH
Maximum length for a share key value.
static getRandomString(int $length=8)
Generate a random string.
Definition: Util.php:558

References ILIAS\LTI\ToolProvider\ResourceLinkShareKey\DEFAULT_SHARE_KEY_LIFE, ILIAS\LTI\ToolProvider\Util\getRandomString(), and ILIAS\LTI\ToolProvider\ResourceLinkShareKey\MAX_SHARE_KEY_LENGTH.

+ Here is the call graph for this function:

Field Documentation

◆ $autoApprove

bool ILIAS\LTI\ToolProvider\ResourceLinkShareKey::$autoApprove = false

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

Definition at line 78 of file ResourceLinkShareKey.php.

◆ $dataConnector

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

Data connector.

Definition at line 99 of file ResourceLinkShareKey.php.

◆ $expires

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

Timestamp for when the share key expires.

Definition at line 85 of file ResourceLinkShareKey.php.

◆ $id

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

◆ $length

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

Length of share key.

Definition at line 64 of file ResourceLinkShareKey.php.

◆ $life

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

Life of share key.

Definition at line 71 of file ResourceLinkShareKey.php.

◆ $resourceLinkId

int null ILIAS\LTI\ToolProvider\ResourceLinkShareKey::$resourceLinkId = null

ID for resource link being shared.

Definition at line 57 of file ResourceLinkShareKey.php.

◆ DEFAULT_SHARE_KEY_LIFE

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

Default life for a share key value.

Definition at line 40 of file ResourceLinkShareKey.php.

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

◆ MAX_SHARE_KEY_LENGTH

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

Maximum length for a share key value.

Definition at line 50 of file ResourceLinkShareKey.php.

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

◆ MAX_SHARE_KEY_LIFE

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

Maximum permitted life for a share key value.

Definition at line 35 of file ResourceLinkShareKey.php.

◆ MIN_SHARE_KEY_LENGTH

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

Minimum length for a share key value.

Definition at line 45 of file ResourceLinkShareKey.php.


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