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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
|
<?php
# Lifter007: TODO
# Lifter003: TEST
# Lifter010: TODO
/*
* siteinfo - display information about Stud.IP
*
* Copyright (c) 2008 Ansgar Bockstiegel
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
require_once 'lib/user_visible.inc.php';
class Siteinfo {
private $sme; //SiteinfoMarkupEngine
private $rubrics_empty; //boolean; true if there is no rubric
private $db; //DBManager
function __construct() {
$this->sme = new SiteinfoMarkupEngine();
$this->db = DBManager::get();
}
function get_detail_content($id) {
//first we define some fallbacks
if ((int)$id === 0) {
//users with root priveleges get a hint whether what to do...
if ($GLOBALS['perm']->have_perm('root')) {
if ($this->rubrics_empty) {
return _("Benutzen Sie den Link »neue Rubrik anlegen« in der Infobox, um eine Rubrik anzulegen.");
} else {
return _("Benutzen Sie den Link »neue Seite anlegen« in der Infobox, um eine Seite in dieser Rubrik anzulegen.");
}
//...while unauthorized users just get informed that there's something missing und who might be the person to fix this
} else {
return _("Der für diese Stud.IP-Installation verantwortliche Administrator muss hier noch Inhalte einfügen.\n(:rootlist:)");
}
} else {
$sql = "SELECT content
FROM siteinfo_details
WHERE detail_id = :id";
$statement = DBManager::get()->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
return $statement->fetchColumn();
}
}
public function get_detail_draft_status($id) {
$sql = "SELECT draft_status
FROM siteinfo_details
WHERE detail_id = :id";
$statement = DBManager::get()->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
return $statement->fetchColumn();
}
function get_detail($id) {
$sql = "SELECT *
FROM siteinfo_details
WHERE detail_id = :id";
$statement = DBManager::get()->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
return $statement->fetch(PDO::FETCH_ASSOC);
}
function get_detail_content_processed($id) {
//applying Schnellformatierungen and Siteinfo-specific markup to the content
$content = $this->get_detail_content($id);
return $this->sme->siteinfoDirectives(formatReady(language_filter($content)));
}
function get_all_details() {
$sql = "SELECT *
FROM siteinfo_details
ORDER BY position, detail_id ASC";
$result = $this->db->query($sql);
return $result->fetchAll();
}
function first_detail_id($rubric = null, $nodraft = null, $nobody = null) {
$rubric_id = $rubric ?: $this->first_rubric_id();
$sql = "SELECT detail_id
FROM siteinfo_details
WHERE rubric_id = IFNULL(?, rubric_id)";
if ($nodraft) {
$sql .= " AND draft_status = 0 ";
}
if ($nobody) {
$sql .= " AND page_disabled_nobody = 0 ";
}
$sql .= "
ORDER BY position, detail_id ASC
LIMIT 1";
$statement = DBManager::get()->prepare($sql);
$statement->execute([
$rubric_id ?: null
]);
return $statement->fetchColumn() ?: 0;
}
function get_all_rubrics() {
$sql = "SELECT rubric_id, name, position
FROM siteinfo_rubrics
ORDER BY position, rubric_id ASC";
$result = $this->db->query($sql);
return $result->fetchAll();
}
function first_rubric_id() {
$sql = "SELECT rubric_id
FROM siteinfo_rubrics
ORDER BY position, rubric_id ASC
LIMIT 1";
$result = $this->db->query($sql);
$rows = $result->fetch();
if ($result->rowCount() > 0) {
return $rows[0];
} else {
$this->rubrics_empty = true;
return null;
}
}
function rubric_for_detail($id) {
$sql = "SELECT rubric_id
FROM siteinfo_details
WHERE detail_id = :id";
$statement = DBManager::get()->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
return $statement->fetchColumn();
}
function rubric($id) {
$sql = "SELECT *
FROM siteinfo_rubrics
WHERE rubric_id = :id";
$statement = DBManager::get()->prepare($sql);
$statement->bindValue(':id', $id, PDO::PARAM_INT);
$statement->execute();
return $statement->fetch(PDO::FETCH_ASSOC);
}
function get_rubric_max_position()
{
return DBManager::get()->fetchColumn("SELECT MAX(position) FROM siteinfo_rubrics");
}
function get_detail_max_position($rubric_id)
{
return DBManager::get()->fetchColumn("SELECT MAX(position) FROM siteinfo_details WHERE rubric_id=?", [$rubric_id]);
}
function save($type, $input) {
//distinguish the subject and the action (modification/insertion)
$rubric = '';
$detail = '';
switch ($type) {
case 'update_detail':
$old_detail = $this->get_detail($input['detail_id']);
$query = "UPDATE siteinfo_details
SET rubric_id = :rubric_id, name = :name, content = :content,
draft_status = :draft_status, position = :position, page_disabled_nobody = :page_disabled_nobody
WHERE detail_id = :detail_id";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':rubric_id', $input['rubric_id'], PDO::PARAM_INT);
$statement->bindValue(':name', $input['detail_name']);
$statement->bindValue(':content', $input['content']);
$statement->bindValue(':detail_id', $input['detail_id'], PDO::PARAM_INT);
$statement->bindValue(':draft_status', $input['draft_status']);
$statement->bindValue(':position', $input['page_position'], PDO::PARAM_INT);
$statement->bindValue(':page_disabled_nobody', $input['page_disabled_nobody'], PDO::PARAM_BOOL);
$statement->execute();
$this->renumber_details($input['rubric_id'], $input['detail_id'], $old_detail['position'] <=> $input['page_position']);
$rubric = $input['rubric_id'];
$detail = $input['detail_id'];
break;
case 'insert_detail':
$query = "INSERT INTO siteinfo_details (rubric_id, name, content, draft_status, position, page_disabled_nobody )
VALUES (:rubric_id, :name, :content, :draft_status, :position, :page_disabled_nobody)";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':rubric_id', $input['rubric_id'], PDO::PARAM_INT);
$statement->bindValue(':name', $input['detail_name']);
$statement->bindValue(':content', $input['content']);
$statement->bindValue(':draft_status', $input['draft_status']);
$statement->bindValue(':position', $input['page_position'], PDO::PARAM_INT);
$statement->bindValue(':page_disabled_nobody', $input['page_disabled_nobody'], PDO::PARAM_INT);
$statement->execute();
$detail = DBManager::get()->lastInsertId();
$this->renumber_details($input['rubric_id'], $detail, 1);
$rubric = $input['rubric_id'];
break;
case "update_rubric":
$old_rubric = $this->rubric($input['rubric_id']);
$query = "UPDATE siteinfo_rubrics
SET name = :name, position = :position
WHERE rubric_id = :id";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':name', $input['rubric_name']);
$statement->bindValue(':id', $input['rubric_id'], PDO::PARAM_INT);
$statement->bindValue(':position', $input['rubric_position'], PDO::PARAM_INT);
$statement->execute();
$this->renumber_rubrics($input['rubric_id'], $old_rubric['position'] <=> $input['rubric_position']);
$rubric = $input['rubric_id'];
$detail = $this->first_detail_id($rubric);
break;
case "insert_rubric":
$query = "INSERT INTO siteinfo_rubrics (name, position)
VALUES (:name, :position)";
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':name', $input['rubric_name']);
$statement->bindValue(':position', $input['rubric_position'], PDO::PARAM_INT);
$statement->execute();
$rubric = DBManager::get()->lastInsertId();
$this->renumber_rubrics($rubric, 1);
$detail = 0;
}
return [$rubric, $detail];
}
public function delete($type, $id)
{
if ($type === 'rubric') {
$query = "DELETE FROM siteinfo_details WHERE rubric_id = ?";
$statement = DBManager::get()->prepare($query);
$statement->execute([$id]);
$query = "DELETE FROM siteinfo_rubrics WHERE rubric_id = ?";
$statement = DBManager::get()->prepare($query);
$statement->execute([$id]);
} else {
$query = "DELETE FROM siteinfo_details WHERE detail_id = ?";
$statement = DBManager::get()->prepare($query);
$statement->execute([$id]);
}
}
public function renumber_rubrics($changed = 0, $direction = 0)
{
$db = DBManager::get();
$position = 1;
foreach($db->fetchFirst("SELECT rubric_id
FROM siteinfo_rubrics
ORDER BY position, rubric_id=" . (int)$changed . ($direction > 0 ? ' desc' : ' asc')) as $rubric_id) {
$db->execute("UPDATE siteinfo_rubrics SET position=? WHERE rubric_id=?", [$position++, $rubric_id]);
}
}
public function renumber_details($rubric_id, $changed = 0, $direction = 0)
{
$db = DBManager::get();
$page_position = 1;
foreach($db->fetchFirst("SELECT detail_id
FROM siteinfo_details
WHERE rubric_id = ?
ORDER BY position, detail_id=" . (int)$changed . ($direction > 0 ? ' desc' : ' asc'), [$rubric_id]) as $detail_id) {
$db->execute("UPDATE siteinfo_details SET position=? WHERE detail_id=?", [$page_position++, $detail_id]);
}
}
}
class SiteinfoMarkupEngine {
private $db;
private $template_factory;
private $siteinfo_directives;
//a copy of wiki-engine to support specialized markup in order
//to preserve (parts?) of the old impressum.php-functionality
//and add new markup as needed
function __construct() {
$this->db = DBManager::get();
$this->template_factory = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH'].'/app/views/siteinfo/markup/');
$this->siteinfoMarkup("/\(:version:\)/", [$this, 'version']);
$this->siteinfoMarkup("/\(:uniname:\)/", [$this, 'uniName']);
$this->siteinfoMarkup("/\(:unicontact:\)/", [$this, 'uniContact']);
$this->siteinfoMarkup("/\(:userinfo ([a-z_@\-]*):\)/", function ($m) {return $this->userinfo($m[1]);});
$this->siteinfoMarkup("/\(:userlink ([a-z_@\-]*):\)/", function ($m) {return $this->userlink($m[1]);});
$this->siteinfoMarkup("/\(:rootlist:\)/", [$this, 'rootlist']);
$this->siteinfoMarkup("/\(:adminlist:\)/", [$this, 'adminlist']);
$this->siteinfoMarkup("/\(:coregroup:\)/", [$this, 'coregroup']);
$this->siteinfoMarkup("/\(:toplist ([a-z]*):\)/i", function ($m) {return $this->toplist($m[1]);});
$this->siteinfoMarkup("/\(:indicator ([a-z_\-]*):\)/i", function ($m) {return $this->indicator($m[1]);});
$this->siteinfoMarkup("/\(:history:\)/", [$this, 'history']);
$this->siteinfoMarkup("/\(:terms:\)/", [$this, 'termsOfUse']);
$this->siteinfoMarkup("/\(:reportbarrierlink:\)/", [$this, 'reportBarrierLink']);
$this->siteinfoMarkup("'\[style=(")?(.*?)(")?\]\s*(.*?)\s*\[/style\]'s", function ($m) {return $this->style($m[2], $m[4]);});
}
function siteinfoMarkup($pattern, $replace) {
//function to register markup for later processing
$this->siteinfo_directives[] = [$pattern, $replace];
}
function siteinfoDirectives($str) {
//function to process registered markup
if (is_array($this->siteinfo_directives)) {
foreach ($this->siteinfo_directives as $direct) {
$str = preg_replace_callback($direct[0],$direct[1],$str);
}
}
return $str;
}
function version() {
return htmlReady($GLOBALS['SOFTWARE_VERSION']);
}
function uniName() {
return htmlReady(Config::get()->UNI_NAME_CLEAN);
}
function uniContact() {
$template = $this->template_factory->open('uniContact');
$template->contact = $GLOBALS['UNI_CONTACT'];
return $template->render();
}
function userinfo($input) {
$template = $this->template_factory->open('userinfo');
$sql = "SELECT {$GLOBALS['_fullname_sql']['full']} AS fullname,
Email, username
FROM auth_user_md5
LEFT JOIN user_info USING (user_id)
WHERE username = ? AND ".get_vis_query();
$statement = DBManager::get()->prepare($sql);
$statement->execute([$input]);
$temp = $statement->fetchAll(PDO::FETCH_ASSOC);
if (count($temp) === 1) {
$user = reset($temp);
$template->username = $user['username'];
$template->fullname = $user['fullname'];
$template->email = $user['Email'];
} else {
$template->error = TRUE;
}
return $template->render();
}
function userlink($input) {
$template = $this->template_factory->open('userlink');
$sql = "SELECT {$GLOBALS['_fullname_sql']['full']} AS fullname, username
FROM auth_user_md5
LEFT JOIN user_info USING (user_id)
WHERE username = ? AND ".get_vis_query();
$statement = DBManager::get()->prepare($sql);
$statement->execute([$input]);
$temp = $statement->fetchAll(PDO::FETCH_ASSOC);
if (count($temp) === 1) {
$user = reset($temp);
$template->username = $user['username'];
$template->fullname = $user['fullname'];
} else {
$template->error = TRUE;
}
return $template->render();
}
/**
* Returns a list of all root accounts as html
* @return string html
*/
public function rootlist()
{
$template = $this->template_factory->open('rootlist');
$sql = "SELECT {$GLOBALS['_fullname_sql']['full']} AS fullname,
Email, username
FROM auth_user_md5
LEFT JOIN user_info USING (user_id)
WHERE perms = 'root'
AND " . get_vis_query() . "
ORDER BY Nachname, Vorname";
$result = $this->db->query($sql);
if ($result->rowCount() > 0) {
$template->users = $result->fetchAll(PDO::FETCH_ASSOC);
} else {
$template->error = true;
}
return $template->render();
}
/**
* Returns a list of all admin accounts as html
* @return string html
*/
public function adminList()
{
$template = $this->template_factory->open('adminList');
$sql = "SELECT Institute.Name AS institute,
{$GLOBALS['_fullname_sql']['full']} AS fullname,
auth_user_md5.Email, auth_user_md5.username
FROM user_inst
LEFT JOIN Institute ON (user_inst.institut_id = Institute.Institut_id)
LEFT JOIN auth_user_md5 USING (user_id)
LEFT JOIN user_info USING (user_id)
WHERE inst_perms = 'admin'
AND ".get_vis_query()."
ORDER BY Institute.Name, auth_user_md5.Nachname, auth_user_md5.Vorname";
$result = $this->db->query($sql);
if ($result->rowCount() > 0) {
$template->admins = $result->fetchAll(PDO::FETCH_ASSOC);
} else {
$template->error = TRUE;
}
return $template->render();
}
function coregroup() {
$cache = StudipCacheFactory::getCache();
if (!($remotefile = $cache->read('coregroup'))) {
$remotefile = file_get_contents('https://develop.studip.de/studip/extern.php?module=Persons&config_id=8d1dafc3afca2bce6125d57d4119b631&range_id=4498a5bc62d7974d0a0ac3e97aca5296', false, get_default_http_stream_context('https://develop.studip.de'));
$cache->write('coregroup', $remotefile);
}
return str_replace(['class="normal"', 'align="left"'], ['', ''], $remotefile);
}
function toplist($item) {
$cache = StudipCacheFactory::getCache();
if ($found_in_cache = $cache->read(__METHOD__ . $item)) {
return $found_in_cache;
}
$template = $this->template_factory->open('toplist');
$sql = '';
switch ($item) {
case "mostparticipants":
$template->heading = _("die meisten Teilnehmenden");
$sql = "SELECT seminar_user.seminar_id,
seminare.name AS display,
count(seminar_user.seminar_id) AS count
FROM seminar_user
INNER JOIN seminare USING(seminar_id)
WHERE seminare.visible = 1
GROUP BY seminar_user.seminar_id
ORDER BY count DESC
LIMIT 10";
$template->type = "seminar";
break;
case "recentlycreated":
$template->heading = _("zuletzt angelegt");
$sql = "SELECT seminare.seminar_id,
seminare.name AS display,
FROM_UNIXTIME(mkdate, '%d.%m.%Y %h:%i:%s') AS count
FROM seminare
WHERE visible = 1
ORDER BY mkdate DESC
LIMIT 10";
$template->type = "seminar";
break;
case "mostdocuments":
$template->heading = _("die meisten Materialien (Dokumente)");
$sql = "SELECT b.seminar_id,
b.name AS display,
count(b.seminar_id) AS count
FROM seminare b
INNER JOIN folders ON (range_id = seminar_id)
INNER JOIN file_refs ON (folders.id = folder_id)
WHERE b.visible=1
GROUP BY b.seminar_id
ORDER BY count DESC
LIMIT 10";
$template->type = "seminar";
break;
case "mostpostings":
$template->heading = _("die aktivsten Veranstaltungen (Postings der letzten zwei Wochen)");
$seminars = [];
// get TopTen of seminars from all ForumModules and add up the
// count for seminars with more than one active ForumModule
// to get a combined toplist
foreach (PluginEngine::getPlugins('ForumModule') as $plugin) {
$new_seminars = $plugin->getTopTenSeminars();
foreach ($new_seminars as $sem) {
if (!isset($seminars[$sem['seminar_id']])) {
$seminars[$sem['seminar_id']] = $sem;
} else {
$seminars[$sem['seminar_id']]['count'] += $sem['count'];
}
}
}
// sort the seminars by the number of combined postings
usort($seminars, function($a, $b) {
if ($a['count'] === $b['count']) {
return 0;
}
return ($a['count'] > $b['count']) ? -1 : 1;
});
// fill the template and returned the rendered code
$template->lines = $seminars;
$template->type = "seminar";
break;
case "mostvisitedhomepages":
$template->heading = _("die beliebtesten Profile (Besucher)");
$sql = "SELECT auth_user_md5.user_id,
username,
views AS count,
{$GLOBALS['_fullname_sql']['full']} AS display
FROM object_views
LEFT JOIN auth_user_md5 ON (object_id = auth_user_md5.user_id)
LEFT JOIN user_info USING (user_id)
WHERE auth_user_md5.user_id IS NOT NULL
ORDER BY count DESC
LIMIT 10";
$template->type = "user";
break;
}
if ($sql) {
$result = $this->db->query($sql);
if ($result->rowCount() > 0) {
$template->lines = $result->fetchAll(PDO::FETCH_ASSOC);
}
}
$ret = $template->render();
$cache->write(__METHOD__ . $item, $ret);
return $ret;
}
function indicator($key) {
$cache = StudipCacheFactory::getCache();
if ($found_in_cache = $cache->read(__METHOD__ . $key)) {
return $found_in_cache;
}
$template = $this->template_factory->open('indicator');
$indicator['seminar_all'] = ["count" => ['count_table_rows','seminare'],
"title" => _("Aktive Veranstaltungen"),
"detail" => _("alle Veranstaltungen, die nicht archiviert wurden")];
$indicator['seminar_archived'] = ["count" => ['count_table_rows','archiv'],
"title" => _("Archivierte Veranstaltungen"),
"detail" => _("alle Veranstaltungen, die archiviert wurden")];
$indicator['institute_secondlevel_all'] = ["query" => "SELECT COUNT(*) FROM Institute WHERE Institut_id != fakultaets_id",
"title" => _("beteiligte Einrichtungen"),
"detail" => _("alle Einrichtungen außer den Fakultäten")];
$indicator['institute_firstlevel_all'] = ["query" => "SELECT COUNT(*) FROM Institute WHERE Institut_id = fakultaets_id",
"title" => _("beteiligte Fakultäten"),
"detail" => _("alle Fakultäten")];
$indicator['user_admin'] = ["query" => "SELECT COUNT(*) FROM auth_user_md5 WHERE perms='admin'",
"title" => _("registrierte Administratoren"),
"detail" => ""];
$indicator['user_dozent'] = ["query" => "SELECT COUNT(*) FROM auth_user_md5 WHERE perms='dozent'",
"title" => _("registrierte Dozenten"),
"detail" => ""];
$indicator['user_tutor'] = ["query" => "SELECT COUNT(*) FROM auth_user_md5 WHERE perms='tutor'",
"title" => _("registrierte Tutoren"),
"detail" => ""];
$indicator['user_autor'] = ["query" => "SELECT COUNT(*) FROM auth_user_md5 WHERE perms='autor'",
"title" => _("registrierte Autoren"),
"detail" => ""];
$indicator['document'] = ["query" => "SELECT COUNT(*) FROM files WHERE filetype='StandardFile'",
"title" => _("Dokumente"),
"detail" => ""];
$indicator['link'] = ["query" => "SELECT COUNT(*) FROM files WHERE filetype='URLFile'",
"title" => _("verlinkte Dateien"),
"detail" => ""];
$indicator['termin'] = ["count" => ['count_table_rows','termine'],
"title" => _("Termine"),
"detail" => ""];
$indicator['news'] = ["count" => ['count_table_rows','news'],
"title" => _("Ankündigungen"),
"detail" => ""];
$indicator['vote'] = ["count" => ['count_table_rows', 'questionnaires'],
"title" => _("Fragebögen"),
"detail" => "",
"constraint" => Config::get()->VOTE_ENABLE];
$indicator['evaluation'] = ["count" => ['count_table_rows','eval'],
"title" => _("Evaluationen"),
"detail" => "",
"constraint" => Config::get()->VOTE_ENABLE];
$indicator['wiki_pages'] = ["query" => "SELECT COUNT(DISTINCT keyword) AS count FROM wiki",
"title" => _("Wiki-Seiten"),
"detail" => "",
"constraint" => Config::get()->WIKI_ENABLE];
$indicator['resource'] = ["count" => ['count_table_rows','resources'],
"title" => _("Ressourcen-Objekte"),
"detail" => _("von Stud.IP verwaltete Ressourcen wie Räume oder Geräte"),
"constraint" => Config::get()->RESOURCES_ENABLE];
if ($key === 'posting') {
$count = 0;
// sum up number of postings for all availabe ForumModules
foreach (PluginEngine::getPlugins('ForumModule') as $plugin) {
$count += $plugin->getNumberOfPostings();
}
$template->title = _('Forenbeiträge');
$template->detail = _('Anzahl Beiträge aller verwendeten Foren');
$template->count = $count;
} else {
// iterate over the other indicators
if (in_array($key,array_keys($indicator))) {
if (!isset($indicator[$key]['constraint']) || $indicator[$key]['constraint']) {
if (isset($indicator[$key]['query'])) {
$result = $this->db->query($indicator[$key]['query']);
$rows = $result->fetch(PDO::FETCH_NUM);
$template->count = $rows[0];
} else {
$template->count = call_user_func($indicator[$key]['count'][0], $indicator[$key]['count'][1]);
}
$template->title = $indicator[$key]['title'];
if ($indicator[$key]['detail']) {
$template->detail = $indicator[$key]['detail'];
}
} else {
return '';
}
} else {
return '';
}
}
$ret = $template->render();
$cache->write(__METHOD__ . $key, $ret);
return $ret;
}
function history() {
return formatReady(file_get_contents($GLOBALS['ABSOLUTE_PATH_STUDIP'] . 'history.txt'));
}
function termsOfUse() {
return @file_get_contents($GLOBALS['STUDIP_BASE_PATH'] . '/locale/' . ($GLOBALS['_language_path'] ?? 'de') . '/LC_HELP/pages/nutzung.html');
}
function style($style, $styled) {
$style = str_replace('\"', '"', $style);
$styled = str_replace('\"', '"', $styled);
return '<div style="'.$style.'">'.$styled.'</div>';
}
public function reportBarrierLink(): string
{
return sprintf(
'<a href="%s">' . _('Barriere melden') . '</a>',
URLHelper::getLink(
'dispatch.php/accessibility/forms/report_barrier',
['page' => Request::url(), 'cancel_login' => '1'],
true
)
);
}
}
//functions for language filtering; used both in page-content and detail- and rubric-names
function language_filter($input) {
return preg_replace_callback("'\[lang=(\w*)\]\s*(.*?)\s*\[/lang\]'s",
function ($m) {return stripforeignlanguage($m[1], $m[2]);},
$input);
}
function stripforeignlanguage($language, $text) {
list($primary, $sub) = explode('_',$_SESSION['_language']);
if ($language === $primary || $language === $_SESSION['_language']) {
return str_replace('\"', '"', $text);
} else {
return '';
}
}
|