Ujednolicenie formatowania kodu w klasie GlobelusFirms poprzez usunięcie zbędnych spacji w deklaracjach funkcji i wywołaniach metod.
This commit is contained in:
@@ -6,32 +6,32 @@ class GlobelusFirms
|
||||
{
|
||||
const firm_list_limit = 12;
|
||||
|
||||
static public function is_user_advert( $user_id, $advert_id )
|
||||
static public function is_user_advert($user_id, $advert_id)
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> count( 'globelus_adverts', [ 'AND' => [ 'user_id' => $user_id, 'id' => $advert_id ] ] );
|
||||
return $mdb->count('globelus_adverts', ['AND' => ['user_id' => $user_id, 'id' => $advert_id]]);
|
||||
}
|
||||
|
||||
static public function proposed_candidates( $advert_id = null, $adverts )
|
||||
static public function proposed_candidates($advert_id = null, $adverts)
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( !$advert_id )
|
||||
if (!$advert_id)
|
||||
{
|
||||
foreach ( $adverts as $advert )
|
||||
foreach ($adverts as $advert)
|
||||
$advert_id[] = $advert['id'];
|
||||
}
|
||||
|
||||
$results = $mdb -> query( 'SELECT candidate_id, IF ( gu.last_refresh IS NULL, register_date, gu.last_refresh ) AS date_active FROM globelus_proposed_candidates AS gpc INNER JOIN globelus_candidates_data AS gcd ON gcd.user_id = gpc.candidate_id INNER JOIN globelus_users AS gu ON gcd.user_id = gu.id WHERE advert_id IN (' . implode( ',', array_merge( [ 0 ], $advert_id ) ) . ') ORDER BY date_active DESC' ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||
foreach ( $results as $row )
|
||||
$results = $mdb->query('SELECT candidate_id, IF ( gu.last_refresh IS NULL, register_date, gu.last_refresh ) AS date_active FROM globelus_proposed_candidates AS gpc INNER JOIN globelus_candidates_data AS gcd ON gcd.user_id = gpc.candidate_id INNER JOIN globelus_users AS gu ON gcd.user_id = gu.id WHERE advert_id IN (' . implode(',', array_merge([0], $advert_id)) . ') ORDER BY date_active DESC')->fetchAll(\PDO::FETCH_ASSOC);
|
||||
foreach ($results as $row)
|
||||
$candidates[] = $row['candidate_id'];
|
||||
return $candidates;
|
||||
}
|
||||
|
||||
static public function active_adverts_list( $user_id )
|
||||
static public function active_adverts_list($user_id)
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> select( 'globelus_adverts', [ 'id', 'title' ], [ 'AND' => [ 'user_id' => $user_id, 'visible' => 1 ], 'ORDER' => [ 'title' => 'ASC' ] ] );
|
||||
return $mdb->select('globelus_adverts', ['id', 'title'], ['AND' => ['user_id' => $user_id, 'visible' => 1], 'ORDER' => ['title' => 'ASC']]);
|
||||
}
|
||||
|
||||
public static function is_advert_visible($advert_id)
|
||||
@@ -215,8 +215,9 @@ class GlobelusFirms
|
||||
return $file_name = 'files/img_header/' . $img_header_hash[0] . '/' . $img_header_hash[1] . '/' . $img_header_hash;
|
||||
}
|
||||
|
||||
static public function img_top_url( $user_id ) {
|
||||
$img_top_hash = \front\factory\GlobelusFirms::img_header_hash( $user_id );
|
||||
static public function img_top_url($user_id)
|
||||
{
|
||||
$img_top_hash = \front\factory\GlobelusFirms::img_header_hash($user_id);
|
||||
return $file_name = 'files/img_header/' . $img_top_hash[0] . '/' . $img_top_hash[1] . '/' . $img_top_hash;
|
||||
}
|
||||
|
||||
@@ -662,54 +663,54 @@ class GlobelusFirms
|
||||
]);
|
||||
}
|
||||
|
||||
public static function advert_refresh( $advert_id, $user_id )
|
||||
public static function advert_refresh($advert_id, $user_id)
|
||||
{
|
||||
global $mdb, $globelus_settings;
|
||||
|
||||
$advert = \front\factory\GlobelusAdverts::advert_details( $advert_id );
|
||||
$advert = \front\factory\GlobelusAdverts::advert_details($advert_id);
|
||||
|
||||
if ( $advert['disabled_by_admin'] )
|
||||
if ($advert['disabled_by_admin'])
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b> zostało zablokowane przez administratora.</p>'
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> zostało zablokowane przez administratora.</p>'
|
||||
];
|
||||
|
||||
if ( !$advert['visible'] )
|
||||
if (!$advert['visible'])
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b> nie jest widoczne.</p>'
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> nie jest widoczne.</p>'
|
||||
];
|
||||
|
||||
$points = \front\factory\GlobelusFirms::get_firm_points( $user_id );
|
||||
$points = \front\factory\GlobelusFirms::get_firm_points($user_id);
|
||||
|
||||
if ( $points < $globelus_settings['pkt-odswiezenie-ogloszenia'] )
|
||||
if ($points < $globelus_settings['pkt-odswiezenie-ogloszenia'])
|
||||
{
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Nie masz wystarczającej ilości punktów, aby odświeżyć ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b>.</p>'
|
||||
'msg' => '<p>Nie masz wystarczającej ilości punktów, aby odświeżyć ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b>.</p>'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$last_refresh = \front\factory\GlobelusAdverts::last_refresh( $advert_id );
|
||||
$refresh_diff = \S::date_diff( date('Y-m-d H:i:s', strtotime($last_refresh)), date('Y-m-d H:i:s'), 60 * 60 * 24 );
|
||||
$last_refresh = \front\factory\GlobelusAdverts::last_refresh($advert_id);
|
||||
$refresh_diff = \S::date_diff(date('Y-m-d H:i:s', strtotime($last_refresh)), date('Y-m-d H:i:s'), 60 * 60 * 24);
|
||||
|
||||
if ( $refresh_diff < 1 )
|
||||
if ($refresh_diff < 1)
|
||||
{
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title( $advert_id ) . '<\/b> może być odświeżone raz na dobę.</p>'
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> może być odświeżone raz na dobę.</p>'
|
||||
];
|
||||
}
|
||||
|
||||
$mdb -> update( 'globelus_users', [ 'points[-]' => $globelus_settings['pkt-odswiezenie-ogloszenia'] ], [ 'id' => $user_id] );
|
||||
$mdb -> insert( 'globelus_points_history', [
|
||||
$mdb->update('globelus_users', ['points[-]' => $globelus_settings['pkt-odswiezenie-ogloszenia']], ['id' => $user_id]);
|
||||
$mdb->insert('globelus_points_history', [
|
||||
'user_id' => $user_id,
|
||||
'points' => $globelus_settings['pkt-odswiezenie-ogloszenia'],
|
||||
'event_type' => 3
|
||||
] );
|
||||
]);
|
||||
|
||||
if ( $mdb -> update( 'globelus_adverts', [ 'last_refresh' => date('Y-m-d H:i:s'), 'refresh_count[+]' => 1 ], [ 'AND' => [ 'id' => $advert_id, 'user_id' => $user_id ] ] ) )
|
||||
if ($mdb->update('globelus_adverts', ['last_refresh' => date('Y-m-d H:i:s'), 'refresh_count[+]' => 1], ['AND' => ['id' => $advert_id, 'user_id' => $user_id]]))
|
||||
{
|
||||
\S::log($user_id, __METHOD__, [0 => ['points' => $points, 'advert_id' => $advert_id, 'refresh_diff' => $refresh_diff]]);
|
||||
return [
|
||||
@@ -950,12 +951,6 @@ class GlobelusFirms
|
||||
{
|
||||
global $mdb, $lang, $settings, $globelus_settings;
|
||||
|
||||
// if ($mdb->get('globelus_adverts', 'old', ['id' => $advert_id]))
|
||||
// return [
|
||||
// 'result' => false,
|
||||
// 'msg' => '<p>Nie możesz opublikować ogłoszenia <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> ponieważ <b>ma ono ponad 90 dni<\/b>.</p>'
|
||||
// ];
|
||||
|
||||
if (\front\factory\GlobelusFirms::adverts_count($user_id) > $globelus_settings['limit-ogloszen'] and \front\factory\GlobelusFirms::get_firm_points($user_id) < $globelus_settings['pkt-dodanie-ogloszenia-powyzej-limitu'])
|
||||
return false;
|
||||
|
||||
@@ -965,7 +960,7 @@ class GlobelusFirms
|
||||
$highlight = $mdb->get('globelus_adverts', 'highlight', ['AND' => ['user_id' => $user_id, 'id' => $advert_id]]);
|
||||
$main_page = $mdb->get('globelus_adverts', 'main_page', ['AND' => ['user_id' => $user_id, 'id' => $advert_id]]);
|
||||
|
||||
if ( $globelus_settings['maile-wysylanie'] )
|
||||
if ($globelus_settings['maile-wysylanie'])
|
||||
{
|
||||
$text = $settings['newsletter_header'];
|
||||
$text .= \front\factory\Newsletter::get_template('#potwierdzenie-dodania-ogloszenia');
|
||||
@@ -988,15 +983,15 @@ class GlobelusFirms
|
||||
}
|
||||
}
|
||||
|
||||
if ($mdb->get('globelus_adverts', 'visible', ['id' => $advert_id]))
|
||||
if ( $mdb -> get('globelus_adverts', 'visible', [ 'id' => $advert_id ] ) )
|
||||
return [
|
||||
'result' => false,
|
||||
'msg' => '<p>Ogłoszenie <b>' . \front\factory\GlobelusAdverts::advert_title($advert_id) . '<\/b> jest już widoczne.</p>'
|
||||
];
|
||||
|
||||
if ( $mdb -> update('globelus_adverts', ['visible' => 1, 'mail_expired' => 0 ], ['AND' => ['user_id' => $user_id, 'id' => $advert_id]]))
|
||||
if ( $mdb -> update( 'globelus_adverts', [ 'visible' => 1, 'mail_expired' => 0, 'last_refresh' => date('Y-m-d H:i:s') ] , [ 'AND' => ['user_id' => $user_id, 'id' => $advert_id]]))
|
||||
{
|
||||
if ( \front\factory\GlobelusFirms::adverts_count($user_id) > $globelus_settings['limit-ogloszen'] and \front\factory\GlobelusFirms::get_firm_points($user_id) >= $globelus_settings['pkt-dodanie-ogloszenia-powyzej-limitu'] )
|
||||
if (\front\factory\GlobelusFirms::adverts_count($user_id) > $globelus_settings['limit-ogloszen'] and \front\factory\GlobelusFirms::get_firm_points($user_id) >= $globelus_settings['pkt-dodanie-ogloszenia-powyzej-limitu'])
|
||||
{
|
||||
$mdb->update('globelus_users', ['points[-]' => $globelus_settings['pkt-dodanie-ogloszenia-powyzej-limitu']], ['id' => $user_id]);
|
||||
$mdb->insert('globelus_points_history', [
|
||||
@@ -1006,9 +1001,9 @@ class GlobelusFirms
|
||||
]);
|
||||
}
|
||||
|
||||
if ( $mdb -> get( 'globelus_adverts', 'old', [ 'id' => $advert_id ] ) )
|
||||
if ($mdb->get('globelus_adverts', 'old', ['id' => $advert_id]))
|
||||
{
|
||||
$mdb->update('globelus_adverts', [ 'old' => 0, 'active_to' => date( 'Y-m-d', strtotime('+' . $globelus_settings['ogloszenie-ilosc-dni-waznosci'] . ' days', time())), 'date_add' => date( 'Y-m-d H:i:s' ), 'last_refresh' => date( 'Y-m-d H:i:s' ) ], [ 'id' => $advert_id ]);
|
||||
$mdb->update('globelus_adverts', ['old' => 0, 'active_to' => date('Y-m-d', strtotime('+' . $globelus_settings['ogloszenie-ilosc-dni-waznosci'] . ' days', time())), 'date_add' => date('Y-m-d H:i:s'), 'last_refresh' => date('Y-m-d H:i:s')], ['id' => $advert_id]);
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -1047,7 +1042,7 @@ class GlobelusFirms
|
||||
];
|
||||
}
|
||||
|
||||
static public function advert_save($values, $id_voivodeship, $aplication_link, $advert_add_img_bottom, $advert_add_img_top, $id_position = null )
|
||||
static public function advert_save($values, $id_voivodeship, $aplication_link, $advert_add_img_bottom, $advert_add_img_top, $id_position = null)
|
||||
{
|
||||
global $mdb, $globelus_settings, $lang;
|
||||
|
||||
@@ -1067,7 +1062,7 @@ class GlobelusFirms
|
||||
'id_position' => $id_position ? $id_position : null,
|
||||
'city' => $values['city'],
|
||||
'region' => $values['region'],
|
||||
'text' => \S::clear_advert_text( $values['text'] ),
|
||||
'text' => \S::clear_advert_text($values['text']),
|
||||
'contact_person' => $values['contact_person'],
|
||||
'email' => $values['email'],
|
||||
'phone' => $values['phone'],
|
||||
@@ -1104,7 +1099,7 @@ class GlobelusFirms
|
||||
'id_position' => $id_position ? $id_position : null,
|
||||
'city' => $values['city'],
|
||||
'region' => $values['region'],
|
||||
'text' => \S::clear_advert_text( $values['text'] ),
|
||||
'text' => \S::clear_advert_text($values['text']),
|
||||
'contact_person' => $values['contact_person'],
|
||||
'email' => $values['email'],
|
||||
'phone' => $values['phone'],
|
||||
@@ -1129,7 +1124,7 @@ class GlobelusFirms
|
||||
]
|
||||
]);
|
||||
|
||||
if ( $mdb ->get('globelus_adverts', 'old', ['AND' => ['id' => $values['advert_id'], 'user_id' => $values['user_id']]]))
|
||||
if ($mdb->get('globelus_adverts', 'old', ['AND' => ['id' => $values['advert_id'], 'user_id' => $values['user_id']]]))
|
||||
{
|
||||
$mdb->update('globelus_adverts', [
|
||||
'old' => 0,
|
||||
@@ -1162,14 +1157,14 @@ class GlobelusFirms
|
||||
|
||||
$advert_add_img_top_error = false;
|
||||
|
||||
if ( $advert_add_img_top['tmp_name'] and $advert_add_img_top["size"] > 1048576 )
|
||||
if ($advert_add_img_top['tmp_name'] and $advert_add_img_top["size"] > 1048576)
|
||||
{
|
||||
\S::set_alert_prompt('Informacja', $lang['plik-logo-jest-zbyt-duzy']);
|
||||
$advert_add_img_top_error = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $advert_add_img_top['tmp_name'] and !$advert_add_img_top_error and !in_array($advert_add_img_top["type"], $allowed_mime_types_advert_top ) )
|
||||
if ($advert_add_img_top['tmp_name'] and !$advert_add_img_top_error and !in_array($advert_add_img_top["type"], $allowed_mime_types_advert_top))
|
||||
{
|
||||
\S::set_alert_prompt('Informacja', $lang['logo-niedozwolony-format-pliku']);
|
||||
return false;
|
||||
@@ -1181,7 +1176,8 @@ class GlobelusFirms
|
||||
list($width, $height) = getimagesize($advert_add_img_top['tmp_name']);
|
||||
$ratio = $width / $height;
|
||||
|
||||
if ($ratio < 2.6667 || $ratio > 8.0) {
|
||||
if ($ratio < 2.6667 || $ratio > 8.0)
|
||||
{
|
||||
\S::set_alert_prompt('Informacja', 'Obrazek górny ma nieprawidłowe proporcje. Dozwolony zakres to od 2.66:1 do 8:1.');
|
||||
return false;
|
||||
}
|
||||
@@ -1224,7 +1220,8 @@ class GlobelusFirms
|
||||
list($width, $height) = getimagesize($advert_add_img_bottom['tmp_name']);
|
||||
$ratio = $width / $height;
|
||||
|
||||
if ($ratio < 2.6667 || $ratio > 8.0) {
|
||||
if ($ratio < 2.6667 || $ratio > 8.0)
|
||||
{
|
||||
\S::set_alert_prompt('Informacja', 'Obrazek dolny ma nieprawidłowe proporcje. Dozwolony zakres to od 2.66:1 do 8:1.');
|
||||
return false;
|
||||
}
|
||||
@@ -1243,7 +1240,7 @@ class GlobelusFirms
|
||||
$mdb->update('globelus_adverts', ['advert_add_img_bottom' => $file_ext], ['id' => $advert_id]);
|
||||
}
|
||||
|
||||
if ( $advert_id )
|
||||
if ($advert_id)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user