groups
This commit is contained in:
@@ -17,9 +17,9 @@ class log {
|
||||
if (is_object($user)) {
|
||||
//ha a user változó objektum, akkor megvizsgáljuk, hogy coach vagy parent
|
||||
if (get_class($user) == 'user') $function_name = 'get_ua_id';
|
||||
elseif(get_class($user) == 'user_kid') $function_name = 'get_uk_id';
|
||||
elseif(get_class($user) == 'camp_user') $function_name = 'get_cu_id';
|
||||
elseif(get_class($user) == 'user_camp_leader') $function_name = 'get_ucl_id';
|
||||
elseif(get_class($user) == 'user_kid') $function_name = 'get_uk_id';
|
||||
elseif(get_class($user) == 'camp_user') $function_name = 'get_cu_id';
|
||||
elseif(get_class($user) == 'user_camp_leader') $function_name = 'get_ucl_id';
|
||||
}
|
||||
|
||||
$sql->insert_into('log', array(
|
||||
@@ -115,11 +115,11 @@ class log {
|
||||
}
|
||||
|
||||
public function get_log_img() {
|
||||
if (strstr($this->get_log_category()->get_logc_name(), 'new')) return 'tick';
|
||||
elseif (strstr($this->get_log_category()->get_logc_name(), 'delete')) return 'delete';
|
||||
elseif (strstr($this->get_log_category()->get_logc_name(), 'update')) return 'edit';
|
||||
elseif (in_array($this->get_log_category()->get_logc_name(), array('training_close', 'training_open'))) return 'lock';
|
||||
elseif (in_array($this->get_log_category()->get_logc_name(), array('admin_login', 'admin_logout', 'kid_login', 'kid_logout', 'coach_login', 'coach_logout', 'camp_user_login', 'camp_user_logout'))) return 'login';
|
||||
if (strstr($this->get_log_category()->get_logc_name(), 'new')) return 'tick';
|
||||
elseif (strstr($this->get_log_category()->get_logc_name(), 'delete')) return 'delete';
|
||||
elseif (strstr($this->get_log_category()->get_logc_name(), 'update')) return 'edit';
|
||||
elseif (in_array($this->get_log_category()->get_logc_name(), array('training_close', 'training_open'))) return 'lock';
|
||||
elseif (in_array($this->get_log_category()->get_logc_name(), array('admin_login', 'admin_logout', 'kid_login', 'kid_logout', 'coach_login', 'coach_logout', 'camp_user_login', 'camp_user_logout', 'camp_leader_login', 'camp_leader_logout'))) return 'login';
|
||||
}
|
||||
|
||||
public function set_log_data_by_id($_log_id) {
|
||||
@@ -141,6 +141,7 @@ class log {
|
||||
if ($this->get_log_category()->get_logc_type() == 1) $new_user = new user();
|
||||
elseif($this->get_log_category()->get_logc_type() == 2) $new_user = new user_kid();
|
||||
elseif($this->get_log_category()->get_logc_type() == 3) $new_user = new camp_user();
|
||||
elseif($this->get_log_category()->get_logc_type() == 4) $new_user = new user_camp_leader();
|
||||
$new_user->set_user_data_by_id($value);
|
||||
$this->set_log_user($new_user);
|
||||
}
|
||||
@@ -150,4 +151,4 @@ class log {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -219,6 +219,10 @@ class page {
|
||||
# turnusok
|
||||
include('include_camp_details.php');
|
||||
break;
|
||||
case 'user_groups':
|
||||
# csoportok
|
||||
include('include_user_groups.php');
|
||||
break;
|
||||
case 'delete_training_type':
|
||||
# EDZÉS TÍPUS TÖRLÉS
|
||||
include('include_delete_training_type.php');
|
||||
@@ -275,6 +279,10 @@ class page {
|
||||
# TÁBORVEZETŐ TÖRLÉS
|
||||
include('include_delete_camp_leader.php');
|
||||
break;
|
||||
case 'delete_user_group':
|
||||
# CSOPORT TÖRLÉS
|
||||
include('include_delete_user_group.php');
|
||||
break;
|
||||
case 'logout':
|
||||
# kijelentkezés
|
||||
$from = "admin";
|
||||
|
||||
194
_class/class_user_group.php
Normal file
194
_class/class_user_group.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
class user_group {
|
||||
private $ug_id;
|
||||
private $ug_name;
|
||||
private $ug_description;
|
||||
private $ug_is_automatic;
|
||||
private $ug_deleted;
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ug_id()
|
||||
{
|
||||
return $this->ug_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ug_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ug_id($ug_id)
|
||||
{
|
||||
$this->ug_id = $ug_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ug_name()
|
||||
{
|
||||
return $this->ug_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ug_name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ug_name($ug_name)
|
||||
{
|
||||
$this->ug_name = $ug_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ug_description()
|
||||
{
|
||||
return $this->ug_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ug_description
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ug_description($ug_description)
|
||||
{
|
||||
$this->ug_description = $ug_description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ug_is_automatic()
|
||||
{
|
||||
return $this->ug_is_automatic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ug_is_automatic
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ug_is_automatic($ug_is_automatic)
|
||||
{
|
||||
$this->ug_is_automatic = $ug_is_automatic;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ug_deleted()
|
||||
{
|
||||
return $this->ug_deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ug_deleted
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ug_deleted($ug_deleted)
|
||||
{
|
||||
$this->ug_deleted = $ug_deleted;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ug_filter()
|
||||
{
|
||||
return $this->ug_filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ug_filter
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ug_filter($ug_filter)
|
||||
{
|
||||
$this->ug_filter = $ug_filter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function set_ug_data_by_id($_id) {
|
||||
global $sql;
|
||||
$set_data_assoc_array = $sql->assoc_array("select * from user_group where ug_id = " . $_id);
|
||||
$set_data_array = $set_data_assoc_array[0];
|
||||
foreach ($set_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
}
|
||||
}
|
||||
|
||||
public static function create_user_group($_name, $_description, $_is_automatic = 0) {
|
||||
global $sql;
|
||||
|
||||
return $sql->insert_into('user_group', array(
|
||||
'ug_name' => $_name,
|
||||
'ug_description' => $_description,
|
||||
'ug_is_automatic' => $_is_automatic,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function update_user_group($_name, $_description, $_id, $_is_automatic = 0) {
|
||||
global $sql;
|
||||
|
||||
$sql->update_table('user_group', array(
|
||||
'ug_name' => $_name,
|
||||
'ug_description' => $_description,
|
||||
'ug_is_automatic' => $_is_automatic,
|
||||
),
|
||||
array(
|
||||
'ug_id' => $_id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function empty_group($_group_id) {
|
||||
//kitörli a usereket a groupból; categoryra szűrhető
|
||||
global $sql;
|
||||
$sql->execute_query("DELETE FROM user_group_kid WHERE ugk_user_group_ug_id = " . $_group_id);
|
||||
$sql->execute_query("DELETE FROM user_group_category WHERE ugc_user_group_ug_id = " . $_group_id);
|
||||
|
||||
}
|
||||
|
||||
public function get_user_group_filter_values() {
|
||||
global $sql;
|
||||
|
||||
$ugfv_array = array();
|
||||
|
||||
$ugfv_assoc_array = $sql->assoc_array("SELECT * FROM user_group_filter_value WHERE ugfv_group_id = " . $this->get_ug_id());
|
||||
|
||||
foreach ($ugfv_assoc_array as $u) {
|
||||
$ugfv = new user_group_filter_value();
|
||||
$ugfv->set_ugfv_data_by_id($u['ugfv_id']);
|
||||
$ugfv_array[] = $ugfv;
|
||||
}
|
||||
|
||||
return $ugfv_array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
86
_class/class_user_group_category.php
Normal file
86
_class/class_user_group_category.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
class user_group_category {
|
||||
private $ugc_id;
|
||||
private $ugc_name;
|
||||
private $ugc_user_group_ug_id;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugc_id()
|
||||
{
|
||||
return $this->ugc_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugc_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugc_id($ugc_id)
|
||||
{
|
||||
$this->ugc_id = $ugc_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugc_name()
|
||||
{
|
||||
return $this->ugc_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugc_name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugc_name($ugc_name)
|
||||
{
|
||||
$this->ugc_name = $ugc_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugc_user_group_ug_id()
|
||||
{
|
||||
return $this->ugc_user_group_ug_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugc_user_group_ug_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugc_user_group_ug_id($ugc_user_group_ug_id)
|
||||
{
|
||||
$this->ugc_user_group_ug_id = $ugc_user_group_ug_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_ugc_data_by_id($_id) {
|
||||
global $sql;
|
||||
$set_data_assoc_array = $sql->assoc_array("select * from user_group_category where ugc_id = " . $_id);
|
||||
$set_data_array = $set_data_assoc_array[0];
|
||||
foreach ($set_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function get_ugc_by_name($_name, $_group_id) {
|
||||
global $sql;
|
||||
return $sql->single_varible("select ugc_id from user_group_category where ugc_user_group_ug_id = " . $_group_id . " AND ugc_name = '".$_name."';");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
167
_class/class_user_group_filter.php
Normal file
167
_class/class_user_group_filter.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
class user_group_filter {
|
||||
private $ugf_id;
|
||||
private $ugf_name;
|
||||
private $ugf_field;
|
||||
private $ugf_table;
|
||||
private $ugf_label;
|
||||
private $ugf_value;
|
||||
private $ugf_condition;
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_id()
|
||||
{
|
||||
return $this->ugf_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_id($ugf_id)
|
||||
{
|
||||
$this->ugf_id = $ugf_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_name()
|
||||
{
|
||||
return $this->ugf_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_name($ugf_name)
|
||||
{
|
||||
$this->ugf_name = $ugf_name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_field()
|
||||
{
|
||||
return $this->ugf_field;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_field
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_field($ugf_field)
|
||||
{
|
||||
$this->ugf_field = $ugf_field;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_table()
|
||||
{
|
||||
return $this->ugf_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_table
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_table($ugf_table)
|
||||
{
|
||||
$this->ugf_table = $ugf_table;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_label()
|
||||
{
|
||||
return $this->ugf_label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_label
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_label($ugf_label)
|
||||
{
|
||||
$this->ugf_label = $ugf_label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_value()
|
||||
{
|
||||
return $this->ugf_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_value($ugf_value)
|
||||
{
|
||||
$this->ugf_value = $ugf_value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugf_condition()
|
||||
{
|
||||
return $this->ugf_condition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugf_condition
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugf_condition($ugf_condition)
|
||||
{
|
||||
$this->ugf_condition = $ugf_condition;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_ugf_data_by_id($_ugf_id) {
|
||||
global $sql;
|
||||
$ugf_assoc_array = $sql->assoc_array("select * from user_group_filter where ugf_id = " . $_ugf_id);
|
||||
$ugf_array = $ugf_assoc_array[0];
|
||||
//alapadatok
|
||||
foreach ($ugf_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
232
_class/class_user_group_filter_value.php
Normal file
232
_class/class_user_group_filter_value.php
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
class user_group_filter_value {
|
||||
private $ugfv_id;
|
||||
private $ugfv_filter_id; //obj
|
||||
private $ugfv_group_id; //obj
|
||||
private $ugfv_value;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugfv_id()
|
||||
{
|
||||
return $this->ugfv_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugfv_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugfv_id($ugfv_id)
|
||||
{
|
||||
$this->ugfv_id = $ugfv_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugfv_filter_id()
|
||||
{
|
||||
return $this->ugfv_filter_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugfv_filter_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugfv_filter_id($ugfv_filter_id)
|
||||
{
|
||||
$this->ugfv_filter_id = $ugfv_filter_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugfv_group_id()
|
||||
{
|
||||
return $this->ugfv_group_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugfv_group_id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugfv_group_id($ugfv_group_id)
|
||||
{
|
||||
$this->ugfv_group_id = $ugfv_group_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_ugfv_value()
|
||||
{
|
||||
return $this->ugfv_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ugfv_value
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function set_ugfv_value($ugfv_value)
|
||||
{
|
||||
$this->ugfv_value = $ugfv_value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set_ugfv_data_by_id($_sc_id) {
|
||||
global $sql;
|
||||
$ugfv_data_assoc_array = $sql->assoc_array("select * from user_group_filter_value where ugfv_id = " . $_sc_id);
|
||||
$ugfv_data_array = $ugfv_data_assoc_array[0];
|
||||
foreach ($ugfv_data_array as $field => $value) {
|
||||
$function_name = "set_" . $field;
|
||||
$this->$function_name($value); //alapadatok beállítása
|
||||
if ($field == 'ugfv_filter_id' && !empty($value)) {
|
||||
$filter = new user_group_filter();
|
||||
$filter->set_ugf_data_by_id($value);
|
||||
$this->set_ugfv_filter_id($filter);
|
||||
}
|
||||
if ($field == 'ugfv_group_id' && !empty($value)) {
|
||||
$group = new user_group();
|
||||
$group->set_ug_data_by_id($value);
|
||||
$this->set_ugfv_group_id($group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function apply($intersect = 0) {
|
||||
global $sql;
|
||||
//EZ CSAK BEILLESZT, A SZÜKSÉGES TÖRLÉSEKET ELŐTTE KELL MEGCSINÁLNI
|
||||
//$this->get_ugfv_group_id()->empty_group($ugc_id);
|
||||
//$this->get_ugfv_group_id()->empty_group($ugc_id);
|
||||
//lekéri az usereket a megadott értékek alapján, és ha még nincs ilyen user a csoportban ezzel a category-val, akkor beilleszti
|
||||
|
||||
if (!$intersect) {
|
||||
$ugc_id = $sql->insert_into('user_group_category', array(
|
||||
'ugc_name' => $this->get_ugfv_value(),
|
||||
'ugc_user_group_ug_id' => $this->get_ugfv_group_id()->get_ug_id(),
|
||||
'ugc_ugfv_id' => $this->get_ugfv_id()
|
||||
));
|
||||
}
|
||||
|
||||
if ($this->get_ugfv_filter_id()->get_ugf_table()) {
|
||||
//ha meg van adva table, akkor az alapján rakjuk össze a query-t
|
||||
$table = $this->get_ugfv_filter_id()->get_ugf_table();
|
||||
$uk_field = 'uk_'.$this->get_ugfv_filter_id()->get_ugf_field();
|
||||
$value = $this->get_ugfv_filter_id()->get_ugf_value();
|
||||
$condition = $this->get_ugfv_filter_id()->get_ugf_condition();
|
||||
|
||||
$filter_query = "
|
||||
SELECT
|
||||
uk_id
|
||||
FROM
|
||||
user_kid
|
||||
JOIN
|
||||
".$table." ON ".$value." = ".$uk_field."
|
||||
WHERE ".($table!='user_kid_is_active'?"uk_is_active = 1 ":"")." AND uk_deleted = 0 AND
|
||||
".$uk_field." = ".$this->get_ugfv_value() . ($condition?" AND " . $condition:"") .
|
||||
";";
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$filter_query = "
|
||||
SELECT uk_id FROM user_kid
|
||||
WHERE uk_is_active = 1 AND uk_deleted = 0 AND uk_".$this->get_ugfv_filter_id()->get_ugf_field()." = '".$this->get_ugfv_value()."';
|
||||
";
|
||||
|
||||
}
|
||||
//var_dump($filter_query);
|
||||
|
||||
|
||||
$uk_assoc_array = $sql->assoc_array($filter_query);
|
||||
|
||||
$uk_ids = [];
|
||||
foreach ($uk_assoc_array as $uk_array) {
|
||||
$uk_ids[] = $uk_array['uk_id'];
|
||||
}
|
||||
|
||||
$ugfv_list = $sql->assoc_array('SELECT * FROM user_group_kid WHERE ugk_ugfv_id in (SELECT ugfv_id FROM user_group_filter_value WHERE ugfv_group_id = ' . $this->get_ugfv_group_id()->get_ug_id(). ');');
|
||||
if ($intersect && count($ugfv_list)) {
|
||||
//ha már van vmi a metszetben
|
||||
//végigmegyünk a metszeten, és ha az aktuális elem nincs benne az uk_assoc_arrayben, akkor kivesszük a metszetből
|
||||
foreach ($ugfv_list as $index => $ugfv_array) {
|
||||
if (!in_array($ugfv_array['ugk_user_kid_uk_id'], $uk_ids)) {
|
||||
$sql->execute_query('DELETE FROM user_group_kid WHERE ugk_id = ' . $ugfv_array['ugk_id']);
|
||||
unset($ugfv_list[$index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
foreach ($uk_assoc_array as $uk) {
|
||||
$sql->insert_into('user_group_kid', array(
|
||||
'ugk_user_kid_uk_id' => $uk['uk_id'],
|
||||
'ugk_user_group_ug_id' => $this->get_ugfv_group_id()->get_ug_id(),
|
||||
'ugk_category_ugc_id' => ($intersect?'null':$ugc_id),
|
||||
'ugk_ugfv_id' => $this->get_ugfv_id(),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function is_user_filterable($user) {
|
||||
global $sql;
|
||||
|
||||
if ($this->get_ugfv_filter_id()->get_ugf_table()) {
|
||||
//ha meg van adva table, akkor az alapján rakjuk össze a query-t
|
||||
$table = $this->get_ugfv_filter_id()->get_ugf_table();
|
||||
$uk_field = 'uk_'.$this->get_ugfv_filter_id()->get_ugf_field();
|
||||
$value = $this->get_ugfv_filter_id()->get_ugf_value();
|
||||
$condition = $this->get_ugfv_filter_id()->get_ugf_condition();
|
||||
|
||||
$filter_query = "
|
||||
SELECT
|
||||
uk_id
|
||||
FROM
|
||||
user_kid
|
||||
JOIN
|
||||
".$table." ON ".$value." = ".$uk_field."
|
||||
WHERE ".($table!='user_kid_is_active'?"uk_is_active = 1 ":"")." AND uk_id = ".$user->get_uk_id()." AND uk_deleted = 0 AND
|
||||
".$uk_field." = ".$this->get_ugfv_value() . ($condition?" AND " . $condition:"") .
|
||||
";";
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
$filter_query = "
|
||||
SELECT uk_id FROM user_kid
|
||||
WHERE uk_is_active = 1 AND uk_deleted = 0 AND uk_id = ".$user->get_uk_id()." AND uk_".$this->get_ugfv_filter_id()->get_ugf_field()." = '".$this->get_ugfv_value()."';
|
||||
";
|
||||
|
||||
}
|
||||
//var_dump($filter_query);
|
||||
return $sql->num_of_rows($filter_query);
|
||||
}
|
||||
|
||||
public function is_intersect() {
|
||||
global $sql;
|
||||
return empty($sql->single_variable('SELECT ugk_category_ugc_id FROM user_group_kid WHERE ugk_user_group_ug_id = ' . $this->get_ugfv_group_id()->get_ug_id(). ' AND ugk_ugfv_id = ' . $this->get_ugfv_id()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -21,6 +21,7 @@ class user_kid extends user_parent {
|
||||
private $user_first_training;
|
||||
private $user_beforehand;
|
||||
private $user_hand;
|
||||
private $user_level;
|
||||
private $user_last_modified;
|
||||
private $logged_in;
|
||||
private $user_type;
|
||||
@@ -33,34 +34,35 @@ class user_kid extends user_parent {
|
||||
private $user_phone;
|
||||
private $user_facebook;
|
||||
private $user_region;
|
||||
private $user_ago_category;
|
||||
private $user_age_category;
|
||||
private $user_official_age_category;
|
||||
private $user_contact;
|
||||
private $user_other;
|
||||
private $user_deleted;
|
||||
|
||||
public function set_uk_id($_uid) {
|
||||
$this->user_id = $_uid;
|
||||
$this->user_id = $_uid;
|
||||
}
|
||||
public function set_uk_name($_uname) {
|
||||
$this->user_name = $_uname;
|
||||
$this->user_name = $_uname;
|
||||
}
|
||||
public function set_uk_is_active($_active) {
|
||||
$this->user_is_active = $_active;
|
||||
$this->user_is_active = $_active;
|
||||
}
|
||||
public function set_uk_password($_u_pass) {
|
||||
$this->user_password = $_u_pass;
|
||||
$this->user_password = $_u_pass;
|
||||
}
|
||||
public function set_uk_email($_u_email) {
|
||||
$this->user_email = $_u_email;
|
||||
$this->user_email = $_u_email;
|
||||
}
|
||||
public function set_uk_phone($_u_phone) {
|
||||
$this->user_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;
|
||||
$this->user_last_login = $_u_last_login;
|
||||
}
|
||||
public function set_uk_shirt_size_ss_id($_shirt_size) {
|
||||
$this->user_shirt_size = $_shirt_size;
|
||||
@@ -178,73 +180,85 @@ class user_kid extends user_parent {
|
||||
}
|
||||
|
||||
public function set_uk_gender($_gender) {
|
||||
$this->user_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;
|
||||
$this->user_birth_date = $_birth_date;
|
||||
}
|
||||
public function get_uk_birth_date() {
|
||||
return $this->user_birth_date;
|
||||
}
|
||||
public function set_uk_birth_year($_birth_year) {
|
||||
$this->user_birth_year = $_birth_year;
|
||||
$this->user_birth_year = $_birth_year;
|
||||
}
|
||||
public function get_uk_birth_year() {
|
||||
return $this->user_birth_year;
|
||||
}
|
||||
public function set_uk_first_training($_first_training) {
|
||||
$this->user_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;
|
||||
$this->user_hand = $_hand;
|
||||
}
|
||||
public function get_uk_hand() {
|
||||
return $this->user_hand;
|
||||
}
|
||||
public function set_uk_level($_level) {
|
||||
$this->user_level = $_level;
|
||||
}
|
||||
public function get_uk_level() {
|
||||
return $this->user_level;
|
||||
}
|
||||
public function set_uk_last_modified($_last_modified) {
|
||||
$this->user_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_scc_id($_address) {
|
||||
$this->user_address_scc_id = $_address;
|
||||
$this->user_address_scc_id = $_address;
|
||||
}
|
||||
public function get_uk_address_scc_id() {
|
||||
return $this->user_address_scc_id;
|
||||
}
|
||||
public function set_uk_address($_address) {
|
||||
$this->user_address = $_address;
|
||||
$this->user_address = $_address;
|
||||
}
|
||||
public function get_uk_address() {
|
||||
return $this->user_address;
|
||||
}
|
||||
public function set_uk_beforehand($_beforehand) {
|
||||
$this->user_beforehand = $_beforehand;
|
||||
$this->user_beforehand = $_beforehand;
|
||||
}
|
||||
public function get_uk_beforehand() {
|
||||
return $this->user_beforehand;
|
||||
}
|
||||
public function set_uk_age_category($_age_category) {
|
||||
$this->user_age_category = $_age_category;
|
||||
$this->user_age_category = $_age_category;
|
||||
}
|
||||
public function get_uk_age_category() {
|
||||
return $this->user_age_category;
|
||||
}
|
||||
public function set_uk_official_age_category($_age_category) {
|
||||
$this->user_official_age_category = $_age_category;
|
||||
}
|
||||
public function get_uk_official_age_category() {
|
||||
return $this->user_official_age_category;
|
||||
}
|
||||
public function set_uk_school($_school) {
|
||||
$this->user_school = $_school;
|
||||
$this->user_school = $_school;
|
||||
}
|
||||
public function get_uk_school() {
|
||||
return $this->user_school;
|
||||
}
|
||||
public function set_uk_balance($_balance) {
|
||||
$this->user_balance = $_balance;
|
||||
$this->user_balance = $_balance;
|
||||
}
|
||||
public function get_uk_balance() {
|
||||
return $this->user_balance;
|
||||
@@ -306,11 +320,11 @@ class user_kid extends user_parent {
|
||||
//beilleszti AB-ba
|
||||
//visszaadja az ID-t
|
||||
|
||||
if ($_email == '') $_email = 'null';
|
||||
if ($_facebook == '') $_facebook = 'null';
|
||||
if ($_phone == '') $_phone = 'null';
|
||||
|
||||
return $sql->insert_into('user_parent',
|
||||
if ($_email == '') $_email = 'null';
|
||||
if ($_facebook == '') $_facebook = 'null';
|
||||
if ($_phone == '') $_phone = 'null';
|
||||
|
||||
return $sql->insert_into('user_parent',
|
||||
array(
|
||||
'up_name' => $_parent_name,
|
||||
'up_email' => $_email,
|
||||
@@ -324,7 +338,7 @@ class user_kid extends user_parent {
|
||||
//SCHOOL_HANDLER
|
||||
if (isset($_user_value_array['add_school']) && $_user_value_array['add_school'] != "") {
|
||||
//megnézzük adott-e az iskolához települést, ha nem, akkor null-ra állítjuk
|
||||
//if (isset($_user_value_array['uk_school_city_scc_id']) && $_user_value_array['uk_school_city_scc_id'] == '') $_user_value_array['uk_school_city_scc_id'] = 'null';
|
||||
//if (isset($_user_value_array['uk_school_city_scc_id']) && $_user_value_array['uk_school_city_scc_id'] == '') $_user_value_array['uk_school_city_scc_id'] = 'null';
|
||||
//$new_school_id = $sql->insert_into('school', array('sc_name' => $_user_value_array['add_school'], 'sc_school_city_scc_id' => $_user_value_array['uk_school_city_scc_id']));
|
||||
$new_school_id = school::create_school($_user_value_array['add_school'], $_user_value_array['uk_school_city_scc_id']);
|
||||
log::register('new_school', $new_school_id);
|
||||
@@ -354,7 +368,7 @@ class user_kid extends user_parent {
|
||||
$_user_value_array['parent_2_email'], $_user_value_array['parent_2_facebook'],
|
||||
$_user_value_array['parent_2_phone']);
|
||||
log::register('new_parent', $_user_value_array['uk_parent_2']);
|
||||
}
|
||||
}
|
||||
if (isset($_user_value_array['add_parent_2'])) 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']);
|
||||
@@ -387,13 +401,13 @@ class user_kid extends user_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']);
|
||||
log::register('new_parent', $_user_value_array['uk_parent_1']);
|
||||
log::register('new_parent', $_user_value_array['uk_parent_1']);
|
||||
}
|
||||
else {
|
||||
//meglévő szülő updatelése
|
||||
user_parent::update_parent(array(
|
||||
'up_email' => $_user_value_array['parent_1_email'],
|
||||
'up_facebook' => $_user_value_array['parent_1_facebook'],
|
||||
'up_facebook' => $_user_value_array['parent_1_facebook'],
|
||||
'up_phone' => $_user_value_array['parent_1_phone']), $_user_value_array['uk_parent_1']);
|
||||
|
||||
}
|
||||
@@ -408,13 +422,13 @@ class user_kid extends user_parent {
|
||||
$_user_value_array['parent_2_email'], $_user_value_array['parent_2_facebook'],
|
||||
$_user_value_array['parent_2_phone']);
|
||||
log::register('new_parent', $_user_value_array['uk_parent_2']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//meglévő szülő updatelése
|
||||
//var_dump($_user_value_array['uk_parent_2']);
|
||||
user_parent::update_parent(array(
|
||||
'up_email' => $_user_value_array['parent_2_email'],
|
||||
'up_facebook' => $_user_value_array['parent_2_facebook'],
|
||||
'up_facebook' => $_user_value_array['parent_2_facebook'],
|
||||
'up_phone' => $_user_value_array['parent_2_phone']), $_user_value_array['uk_parent_2']);
|
||||
|
||||
}
|
||||
@@ -501,12 +515,110 @@ class user_kid extends user_parent {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (isset($_de)) $sql->update_table('user_kid', (array('uk_balance' => $_de->get_de_balance())), array('uk_id' => (is_object($_user_obj)?$_user_obj->get_uk_id():$this->get_uk_id())), false);
|
||||
else $sql->update_table('user_kid', (array('uk_balance' => 0)), array('uk_id' => (is_object($_user_obj)?$_user_obj->get_uk_id():$this->get_uk_id())), false);
|
||||
|
||||
return $_de_obj_array;
|
||||
}
|
||||
|
||||
public function get_groups() {
|
||||
global $sql;
|
||||
|
||||
$group_array = array();
|
||||
$g_assoc = $sql->assoc_array("select * from user_group_kid join user_group on ug_id = ugk_user_group_ug_id where ug_is_automatic = 1 and ugk_user_kid_uk_id = ".$this->get_uk_id().";");
|
||||
|
||||
foreach ($g_assoc as $g) {
|
||||
$group = new user_group();
|
||||
$group->set_ug_data_by_id($g['ugk_user_group_ug_id']);
|
||||
$group_array[] = $group;
|
||||
}
|
||||
|
||||
return $group_array;
|
||||
}
|
||||
|
||||
public function update_filters() {
|
||||
global $sql;
|
||||
|
||||
//azok a csoportokban, amikben az user benne van
|
||||
$user_groups = $this->get_groups();
|
||||
|
||||
//az user csoportjainak ugfv-i; tömb[tömb]
|
||||
$my_ugfv_array = array();
|
||||
foreach ($user_groups as $user_group) {
|
||||
$ugfv = $user_group->get_user_group_filter_values();
|
||||
$no_falses = 0;
|
||||
$index = 0;
|
||||
foreach ($ugfv as $ugfv_obj) {
|
||||
//var_dump($ugfv_obj->is_intersect());
|
||||
if(!$ugfv_obj->is_user_filterable($this) && $ugfv_obj->is_intersect()) {
|
||||
//var_dump("DELETE FROM user_group_kid WHERE ugk_user_kid_uk_id = " . $this->get_uk_id() . " AND ugk_user_group_ug_id = " . $user_group->get_ug_id());
|
||||
$sql->execute_query("DELETE FROM user_group_kid WHERE ugk_user_kid_uk_id = " . $this->get_uk_id() . " AND ugk_user_group_ug_id = " . $user_group->get_ug_id());
|
||||
continue 2;
|
||||
}
|
||||
elseif (!$ugfv_obj->is_user_filterable($this) && !$ugfv_obj->is_intersect()) {
|
||||
//var_dump("DELETE FROM user_group_kid WHERE ugk_user_kid_uk_id = " . $this->get_uk_id() . " AND ugk_user_group_ug_id = " . $user_group->get_ug_id() . " AND ugfv_id = " . $ugfv_obj->get_ugfv_id());
|
||||
$sql->execute_query("DELETE FROM user_group_kid WHERE ugk_user_kid_uk_id = " . $this->get_uk_id() . " AND ugk_user_group_ug_id = " . $user_group->get_ug_id() . " AND ugfv_id = " . $ugfv_obj->get_ugfv_id());
|
||||
$no_falses++;
|
||||
}
|
||||
$index ++;
|
||||
}
|
||||
if($no_falses == $index) {
|
||||
//var_dump("DELETE FROM user_group_kid WHERE ugk_user_kid_uk_id = " . $this->get_uk_id() . " AND ugk_user_group_ug_id = " . $user_group->get_ug_id() . " AND ugfv_id = " . $this->get_ugfv_id());
|
||||
}
|
||||
}
|
||||
|
||||
//lekérni minden csoport (ami nem az előzőek egyike) minden filtervalue-ját, és megnézni, hogy beszűrné-e
|
||||
|
||||
//minden csoport, ami nem az előzőek
|
||||
$user_groups_assoc = $sql->assoc_array("select * from user_group where ug_id not in (select distinct ugk_user_group_ug_id from user_group_kid where ugk_user_kid_uk_id = ".$this->get_uk_id().") and ug_is_automatic = 1 and ug_deleted = 0;");
|
||||
|
||||
$user_groups = array();
|
||||
foreach ($user_groups_assoc as $ug) {
|
||||
$new_ug = new user_group();
|
||||
$new_ug->set_ug_data_by_id($ug['ug_id']);
|
||||
$user_groups[] = $new_ug;
|
||||
}
|
||||
|
||||
foreach ($user_groups as $user_group) {
|
||||
$ugfv = $user_group->get_user_group_filter_values();
|
||||
$no_success = 0;
|
||||
$index = 0;
|
||||
foreach ($ugfv as $ugfv_obj) {
|
||||
if($ugfv_obj->is_user_filterable($this) && !$ugfv_obj->is_intersect()) {
|
||||
$category_id = $sql->single_variable("SELECT ugc_id FROM user_group_category WHERE ugc_ugfv_id =" . $ugfv_obj->get_ugfv_id());
|
||||
//var_dump("INSERT INTO user_group_kid (ugk_user_kid_uk_id, ugk_user_group_ug_id, ugk_category_ugc_id) VALUES (".$this->get_uk_id().", ".$user_group->get_ug_id().", " . $category_id . ");");
|
||||
$sql->insert_into(
|
||||
'user_group_kid',
|
||||
array(
|
||||
'ugk_user_kid_uk_id' => $this->get_uk_id(),
|
||||
'ugk_user_group_ug_id' => $user_group->get_ug_id(),
|
||||
'ugk_category_ugc_id' => $category_id,
|
||||
'ugk_ugfv_id' => $ugfv_obj->get_ugfv_id()
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($ugfv_obj->is_user_filterable($this) && $ugfv_obj->is_intersect()) {
|
||||
$no_success++;
|
||||
|
||||
//continue 2;
|
||||
}
|
||||
$index ++;
|
||||
}
|
||||
if($no_success == $index) {
|
||||
//var_dump("INSERT INTO user_group_kid (ugk_user_kid_uk_id, ugk_user_group_ug_id) VALUES (".$this->get_uk_id().", ".$user_group->get_ug_id().");");
|
||||
//var_dump("INSERT INTO user_group_kid (ugk_user_kid_uk_id, ugk_user_group_ug_id) VALUES (".$this->get_uk_id().", ".$user_group->get_ug_id().");");
|
||||
$sql->insert_into(
|
||||
'user_group_kid',
|
||||
array(
|
||||
'ugk_user_kid_uk_id' => $this->get_uk_id(),
|
||||
'ugk_user_group_ug_id' => $user_group->get_ug_id(),
|
||||
'ugk_ugfv_id' => $ugfv_obj->get_ugfv_id()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user