Pour chaque message édité après dernière lecture, le message passe en "non lu" (dans les icônes de forums, icônes de topics, recherche des "non lus", et recherches générales) il n'y a pas de changement sur l'index des forums pour ne pas alourdir, vu que le principal intérêt c'est surtout dans la recherche des messages "non lus" (notamment ds un but de modération en cas d'éditions abusives)
Donc ce mod en dev, vas s'attaquer à toutes les éditions de tous les messages (pas juste du dernier) donc au cœur de la vraie difficulté (c'est pour cela qu'aucun mod de ce type n'existe actuellement)Nb: ce mod a été fait suite a une discussion sur ce mod http://www.phpbb.com/customise/db/mod/m ... _as_unread qui a montré ses limites car contrairement à son titre il ne passe pas en "non lus" les messages édités
En effet dans ce mod le sujet passe en tant que "non lu" que lorsque c'est le dernier message du sujet qui est édité. Si on édite un des messages précédents le sujet ne sera pas passé en tant que "non lu". Et il le passe en "non lu" en simplifiant beaucoup, car il efface la date du post initial, par la date d'édition, ce qui en fait efface des informations utiles.
1) il faut créer un champs "topic_last_edit_time" (meme forme que "topic_last_post_time") dans la table "topics" de la base de donnée :
SQL
Code : Tout sélectionner
ALTER TABLE phpbb_topics ADD topic_last_edit_time int(11) DEFAULT '0' NOT NULL;
2) a chaque édition d'un message, nous enregistrons la date d'édition (dans "topic_last_edit_time" et "post_edit_time") :
dans includes/functions_posting.php :
trouver :
Code : Tout sélectionner
else if ($mode == 'edit')
{
$post_mode = ($data['topic_replies_real'] == 0) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit'));
}
// First of all make sure the subject and topic title are having the correct length.
Code : Tout sélectionner
else if ($mode == 'edit')
{
// Start Mod mark unread new edits
$sql_topic_last_edit_time = 'UPDATE ' . TOPICS_TABLE . '
SET topic_last_edit_time = ' . $current_time . '
WHERE topic_id = ' . $data['topic_id'];
$db->sql_query($sql_topic_last_edit_time);
$sql_post_last_edit_time = 'UPDATE ' . POSTS_TABLE . '
SET post_edit_time = ' . $current_time . '
WHERE post_id = ' . $data['post_id'];
$db->sql_query($sql_post_last_edit_time);
// End Mod mark unread new edits
$post_mode = ($data['topic_replies_real'] == 0) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit'));
}
// First of all make sure the subject and topic title are having the correct length.
dans viewtopic.php :
trouver :
Code : Tout sélectionner
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
Code : Tout sélectionner
// Start Mod mark unread new edits (voir le logo des messages en non lu lorsque les editions sont postérieures au dernier accès sujet)
// ligne originale remplacée : $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
if (isset($topic_tracking_info[$topic_id]) && $row['post_edit_time'] > $topic_tracking_info[$topic_id])
{
$post_unread = true;
}
else
{
$post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
}
// End Mod mark unread new edits
dans viewforum.php :
trouver :
Code : Tout sélectionner
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
Code : Tout sélectionner
// Start Mod mark unread new edits (voir l'icone de topic en non lu lorsque les editions sont postérieures au dernier accès sujet)
// ligne originale remplacée : $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
if (isset($topic_tracking_info[$topic_id]) && $row['topic_last_edit_time'] > $topic_tracking_info[$topic_id])
{
$unread_topic = true;
}
else
{
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
}
// End Mod mark unread new edits
dans search.php :
chercher :
Code : Tout sélectionner
$unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false;
Code : Tout sélectionner
// Start Mod mark unread new edits (voir le logo des messages en non lu lorsque dans les recherches)
// ligne originale remplacée : $unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false;
if (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_edit_time'] > $topic_tracking_info[$forum_id][$row['topic_id']])
{
$unread_topic = true;
}
else
{
$unread_topic = (isset($topic_tracking_info[$forum_id][$row['topic_id']]) && $row['topic_last_post_time'] > $topic_tracking_info[$forum_id][$row['topic_id']]) ? true : false;
}
// End Mod mark unread new edits
dans includes/functions.php :
chercher :
Code : Tout sélectionner
'SELECT' => 't.topic_id, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time',
Code : Tout sélectionner
'SELECT' => 't.topic_id, t.topic_last_edit_time, t.topic_last_post_time, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time',
Code : Tout sélectionner
(tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR
Code : Tout sélectionner
(tt.mark_time IS NOT NULL AND t.topic_last_edit_time > tt.mark_time) OR
(tt.mark_time IS NOT NULL AND t.topic_last_post_time > tt.mark_time) OR
dans viewtopic.php :
trouver :
Code : Tout sélectionner
if ($view == 'unread')
{
// Get topic tracking info
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
$topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;
$sql = 'SELECT post_id, topic_id, forum_id
FROM ' . POSTS_TABLE . "
WHERE topic_id = $topic_id
" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
AND post_time > $topic_last_read
AND forum_id = $forum_id
ORDER BY post_time ASC";
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
Code : Tout sélectionner
// Start Mod mark unread new edits (marquer les messages lus à la visite d'une edition non lue)
if ($config['load_db_lastread'] && $user->data['is_registered'])
{
$sql = 'UPDATE ' . TOPICS_TRACK_TABLE . "
SET mark_time = '" . time() . "'
WHERE user_id = '" . $user->data['user_id'] . "'
AND topic_id = '" . $topic_id ."'";
$db->sql_query($sql);
}
// End Mod mark unread new edits// Start Mod mark unread new edits (marquer les messages lus à la visite d'une edition non lue)
dans viewtopic.php :
trouver :
Code : Tout sélectionner
'S_UNREAD_POST' => $row['post_unread'] ? true : false,
Code : Tout sélectionner
// Start Mod mark unread new edits (affichage date d'édition)
'S_EDIT_UNREAD_POST' => $user->format_date($row['post_edit_time']),
// End Mod mark unread new edits
trouver :
Code : Tout sélectionner
<p class="author"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF -->{L_POST_BY_AUTHOR} <strong>{postrow.POST_AUTHOR_FULL}</strong> » {postrow.POST_DATE}</p>
Code : Tout sélectionner
<p class="author"><!-- IF S_IS_BOT -->{postrow.MINI_POST_IMG}<!-- ELSE --><a href="{postrow.U_MINI_POST}">{postrow.MINI_POST_IMG}</a><!-- ENDIF -->{L_POST_BY_AUTHOR} <strong>{postrow.POST_AUTHOR_FULL}</strong> » {postrow.POST_DATE} <!-- IF postrow.S_FIRST_UNREAD and U_MCP --><i>(édité le {postrow.S_EDIT_UNREAD_POST})</i><!-- ENDIF --></p>
