diff --git a/web/inc/core.php b/web/inc/core.php
index 980443a..e1167b0 100644
--- a/web/inc/core.php
+++ b/web/inc/core.php
@@ -86,10 +86,15 @@ function callHook($url)
} else
$dispatch = new $componentName($component, $action, true, $queryString);
- if (method_exists($componentName, $action)) {
+ if (method_exists($componentName, $action))
$response = call_user_func_array(array($dispatch, $action), $queryString);
- } else if (method_exists($componentName, 'catchAll'))
+ else if (method_exists($componentName, 'catchAll'))
$response = call_user_func_array(array($dispatch, 'catchAll'), array($params));
+ else
+ {
+ $dispatch = new Err('err', 'notfound', false);
+ $response = call_user_func_array(array($dispatch, 'notfound'), array($params));
+ }
if(is_string($response))
return $response;
diff --git a/web/models/Dog.model.php b/web/models/Dog.model.php
index 9b8b4b4..4790ff7 100644
--- a/web/models/Dog.model.php
+++ b/web/models/Dog.model.php
@@ -4,7 +4,6 @@ class Dog extends Model
{
protected $dbTable = "dogs";
protected $dbFields = array(
- 'uuid' => ['type' => 'text', 'required', 'unique', 'autoValMethod' => 'gen_ulid'],
'registered' => ['type' => 'datetime', 'required', 'unique', 'autoValMethod' => 'getDateTime'],
'name' => ['type' => 'text'],
'kennel_name' => ['type' => 'text'],
diff --git a/web/models/Tournament.model.php b/web/models/Tournament.model.php
new file mode 100644
index 0000000..6ca84d9
--- /dev/null
+++ b/web/models/Tournament.model.php
@@ -0,0 +1,17 @@
+ ['type' => 'datetime', 'required', 'unique', 'autoValMethod' => 'getDateTime'],
+ 'name' => ['type' => 'text', 'required'],
+ 'date' => ['type' => 'datetime','required'],
+ 'duration' => ['type' => 'int'], //in days
+ 'referee' => ['type' => 'text'],
+ 'text' => ['type' => 'text'],
+ 'url' => ['type' => 'text'], //if there is one
+ 'logo' => ['type' => 'text', 'default' => 'https://pictshare.net/prrnrk.jpg']
+ );
+
+}
diff --git a/web/models/User.model.php b/web/models/User.model.php
index 3bf6848..370aec0 100644
--- a/web/models/User.model.php
+++ b/web/models/User.model.php
@@ -3,7 +3,6 @@
class User extends Model {
protected $dbTable = "users";
protected $dbFields = Array (
- 'uuid' => ['type'=>'text','required','unique','autoValMethod'=>'gen_ulid'],
'password' => ['type'=>'text'],
'registered' => ['type'=>'datetime','required','unique','autoValMethod'=>'getDateTime'],
'email' => ['type'=>'email','unique'],
@@ -13,6 +12,7 @@ class User extends Model {
'token' => ['type'=>'text','required','unique','autoValMethod'=>'uuid4'],
'timezone' => ['type'=>'int'],
'dogs' => ['type'=> 'array','default'=>[]],
+ 'tournaments' => ['type'=> 'array','default'=>[]],
'active' => ['type'=>'int','default'=>0]
);
protected $hidden = ['password','token'];
diff --git a/web/pages/demo/demo.html b/web/pages/demo/demo.html
index 1ae12df..1adc7b7 100644
--- a/web/pages/demo/demo.html
+++ b/web/pages/demo/demo.html
@@ -4,4 +4,6 @@
= partial('info.html',['infoTitle'=>'Dies ist ein Info titel','infoMessage'=>'InfoNachricht ist so']); ?>
-= partial('notice.html',['noticeTitle'=>'Dies ist ein notice titel','noticeMessage'=>'noticeNachricht ist so']); ?>
\ No newline at end of file
+= partial('notice.html',['noticeTitle'=>'Dies ist ein notice titel','noticeMessage'=>'noticeNachricht ist so']); ?>
+
+= partial('../../pages/tournaments/edit.html',[]); ?>
\ No newline at end of file
diff --git a/web/pages/err/controller.php b/web/pages/err/controller.php
index 68ed3d7..b91fde0 100644
--- a/web/pages/err/controller.php
+++ b/web/pages/err/controller.php
@@ -2,10 +2,11 @@
class Err extends Page {
- function notfound($params)
+ function notfound($params=false)
{
$this->set("page",$params[0]);
$this->set('template', "notfound.html");
+
}
function notallowed()
diff --git a/web/pages/err/notfound.html b/web/pages/err/notfound.html
index 11468fd..93608cd 100644
--- a/web/pages/err/notfound.html
+++ b/web/pages/err/notfound.html
@@ -1,5 +1,5 @@
404 - Not found
-
I have no memory of = escape($page) ?>
+
I have no memory of = escape($page) ?>
\ No newline at end of file
diff --git a/web/pages/tournaments/controller.php b/web/pages/tournaments/controller.php
index 6cb268f..348a074 100644
--- a/web/pages/tournaments/controller.php
+++ b/web/pages/tournaments/controller.php
@@ -8,189 +8,30 @@ class Tournaments extends Page {
$this->menu_image = 'far fa-medal';
$this->menu_priority = 1;
}
+
+ function setSubmenu()
+ {
+ $this->addSubmenuItem('Übersicht','/tournaments','far fa-list-alt');
+ $this->addSubmenuItem('Turnier anlegen','/tournaments/add','fas fa-calendar-plus');
+ if($_SESSION['user']->data['dogs'] && count($_SESSION['user']->data['tournaments']) > 0)
+ {
+ $this->addSubmenuItem('divider');
+ foreach($_SESSION['user']->data['tournaments'] as $tid)
+ {
+ $t = new Tournament();
+ $t->load($tid);
+ $this->addSubmenuItem($t->data['name'],'/dogs/overview/'.$tid,'fas fa-dog');
+ }
+ }
+ }
+
+ function add()
+ {
+ $this->set('template','edit_tournament.html');
+ }
function index() {
- $dogs = $_SESSION['user']->data['dogs'];
- $doggos = [];
-
- foreach($dogs as $key => $dogid)
- {
- //var_dump($dogid);
- $dog = new Dog();
- try{
- $dog->load($dogid);
- }
- catch(Exception $e)
- {
- error_log("Dog $dogid not found. Deleting from user");
- unset($_SESSION['user']->data['dogs'][$key]);
- $_SESSION['user']->save();
- continue;
- }
- if($dog->data)
- $doggos[] = array_merge($dog->data,['id'=>$dogid]);
- }
-
- //var_dump($doggos);
-
- if(count($doggos) > 0)
- {
- $this->set('doggos',$doggos);
- $this->set('template', 'list.html');
- }
- else
- {
- $this->set('template','/templates/partials/info.html');
- $this->set('infoTitle', 'Keine Turniere gefunden');
- $this->set('infoMessage', 'Du hast aktuell noch kein Turnier angelegt. Klicke im Menü auf "Turnier hinzufügen" um einen Turnier anzulegen.');
- }
- }
-
- function add() {
- $this->set('template', 'edit.html');
- }
-
- function edit() {
- if($_REQUEST['submit'])
- {
- $id = $_REQUEST['dog_id'];
- $name = $_REQUEST['name'];
- $kennel_name = $_REQUEST['kennel_name'];
- $dog_breed = $_REQUEST['dog_breed'];
- $dog_size = $_REQUEST['dog_size'];
- $dog_birthday = $_REQUEST['dog_birthday'];
- $agi_height_category = $_REQUEST['agi_height_category'];
- $newphoto = false;
-
- if($_FILES['photo'])
- {
- $photo = $_FILES['photo'];
- $photo_name = $photo['name'];
- $photo_tmp_name = $photo['tmp_name'];
- $photo_size = $photo['size'];
- $photo_error = $photo['error'];
- $photo_type = $photo['type'];
-
- $allowed = ['jpg','jpeg','png'];
- $photo_ext = strtolower(end(explode('.', $photo_name)));
- $photo_name = $name.'.'.$photo_ext;
- $photo_path = 'uploads/'.$photo_name;
-
- if(in_array($photo_ext, $allowed))
- {
- if($photo_error === 0)
- {
- if($photo_size < 10000000)
- {
- $answer = pictshareUploadImage($photo_tmp_name);
- if($answer['status']=='ok' && in_array($answer['filetype'],['jpeg','png','gif']))
- $newphoto = $answer['url'];
- }
- else
- {
- return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Die Datei ist zu groß. Bitte eine kleinere Datei hochladen']);
- }
- }
- else
- {
- return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Beim Upload der Datei ist ein Fehler aufgetreten']);
- }
- }
- else
- {
- return partial('error.html', ['errorTitle' => 'Error', 'errorMessage' => 'Dieser Dateityp ist nicht erlaubt. Bitte nur jpg, jpeg oder png Dateien hochladen']);
- }
- }
-
- $error = false;
- if(!$name || !$dog_birthday )
- $error = 'Bitte zumindest Name und Geburtsdatum angeben';
- else if(!strtotime($dog_birthday))
- $error = 'Das Geburstdatum ist ungültig. Bitte die Eingabe prüfen';
-
- if($error){
- $this->set('errorMessage', $error);
- $this->set('template', '/templates/partials/error.html');
- return;
- }
- else
- {
- $dog = new Dog();
- if($id)
- $dog->load($id);
-
- $dog->name = $name;
- $dog->kennel_name = $kennel_name;
- $dog->breed = $dog_breed;
- $dog->size = $dog_size;
- $dog->birthday = $dog_birthday;
- $dog->agility_size = $agi_height_category;
- if($newphoto)
- $dog->photo = $newphoto;
-
- try
- {
- $dogid = $dog->save();
- }
- catch(Exception $e)
- {
- $this->set('template', '/templates/partials/error.html');
- $this->set('errorTitle', 'Error');
- $this->set('errorMessage', $e->getMessage());
- return;
- }
-
- //var_dump($_SESSION['user']->data['dogs']);
-
- if(!is_array($_SESSION['user']->data['dogs']) || !in_array($dogid, $_SESSION['user']->data['dogs'])) // new dog!
- {
- $_SESSION['user']->data['dogs'][] = $dogid;
- try
- {
- $_SESSION['user']->save();
- }
- catch(Exception $e)
- {
- $this->set('template', '/templates/partials/error.html');
- $this->set('errorTitle', 'Error');
- $this->set('errorMessage', $e->getMessage());
- return;
- }
- $this->redirect('/dogs');
- }
- else
- {
- $this->set('template', '/templates/partials/success.html');
- $this->set('successMessage', "Daten erfolgreich gespeichert");
- return;
- }
-
- }
- }
- else
- {
- //checken ob der den hund eh bearbeiten darf
- $id = $this->params[0];
- $dog = new Dog();
- $dog->load($id);
- $this->set('dogdata',$dog->data);
- $this->set('dogid',$dog->id);
- $this->set('template', 'edit.html');
- }
- }
-
- function overview()
- {
- $dogid = $this->params[0];
- $d = new Dog();
-
- if(!$d->isMyDog($dogid))
- return 'Not your dog :(';
- $d->load($dogid);
- $this->set('dogdata', $d->data);
- $this->set('dogid', $dogid);
- $this->set('template', 'dog.html');
}
function maySeeThisPage() {
diff --git a/web/pages/tournaments/edit_run.html b/web/pages/tournaments/edit_run.html
index dc60a21..3a1a9e8 100644
--- a/web/pages/tournaments/edit_run.html
+++ b/web/pages/tournaments/edit_run.html
@@ -8,8 +8,8 @@
Parcourtyp
- >Agility
- >Jumping
+ >Agility
+ >Jumping
@@ -57,10 +57,10 @@
Bewertung
- >V
- >SG
- >G
- >B
+ >V
+ >SG
+ >G
+ >B
diff --git a/web/pages/tournaments/edit.html b/web/pages/tournaments/edit_tournament.html
similarity index 92%
rename from web/pages/tournaments/edit.html
rename to web/pages/tournaments/edit_tournament.html
index 46a81eb..0dbb706 100644
--- a/web/pages/tournaments/edit.html
+++ b/web/pages/tournaments/edit_tournament.html
@@ -19,10 +19,4 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/web/templates/menu.html b/web/templates/menu.html
index 2206c64..d7739d9 100644
--- a/web/templates/menu.html
+++ b/web/templates/menu.html
@@ -16,6 +16,7 @@