ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilObjLTIAdministration.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Services/Object/classes/class.ilObject.php';
5
13{
14 public function __construct($a_id = 0, $a_call_by_reference = true)
15 {
16 $this->type = "ltis";
17 parent::__construct($a_id, $a_call_by_reference);
18 }
19
23 public function getLTIObjectTypes()
24 {
25 $obj_def = new ilObjectDefinition();
26 return $obj_def->getLTIProviderTypes();
27 }
28
32 public function getLTIRoles()
33 {
34 global $rbacreview;
35
36 require_once("Services/AccessControl/classes/class.ilObjRole.php");
37
38 $global_roles = $rbacreview->getGlobalRoles();
39
40 $filtered_roles = array_diff($global_roles, array(SYSTEM_ROLE_ID, ANONYMOUS_ROLE_ID));
41
42 $roles = array();
43 foreach ($filtered_roles as $role) {
44 $obj_role = new ilObjRole($role);
45 $roles[$role] = $obj_role->getTitle();
46 }
47
48 return $roles;
49 }
50
55 public function saveConsumerObjectTypes($a_consumer_id, $a_obj_types)
56 {
57 global $ilDB;
58
59 $ilDB->manipulate("DELETE FROM lti_ext_consumer_otype WHERE consumer_id = " . $ilDB->quote($a_consumer_id, "integer"));
60
61 if ($a_obj_types) {
62 $query = "INSERT INTO lti_ext_consumer_otype (consumer_id, object_type) VALUES (%s, %s)";
63 $types = array("integer", "text");
64 foreach ($a_obj_types as $ot) {
65 $values = array($a_consumer_id, $ot);
66 $ilDB->manipulateF($query, $types, $values);
67 }
68 }
69 }
70
75 public function getActiveObjectTypes($a_consumer_id)
76 {
77 global $DIC;
78 $ilDB = $DIC['ilDB'];
79
80 $result = $ilDB->query("SELECT object_type FROM lti_ext_consumer_otype WHERE consumer_id = " . $ilDB->quote($a_consumer_id, "integer"));
81
82 $obj_ids = array();
83 while ($record = $ilDB->fetchAssoc($result)) {
84 array_push($obj_ids, $record['object_type']);
85 }
86 return $obj_ids;
87 }
88
92 public static function isEnabledForType($a_type)
93 {
97 $db = $GLOBALS['DIC']->database();
98
99 $query = 'select id from lti_ext_consumer join lti_ext_consumer_otype on id = consumer_id ' .
100 'WHERE active = ' . $db->quote(1, 'integer') . ' ' .
101 'AND object_type = ' . $db->quote($a_type, 'text');
102 $res = $db->query($query);
103 while ($row = $res->fetchObject()) {
104 return true;
105 }
106 return false;
107 }
108
114 public static function getEnabledConsumersForType($a_type)
115 {
119 $db = $GLOBALS['DIC']->database();
120
121 $query = 'select distinct(id) id from lti_ext_consumer join lti_ext_consumer_otype on id = consumer_id ' .
122 'WHERE active = ' . $db->quote(1, 'integer') . ' ' .
123 'AND object_type = ' . $db->quote($a_type, 'text');
124 $res = $db->query($query);
125
126 $connector = new ilLTIDataConnector();
127 $consumers = array();
128 while ($row = $res->fetchObject()) {
129 $consumers[] = ilLTIToolConsumer::fromExternalConsumerId($row->id, $connector);
130 }
131 return $consumers;
132 }
133
137 public static function lookupLTISettingsRefId()
138 {
139 $res = $GLOBALS['DIC']->database()->queryF(
140 '
141 SELECT object_reference.ref_id FROM object_reference, tree, object_data
142 WHERE tree.parent = %s
143 AND object_data.type = %s
144 AND object_reference.ref_id = tree.child
145 AND object_reference.obj_id = object_data.obj_id',
146 array('integer', 'text'),
147 array(SYSTEM_FOLDER_ID, 'ltis')
148 );
149 while ($row = $GLOBALS['DIC']->database()->fetchAssoc($res)) {
150 $lti_ref_id = $row['ref_id'];
151 }
152 return $lti_ref_id;
153 }
154
158 public static function readReleaseObjects()
159 {
160 $db = $GLOBALS['DIC']->database();
161
162 $query = 'select ref_id, title from lti2_consumer join lti_ext_consumer ' .
163 'on id = ext_consumer_id where enabled = ' . $db->quote(1, 'integer');
164 $res = $db->query($query);
165
166 ilLoggerFactory::getLogger('lti')->debug($query);
167
168 $rows = [];
169 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
170 $item['ref_id'] = $row->ref_id;
171 $item['title'] = $row->title;
172
173 $rows[] = $item;
174 }
175 return $rows;
176 }
177}
$result
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Class to represent an LTI Data Connector for ILIAS.
static fromExternalConsumerId($id, $dataConnector)
static getLogger($a_component_id)
Get component logger.
static lookupLTISettingsRefId()
Lookup ref_id.
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
saveConsumerObjectTypes($a_consumer_id, $a_obj_types)
static readReleaseObjects()
Read released objects.
Class ilObjRole.
parses the objects.xml it handles the xml-description of all ilias objects
Class ilObject Basic functions for all objects.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46
$rows
Definition: xhr_table.php:10