mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-08-15 23:08:44 +02:00
Added filter to get last messages by notification ball
Former-commit-id: 57619fe6cd46f3f723c5b2c3bdbe3aa9ba155a0c
This commit is contained in:
parent
e6dc69e3be
commit
a50a251b00
@ -411,6 +411,32 @@ config_check();
|
||||
element.style.display = "none"
|
||||
}
|
||||
|
||||
function check_new_notifications() {
|
||||
var last_id = document.getElementById('notification-ball-header')
|
||||
.getAttribute('last_id');
|
||||
if (last_id === null) {
|
||||
console.error('Cannot retrieve notifications ball last_id.');
|
||||
return;
|
||||
}
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "godmode/setup/setup_notifications",
|
||||
"check_new_notifications" : 1,
|
||||
"last_id": last_id
|
||||
},
|
||||
function (data, status) {
|
||||
// TODO
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.fail(function(xhr, textStatus, errorThrown){
|
||||
console.error(
|
||||
"Cannot get new notifications. Error: ",
|
||||
xhr.responseText
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Resize event
|
||||
window.addEventListener("resize", function() {
|
||||
attatch_to_image();
|
||||
@ -420,6 +446,10 @@ config_check();
|
||||
|
||||
var new_chat = <?php echo (int) $_SESSION['new_chat']; ?>;
|
||||
$(document).ready (function () {
|
||||
|
||||
// Check new notifications on a periodic way
|
||||
setInterval(check_new_notifications, 10000);
|
||||
|
||||
<?php
|
||||
if (($autorefresh_list !== null) && (array_search($_GET['sec2'], $autorefresh_list) !== false) && (!isset($_GET['refr']))) {
|
||||
$do_refresh = true;
|
||||
|
@ -94,6 +94,32 @@ if (get_parameter('update_config', 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_parameter('check_new_notifications', 0)) {
|
||||
$last_id_ui = (int) get_parameter('last_id', 0);
|
||||
$counters = notifications_get_counters();
|
||||
if ((int) $last_id_ui === (int) $counters['last_id']) {
|
||||
echo json_encode(['new_notifications' => []]);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is new messages, get the info.
|
||||
echo json_encode(
|
||||
[
|
||||
'notifications' => $counters['notifications'],
|
||||
'last_id' => $counters['last_id'],
|
||||
'new_notifications' => messages_get_overview(
|
||||
'timestamp',
|
||||
'ASC',
|
||||
false,
|
||||
true,
|
||||
0,
|
||||
['id_mensaje' => '>'.$last_id_ui]
|
||||
),
|
||||
]
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Notification table. It is just a wrapper.
|
||||
$table_content = new StdClass();
|
||||
$table_content->data = [];
|
||||
|
@ -426,7 +426,8 @@ function messages_get_overview(
|
||||
string $order_dir='ASC',
|
||||
bool $incl_read=true,
|
||||
bool $incl_source_info=false,
|
||||
int $limit=0
|
||||
int $limit=0,
|
||||
array $other_filter=[]
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -480,6 +481,7 @@ function messages_get_overview(
|
||||
AND (up.id_usuario="%s" OR nu.id_user="%s" OR ng.id_group=0)
|
||||
) t
|
||||
%s
|
||||
%s
|
||||
ORDER BY %s
|
||||
%s',
|
||||
$source_fields,
|
||||
@ -487,6 +489,7 @@ function messages_get_overview(
|
||||
$config['id_user'],
|
||||
$config['id_user'],
|
||||
$read,
|
||||
db_format_array_where_clause_sql($other_filter, 'AND', ' AND '),
|
||||
$order,
|
||||
($limit !== 0) ? ' LIMIT '.$limit : ''
|
||||
);
|
||||
|
@ -26,6 +26,8 @@
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
require_once $config['homedir'].'/include/functions_messages.php';
|
||||
|
||||
define('NOTIFICATIONS_POSTPONE_FOREVER', -1);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user