first commit
This commit is contained in:
71
_class/class_login.php
Normal file
71
_class/class_login.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
LOGIN CLASS
|
||||
belépés végrehajtása
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class login {
|
||||
|
||||
public function check_login($_user_name, $_user_password) {
|
||||
global $sql;
|
||||
//ez a függvény ellenőrzi le a bevitt adatok
|
||||
//vissszadja a user_id-t, ha helyesek az adatok
|
||||
//null ha nem
|
||||
$check_query =
|
||||
"
|
||||
SELECT ua_id FROM user_coach WHERE
|
||||
(ua_name = '" . $_user_name . "' AND
|
||||
ua_password = '" . md5($_user_password ) . "')";
|
||||
|
||||
if ($sql->num_of_rows($check_query)) return $sql->single_variable($check_query);
|
||||
|
||||
|
||||
$check_query =
|
||||
"
|
||||
SELECT uk_id FROM user_kid WHERE
|
||||
(uk_name = '" . $_user_name . "' AND
|
||||
uk_password = '" . md5($_user_password ) . "')";
|
||||
|
||||
if ($sql->num_of_rows($check_query)) return $sql->single_variable($check_query);
|
||||
|
||||
$check_query =
|
||||
"
|
||||
SELECT up_id FROM user_parent WHERE
|
||||
(up_name = '" . $_user_name . "' AND
|
||||
up_password = '" . md5($_user_password ) . "')";
|
||||
|
||||
if ($sql->num_of_rows($check_query)) return $sql->single_variable($check_query);
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function login_user($_user_id, $_user_type) {
|
||||
//beállítja a belépett user adatait cookieba (ha még nincs)
|
||||
global $sql;
|
||||
|
||||
if (!isset($_COOKIE['badminon_coach_user'])) {
|
||||
//user objektumot nem lehet cookie-ban tárolni, ezért user_id-t rakunk bele
|
||||
$user_login = new user();
|
||||
$user_login->set_user_data_by_id($_user_id);
|
||||
$user_login->update_login_time();
|
||||
setcookie('badminton_coach_user', $_user_id, time()+60*60*72, '/');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
141
_class/class_page.php
Normal file
141
_class/class_page.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
PAGE CLASS
|
||||
url alapjan lekeri a template-et
|
||||
http://badmintoncoach.hu/PAGE/SUBPAGE/ID
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class page {
|
||||
|
||||
private $page = null;
|
||||
private $subpage = null;
|
||||
private $id = null;
|
||||
|
||||
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;
|
||||
//itt majd el lehet ágaztatni, ha nem admin oldalon vagyunk stb, de egyenlőre nem kell
|
||||
$smarty->display('nav.tpl');
|
||||
}
|
||||
|
||||
public function get_page_content() {
|
||||
global $sql, $user, $smarty;
|
||||
//var_dump($user);
|
||||
ini_set('include_path', '/opt/lampp/htdocs/badminton_coach/_include');
|
||||
if (!empty($user) && $user->is_logged_in()) {
|
||||
if ($this->is_page()) {
|
||||
//TODO: mi van ha nincs page? átirányítás v 404?
|
||||
//page alapján betölti a tpl-t
|
||||
//die($_GET['page']);
|
||||
switch ($this->get_page()) {
|
||||
case 'admin':
|
||||
# ADMIN OLDALAK
|
||||
switch ($this->get_subpage()) {
|
||||
case 'members':
|
||||
# TAGOK KEZELÉSE
|
||||
$tpl = "view";
|
||||
include('include_members.php');
|
||||
break;
|
||||
|
||||
case 'edit_member':
|
||||
# TAG SZERKESZTÉSE
|
||||
$tpl = "edit";
|
||||
include('include_members.php');
|
||||
break;
|
||||
case 'trainings':
|
||||
# EDZÉSEK
|
||||
# itt az edzések listája jelenik meg az aktuális hónapban
|
||||
$tpl = "view";
|
||||
include('include_trainings.php');
|
||||
break;
|
||||
case 'edit_training':
|
||||
# TAG SZERKESZTÉSE
|
||||
$tpl = "edit";
|
||||
include('include_trainings.php');
|
||||
break;
|
||||
case 'create':
|
||||
# LÉTREHOZÓS OLDALAK
|
||||
include('include_create.php');
|
||||
break;
|
||||
case 'presence':
|
||||
# JELENLÉT
|
||||
$tpl = "presence";
|
||||
include('include_presence.php');
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'ajax':
|
||||
if ($this->is_subpage()) {
|
||||
include('ajax/'.$this->get_subpage());
|
||||
}
|
||||
break;
|
||||
case 'style':
|
||||
var_dump('haha');
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//nincs bejelentkezve
|
||||
$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;
|
||||
}
|
||||
|
||||
private function get_page() {
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
private function get_subpage() {
|
||||
return $this->subpage;
|
||||
}
|
||||
|
||||
private function get_id() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
private function is_page() {
|
||||
return !empty($this->page);
|
||||
}
|
||||
|
||||
private function is_subpage() {
|
||||
return !empty($this->subpage);
|
||||
}
|
||||
|
||||
private function is_id() {
|
||||
return !empty($this->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
91
_class/class_sql.php
Normal file
91
_class/class_sql.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
SQL osztály
|
||||
adatbázis műveletek
|
||||
SQLI osztályból származtatva
|
||||
*/
|
||||
|
||||
|
||||
class sql extends mysqli {
|
||||
private $_query;
|
||||
|
||||
function __construct($_host, $_username, $_password, $_dbname) {
|
||||
parent::__construct($_host, $_username, $_password, $_dbname);
|
||||
self::set_charset("utf8");
|
||||
}
|
||||
|
||||
public function single_variable($_query) {
|
||||
$result = self::query($_query);
|
||||
$assoc_array = $result->fetch_array(MYSQLI_NUM);
|
||||
return $assoc_array['0'];
|
||||
}
|
||||
|
||||
public function assoc_array($_query) {
|
||||
//var_dump($_query);
|
||||
$result = self::query($_query);
|
||||
$ret_array = array();
|
||||
while ($item = $result->fetch_assoc()) {
|
||||
$ret_array[] = $item;
|
||||
}
|
||||
return $ret_array;
|
||||
}
|
||||
|
||||
|
||||
public function insert_into($table, $value_array, $need_apostrophs = true) {
|
||||
//a beszúrt rekord id-ját adja vissza
|
||||
$fields = '';
|
||||
$values = '';
|
||||
$i = 0;
|
||||
$n = count($value_array);
|
||||
foreach ($value_array as $key => $value) {
|
||||
$fields .= $key;
|
||||
$need_apostrophs = $value!='null';
|
||||
$values .= ($need_apostrophs ? "'" : "") . $value . ($need_apostrophs ? "'" : "");
|
||||
if ($i!=($n-1)) {
|
||||
$fields .= ', ';
|
||||
$values .= ', ';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$this->_query = 'insert into ' . $table . ' (' . $fields . ') values (' . $values . ');';
|
||||
var_dump($this->_query);
|
||||
self::query($this->_query);
|
||||
return $this->insert_id;
|
||||
}
|
||||
|
||||
public function update_table($table, $value_array, $conditions, $need_apostrophs = true) {
|
||||
$this->_query = "update " . $table . " set ";
|
||||
$n = count($value_array);
|
||||
$i=0;
|
||||
foreach ($value_array as $key => $val) {
|
||||
$need_apostrophs = $val!='null';
|
||||
$this->_query .= $key . "=" . ($need_apostrophs ? "'" : "") . $val . ($need_apostrophs ? "'" : "") . ($i!=$n-1 ? ", " : "");
|
||||
$i++;
|
||||
}
|
||||
$this->_query .= " where ";
|
||||
$n = count($conditions);
|
||||
$i=0;
|
||||
foreach ($conditions as $key_ => $val_) {
|
||||
$this->_query .= $key_ . "='" . $val_ . "'" . ($i!=$n-1 ? " and " : ";");
|
||||
$i++;
|
||||
}
|
||||
//var_dump($this->_query);
|
||||
self::query($this->_query);
|
||||
}
|
||||
|
||||
|
||||
public function num_of_rows($_query) {
|
||||
$result = self::query($_query);
|
||||
return is_object($result)?$result->num_rows:0;
|
||||
}
|
||||
|
||||
public function execute_query($_query) {
|
||||
return self::query($_query);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
100
_class/class_training.php
Normal file
100
_class/class_training.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
TRAINING osztály
|
||||
Edzések
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class training {
|
||||
private $tr_id;
|
||||
private $tr_date;
|
||||
private $tr_training_type_trt_id;
|
||||
private $tr_user_coach_uc_id;
|
||||
|
||||
|
||||
public function set_tr_id($_tr_id) {
|
||||
$this->tr_id = $_tr_id;
|
||||
}
|
||||
|
||||
public function set_tr_date($_tr_date) {
|
||||
$this->tr_date = $_tr_date;
|
||||
}
|
||||
|
||||
public function set_tr_training_type_trt_id($_tr_training_type_trt_id) {
|
||||
$this->tr_training_type_trt_id = $_tr_training_type_trt_id;
|
||||
}
|
||||
|
||||
public function set_tr_user_coach_uc_id($_tr_user_coach_uc_id) {
|
||||
$this->tr_user_coach_uc_id = $_tr_user_coach_uc_id;
|
||||
}
|
||||
|
||||
public function get_tr_id() {
|
||||
return $this->tr_id;
|
||||
}
|
||||
|
||||
public function get_tr_date() {
|
||||
return $this->tr_date;
|
||||
}
|
||||
|
||||
public function get_tr_training_type_trt_id() {
|
||||
return $this->tr_training_type_trt_id;
|
||||
}
|
||||
|
||||
public function get_tr_user_coach_uc_id() {
|
||||
return $this->tr_user_coach_uc_id;
|
||||
}
|
||||
|
||||
public function get_tr_type_name_by_id() {
|
||||
global $sql;
|
||||
return $sql->single_variable("SELECT trt_name FROM training_type WHERE trt_id = " . $this->get_tr_training_type_trt_id());
|
||||
}
|
||||
|
||||
public function set_training_data_by_id($_tr_id) {
|
||||
global $sql;
|
||||
$training_data_assoc_array = $sql->assoc_array("select * from training where tr_id = " . $_tr_id);
|
||||
$training_data_array = $training_data_assoc_array[0];
|
||||
foreach ($training_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function create_training($_training_value_array, $_every_week) {
|
||||
global $sql;
|
||||
//megnézzük, hogy minden hétre be kell-e rakni
|
||||
//ha igen, akkor az adott hónapban, a hét minden azonos napjára létrehozza
|
||||
if ($_every_week) {
|
||||
//megnézzük milyen nap van a megadott dátumon
|
||||
$day_of_week = date('N', strtotime($_training_value_array['tr_date']));
|
||||
//kigyűjtük a hónap további ilyen napjait
|
||||
$last_day = date("t", strtotime($_training_value_array['tr_date']));
|
||||
|
||||
for ($actual_day=date('d', strtotime($_training_value_array['tr_date'])); $actual_day <= $last_day; $actual_day=$actual_day+7) {
|
||||
$sql->insert_into('training',
|
||||
array(
|
||||
'tr_date' => date('Y-m') . '-' . $actual_day . ' ' . date('H:i', strtotime($_training_value_array['tr_date'])),
|
||||
'tr_training_type_trt_id' => $_training_value_array['tr_training_type_trt_id'],
|
||||
'tr_user_coach_uc_id' => $_training_value_array['tr_user_coach_uc_id']
|
||||
)
|
||||
);
|
||||
}
|
||||
//var_dump($day_array);
|
||||
}
|
||||
else {
|
||||
$sql->insert_into('training', $_training_value_array);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function update_training($_training_value_array, $_tr_id) {
|
||||
global $sql;
|
||||
$sql->update_table('training', $_training_value_array, array('tr_id' => $_tr_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
112
_class/class_user.php
Normal file
112
_class/class_user.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
USER CLASS
|
||||
ősosztály
|
||||
USER COACH adatszerkezet
|
||||
az öszes user rendelkezik ezekkel a tulajdonságokkal
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class user {
|
||||
private $user_id;
|
||||
private $user_name;
|
||||
private $user_last_name;
|
||||
private $user_first_name;
|
||||
private $user_password;
|
||||
private $user_email;
|
||||
private $user_last_login;
|
||||
private $logged_in;
|
||||
private $user_type;
|
||||
|
||||
public function set_ua_id($_uid) {
|
||||
$this->user_id = $_uid;
|
||||
}
|
||||
|
||||
public function set_ua_name($_uname) {
|
||||
$this->user_name = $_uname;
|
||||
}
|
||||
|
||||
public function set_ua_last_name($_u_last_name) {
|
||||
$this->user_last_name = $_u_last_name;
|
||||
}
|
||||
|
||||
public function set_ua_first_name($_u_first_name) {
|
||||
$this->user_first_name = $_u_first_name;
|
||||
}
|
||||
|
||||
public function set_ua_password($_u_pass) {
|
||||
$this->user_password = $_u_pass;
|
||||
}
|
||||
|
||||
public function set_ua_email($_u_email) {
|
||||
$this->user_email = $_u_email;
|
||||
}
|
||||
|
||||
public function set_ua_last_login($_u_last_login) {
|
||||
$this->user_last_login = $_u_last_login;
|
||||
}
|
||||
|
||||
public function get_ua_id() {
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
public function get_ua_name() {
|
||||
return $this->user_name;
|
||||
}
|
||||
|
||||
public function get_ua_last_name() {
|
||||
return $this->user_last_name;
|
||||
}
|
||||
|
||||
public function get_ua_first_name() {
|
||||
return $this->user_first_name;
|
||||
}
|
||||
|
||||
public function get_ua_password() {
|
||||
return $this->user_password;
|
||||
}
|
||||
|
||||
public function get_ua_email() {
|
||||
return $this->user_email;
|
||||
}
|
||||
|
||||
public function is_logged_in() {
|
||||
//leellenőrzi cookie alapján h be vagyunk-e jelentkezve
|
||||
//JAVÍTVA: adja vissza az adattag igazságértékét
|
||||
return $this->logged_in;
|
||||
}
|
||||
|
||||
public function set_login($_login) {
|
||||
//bool-t kap paraméterül
|
||||
$this->logged_in = $_login;
|
||||
}
|
||||
|
||||
public function set_user_data_by_id($_ua_id) {
|
||||
global $sql, $user;
|
||||
$user_data_assoc_array = $sql->assoc_array("select * from user_coach where ua_id = " . $_ua_id);
|
||||
$user_data_array = $user_data_assoc_array[0];
|
||||
foreach ($user_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
$this->set_ua_type(1); //coach típus beállítása
|
||||
$this->set_login(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function update_login_time($_ua_id = null) {
|
||||
global $sql;
|
||||
//az adott user_id-n updateli a login_time-ot
|
||||
$sql->update_table('user_coach', array('ua_last_login' => date('Y-m-d')), array('ua_id' => (empty($_ua_id)?$this->get_ua_id():$_ua_id)));
|
||||
}
|
||||
|
||||
public function set_ua_type($_type) {
|
||||
$this->user_type = $_type;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
270
_class/class_user_kid.php
Normal file
270
_class/class_user_kid.php
Normal file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
USER_KID osztály
|
||||
GYEREKEK osztálya, a USER_PARENT osztályból öröklődik
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class user_kid extends user_parent {
|
||||
private $user_id;
|
||||
private $user_name;
|
||||
private $user_last_name;
|
||||
private $user_first_name;
|
||||
private $user_password;
|
||||
private $user_email;
|
||||
private $user_last_login;
|
||||
private $user_gender;
|
||||
private $user_address;
|
||||
private $user_birth_date;
|
||||
private $user_first_training;
|
||||
private $user_hand;
|
||||
private $user_last_modified;
|
||||
private $logged_in;
|
||||
private $user_type;
|
||||
private $user_shirt_size;
|
||||
private $user_school_sc_id;
|
||||
private $user_school_district;
|
||||
private $user_school_city_scc_id;
|
||||
private $user_parent_1;
|
||||
private $user_parent_2;
|
||||
private $user_phone;
|
||||
private $user_facebook;
|
||||
|
||||
public function set_uk_id($_uid) {
|
||||
$this->user_id = $_uid;
|
||||
}
|
||||
|
||||
public function set_uk_name($_uname) {
|
||||
$this->user_name = $_uname;
|
||||
}
|
||||
|
||||
public function set_uk_last_name($_u_last_name) {
|
||||
$this->user_last_name = $_u_last_name;
|
||||
}
|
||||
|
||||
public function set_uk_first_name($_u_first_name) {
|
||||
$this->user_first_name = $_u_first_name;
|
||||
}
|
||||
|
||||
public function set_uk_password($_u_pass) {
|
||||
$this->user_password = $_u_pass;
|
||||
}
|
||||
|
||||
public function set_uk_email($_u_email) {
|
||||
$this->user_email = $_u_email;
|
||||
}
|
||||
|
||||
public function set_uk_phone($_u_phone) {
|
||||
$this->user_phone = $_u_phone;
|
||||
}
|
||||
|
||||
public function set_uk_facebook($_facebook) {
|
||||
$this->user_facebook = $_facebook;
|
||||
}
|
||||
|
||||
public function set_uk_last_login($_u_last_login) {
|
||||
$this->user_last_login = $_u_last_login;
|
||||
}
|
||||
|
||||
public function set_uk_shirt_size_ss_id($_shirt_size) {
|
||||
$this->shirt_size = $_shirt_size;
|
||||
}
|
||||
|
||||
public function set_uk_school_sc_id($_school) {
|
||||
$this->user_school_sc_id = $_school;
|
||||
}
|
||||
|
||||
public function set_uk_school_district($_district) {
|
||||
$this->user_school_district = $_district;
|
||||
}
|
||||
|
||||
|
||||
public function set_uk_school_city_scc_id($_city_id) {
|
||||
$this->user_school_city_scc_id = $_city_id;
|
||||
}
|
||||
|
||||
public function set_uk_parent_1($_uk_parent_1) {
|
||||
$this->user_parent_1 = $_uk_parent_1;
|
||||
}
|
||||
|
||||
public function set_uk_parent_2($_uk_parent_2) {
|
||||
$this->user_parent_2 = $_uk_parent_2;
|
||||
}
|
||||
|
||||
public function get_uk_id() {
|
||||
return $this->user_id;
|
||||
}
|
||||
|
||||
public function get_uk_name() {
|
||||
return $this->user_name;
|
||||
}
|
||||
|
||||
public function get_uk_last_name() {
|
||||
return $this->user_last_name;
|
||||
}
|
||||
|
||||
public function get_uk_first_name() {
|
||||
return $this->user_first_name;
|
||||
}
|
||||
|
||||
public function get_uk_password() {
|
||||
return $this->user_password;
|
||||
}
|
||||
|
||||
public function get_uk_email() {
|
||||
return $this->user_email;
|
||||
}
|
||||
|
||||
public function get_uk_shirt_size() {
|
||||
return $this->user_shirt_size;
|
||||
}
|
||||
|
||||
public function get_uk_school_sc_id() {
|
||||
return $this->user_school_sc_id;
|
||||
}
|
||||
|
||||
public function get_uk_school_district() {
|
||||
return $this->user_school_district;
|
||||
}
|
||||
|
||||
public function get_uk_school_city_scc_id() {
|
||||
return $this->user_school_city_scc_id;
|
||||
}
|
||||
|
||||
public function get_uk_parent_1() {
|
||||
return $this->user_parent_1;
|
||||
}
|
||||
|
||||
public function get_uk_parent_2() {
|
||||
return $this->user_parent_2;
|
||||
}
|
||||
|
||||
public function get_uk_presence($_training_id) {
|
||||
global $sql;
|
||||
return $sql->num_of_rows('select * from presence where pr_user_kid_uk_id = ' . $this->get_uk_id() . ' AND pr_training_tr_id = ' . $_training_id);
|
||||
|
||||
}
|
||||
|
||||
public function set_uk_gender($_gender) {
|
||||
$this->user_gender = $_gender;
|
||||
}
|
||||
public function get_uk_gender() {
|
||||
return $this->user_gender;
|
||||
}
|
||||
|
||||
public function set_uk_birth_date($_birth_date) {
|
||||
$this->user_birth_date = $_birth_date;
|
||||
}
|
||||
public function get_uk_birth_date() {
|
||||
return $this->user_birth_date;
|
||||
}
|
||||
|
||||
public function set_uk_first_training($_first_training) {
|
||||
$this->user_first_training = $_first_training;
|
||||
}
|
||||
public function get_uk_first_training() {
|
||||
return $this->user_first_training;
|
||||
}
|
||||
|
||||
public function set_uk_hand($_hand) {
|
||||
$this->user_hand = $_hand;
|
||||
}
|
||||
public function get_uk_hand() {
|
||||
return $this->user_hand;
|
||||
}
|
||||
|
||||
public function set_uk_last_modified($_last_modified) {
|
||||
$this->user_last_modified = $_last_modified;
|
||||
}
|
||||
public function get_uk_last_modified() {
|
||||
return $this->user_last_modified;
|
||||
}
|
||||
|
||||
public function set_uk_address($_address) {
|
||||
$this->user_address = $_address;
|
||||
}
|
||||
public function get_uk_address() {
|
||||
return $this->user_address;
|
||||
}
|
||||
|
||||
public function set_user_data_by_id($_uk_id) {
|
||||
global $sql, $user;
|
||||
$user_data_assoc_array = $sql->assoc_array("select * from user_kid where uk_id = " . $_uk_id);
|
||||
$user_data_array = $user_data_assoc_array[0];
|
||||
foreach ($user_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
$this->set_ua_type(2); //kid típus beállítása
|
||||
$this->set_login(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function add_new_parent($_parent_name, $_email, $_facebook, $_phone) {
|
||||
global $sql;
|
||||
//beilleszti AB-ba
|
||||
//visszaadja az ID-t
|
||||
|
||||
return $sql->insert_into('user_parent',
|
||||
array(
|
||||
'up_name' => $_parent_name,
|
||||
'up_email' => $_email,
|
||||
'up_facebook' => $_facebook,
|
||||
'up_phone' => $_phone
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function create_user($_user_value_array) {
|
||||
global $sql;
|
||||
|
||||
//SCHOOL_HANDLER
|
||||
if (isset($_user_value_array['add_school'])) {
|
||||
$new_school_id = $sql->insert_into('school', array('sc_name' => $_user_value_array['add_school']));
|
||||
$_user_value_array['uk_school_sc_id'] = $new_school_id;
|
||||
unset($_user_value_array['add_school']);
|
||||
}
|
||||
|
||||
//PARENT_1 HANDLER
|
||||
if (isset($_user_value_array['add_parent_1'])) {
|
||||
//lehet, hogy csak a neve van megadva, ezért meg kell vizsgálni, hogy a többi létezik-e; ha nem => null
|
||||
|
||||
$_user_value_array['uk_parent_1'] = self::add_new_parent(
|
||||
$_user_value_array['add_parent_1'],
|
||||
$_user_value_array['parent_1_email'],
|
||||
$_user_value_array['parent_1_facebook'], $_user_value_array['parent_1_phone']);
|
||||
unset($_user_value_array['add_parent_1']);
|
||||
|
||||
if (isset($_user_value_array['parent_1_email'])) unset($_user_value_array['parent_1_email']);
|
||||
if (isset($_user_value_array['parent_1_facebook'])) unset($_user_value_array['parent_1_facebook']);
|
||||
if (isset($_user_value_array['parent_1_phone'])) unset($_user_value_array['parent_1_phone']);
|
||||
}
|
||||
|
||||
//PARENT_2 HANDLER
|
||||
if (isset($_user_value_array['add_parent_2'])) {
|
||||
$_user_value_array['uk_parent_2'] = self::add_new_parent(
|
||||
$_user_value_array['add_parent_2'],
|
||||
$_user_value_array['parent_2_email'], $_user_value_array['parent_2_facebook'],
|
||||
$_user_value_array['parent_2_phone']);
|
||||
unset($_user_value_array['add_parent_2']);
|
||||
|
||||
if (isset($_user_value_array['parent_2_email'])) unset($_user_value_array['parent_2_email']);
|
||||
if (isset($_user_value_array['parent_2_facebook'])) unset($_user_value_array['parent_2_facebook']);
|
||||
if (isset($_user_value_array['parent_2_phone'])) unset($_user_value_array['parent_2_phone']);
|
||||
}
|
||||
return $sql->insert_into('user_kid', $_user_value_array);
|
||||
}
|
||||
|
||||
public function update_user($_user_value_array, $_user_id) {
|
||||
global $sql;
|
||||
//ha nincs bejelölve h aktív akkor nem kapja meg ezt az értéket, manuálisan kell beállítani
|
||||
if (!isset($_user_value_array['uk_is_active'])) $_user_value_array['uk_is_active'] = 0;
|
||||
$sql->update_table('user_kid', $_user_value_array, array('uk_id' => $_user_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
32
_class/class_user_parent.php
Normal file
32
_class/class_user_parent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
USER_PARENT osztály
|
||||
SZÜLŐK osztálya, a USER osztályból öröklődik
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class user_parent extends user {
|
||||
|
||||
|
||||
protected function set_user_phone($_phone) {
|
||||
$this->$user_phone = $_phone;
|
||||
}
|
||||
|
||||
protected function set_user_facebook($_facebook) {
|
||||
$this->$user_facebook = $_facebook;
|
||||
}
|
||||
|
||||
protected function get_user_phone() {
|
||||
return $this->user_phone;
|
||||
}
|
||||
|
||||
protected function get_user_facebook() {
|
||||
return $this->user_facebook;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user