This repository has been archived by the owner on Apr 5, 2019. It is now read-only.
forked from basisentscheid/basisentscheid
/
areas.php
103 lines (88 loc) · 1.99 KB
/
areas.php
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
<?
/**
*
* @author Magnus Rosenbaum <dev@cmr.cx>
* @package Basisentscheid
*/
require "inc/common_http.php";
$ngroup = Ngroup::get();
if ($action) {
Login::access_action("member");
action_required_parameters('area');
$area = new Area($_POST['area']);
if (!$area->id) {
warning("The requested area does not exist!");
redirect();
}
switch ($action) {
case "subscribe":
$area->activate_participation();
redirect();
break;
case "unsubscribe":
$area->deactivate_participation();
redirect();
break;
}
warning(_("Unknown action"));
redirect();
}
html_head(_("Subject areas"), true);
$entitled = ( Login::$member and Login::$member->entitled($ngroup->id) );
?>
<table>
<tr>
<th><?=_("Name")?></th>
<th><?=_("Participants")?></th>
<? if ($entitled) { ?>
<th><?=_("Participation")?></th>
<? } ?>
</tr>
<?
if ($entitled) {
$sql = "SELECT area.*, participant.activated
FROM area
LEFT JOIN participant ON area.id = participant.area AND participant.member=".intval(Login::$member->id);
} else {
$sql = "SELECT area.*
FROM area";
}
$sql .= " WHERE ngroup = ".intval($ngroup->id)." ORDER BY area.name, area.id";
$result = DB::query($sql);
while ($row = DB::fetch_assoc($result)) {
?>
<tr class="<?=stripes()?>">
<td><?=$row['name']?></td>
<td class="center"><?=$row['participants']?></td>
<? if ($entitled) { ?>
<td>
<?
if ($row['activated']) {
?>
✓ <?=_("last time activated")?>: <?=dateformat($row['activated'])?>
<?
form(URI::same(), 'class="button"');
?>
<input type="hidden" name="area" value="<?=$row['id']?>">
<input type="hidden" name="action" value="unsubscribe">
<input type="submit" value="<?=_("unsubscribe")?>">
<?
form_end();
}
form(URI::same(), 'class="button"');
?>
<input type="hidden" name="area" value="<?=$row['id']?>">
<input type="hidden" name="action" value="subscribe">
<input type="submit" value="<?=$row['activated']?_("subscribe anew"):_("subscribe")?>">
<?
form_end();
?>
</td>
<? } ?>
</tr>
<?
}
?>
</table>
<?
html_foot();