mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-04-08 18:55:09 +02:00
Merge branch 'ent-3673-bug-webchat-consola' into 'develop'
Modified jquery window function See merge request artica/pandorafms!2550
This commit is contained in:
commit
f08b5204c7
pandora_console
@ -617,16 +617,21 @@ function users_save_login()
|
||||
|
||||
$user_list = json_decode($user_list_json, true);
|
||||
if (empty($user_list)) {
|
||||
$user_list = [];
|
||||
}
|
||||
|
||||
if (isset($user_list[$config['id_user']])) {
|
||||
$user_list[$config['id_user']]['count']++;
|
||||
} else {
|
||||
$user_list[$config['id_user']] = [
|
||||
'name' => $user['fullname'],
|
||||
'count' => 1,
|
||||
];
|
||||
} else if (isset($user_list[$config['id_user']])) {
|
||||
$user_list[$config['id_user']] = [
|
||||
'name' => $user['fullname'],
|
||||
'count' => $user_list[$config['id_user']]['count'],
|
||||
];
|
||||
} else {
|
||||
$users_count = count($user_list);
|
||||
$user_list[$config['id_user']] = [
|
||||
'name' => $user['fullname'],
|
||||
'count' => ++$users_count,
|
||||
];
|
||||
}
|
||||
|
||||
// Clean the file
|
||||
@ -704,17 +709,7 @@ function users_save_logout($user=false, $delete=false)
|
||||
$user_list = [];
|
||||
}
|
||||
|
||||
if ($delete) {
|
||||
unset($user_list[$user['id_user']]);
|
||||
} else {
|
||||
if (isset($user_list[$config['id_user']])) {
|
||||
$user_list[$config['id_user']]['count']--;
|
||||
}
|
||||
|
||||
if ($user_list[$config['id_user']]['count'] <= 0) {
|
||||
unset($user_list[$user['id_user']]);
|
||||
}
|
||||
}
|
||||
unset($user_list[$user['id_user']]);
|
||||
|
||||
// Clean the file
|
||||
ftruncate($fp_user_list, 0);
|
||||
@ -1052,6 +1047,13 @@ function users_check_users()
|
||||
'users' => '',
|
||||
];
|
||||
|
||||
$users_with_session = db_get_all_rows_sql('SELECT tsessions_php.data FROM pandora.tsessions_php;');
|
||||
$users_logged_now = [];
|
||||
foreach ($users_with_session as $user_with_session) {
|
||||
$tmp_id_user = explode('"', $user_with_session['data']);
|
||||
array_push($users_logged_now, $tmp_id_user[1]);
|
||||
}
|
||||
|
||||
$file_global_user_list = $config['attachment_store'].'/pandora_chat.user_list.json.txt';
|
||||
|
||||
// First lock the file
|
||||
@ -1082,13 +1084,32 @@ function users_check_users()
|
||||
$user_list = [];
|
||||
}
|
||||
|
||||
fclose($fp_user_list);
|
||||
|
||||
// Compare both user list. Meanwhile the user from chat file have an active
|
||||
// session, his continue in the list of active chat users
|
||||
$user_name_list = [];
|
||||
foreach ($user_list as $user) {
|
||||
$user_name_list[] = $user['name'];
|
||||
foreach ($user_list as $key => $user) {
|
||||
if (in_array($key, $users_logged_now)) {
|
||||
array_push($user_name_list, $user['name']);
|
||||
} else {
|
||||
unset($user_list[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the file
|
||||
ftruncate($fp_user_list, 0);
|
||||
|
||||
// Update the file with the correct list of users
|
||||
$status = fwrite($fp_user_list, json_encode($user_list));
|
||||
|
||||
/*
|
||||
if ($status === false) {
|
||||
fclose($fp_user_list);
|
||||
|
||||
return;
|
||||
} */
|
||||
// Closing the resource
|
||||
fclose($fp_user_list);
|
||||
|
||||
$return['correct'] = true;
|
||||
$return['users'] = implode('<br />', $user_name_list);
|
||||
echo json_encode($return);
|
||||
|
@ -115,16 +115,16 @@ echo "<div style='width:100%'>".html_print_button(
|
||||
//Enter key.
|
||||
if (e.keyCode == 13) {
|
||||
send_message();
|
||||
check_users();
|
||||
}
|
||||
});
|
||||
|
||||
init_webchat();
|
||||
});
|
||||
|
||||
$(window).unload(function () {
|
||||
$(window).on("beforeunload",function () {
|
||||
exit_webchat();
|
||||
});
|
||||
|
||||
|
||||
function init_webchat() {
|
||||
send_login_message();
|
||||
long_polling_check_messages();
|
||||
|
Loading…
x
Reference in New Issue
Block a user