ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLTIToolConsumer.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
6
14{
18 protected $ref_id;
19
20
24 protected $ext_consumer_id = 0;
25
29 protected $title = '';
30
34 protected $description = '';
35
39 protected $prefix = '';
40
44 protected $user_language = '';
45
49 protected $role = 0;
50
51
52 public function setExtConsumerId($a_id)
53 {
54 $this->ext_consumer_id = $a_id;
55 }
56
57 public function getExtConsumerId()
58 {
60 }
61
62 public function setRefId($a_ref_id)
63 {
64 $this->ref_id = $a_ref_id;
65 }
66
67 public function getRefId()
68 {
69 return $this->ref_id;
70 }
71
75 public function getId()
76 {
77 return $this->getRecordId();
78 }
79
83 public function setTitle($title)
84 {
85 $this->title = $title;
86 // $this->consumerName = $title;
87 }
88
92 public function getTitle()
93 {
94 return $this->title;
95 }
96
101 {
102 $this->description = $description;
103 }
104
108 public function getDescription()
109 {
110 return $this->description;
111 }
112
116 public function setPrefix($prefix)
117 {
118 $this->prefix = $prefix;
119 }
120
124 public function getPrefix()
125 {
126 return $this->prefix;
127 }
128
132 public function setSecret($secret)
133 {
134 $this->secret = $secret;
135 }
136
140 public function getSecret()
141 {
142 return $this->secret;
143 }
144
145
149 public function createSecret()
150 {
151 $this->setSecret(\IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector::getRandomString(12));
152 }
153
157 public function setLanguage($lang)
158 {
159 $this->user_language = $lang;
160 }
161
165 public function getLanguage()
166 {
168 }
169
173 public function setActive($value)
174 {
175 $this->active = $value;
176 }
177
181 public function getActive()
182 {
183 return $this->active;
184 }
185
189 public function setRole($role_id)
190 {
191 $this->role = $role_id;
192 }
193
197 public function getRole()
198 {
199 return $this->role;
200 }
201
202
203 public function setEnabled($a_status)
204 {
205 $this->enabled = $a_status;
206 }
207
208 public function getEnabled()
209 {
210 return $this->enabled;
211 }
212
213 // local_role_always_member, default_skin
214
223 public static function fromRecordId($id, $dataConnector)
224 {
225 $toolConsumer = new ilLTIToolConsumer(null, $dataConnector);
226
227 $toolConsumer->initialize();
228 $toolConsumer->setRecordId($id);
229 if (!$dataConnector->loadToolConsumerILIAS($toolConsumer)) {
230 $toolConsumer->initialize();
231 }
232 $toolConsumer->setRecordId($id);
233
234 ilLoggerFactory::getLogger('lti')->info('Loading with record id: ' . $toolConsumer->getRecordId());
235
236 return $toolConsumer;
237 }
238
245 {
246 $toolConsumer = new ilLTIToolConsumer(null, $dataConnector);
247 $toolConsumer->initialize();
248 $toolConsumer->setExtConsumerId($id);
249 if (!$dataConnector->loadGlobalToolConsumerSettings($toolConsumer)) {
250 $toolConsumer->initialize();
251 }
252 return $toolConsumer;
253 }
254
255
263 public static function fromGlobalSettingsAndRefId($a_ext_consumer_id, $a_ref_id, ilLTIDataConnector $a_data_connector)
264 {
265 $toolConsumer = new ilLTIToolConsumer(null, $a_data_connector);
266 $toolConsumer->initialize();
267 $toolConsumer->setExtConsumerId($a_ext_consumer_id);
268 $toolConsumer->setRefId($a_ref_id);
269
270 $consumer_pk = $a_data_connector->lookupRecordIdByGlobalSettingsAndRefId($toolConsumer);
271 if ($consumer_pk) {
272 return self::fromRecordId($consumer_pk, $a_data_connector);
273 }
274 $toolConsumer->initialize();
275 return $toolConsumer;
276 }
277
278
284 {
285 $dataConnector->saveGlobalToolConsumerSettings($this);
286 }
287
293 {
294 $dataConnector->deleteGlobalToolConsumerSettings($this);
295 }
296
297
303 public function saveLTI($dataConnector)
304 {
305 $ok = $dataConnector->saveToolConsumerILIAS($this);
306 return $ok;
307 }
308}
An exception for terminatinating execution or to throw for unit testing.
Class to represent a tool consumer.
$enabled
Whether the tool consumer instance is enabled to accept incoming connection requests.
$dataConnector
Data connector object or string.
getRecordId()
Get the tool consumer record ID.
Class to represent an LTI Data Connector for ILIAS.
lookupRecordIdByGlobalSettingsAndRefId(ilLTIToolConsumer $consumer)
Lookup record id for global settings and ref_id.
LTI provider for LTI launch.
static fromGlobalSettingsAndRefId($a_ext_consumer_id, $a_ref_id, ilLTIDataConnector $a_data_connector)
Load consumer from global settings and ref_id.
deleteGlobalToolConsumerSettings(ilLTIDataConnector $dataConnector)
Delete global tool consumer settings.
static fromRecordId($id, $dataConnector)
Load the tool consumer from the database by its record ID.
saveLTI($dataConnector)
Save the tool consumer to the database with ILIAS extension.
static fromExternalConsumerId($id, $dataConnector)
createSecret()
Create a secret.
saveGlobalToolConsumerSettings(ilLTIDataConnector $dataConnector)
Save global consumer settings.
static getLogger($a_component_id)
Get component logger.
$lang
Definition: consent.php:3