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
|
<?
# Lifter002: TODO
# Lifter003: TEST
# Lifter007: TODO
# Lifter010: TODO
/*
archiv.inc.php - Funktionen zur Archivierung in Stud.IP
Copyright (C) 2000 Cornelis Kater <ckater@gwdg.de>, Ralf Stockmann <rstockm@gwdg.de>, Stefan Suchi <suchi@gmx.de>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* This function returns the last activity in the course.
*
* @param string $sem_id the id of the course
* @return int timestamp of last activity (max chdate)
*/
function lastActivity ($sem_id)
{
// Cache query generation
static $query = null;
if ($query === null) {
$queries = [
// Veranstaltungs-data
"SELECT chdate FROM seminare WHERE Seminar_id = :id",
// Folders
"SELECT MAX(chdate) AS chdate FROM folders WHERE range_id = :id",
// Documents
"SELECT MAX(file_refs.chdate) AS chdate FROM file_refs
INNER JOIN folders
ON file_refs.folder_id = folders.id
WHERE folders.range_id = :id",
// SCM
"SELECT MAX(chdate) AS chdate FROM scm WHERE range_id = :id",
// Dates
"SELECT MAX(chdate) AS chdate FROM termine WHERE range_id = :id",
// News
"SELECT MAX(`date`) AS chdate FROM news_range LEFT JOIN news USING (news_id) WHERE range_id = :id",
];
// Votes
if (Config::get()->VOTE_ENABLE) {
$queries[] = "SELECT MAX(questionnaires.chdate) AS chdate FROM questionnaires INNER JOIN questionnaire_assignments ON (questionnaire_assignments.questionnaire_id = questionnaires.questionnaire_id) WHERE questionnaire_assignments.range_id = :id";
}
// Wiki
if (Config::get()->WIKI_ENABLE) {
$queries[] = "SELECT MAX(`chdate`) AS chdate
FROM `wiki_pages`
WHERE `range_id` = :id";
}
// Forum
$queries[] = 'SELECT MAX(`chdate`) AS chdate FROM `forum_postings` WHERE `range_id` = :id';
$query = "SELECT MAX(chdate) FROM (" . implode(' UNION ', $queries) . ") AS tmp";
}
$statement = DBManager::get()->prepare($query);
$statement->bindValue(':id', $sem_id);
$statement->execute();
$timestamp = $statement->fetchColumn() ?: 0;
//correct the timestamp, if date in the future (news can be in the future!)
if ($timestamp > time()) {
$timestamp = time();
}
return $timestamp;
}
|