3 class IndexController extends ControllerBase implements ControllerInterface
5 public function allowUnauthenticated()
10 public function getNavigation()
12 if (empty($_SESSION['userid']))
16 $list[] = ['url' => $this->app->getBaseURL(),
18 $list[] = ['url' => $this->app->getBaseURL() . 'index/settings',
19 'title' => 'Einstellungen'];
20 if ($this->app->isAdmin()) {
21 $list[] = ['url' => $this->app->getBaseURL() . 'tour/newmember',
22 'title' => 'Neuer Biker'];
23 $list[] = ['url' => $this->app->getBaseURL() . 'tour/new',
24 'title' => 'Neue Tour'];
26 $list[] = ['url' => $this->app->getBaseURL() . 'account/logout',
32 public function indexAction($request, $response)
34 $base = $this->app->getBaseURL();
36 SELECT tour.name, start_date,
37 tour_status.key = 'plan' AS plan,
38 tour_status.key = 'cancel' AS cancel,
39 '{$base}' || 'tour/' || tour.key || '/index' AS url
41 JOIN tour_member ON tour_id = tour.id
42 JOIN tour_status ON tour_status_id = tour_status.id
43 LEFT JOIN tour_date ON tour_date_id = tour_date.id
44 WHERE member_id = {$_SESSION['userid']}
45 ORDER BY year DESC, start_date DESC, plan DESC
47 $list = $this->db->fetchObjectList($sql);
49 $response->setData(Template::render('page/list', ['list' => $list]));
52 public function loginAction($request, $response)
54 $response->setData(Template::render('page/login',
56 'action' => $this->app->getBaseURL().'account/login'
60 public function settingsAction($request, $response)
62 $user = new Sys_User($_SESSION['userid']);
64 $form = new Form('settings');
65 $form->setTitle('Einstellungen');
66 $form->add(new FormElement('text', ['name' => 'email',
67 'title' => 'Mail-Adresse',
68 'help' => 'Nach Änderung muß das Passwort neu gesetzt werden',
69 'value' => $_SESSION['email']]));
70 $form->add(new FormElement('text', ['name' => 'mobile',
71 'title' => 'Mobiltelefon',
72 'help' => 'Nur sichtbar für Tour-Mitglieder',
73 'placeholder' => '0150-1234567',
74 'value' => $user->get('mobile')]));
75 $form->add(new FormElement('checkbox', ['name' => 'single_room',
76 'title' => 'Einzelzimmer gewünscht',
77 'help' => 'Normalerweise teilen wir uns zu zweit ein Doppelzimmer',
78 'checked' => $user->get('single_room')]));
80 $response->setData($form->toString());
83 public function ajaxSettings($request, $response, $data)
85 $ok = $this->db->update('sys_user',
86 ['email' => $data['email'],
87 'mobile' => $data['mobile'],
88 'single_room' => isset($data['single_room']) && $data['single_room'] == '1'],
89 'id='.$_SESSION['userid']);
92 return $response->setError('Fehler beim Speichern');
95 $_SESSION['email'] = $data['email'];