minor fix notification direct assignment
Former-commit-id: 59ffb2338377ac2c3270681e6905f5d853add16b
This commit is contained in:
parent
bb83f4ba4a
commit
af110f4820
|
@ -356,49 +356,59 @@ function messages_get_count(
|
||||||
|
|
||||||
if (!empty($incl_read)) {
|
if (!empty($incl_read)) {
|
||||||
// Do not filter.
|
// Do not filter.
|
||||||
$read = '';
|
$read = ' 1=1 ';
|
||||||
} else {
|
} else {
|
||||||
// Retrieve only unread messages.
|
// Retrieve only unread messages.
|
||||||
$read = 'where t.read is null';
|
$read = ' t.read is null';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ignore_source === true) {
|
if ($ignore_source === true) {
|
||||||
|
$source_select = '';
|
||||||
$source_sql = '';
|
$source_sql = '';
|
||||||
|
$source_extra = '';
|
||||||
} else {
|
} else {
|
||||||
|
$source_select = ',IF(ns.user_editable,nsu.enabled,ns.enabled) as enabled';
|
||||||
|
|
||||||
|
// Row in tnotification_source_user could exist or not.
|
||||||
$source_sql = sprintf(
|
$source_sql = sprintf(
|
||||||
'INNER JOIN tnotification_source ns
|
'INNER JOIN (
|
||||||
ON tm.id_source = ns.id
|
tnotification_source ns
|
||||||
AND ns.enabled = 1
|
LEFT JOIN tnotification_source_user nsu
|
||||||
INNER JOIN tnotification_source_user nsu
|
ON ns.id=nsu.id_source
|
||||||
ON nsu.id_source=ns.id
|
AND nsu.id_user="test")
|
||||||
AND nsu.enabled = 1
|
ON tm.id_source=ns.id',
|
||||||
AND nsu.id_user = "%s"',
|
|
||||||
$user
|
$user
|
||||||
);
|
);
|
||||||
|
$source_extra = 'AND (t.enabled=1 OR t.enabled is null)';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = sprintf(
|
$sql = sprintf(
|
||||||
'SELECT count(*) FROM (
|
'SELECT count(*) as "n" FROM (
|
||||||
SELECT DISTINCT tm.*, utimestamp_read > 0 as "read"
|
SELECT
|
||||||
FROM tmensajes tm
|
tm.*,
|
||||||
%s
|
utimestamp_read > 0 as "read"
|
||||||
LEFT JOIN tnotification_user nu
|
%s
|
||||||
ON tm.id_mensaje=nu.id_mensaje
|
FROM tmensajes tm
|
||||||
AND nu.id_user="%s"
|
%s
|
||||||
LEFT JOIN (tnotification_group ng
|
LEFT JOIN tnotification_user nu
|
||||||
INNER JOIN tusuario_perfil up
|
ON tm.id_mensaje=nu.id_mensaje
|
||||||
ON ng.id_group=up.id_grupo
|
AND nu.id_user="%s"
|
||||||
AND up.id_grupo=ng.id_group
|
LEFT JOIN (tnotification_group ng
|
||||||
) ON tm.id_mensaje=ng.id_mensaje
|
INNER JOIN tusuario_perfil up
|
||||||
|
ON ng.id_group=up.id_grupo
|
||||||
|
AND up.id_grupo=ng.id_group)
|
||||||
|
ON tm.id_mensaje=ng.id_mensaje
|
||||||
WHERE utimestamp_erased is null
|
WHERE utimestamp_erased is null
|
||||||
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
|
AND (nu.id_user="%s" OR up.id_usuario="%s" OR ng.id_group=0)
|
||||||
) t
|
) t
|
||||||
%s',
|
WHERE %s %s',
|
||||||
|
$source_select,
|
||||||
$source_sql,
|
$source_sql,
|
||||||
$user,
|
$user,
|
||||||
$user,
|
$user,
|
||||||
$user,
|
$user,
|
||||||
$read
|
$read,
|
||||||
|
$source_extra
|
||||||
);
|
);
|
||||||
|
|
||||||
return (int) db_get_sql($sql);
|
return (int) db_get_sql($sql);
|
||||||
|
|
Loading…
Reference in New Issue