Dodaj obsługę zablokowanych kont użytkowników w widokach oraz aktualizuj zapytania SQL w klasach związanych z ogłoszeniami i firmami.

This commit is contained in:
2025-10-17 00:19:53 +02:00
parent 8d8d3b6174
commit dbe75c8e1b
6 changed files with 64 additions and 19 deletions

View File

@@ -413,8 +413,8 @@ class GlobelusAdverts
$sql = 'SELECT COUNT(0) '
. 'FROM ('
. 'SELECT '
. 'ga.id, title, title_nopl, date_add, gc.name AS country, gc.name_nopl AS country_nopl, ga.city, ga.city_nopl, firm_name_profile, firm_name_profile_nopl, gac.name AS category, text, text_nopl, visits, ga.user_id, ga.highlight, category_id, '
. 'ga.country_id, IF ( last_refresh IS NULL, date_add, last_refresh ) AS date_active, work_type, salary, without_language, without_experience, for_couples, from_now, outside_ue, without_driving_license, travel_refund, id_voivodeship '
. 'ga.id, title, title_nopl, date_add, gc.name AS country, gc.name_nopl AS country_nopl, ga.city, ga.city_nopl, firm_name_profile, firm_name_profile_nopl, gac.name AS category, text, text_nopl, ga.visits, ga.user_id, ga.highlight, category_id, '
. 'ga.country_id, IF ( ga.last_refresh IS NULL, date_add, ga.last_refresh ) AS date_active, ga.last_refresh, work_type, salary, without_language, without_experience, for_couples, from_now, outside_ue, without_driving_license, travel_refund, id_voivodeship '
. 'FROM '
. 'globelus_adverts AS ga '
. 'INNER JOIN globelus_countries AS gc ON gc.id = country_id ';
@@ -424,17 +424,22 @@ class GlobelusAdverts
$sql .= 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
. 'INNER JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
. 'WHERE '
. 'visible = 1 '
. 'ga.visible = 1 '
. 'AND '
. 'gu.status = 1 '
. 'AND '
. 'gu.blocked = 0 '
. 'AND '
. 'disabled_by_admin = 0 '
. 'AND '
. ' ( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
. ' ( ga.active_to >= \'' . date( 'Y-m-d' ) . '\' OR ga.active_to IS NULL ) '
. 'AND '
. '( '
. '( last_refresh IS NULL AND date_add >= \'' . date( 'Y-m-d H:i:s', strtotime( '-6 months', time() ) ) . '\' ) '
. '( ga.last_refresh IS NULL AND ga.date_add >= \'' . date( 'Y-m-d H:i:s', strtotime( '-6 months', time() ) ) . '\' ) '
. 'OR '
. '( last_refresh IS NOT NULL AND last_refresh >= \'' . date( 'Y-m-d', strtotime( '-6 months', time() ) ) . '\' ) '
. '( ga.last_refresh IS NOT NULL AND ga.last_refresh >= \'' . date( 'Y-m-d', strtotime( '-6 months', time() ) ) . '\' ) '
. ') '
. ') AS q1 '
. 'WHERE '
@@ -571,8 +576,8 @@ class GlobelusAdverts
$sql = 'SELECT * '
. 'FROM ('
. 'SELECT '
. 'ga.id, title, title_nopl, date_add, gc.name AS country, gc.name_nopl AS country_nopl, ga.city, ga.city_nopl, firm_name_profile, firm_name_profile_nopl, gac.name AS category, text, text_nopl, visits, ga.user_id, ga.highlight, category_id, '
. 'ga.country_id, IF ( last_refresh IS NULL, date_add, last_refresh ) AS date_active, last_refresh, work_type, salary, without_language, without_experience, for_couples, from_now, overtime, overtime_quantity, accommodation, accommodation_cost, '
. 'ga.id, title, title_nopl, date_add, gc.name AS country, gc.name_nopl AS country_nopl, ga.city, ga.city_nopl, firm_name_profile, firm_name_profile_nopl, gac.name AS category, text, text_nopl, ga.visits, ga.user_id, ga.highlight, category_id, '
. 'ga.country_id, IF ( ga.last_refresh IS NULL, date_add, ga.last_refresh ) AS date_active, ga.last_refresh, work_type, salary, without_language, without_experience, for_couples, from_now, overtime, overtime_quantity, accommodation, accommodation_cost, '
. 'travel_refund, outside_ue, without_driving_license, id_voivodeship '
. 'FROM '
. 'globelus_adverts AS ga '
@@ -583,13 +588,18 @@ class GlobelusAdverts
$sql .= 'INNER JOIN globelus_voivodeships AS gv ON gv.id = id_voivodeship ';
$sql .= 'INNER JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id '
. 'INNER JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
. 'INNER JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id '
. 'INNER JOIN globelus_users AS gu ON gu.id = ga.user_id '
. 'WHERE '
. 'visible = 1 '
. 'ga.visible = 1 '
. 'AND '
. 'gu.status = 1 '
. 'AND '
. 'gu.blocked = 0 '
. 'AND '
. 'disabled_by_admin = 0 '
. 'AND '
. ' ( active_to >= \'' . date( 'Y-m-d' ) . '\' OR active_to IS NULL ) '
. ' ( ga.active_to >= \'' . date( 'Y-m-d' ) . '\' OR ga.active_to IS NULL ) '
. ') AS q1 '
. 'WHERE '
. '1=1 '
@@ -597,7 +607,8 @@ class GlobelusAdverts
. 'ORDER BY '
. $order
. 'LIMIT ' . ( $values['start'] * $values['limit'] ) . ',' . $values['limit'];
// echo $sql;
// echo '%' . \S::seo( $values['keyword'], true ) . '%';
try
{
$results = $mdb -> query( $sql, [
@@ -622,14 +633,15 @@ class GlobelusAdverts
{
global $mdb;
$sql = 'SELECT
ga.id, title, ga.user_id, category_id, ga.country_id, ga.city, ga.region, text, contact_person, email, ga.phone, gfd.clauses,
ga.id, title, ga.user_id, category_id, ga.country_id, ga.city, ga.region, text, contact_person, ga.email, ga.phone, gfd.clauses,
gac.name AS category_name, gc.name AS country_name, gfd.firm_name_profile, date_add, salary, work_type, without_language,
without_experience, for_couples, from_now, accommodation, accommodation_cost, overtime, overtime_quantity, travel_refund,
outside_ue, without_driving_license, ga.old, ga.visible, id_voivodeship, aplication_link, id_position
outside_ue, without_driving_license, ga.old, ga.visible, id_voivodeship, aplication_link, id_position, gu.blocked
FROM globelus_adverts AS ga
LEFT JOIN globelus_adverts_categories AS gac ON gac.id = ga.category_id
LEFT JOIN globelus_countries AS gc ON gc.id = ga.country_id
LEFT JOIN globelus_firms_data AS gfd ON gfd.user_id = ga.user_id
LEFT JOIN globelus_users AS gu ON gu.id = ga.user_id
WHERE ga.id = :advert_id';
return $mdb -> query( $sql, [