1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
use Studip\Button, Studip\LinkButton;
/**
* main-class for connection to ILIAS 3
*
* This class contains the main methods of the elearning-interface to connect to ILIAS 3. Extends ConnectedCMS.
*
* @author Arne Schröder <schroeder@data-quest.de>
* @access public
* @modulegroup elearning_interface_modules
* @module Ilias3ConnectedCMS
* @package ELearning-Interface
*/
class Ilias3ConnectedCMS extends ConnectedCMS
{
var $client_id;
var $root_user_sid;
var $main_category_node_id;
var $user_role_template_id;
var $user_skin;
var $user_style;
var $crs_roles;
var $global_roles;
var $soap_client;
var $encrypt_passwords;
var $is_first_call = true;
/**
* constructor
*
* init class.
* @access public
* @param string $cms system-type
*/
function __construct($cms)
{
global $ELEARNING_INTERFACE_MODULES;
parent::__construct($cms);
require_once($this->CLASS_PREFIX . "Soap.class.php");
$classname = $this->CLASS_PREFIX . "Soap";
$this->soap_client = new $classname($this->cms_type);
$this->soap_client->setCachingStatus(true);
$this->main_category_node_id = ELearningUtils::getConfigValue("category_id", $cms);
if ((ELearningUtils::getConfigValue("user_role_template_id", $cms) == "") AND ($GLOBALS["role_template_name"] == ""))
$GLOBALS["role_template_name"] = "Author";
$this->user_role_template_id = ELearningUtils::getConfigValue("user_role_template_id", $cms);
$this->user_skin = ELearningUtils::getConfigValue("user_skin", $cms);
$this->user_style = ELearningUtils::getConfigValue("user_style", $cms);
$this->encrypt_passwords = ELearningUtils::getConfigValue("encrypt_passwords", $cms);
$this->crs_roles = $ELEARNING_INTERFACE_MODULES[$cms]["crs_roles"];
$this->client_id = $ELEARNING_INTERFACE_MODULES[$cms]["soap_data"]["client"];
$this->global_roles = $ELEARNING_INTERFACE_MODULES[$cms]["global_roles"];
}
/**
* get preferences
*
* shows additional settings.
*/
public function getPreferences()
{
$role_template_name = Request::get('role_template_name');
$cat_name = Request::get('cat_name');
$style_setting = Request::option('style_setting');
$encrypt_passwords = Request::option('encrypt_passwords');
$this->soap_client->setCachingStatus(false);
$messages = ['error' => ''];
if ($cat_name) {
$cat = $this->soap_client->getReferenceByTitle( trim( $cat_name ), "cat");
if (!$cat) {
$messages["error"] .= sprintf(_("Das Objekt mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($cat_name), htmlReady($this->getName())) . "<br>\n";
} else {
ELearningUtils::setConfigValue("category_id", $cat, $this->cms_type);
$this->main_category_node_id = $cat;
}
}
if ($role_template_name) {
$role_template = $this->soap_client->getObjectByTitle( trim( $role_template_name ), "rolt" );
if (!$role_template) {
$messages["error"] .= sprintf(_("Das Rollen-Template mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($role_template_name), htmlReady($this->getName())) . "<br>\n";
} elseif (is_array($role_template)) {
ELearningUtils::setConfigValue("user_role_template_id", $role_template["obj_id"], $this->cms_type);
ELearningUtils::setConfigValue("user_role_template_name", $role_template["title"], $this->cms_type);
$this->user_role_template_id = $role_template["obj_id"];
}
}
if (Request::submitted('submit')) {
ELearningUtils::setConfigValue("user_style", $style_setting, $this->cms_type);
ELearningUtils::setConfigValue("user_skin", $style_setting, $this->cms_type);
ELearningUtils::setConfigValue("encrypt_passwords", $encrypt_passwords, $this->cms_type);
} else {
if (ELearningUtils::getConfigValue("user_style", $this->cms_type)) {
$style_setting = ELearningUtils::getConfigValue("user_style", $this->cms_type);
}
if (ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type)) {
$encrypt_passwords = ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type);
}
}
if ($messages['error']) {
echo "<b>" . Icon::create('decline', 'attention')->asImg(['class' => 'text-top', 'title' => _('Fehler')]) . " " . $messages["error"] . "</b><br><br>";
}
echo "<table>";
echo "<tr valign=\"top\"><td width=30% align=\"left\"><font size=\"-1\">";
echo "<b>" . _("SOAP-Verbindung: ") . "</b>";
echo "</td><td><font size=\"-1\">";
$error = $this->soap_client->getError();
if ($error != false)
echo sprintf(_("Beim Herstellen der SOAP-Verbindung trat folgender Fehler auf:")) . "<br><br>" . $error;
else
echo sprintf(_("Die SOAP-Verbindung zum Klienten \"%s\" wurde hergestellt, der Name des Administrator-Accounts ist \"%s\"."), htmlReady($this->soap_data["client"]), htmlReady($this->soap_data["username"]));
echo "<br>\n";
echo "<br>\n";
echo "</td></tr><tr><td width=30% align=\"left\"><font size=\"-1\">";
$cat = $this->soap_client->getObjectByReference( $this->main_category_node_id );
echo '<b>' . _('Kategorie') . ':</b>';
echo "</td><td>";
echo "<input type=\"text\" size=\"20\" border=0 value=\"" . $cat["title"] . "\" name=\"cat_name\"> ";
echo Icon::create('info-circle', 'inactive', ['title' => _('Geben Sie hier den Namen einer bestehenden ILIAS 3 - Kategorie ein, in der die Lernmodule und User-Kategorien abgelegt werden sollen.')])->asImg();
echo "</td></tr><tr><td></td><td><font size=\"-1\">";
echo " (ID " . $this->main_category_node_id;
if ($cat["description"] != "")
echo ", " . _("Beschreibung: ") . htmlReady($cat["description"]);
echo ")";
echo "<br>\n";
echo "<br>\n";
echo "</td></tr><tr><td width=30% align=\"left\"><font size=\"-1\">";
echo "<b>" . _("Rollen-Template für die persönliche Kategorie: ") . "</b>";
echo "</td><td>";
echo "<input type=\"text\" size=\"20\" border=0 value=\"" . ELearningUtils::getConfigValue("user_role_template_name", $this->cms_type) . "\" name=\"role_template_name\"> ";
echo Icon::create('info-circle', 'inactive', ['title' => _('Geben Sie den Namen des Rollen-Templates ein, das für die persönliche Kategorie von Lehrenden verwendet werden soll (z.B. \"Author\").')])->asImg();
echo "</td></tr><tr><td></td><td><font size=\"-1\">";
echo " (ID " . $this->user_role_template_id;
echo ")";
echo "<br>\n";
echo "<br>\n";
echo "</td></tr><tr><td width=30% align=\"left\"><font size=\"-1\">";
echo "<b>" . _("Passwörter: ") . "</b>";
echo "</td><td><font size=\"-1\">";
echo "<input type=\"checkbox\" border=0 value=\"md5\" name=\"encrypt_passwords\"";
if ($encrypt_passwords == "md5")
echo " checked";
echo "> " . _("ILIAS-Passwörter verschlüsselt speichern.");
echo Icon::create('info-circle', 'inactive', ['title' => _('Wählen Sie diese Option, wenn die ILIAS-Passwörter der zugeordneten Accounts verschlüsselt in der Stud.IP-Datenbank abgelegt werden sollen.')])->asImg();
echo "</td></tr><tr><td></td><td><font size=\"-1\">";
echo "<br>\n";
echo "<br>\n";
echo "</td></tr><tr><td width=30% align=\"left\"><font size=\"-1\">";
echo "<b>" . _("Style / Skin: ") . "</b>";
echo "</td><td><font size=\"-1\">";
echo "<input type=\"checkbox\" border=0 value=\"studip\" name=\"style_setting\"";
if ($style_setting == "studip")
echo " checked";
echo "> " . _("Stud.IP-Style für neue Nutzer-Accounts voreinstellen.");
echo Icon::create('info-circle', 'inactive', ['title' => _('Wählen Sie diese Option, wenn für alle von Stud.IP angelegten ILIAS-Accounts das Stud.IP-Layout als System-Style eingetragen werden soll. ILIAS-seitig angelegte Accounts erhalten weiterhin den Standard-Style.')])->asImg();
echo "</td></tr><tr><td></td><td><font size=\"-1\">";
echo "<br>\n";
echo "<br>\n";
echo "</td></tr>";
echo "</table>";
echo "<center>" . Button::create(_('übernehmen'), 'submit') . "</center><br>";
echo "<br>\n";
parent::getPreferences();
echo "<br>\n";
}
function setContentModule($data, $is_connected = false)
{
parent::setContentModule($data, $is_connected);
if ($data["owner"] != "")
{
$user_data = $this->soap_client->getUser($data["owner"]);
$user_name = trim($user_data["title"] . " " . $user_data["firstname"] . " " . $user_data["lastname"]);
$this->content_module[$data["ref_id"]]->setAuthors($user_name);
}
$this->content_module[$data["ref_id"]]->setPermissions($data["accessInfo"], $data["operations"]);
}
/**
* create new instance of subclass content-module
*
* creates new instance of subclass content-module and gets permissions
* @access public
* @param string $module_id module-id
* @param string $module_type module-type
* @param string $is_connected is module connected to seminar?
*/
function newContentModule($module_id, $module_type, $is_connected = false)
{
global $seminar_id, $current_module, $caching_active;
$current_module = $module_id;
// echo "call module $module_id";
if ($this->is_first_call AND ($seminar_id != "") AND ($is_connected == true))
{
$id = ObjectConnections::getConnectionModuleId( $seminar_id, "crs", $this->cms_type );
if ($id != false)
{
if ($this->user->isConnected())
$this->permissions->checkUserPermissions($id);
$this->is_first_call = false;
}
// echo "first call, ref_id $id";
}
parent::newContentModule($module_id, $module_type, $is_connected);
}
/**
* get user modules
*
* returns user content modules
* @access public
* @return array list of content modules
*/
function getUserContentModules()
{
global $connected_cms;
$types = [];
foreach ($this->types as $type => $name)
{
$types[] = $type;
}
if ($this->user->getCategory() == false)
return false;
$result = $this->soap_client->getTreeChilds($this->user->getCategory(), $types, $connected_cms[$this->cms_type]->user->getId());
$obj_ids = [];
if (is_array($result))
foreach($result as $key => $object_data){
if (is_array($object_data["operations"])){
if ((!in_array($object_data["obj_id"], $obj_ids) && in_array(OPERATION_READ, $object_data["operations"]))
|| in_array(OPERATION_WRITE, $object_data["operations"]))
{
if (is_array($user_modules[$object_data["obj_id"]]["operations"])){
if (in_array(OPERATION_WRITE, $user_modules[$object_data["obj_id"]]["operations"])){
continue;
}
}
$user_modules[$object_data["obj_id"]] = $object_data;
$obj_ids[] = $result[$key]["obj_id"];
}
}
}
return $user_modules;
}
/**
* search for content modules
*
* returns found content modules
* @access public
* @param string $key keyword
* @return array list of content modules
*/
function searchContentModules($key)
{
global $connected_cms;
$types = [];
foreach ($this->types as $type => $name)
{
$types[] = $type;
}
$result = $this->soap_client->searchObjects($types, $key,"and", $connected_cms[$this->cms_type]->user->getId());
return $result;
}
/**
* get client-id
*
* returns client-id
* @access public
* @return string client-id
*/
function getClientId()
{
return $this->client_id;
}
/**
* get session-id
*
* returns soap-session-id
* @access public
* @return string session-id
*/
function getSID()
{
return $this->root_user_sid;
}
/**
* terminate
*
* terminates connection.
*/
public function terminate()
{
// $this->soap_client->logout();
$this->soap_client->saveCacheData();
}
//we have to delete the course only
function deleteConnectedModules($object_id){
global $connected_cms;
$connected_cms[$this->cms_type]->soap_client->setCachingStatus(false);
$connected_cms[$this->cms_type]->soap_client->clearCache();
$connected_cms[$this->cms_type]->soap_client->user_type == "admin";
$crs_id = ObjectConnections::getConnectionModuleId($object_id, "crs", $this->cms_type);
if($crs_id && $connected_cms[$this->cms_type]->soap_client->checkReferenceById($crs_id)){
$connected_cms[$this->cms_type]->soap_client->deleteObject($crs_id);
}
return parent::deleteConnectedModules($object_id);
}
}
?>
|