5 bytes of progress

This commit is contained in:
rusefi 2020-05-06 16:27:01 -04:00
parent 3ee8e98427
commit d70109427a
5 changed files with 28 additions and 2 deletions

View File

@ -8,6 +8,7 @@ services:
- @request
- @template
- @user
- '@rusefi.web.utils'
tags:
- { name: event.listener }
rusefi.web.utils:

View File

@ -29,16 +29,22 @@ class listener implements EventSubscriberInterface
/** @var \phpbb\user */
protected $user;
/** @var \rusefi\web\service\utils */
protected $utils;
public function __construct(
\phpbb\config\config $config,
\phpbb\request\request $request,
\phpbb\template\template $template,
\phpbb\user $user)
\phpbb\user $user,
\rusefi\web\service\utils $utils
)
{
$this->config = $config;
$this->request = $request;
$this->template = $template;
$this->user = $user;
$this->utils = $utils;
}
/**
@ -112,6 +118,13 @@ class listener implements EventSubscriberInterface
*/
public function viewtopic_modify_post_row($event)
{
$user_id = $event['poster_id'];
$count_vehicles = $this->utils->count_vehicles($user_id);
$event['post_row'] = array_merge($event['post_row'],array(
'U_COUNT' => $count_vehicles,
));
}
public function profile_vehicles_list($event)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -62,6 +62,16 @@ class utils
setcookie('rusefi_token', $uid, time() + 365 * 24 * 60 * 60, '/', '.rusefi.com', true);
}
public function count_vehicles($user_id) {
$sql = 'SELECT count(*) as count
FROM ' . 'msqur_engines' . ' ' . 'WHERE user_id = ' . (int) $user_id;
$result = $this->db->sql_query($sql);
$data = $this->db->sql_fetchrow();
$this->db->sql_freeresult($result);
return $data['count'];
}
public function get_token($user_id)
{

View File

@ -1 +1,3 @@
.2
{% if postrow.U_COUNT %}
<img src="/forum/ext/rusefi/web/rusEFI_car.png"/>
{% endif %}