blob: 2bc8557bc90292414123554b207b55e3570d0ee2 (
plain)
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
|
<?php
/**
* ConnectedAdmission.class.php
*
* Represents a rule for access only for members of connected courses.
*
* 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.
*
* @author Rasmus Fuhse <fuhse@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
class ConnectedcourseAdmission extends AdmissionRule
{
/**
* Standard constructor.
*
* @param String ruleId
*/
public function __construct($ruleId = '', $courseSetId = '')
{
parent::__construct($ruleId, $courseSetId);
$this->default_message = _('Die Anmeldung ist nur für Mitglieder der dazu gehörigen Lehrveranstaltung möglich.');
}
/**
* Gets some text that describes what this AdmissionRule (or respective
* subclass) does.
*/
public static function getDescription()
{
return _('Diese Art von Anmelderegel erlaubt die Anmeldung an bestimmte Studiengruppen. Nur wer in einer verknüpften Lehrveranstaltung eingetragen ist, darf sich auch in die Studiengruppe anmelden.');
}
/**
* Return this rule's name.
*/
public static function getName()
{
return _('Anmeldung nur über verknüpfte Lehrveranstaltung');
}
/**
* Internal helper function for loading rule definition from database.
*/
public function load()
{
}
/**
* Does the current rule allow the given user to register as participant
* in the given course? Never happens here as admission is completely
* locked.
*
* @param String userId
* @param String courseId
* @return Array Any errors that occurred on admission.
*/
public function ruleApplies($userId, $courseId)
{
$errors = [];
$statement = DBManager::get()->prepare("
SELECT 1
FROM `studygroup_courses`
INNER JOIN `seminar_user` ON (`seminar_user`.`Seminar_id` = `studygroup_courses`.`course_id`)
WHERE `studygroup_courses`.`studygroup_id` = :studygroup_id
AND `seminar_user`.`user_id` = :user_id
LIMIT 1
");
$statement->execute([
'user_id' => $userId,
'studygroup_id' => $courseId
]);
if (!$statement->fetch(PDO::FETCH_COLUMN)) {
$errors[] = $this->getMessage();
}
return $errors;
}
/**
* Helper function for storing data to DB.
*/
public function store()
{
}
/**
* A textual description of the current rule.
*
* @return String
*/
public function toString() {
$factory = new Flexi\Factory(dirname(__FILE__).'/templates/');
$tpl = $factory->open('info');
$tpl->set_attribute('rule', $this);
return $tpl->render();
}
}
|