Vorwissen und Gebtag date picker.
[fsinf/pub/w2c.git] / funcs.php
index ee6e456c20bd7c7a22235e6923e9282902604a16..b6a9ddcf39266b5b0878fbd7fa37f7c5bc6d92d2 100644 (file)
--- a/funcs.php
+++ b/funcs.php
@@ -10,11 +10,11 @@ require_once('./db_funcs.php');
 require_once('./html_funcs.php');
 
 function login(){
-//  if(!isset($_SERVER['HTTPS'])){
-//    $url = 'https://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
-//    header('Location: '.$url, true, 301);
-//    exit('<h1>Redirecting to: <a href="'.$url.'">'.$url.'</a></h1>');
-//  }
+  if(!isset($_SERVER['HTTPS'])){
+    $url = 'https://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'];
+    header('Location: '.$url, true, 301);
+    exit('<h1>Redirecting to: <a href="'.$url.'">'.$url.'</a></h1>');
+  }
   $uinfo = db_get_uinfo($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
   if($uinfo['lvl'] >= 1){
     $GLOBALS['uname'] = $uinfo['uname'];
@@ -28,9 +28,9 @@ function login(){
 
 function list_anmeldungen(){
   $liste = db_list_anmeldungen();
-  $ret = '<table border=1 class="sortable"><tr><th>Aktion</th><th>id</th><th>Anmeldung bei</th><th>Nachname(n)</th><th>Vorname(n)</th><th>Geboren</th>'.
-    '<th>Nationalität</th><th>Sprachkenntnis</th><th>Vorwissen</th><th>Analphabet</th><th>fotoerlaubnis</th><th>Videoerlaubnis</th>'.
-       '<th>Status</th><th>Bemerkung</th><th>Termin</th></tr>'."\n";
+  $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>'.
+    '<th>Nationalität</th><th>Sprachkenntnis</th><th>Vorwissen</th><th>Analphabet</th><th>Foto-</th><th>Videoerlaubnis</th>'.
+       '<th>Status</th><th>Bemerkung</th><th>Termin</th></tr></thead><tbody>'."\n";
   foreach ($liste as &$person) {
     $ret .='<tr id="pers_'.$person['id'].'"><td><a href="./person.php?id='.$person['id'].'">Bearbeiten</a></td><td>'.$person['id'].'</td>';
        $ret .='<td>'.$person['uname'].'</td><td>'.$person['nname'].'</td><td>'.$person['vname'].'</td><td><nobr>'.$person['gebdatum'].'</nobr></td>';
@@ -38,51 +38,53 @@ function list_anmeldungen(){
        $ret .='<td>'.$person['fotoerlaubnis'].'</td><td>'.$person['videoerlaubnis'].'</td><td>'.$person['status'].'</td><td>'.$person['bemerkungen'].'</td>';
        $ret .='<td>'.$person['termin'].'</td></tr>'."\n";
   }
-  return $ret.'</table>'."\n";
+  return $ret.'</tbody></table>'."\n";
 }
 
 function store_person(){
-  if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save'])) return 0;
+  if(!isset($_REQUEST['delete']) && !isset($_REQUEST['save']))return;
 
 //var_export($_REQUEST);
 
   if(isset($_REQUEST['delete']))return db_delete_person($_REQUEST['id']);
   if(isset($_REQUEST['save'])){
 
-    if(!isset($_REQUEST['vname']))return '-vname- not set!';
+    if(!isset($_REQUEST['vname']))throw new Exception('NOT_SET vname');
     $pdata['vname']=$_REQUEST['vname'];
 
-    if(!isset($_REQUEST['nname']))return '-nname- not set!';
+    if(!isset($_REQUEST['nname']))throw new Exception('NOT_SET nname');
     $pdata['nname']=$_REQUEST['nname'];
 
-    if(!isset($_REQUEST['gebdatum']))return '-gebdatum- not set!';
+    if($pdata['vname'] == '' && $pdata['nname'] == '')throw new Exception('NO_NAME');
+
+    if(!isset($_REQUEST['gebdatum']))throw new Exception('NOT_SET gebdatum');
     $pdata['gebdatum']=$_REQUEST['gebdatum'];
        
-    if(!isset($_REQUEST['nationaliaet']))return '-nationaliaet- not set!';
+    if(!isset($_REQUEST['nationaliaet']))throw new Exception('NOT_SET nationalitaet');
     $pdata['nationaliaet']=$_REQUEST['nationaliaet'];
 
-    if(!isset($_REQUEST['sprachen']))return '-sprachen- not set!';
+    if(!isset($_REQUEST['sprachen']))throw new Exception('NOT_SET sprachen');
     $pdata['sprachen']=$_REQUEST['sprachen'];
 
-    if(!isset($_REQUEST['vorwissen']))return '-vorwissen- not set!';
+    if(!isset($_REQUEST['vorwissen']))throw new Exception('NOT_SET vorwissen');
     $pdata['vorwissen']=$_REQUEST['vorwissen'];
        
-    if(!isset($_REQUEST['analphabet']))return '-analphabet- not set!';
+    if(!isset($_REQUEST['analphabet']))$_REQUEST['analphabet'] = '0';
     $pdata['analphabet']=$_REQUEST['analphabet'];
 
-    if(!isset($_REQUEST['fotoerlaubnis']))return '-fotoerlaubnis- not set!';
+    if(!isset($_REQUEST['fotoerlaubnis']))$_REQUEST['fotoerlaubnis'] = '0';
     $pdata['fotoerlaubnis']=$_REQUEST['fotoerlaubnis'];
 
-    if(!isset($_REQUEST['videoerlaubnis']))return '-videoerlaubnis- not set!';
+    if(!isset($_REQUEST['videoerlaubnis']))$_REQUEST['videoerlaubnis'] = '0';
     $pdata['videoerlaubnis']=$_REQUEST['videoerlaubnis'];
 
-    if(!isset($_REQUEST['bemerkungen']))return '-bemerkungen- not set!';
+    if(!isset($_REQUEST['bemerkungen']))throw new Exception('NOT_SET bemerkungen');
     $pdata['bemerkungen']=$_REQUEST['bemerkungen'];
 
-    if(!isset($_REQUEST['termin']))return '-termin- not set!';
+    if(!isset($_REQUEST['termin']))throw new Exception('NOT_SET termin');
     $pdata['termin']=$_REQUEST['termin'];
 
-    if(!isset($_REQUEST['status']))return '-status- not set!';
+    if(!isset($_REQUEST['status']))throw new Exception('NOT_SET status');
     $pdata['status']=$_REQUEST['status'];
 
     return db_store_person($_REQUEST['id'], $pdata);