]> git.somenet.org - fsinf/pub/w2c.git/blob - funcs.php
gruppenfotoerlaubnis feld geadded
[fsinf/pub/w2c.git] / funcs.php
1 <?php define('FUNCS_PATH', __DIR__);
2 /**
3 * welcome.TU.code Anmeldesystem.
4 * by Jan Vales <jan@jvales.net> (aka. Someone <someone@somenet.org>)
5 */
6
7 require_once(FUNCS_PATH.'/settings.php');
8 require_once(FUNCS_PATH.'/db_funcs.php');
9 require_once(FUNCS_PATH.'/html_funcs.php');
10
11 function login(){
12   if(!isset($_SERVER['HTTPS'])){
13     $url = 'https://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
14     header('Location: '.$url, true, 301);
15     exit('<h1>Redirecting to: <a href="'.$url.'">'.$url.'</a></h1>');
16   }
17   $uinfo = db_get_uinfo($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
18   if($uinfo['lvl'] >= 1){
19     $GLOBALS['uname'] = $uinfo['uname'];
20     $GLOBALS['lvl'] = $uinfo['lvl'];
21   }else{
22     header('WWW-Authenticate: Basic realm="WelcomeTUcode login"');
23     header('HTTP/1.0 401 Unauthorized');
24     exit(html_top("Anmeldesystem").html_linkbox().'<span class="statusERR">Nicht eingeloggt. Falsche Anmeldedaten?</span>'.html_bottom());
25   }
26 }
27
28 function list_anmeldungen(){
29   $liste = db_list_anmeldungen();
30   $ret = '<table id="sortable"><thead><tr><th>Aktion</th><th>id</th><th>Anmeldung bei</th><th>Nachname(n)</th><th>Vorname(n)</th><th>Geboren</th>'.
31     '<th>Nationalität</th><th>Sprachkenntnis</th><th>Vorwissen</th><th>Analphabet</th><th>Gruppen-</th><th>Foto-</th><th>Videoerlaubnis</th>'.
32         '<th>Status</th><th>Bemerkung</th><th>Termin</th></tr></thead><tbody>'."\n";
33   foreach ($liste as &$person) {
34     $ret .='<tr id="pers_'.$person['id'].'"><td><a href="./person.php?id='.$person['id'].'">Bearbeiten</a></td><td>'.$person['id'].'</td>';
35         $ret .='<td>'.$person['uname'].'</td><td>'.$person['nname'].'</td><td>'.$person['vname'].'</td><td><nobr>'.$person['gebdatum'].'</nobr></td>';
36         $ret .='<td>'.$person['nationaliaet'].'</td><td>'.$person['sprachen'].'</td><td>'.$person['vorwissen'].'</td><td>'.$person['analphabet'].'</td>';
37         $ret .='<td>'.$person['gruppenfotoerlaubnis'].'</td><td>'.$person['fotoerlaubnis'].'</td><td>'.$person['videoerlaubnis'].'</td>';
38     $ret .='<td>'.$person['status'].'</td><td>'.$person['bemerkungen'].'</td><td>'.$person['termin'].'</td></tr>'."\n";
39   }
40   return $ret.'</tbody></table>'."\n";
41 }
42
43 function store_person(){
44   if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save']))return;
45
46 //var_export($_REQUEST);
47
48   if(isset($_REQUEST['delete']))return db_delete_person($_REQUEST['id']);
49   if(isset($_REQUEST['save'])){
50
51     if(!isset($_REQUEST['vname']))throw new Exception('NOT_SET vname');
52     $pdata['vname']=$_REQUEST['vname'];
53
54     if(!isset($_REQUEST['nname']))throw new Exception('NOT_SET nname');
55     $pdata['nname']=$_REQUEST['nname'];
56
57     if($pdata['vname'] == '' && $pdata['nname'] == '')throw new Exception('NO_NAME');
58
59     if(!isset($_REQUEST['gebdatum']))throw new Exception('NOT_SET gebdatum');
60     $pdata['gebdatum']=$_REQUEST['gebdatum'];
61         
62     if(!isset($_REQUEST['nationaliaet']))throw new Exception('NOT_SET nationalitaet');
63     $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
64
65     if(!isset($_REQUEST['sprachen']))throw new Exception('NOT_SET sprachen');
66     $pdata['sprachen']=$_REQUEST['sprachen'];
67
68     if(!isset($_REQUEST['vorwissen']))throw new Exception('NOT_SET vorwissen');
69     $pdata['vorwissen']=$_REQUEST['vorwissen'];
70         
71     if(!isset($_REQUEST['analphabet']))$_REQUEST['analphabet'] = '0';
72     $pdata['analphabet']=$_REQUEST['analphabet'];
73
74     if(!isset($_REQUEST['fotoerlaubnis']))$_REQUEST['fotoerlaubnis'] = '0';
75     $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
76
77     if(!isset($_REQUEST['gruppenfotoerlaubnis']))$_REQUEST['gruppenfotoerlaubnis'] = '0';
78     $pdata['gruppenfotoerlaubnis']=$_REQUEST['gruppenfotoerlaubnis'];
79
80     if(!isset($_REQUEST['videoerlaubnis']))$_REQUEST['videoerlaubnis'] = '0';
81     $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
82
83     if(!isset($_REQUEST['bemerkungen']))throw new Exception('NOT_SET bemerkungen');
84     $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
85
86     if(!isset($_REQUEST['termin']))throw new Exception('NOT_SET termin');
87     $pdata['termin']=$_REQUEST['termin'];
88
89     if(!isset($_REQUEST['status']))throw new Exception('NOT_SET status');
90     $pdata['status']=$_REQUEST['status'];
91
92     return db_store_person($_REQUEST['id'], $pdata);
93   }
94 }
95
96 function get_person($id){
97   if(!is_numeric($id)) return NULL;
98   return db_get_person($id);
99 }
100