590 lines
26 KiB
PHP
590 lines
26 KiB
PHP
<?php
|
|
|
|
/*
|
|
PAGE CLASS
|
|
url alapjan lekeri a template-et
|
|
http://cegledcoach.hu/PAGE/SUBPAGE/ID
|
|
|
|
*/
|
|
|
|
class page
|
|
{
|
|
private $page = null;
|
|
private $subpage = null;
|
|
private $id = null;
|
|
|
|
public function __construct()
|
|
{
|
|
if (isset($_GET['page'])) {
|
|
$this->set_page($_GET['page']);
|
|
}
|
|
if (isset($_GET['subpage'])) {
|
|
$this->set_subpage($_GET['subpage']);
|
|
}
|
|
if (isset($_GET['id'])) {
|
|
$this->set_id($_GET['id']);
|
|
}
|
|
}
|
|
|
|
public function get_page_nav()
|
|
{
|
|
global $smarty, $sql, $user;
|
|
//nem kell if, hanem page alapján beillesztük az id-t
|
|
if ('admin' == $this->get_page()) {
|
|
if ($user) {
|
|
$menus_query = '
|
|
SELECT
|
|
*
|
|
FROM
|
|
subpage
|
|
LEFT JOIN
|
|
authority ON a_name = spage_url
|
|
JOIN
|
|
user_authority ON (ua_authority_a_id = a_id
|
|
OR ua_authority_a_id = 1)
|
|
WHERE
|
|
spage_page_id = 1
|
|
AND ua_user_kid_uk_id = '.$user->get_ua_id().' ORDER BY spage_id ASC;
|
|
';
|
|
} else {
|
|
$menus_query = 'SELECT * FROM subpage WHERE spage_page_id = 1;';
|
|
}
|
|
$menu_assoc_array = $sql->assoc_array($menus_query);
|
|
$smarty->assign('menus', $menu_assoc_array);
|
|
} elseif ('view' == $this->get_page() || 'preview' == $this->get_page()) {
|
|
$menus_query = 'SELECT * FROM subpage WHERE spage_page_id = 2;';
|
|
$menu_assoc_array = $sql->assoc_array($menus_query);
|
|
$smarty->assign('menus', $menu_assoc_array);
|
|
} elseif ('coach' == $this->get_page() || 'coach_preview' == $this->get_page()) {
|
|
$menus_query = 'SELECT * FROM subpage WHERE spage_page_id = 3;';
|
|
$menu_assoc_array = $sql->assoc_array($menus_query);
|
|
$smarty->assign('menus', $menu_assoc_array);
|
|
} elseif ('tabor' == $this->get_page()) {
|
|
$menus_query = 'SELECT * FROM subpage WHERE spage_page_id = 4;';
|
|
$menu_assoc_array = $sql->assoc_array($menus_query);
|
|
$smarty->assign('menus', $menu_assoc_array);
|
|
} elseif ('taborvezeto' == $this->get_page()) {
|
|
$menus_query = 'SELECT * FROM subpage WHERE spage_page_id = 5;';
|
|
$menu_assoc_array = $sql->assoc_array($menus_query);
|
|
$smarty->assign('menus', $menu_assoc_array);
|
|
}
|
|
|
|
$smarty->assign('page', $this->get_page());
|
|
$smarty->display('nav.tpl');
|
|
}
|
|
|
|
public function findInStructure($id, &$array)
|
|
{
|
|
if (array_key_exists($id, $array)) {
|
|
return $id;
|
|
}
|
|
|
|
foreach ($array as $key => $submenu) {
|
|
if (in_array($id, $submenu)) {
|
|
return $key;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function get_page_content()
|
|
{
|
|
global $sql, $user, $smarty, $structure;
|
|
//var_dump($user);
|
|
ini_set('include_path', '_include/');
|
|
//ini_set('include_path', '/var/www/badminton_coach/_include');
|
|
$exceptions = ['export_balance', 'send_report', 'money_update'];
|
|
if ((!empty($user) && $user->is_logged_in()) || in_array($this->get_subpage(), $exceptions)) {
|
|
if ($this->is_page()) {
|
|
//TODO: mi van ha nincs page? átirányítás v 404?
|
|
//page alapján betölti a tpl-t
|
|
|
|
if ($this->is_subpage() && 'admin' == $this->get_page()) {
|
|
if ('create' == $this->get_subpage()) {
|
|
$toFind = $this->get_id();
|
|
} elseif (false !== strpos($this->get_subpage(), 'delete')) {
|
|
//delete_ utáni rész
|
|
$toFind = substr($this->get_subpage(), 7);
|
|
} else {
|
|
$toFind = $this->get_subpage();
|
|
}
|
|
$subPage = $this->findInStructure($toFind, $structure);
|
|
if ((!empty($user) && $user->is_logged_in()) && 'exception' != $subPage && !$user->has_authority_by_name($subPage)) {
|
|
include 'include_access_denied.php';
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
switch ($this->get_page()) {
|
|
case 'admin':
|
|
// ADMIN OLDALAK
|
|
switch ($this->get_subpage()) {
|
|
case 'members':
|
|
// TAGOK KEZELÉSE
|
|
$tpl = 'edit';
|
|
include 'include_members.php';
|
|
break;
|
|
case 'edit_member':
|
|
// TAG SZERKESZTÉSE
|
|
$tpl = 'edit';
|
|
include 'include_members.php';
|
|
break;
|
|
case 'delete_member':
|
|
// TAG TÖRLÉSE
|
|
// TODO: error kezelés
|
|
include 'include_delete_member.php';
|
|
break;
|
|
case 'delete_parent':
|
|
// SZÜLŐ TÖRLÉSE
|
|
// TODO: error kezelés
|
|
include 'include_delete_parent.php';
|
|
break;
|
|
case 'parents':
|
|
// SZÜLŐK SZERKESZTÉSE
|
|
include 'include_parents.php';
|
|
break;
|
|
case 'coaches':
|
|
// EDZŐK SZERKESZTÉSE
|
|
include 'include_coaches.php';
|
|
break;
|
|
case 'trainings':
|
|
// EDZÉSEK
|
|
// itt az edzések listája jelenik meg az aktuális hónapban
|
|
$tpl = 'edit';
|
|
include 'include_trainings.php';
|
|
break;
|
|
case 'training_templates':
|
|
// EDZÉS SABLONOK
|
|
include 'include_training_templates.php';
|
|
break;
|
|
case 'delete_training_template':
|
|
// EDZÉS SABLON TÖRLÉS
|
|
include 'include_delete_training_template.php';
|
|
break;
|
|
case 'shirts':
|
|
// PÓLÓK
|
|
include 'include_shirts.php';
|
|
break;
|
|
case 'cities':
|
|
// PÓLÓK
|
|
include 'include_cities.php';
|
|
break;
|
|
case 'edit_training':
|
|
// TAG SZERKESZTÉSE
|
|
$tpl = 'edit';
|
|
include 'include_trainings.php';
|
|
break;
|
|
case 'delete_training':
|
|
// EDZÉS TÖRLÉS
|
|
include 'include_delete_training.php';
|
|
break;
|
|
case 'create':
|
|
// LÉTREHOZÓS OLDALAK
|
|
include 'include_create.php';
|
|
break;
|
|
case 'presence':
|
|
// JELENLÉT
|
|
$tpl = 'presence';
|
|
include 'include_presence.php';
|
|
break;
|
|
case 'schools':
|
|
// ISKOLÁK
|
|
include 'include_schools.php';
|
|
break;
|
|
case 'training_types':
|
|
// EDZÉS TÍPUSOK
|
|
include 'include_training_types.php';
|
|
break;
|
|
case 'regions':
|
|
// DIÁKOLIMPIA KÖRZETEK
|
|
include 'include_regions.php';
|
|
break;
|
|
case 'log':
|
|
// NAPLÓ
|
|
include 'include_log.php';
|
|
break;
|
|
case 'money_deposit':
|
|
// BEFIZETÉSEK
|
|
include 'include_money_deposit.php';
|
|
break;
|
|
case 'lease':
|
|
// BÉRLETTÍPUSOK
|
|
include 'include_lease.php';
|
|
break;
|
|
case 'lock_training':
|
|
// EDZÉS ZÁROLÁS, FELOLDÁS
|
|
include 'include_lock_training.php';
|
|
break;
|
|
case 'view_deposit':
|
|
// BEFIZETÉSEK / USER
|
|
include 'include_view_deposit.php';
|
|
break;
|
|
case 'money_expense':
|
|
// KIADÁSOK
|
|
include 'include_money_expense.php';
|
|
break;
|
|
case 'money_expense_category':
|
|
// KIADÁS KATEGÓRIÁK
|
|
include 'include_money_expense_category.php';
|
|
break;
|
|
case 'money_income_category':
|
|
// BEVÉTEL KATEGÓRIÁK
|
|
include 'include_money_income_category.php';
|
|
break;
|
|
case 'money_income':
|
|
// BEVÉTELEK
|
|
include 'include_money_income.php';
|
|
break;
|
|
case 'money_update':
|
|
// FRISSÍTÉS
|
|
include 'include_money_update.php';
|
|
// no break
|
|
case 'settings':
|
|
// BEÁLLÍTÁSOK
|
|
include 'include_settings.php';
|
|
break;
|
|
case 'balance_list':
|
|
// BEÁLLÍTÁSOK
|
|
include 'include_balance_list.php';
|
|
break;
|
|
case 'stats':
|
|
// STATISZTIKÁK
|
|
include 'include_stats.php';
|
|
break;
|
|
case 'news':
|
|
// INFORMÁCIÓS FAL
|
|
include 'include_information.php';
|
|
break;
|
|
case 'expire_check':
|
|
// CRON FUTTATÁSA
|
|
include 'include_expire_check.php';
|
|
break;
|
|
case 'userlist':
|
|
// GYEREK ADATLISTA
|
|
include 'include_userlist.php';
|
|
break;
|
|
case 'export_users':
|
|
// GYEREKLISTA EXPORTÁLÁSA
|
|
include 'include_export_users.php';
|
|
break;
|
|
case 'traininglist':
|
|
// EDZÉS ADATLISTA
|
|
include 'include_traininglist.php';
|
|
break;
|
|
case 'export_trainings':
|
|
// EDZÉSLISTA EXPORTÁLÁSA
|
|
include 'include_export_trainings.php';
|
|
break;
|
|
case 'export_balance':
|
|
// EGYENLEG LISTA EXPORTÁLÁSA
|
|
include 'include_export_balance.php';
|
|
break;
|
|
case 'download_report':
|
|
// EGYENLEG LISTA LETÖLTÉSE
|
|
include 'include_download_report.php';
|
|
break;
|
|
case 'send_report':
|
|
// EGYENLEG LISTA KÜLDÉSE
|
|
include 'include_send_report.php';
|
|
break;
|
|
case 'set_credit_to_zero':
|
|
// HITELALKALOM NULLÁZÁS
|
|
include 'include_set_credit_to_zero.php';
|
|
break;
|
|
case 'delete_training_type':
|
|
// EDZÉS TÍPUS TÖRLÉS
|
|
include 'include_delete_training_type.php';
|
|
break;
|
|
case 'delete_coach':
|
|
// EDZŐ TÖRLÉS
|
|
include 'include_delete_coach.php';
|
|
break;
|
|
case 'delete_shirt':
|
|
// PÓLÓ TÖRLÉS
|
|
include 'include_delete_shirt.php';
|
|
break;
|
|
case 'delete_city':
|
|
// VÁROS TÖRLÉS
|
|
include 'include_delete_city.php';
|
|
break;
|
|
case 'delete_region':
|
|
// KÖRZET TÖRLÉS
|
|
include 'include_delete_region.php';
|
|
break;
|
|
case 'delete_school':
|
|
// ISKOLA TÖRLÉS
|
|
include 'include_delete_school.php';
|
|
break;
|
|
case 'delete_money_deposit':
|
|
// BEFIZETÉS TÖRLÉS
|
|
include 'include_delete_money_deposit.php';
|
|
break;
|
|
case 'delete_money_expense_category':
|
|
// BEFIZETÉS KATEGÓRIA TÖRLÉS
|
|
include 'include_delete_money_expense_category.php';
|
|
break;
|
|
case 'delete_money_expense':
|
|
// BEFIZETÉS TÖRLÉS
|
|
include 'include_delete_money_expense.php';
|
|
break;
|
|
case 'delete_money_income_category':
|
|
// BEVÉTEL KATEGÓRIA TÖRLÉS
|
|
include 'include_delete_money_income_category.php';
|
|
break;
|
|
case 'delete_money_income':
|
|
// BEVÉTEL TÖRLÉS
|
|
include 'include_delete_money_income.php';
|
|
break;
|
|
case 'delete_news':
|
|
// HÍR TÖRLÉS
|
|
include 'include_delete_news.php';
|
|
break;
|
|
case 'delete_lease':
|
|
// BÉRLETTÍPUS TÖRLÉS
|
|
include 'include_delete_lease.php';
|
|
break;
|
|
case 'logout':
|
|
// kijelentkezés
|
|
$from = 'admin';
|
|
include 'include_logout.php';
|
|
break;
|
|
case 'camps':
|
|
// TÁBOROK
|
|
include 'include_camps.php';
|
|
break;
|
|
case 'camp_types':
|
|
// TÁBOR TÍPUSOK
|
|
include 'include_camp_types.php';
|
|
break;
|
|
case 'camp_shirt_type':
|
|
// TÁBOR PÓLÓ TÍPUSOK
|
|
include 'include_camp_shirt_types.php';
|
|
break;
|
|
case 'accept_apply':
|
|
// TÁBOR JELENTKEZÉS ELFOGADÁSA
|
|
include 'include_accept_apply.php';
|
|
break;
|
|
case 'deny_apply':
|
|
// TÁBOR JELENTKEZÉS ELUTASÍTÁSA
|
|
include 'include_deny_apply.php';
|
|
break;
|
|
case 'remove_apply':
|
|
// TÁBOR JELENTKEZÉS ELTÁVOLÍTÁSA A LISTÁBÓL
|
|
include 'include_remove_apply.php';
|
|
break;
|
|
case 'apply':
|
|
// TÁBORI JELENTKEZŐ ADATAINAK MEGTEKINTÉSE
|
|
include 'include_apply.php';
|
|
break;
|
|
case 'camp_user':
|
|
// táborvezetők
|
|
include 'include_user_camp_leader.php';
|
|
break;
|
|
case 'camp_details':
|
|
// turnusok
|
|
include 'include_camp_details.php';
|
|
break;
|
|
case 'camp_fee':
|
|
// tábordíj befizetés
|
|
include 'include_camp_fee.php';
|
|
break;
|
|
case 'delete_camp_type':
|
|
// TÁBOR TÍPUS TÖRLÉS
|
|
include 'include_delete_camp_type.php';
|
|
break;
|
|
case 'delete_camp':
|
|
// TÁBOR TÖRLÉS
|
|
include 'include_delete_camp.php';
|
|
break;
|
|
case 'delete_camp_shirt':
|
|
// TÁBORI PÓLÓ TÖRLÉS
|
|
include 'include_delete_camp_shirt.php';
|
|
break;
|
|
case 'delete_camp_leader':
|
|
// TÁBORVEZETŐ TÖRLÉS
|
|
include 'include_delete_camp_leader.php';
|
|
break;
|
|
default:
|
|
// code...
|
|
break;
|
|
}
|
|
break;
|
|
case 'ajax':
|
|
if ($this->is_subpage()) {
|
|
include 'ajax/'.$this->get_subpage();
|
|
}
|
|
break;
|
|
case 'view':
|
|
// SZÜLŐ FELÜLET
|
|
switch ($this->get_subpage()) {
|
|
case 'logout':
|
|
// kijelentkezés
|
|
$from = 'view';
|
|
include 'include_logout.php';
|
|
break;
|
|
case 'overview':
|
|
// áttekintő oldal adatokkal
|
|
include 'include_overview.php';
|
|
break;
|
|
case 'diary':
|
|
// napló, edzéslista
|
|
include 'include_diary.php';
|
|
break;
|
|
case 'information':
|
|
// információk
|
|
include 'include_information_wall.php';
|
|
break;
|
|
default:
|
|
include 'include_diary.php';
|
|
break;
|
|
}
|
|
break;
|
|
case 'preview':
|
|
// SZÜLŐI OLDAL ELŐNÉZET
|
|
switch ($this->get_subpage()) {
|
|
case 'overview':
|
|
// áttekintő oldal adatokkal
|
|
include 'include_overview.php';
|
|
break;
|
|
case 'diary':
|
|
// napló, edzéslista
|
|
include 'include_diary.php';
|
|
break;
|
|
case 'information':
|
|
// információk
|
|
include 'include_information_wall.php';
|
|
break;
|
|
default:
|
|
include 'include_diary.php';
|
|
break;
|
|
}
|
|
break;
|
|
case 'coach':
|
|
// EDZŐI NÉZET
|
|
switch ($this->get_subpage()) {
|
|
case 'diary':
|
|
// napló, edzéslista
|
|
include 'include_coach_diary.php';
|
|
break;
|
|
case 'logout':
|
|
// kijelentkezés
|
|
$from = 'coach';
|
|
include 'include_logout.php';
|
|
break;
|
|
default:
|
|
include 'include_coach_diary.php';
|
|
break;
|
|
}
|
|
break;
|
|
case 'coach_preview':
|
|
// EDZŐI ELŐNÉZET
|
|
switch ($this->get_subpage()) {
|
|
case 'diary':
|
|
// napló, edzéslista
|
|
include 'include_coach_diary.php';
|
|
break;
|
|
default:
|
|
include 'include_coach_diary.php';
|
|
break;
|
|
}
|
|
break;
|
|
case 'tabor':
|
|
// TÁBOR OLDALAK
|
|
switch ($this->get_subpage()) {
|
|
case 'informaciok':
|
|
// tábori információk
|
|
include 'include_camp_information.php';
|
|
break;
|
|
case 'jelentkezes':
|
|
// jelentkezés
|
|
include 'include_camp_apply.php';
|
|
break;
|
|
case 'jelentkezesek':
|
|
// jelentkezések
|
|
include 'include_camp_applies.php';
|
|
break;
|
|
case 'move_next':
|
|
// továbblépés mentés nélkül
|
|
include 'include_move_next.php';
|
|
break;
|
|
case 'logout':
|
|
// kijelentkezés
|
|
$from = 'tabor';
|
|
include 'include_logout.php';
|
|
break;
|
|
case 'delete_apply':
|
|
// jelentkezés törlése
|
|
include 'include_delete_apply.php';
|
|
break;
|
|
default:
|
|
include 'include_camp_information.php';
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
//nincs bejelentkezve
|
|
$smarty->assign('page', $this->get_page());
|
|
if ('tabor' == $this->get_page() && $this->is_subpage() && 'regisztracio' == $this->get_subpage()) {
|
|
if (isset($_COOKIE['bc_reg_error'])) {
|
|
$smarty->assign('error_code', $_COOKIE['bc_reg_error']);
|
|
setcookie('bc_reg_error', null, time() - 60 * 60 * 3, '/');
|
|
}
|
|
$smarty->display('register.tpl');
|
|
} else {
|
|
if (isset($_COOKIE['bc_reg_error'])) {
|
|
$smarty->assign('error_code', $_COOKIE['bc_reg_error']);
|
|
setcookie('bc_reg_error', null, time() - 60 * 60 * 2, '/');
|
|
}
|
|
$smarty->display('login.tpl');
|
|
}
|
|
}
|
|
}
|
|
|
|
private function set_page($_page)
|
|
{
|
|
$this->page = $_page;
|
|
}
|
|
|
|
private function set_subpage($_subpage)
|
|
{
|
|
$this->subpage = $_subpage;
|
|
}
|
|
|
|
private function set_id($_id)
|
|
{
|
|
$this->id = $_id;
|
|
}
|
|
|
|
public function get_page()
|
|
{
|
|
return $this->page;
|
|
}
|
|
|
|
public function get_subpage()
|
|
{
|
|
return $this->subpage;
|
|
}
|
|
|
|
public function get_id()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function is_page()
|
|
{
|
|
return !empty($this->page);
|
|
}
|
|
|
|
public function is_subpage()
|
|
{
|
|
return !empty($this->subpage);
|
|
}
|
|
|
|
public function is_id()
|
|
{
|
|
return !empty($this->id);
|
|
}
|
|
}
|