FluxBB.fr

Le site des utilisateurs francophones de FluxBB.

Recherche rapide

Vous n'êtes pas identifié(e).

Version 1.4.13 : [.tar.gz][.zip] (maj 20/10/2014)
Pack langue française pour 1.4.x : [.zip] (maj 06/01/2012)

Branche 1.5.x : fluxbb.org
Pack langue française pour 1.5.x : [.zip] (maj 14/01/2016)

Ancienne Version 1.2.24 fr : [.zip] (maj 26/08/2011)

Vous avez un problème ?
Avant de poser votre question sur les forums d'entraide nous vous invitons à consulter :

#1 14-10-2012 16:47:08

PascL
Habitué très actif
Inscription : 06-09-2007
Messages : 554
Site Web

[Mod] Système de messages non lus similaire à phpbb

Bonjour,

J'en ai parlé sur ce topic précédemment.

Le but de cette mod est de remplacer le système natif de fluxbb par un système similaire à celui de phpBB (de la v3.0.10), c'est-à-dire:

  • Ne pas gérer les messages non lus à partir de la date de dernière visite

  • Par conséquent, laisser non lues les discussions que l'on ne visite pas même après N visites/N jours/N mois

  • Si on ne les visite pas mais qu'on souhaite les afficher non lues, il est toujours possible de marquer comme lu l'intégralité d'un seul forum, ou de tous les forums (pas prévu pour une discussion unique)

Pour cela, il y a 1 champ supplémentaire dans la table users, et 2 tables supplémentaires. Voici le contenu du fichier update_db.php pour créer cela:

<?php

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';

// Nouveau champ dans la table users
$req = 'ALTER TABLE '.$db->prefix.'users ADD user_lastmark INT(10) UNSIGNED NOT NULL DEFAULT \'0\'';
$db->query($req) or error('errA', __FILE__, __LINE__, $db->error());

/** Mise à jour des utilisateurs actuels.
  * Les discussions après leur dernière visite seront considérés comme non lus.
  * Beaucoup d'utilisateurs = potentiellement ça peut être long
  * Sans cette mise à jour, toutes les discussions seraient considérées non lues pour tout le monde
  */      
$req = 'SELECT id, last_visit FROM '.$db->prefix.'users ORDER BY id ASC';
$result = $db->query($req) or error('errB', __FILE__, __LINE__, $db->error());
while($data = $db->fetch_assoc($result))
{
	$req = 'UPDATE '.$db->prefix.'users SET user_lastmark='.$data['last_visit'].' WHERE id='.$data['id'];
	$db->query($req) or error('errC', __FILE__, __LINE__, $db->error());
}

// Nouvelle table track_forums
$req = 'CREATE TABLE IF NOT EXISTS '.$db->prefix.'track_forums (user_id int(10) unsigned NOT NULL DEFAULT \'0\', forum_id int(10) unsigned NOT NULL DEFAULT \'0\', mark_time int(10) unsigned NOT NULL DEFAULT \'0\', PRIMARY KEY (user_id, forum_id)) ENGINE=MyISAM DEFAULT CHARSET=latin1';
$db->query($req) or error('errD', __FILE__, __LINE__, $db->error());

// Nouvelle table track_topics
$req = 'CREATE TABLE IF NOT EXISTS '.$db->prefix.'track_topics (user_id int(10) unsigned NOT NULL DEFAULT \'0\', topic_id int(10) unsigned NOT NULL DEFAULT \'0\', forum_id int(10) unsigned NOT NULL DEFAULT \'0\', mark_time int(10) unsigned NOT NULL DEFAULT \'0\', PRIMARY KEY (user_id, topic_id), KEY topic_id (topic_id), KEY forum_id (forum_id)) ENGINE=MyISAM DEFAULT CHARSET=latin1';
$db->query($req) or error('errE', __FILE__, __LINE__, $db->error());

Et voilà les changements à effectuer dans les fichiers (les lignes indiquées sont les lignes d'un fluxbb1.2.24 vierge):

include/functions.php

à la fin du fichier, ajouter:
include('functions_markread.php');

include/functions_markread.php (fichier à créer avec ce code-là):

<?php
/**
*
* based on phpBB 3.0.10
* modified for FluxBB 1.2.24
* by PascL [Kokoala2k3@Free.Fr]
* created 2012 08 19 (YYYY MM DD)
*
*/

$arr_modlang = array();
$arr_modlang[0] = 'Erreur 01. In markread(\'all\') request 1.';
$arr_modlang[1] = 'Erreur 02. In markread(\'all\') request 2.';
$arr_modlang[2] = 'Erreur 03. In markread(\'all\') request 3.';
$arr_modlang[3] = 'Erreur 04. In markread(\'topics\') request 1.';
$arr_modlang[4] = 'Erreur 05. In markread(\'topics\') request 2.';
$arr_modlang[5] = 'Erreur 06. In markread(\'topics\') request 3.';
$arr_modlang[6] = 'Erreur 07. In markread(\'topics\') request 4.';
$arr_modlang[7] = 'Erreur 08. In markread(\'topic\') request 1.';
$arr_modlang[8] = 'Erreur 09. In markread(\'topic\') request 2.';
$arr_modlang[9] = 'Erreur 10. In get_unread_topics request 1.';
$arr_modlang[10] = 'Erreur 11. In get_unread_forums request 1.';
$arr_modlang[11] = 'Erreur 12. In update_forum_tracking_info request 1.';


/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

function markread($mode, $forum_id = false, $topic_id = false, $post_time = 0)
{
	global $db, $pun_user;
	global $arr_modlang;
	
	$now = time();

	if($mode == 'all')
	{
		if($forum_id === false)
		{
			if(!$pun_user['is_guest'])
			{
				// Mark all forums read (index page)
				$db->query('DELETE FROM '.$db->prefix.'track_topics WHERE user_id='.$pun_user['id']) or error($arr_modlang[0], __FILE__, __LINE__, $db->error());
				$db->query('DELETE FROM '.$db->prefix.'track_forums WHERE user_id='.$pun_user['id']) or error($arr_modlang[1], __FILE__, __LINE__, $db->error());
				$db->query('UPDATE '.$db->prefix.'users SET user_lastmark='.$now.' WHERE id='.$pun_user['id']) or error($arr_modlang[2], __FILE__, __LINE__, $db->error());
			}
		}
		return;
	}
	else
	if($mode == 'topics')
	{
		// Mark all topics in forums read
		if(!is_array($forum_id))
		{
			$forum_id = array($forum_id);
		}

		// Add 0 to forums array to mark global announcements correctly
		// $forum_id[] = 0;

		if(!$pun_user['is_guest'])
		{
			$sql = 'DELETE FROM '.$db->prefix.'track_topics WHERE user_id='.$pun_user['id'].' AND forum_id IN('.implode(', ',$forum_id).')';
			$db->query($sql) or error($arr_modlang[3], __FILE__, __LINE__, $db->error());

			$sql = 'SELECT forum_id FROM '.$db->prefix.'track_forums WHERE user_id='.$pun_user['id'].' AND forum_id IN('.implode(', ',$forum_id).')';
			$result = $db->query($sql) or error($arr_modlang[4], __FILE__, __LINE__, $db->error());

			$sql_update = array();
			while($row = $db->fetch_assoc($result))
			{
				$sql_update[] = (int) $row['forum_id'];
			}

			if($sql_update != null)
			{
				$sql = 'UPDATE '.$db->prefix.'track_forums SET mark_time='.$now.' WHERE user_id='.$pun_user['id'].' AND forum_id IN('.implode(', ',$sql_update).')';
				$db->query($sql) or error($arr_modlang[5], __FILE__, __LINE__, $db->error());
			}

			if ($sql_insert = array_diff($forum_id, $sql_update))
			{
				foreach ($sql_insert as $f_id)
				{
					$sql = 'INSERT INTO '.$db->prefix.'track_forums (user_id, forum_id, mark_time) VALUES ('.$pun_user['id'].', '.$f_id.', '.$now.')';
					$db->query($sql) or error($arr_modlang[6], __FILE__, __LINE__, $db->error());
				}
			}
		}
		
		return;
	}
	else if ($mode == 'topic')
	{
		if ($topic_id === false || $forum_id === false)
		{
			return;
		}

		if(!$pun_user['is_guest'])
		{
			$mytime = ($post_time) ? $post_time : $now;
			$sql = 'UPDATE '.$db->prefix.'track_topics SET mark_time='.$mytime.' WHERE user_id='.$pun_user['id'].' AND topic_id='.$topic_id;
			$db->query($sql) or error($arr_modlang[7], __FILE__, __LINE__, $db->error());

			// insert row
			if (!$db->affected_rows())
			{
				$sql = 'INSERT INTO '.$db->prefix.'track_topics (user_id, topic_id, forum_id, mark_time) VALUES ('.$pun_user['id'].', '.$topic_id.', '.$forum_id.', '.$mytime.')';
				$db->query($sql) or error($arr_modlang[8], __FILE__, __LINE__, $db->error());
			}
		}
		return;
	}
}

function get_topic_tracking($forum_id, $topic_ids, &$rowset, $forum_mark_time)
{
	global $pun_user;

	$last_read = array();

	if (!is_array($topic_ids))
	{
		$topic_ids = array($topic_ids);
	}

	foreach ($topic_ids as $topic_id)
	{
		if (!empty($rowset[$topic_id]['mark_time']))
		{
			$last_read[$topic_id] = $rowset[$topic_id]['mark_time'];
		}
	}

	$topic_ids = array_diff($topic_ids, array_keys($last_read));

	if (sizeof($topic_ids))
	{
		$mark_time = array();

		if (!empty($forum_mark_time[$forum_id]) && $forum_mark_time[$forum_id] !== false)
		{
			$mark_time[$forum_id] = $forum_mark_time[$forum_id];
		}

		$user_lastmark = (isset($mark_time[$forum_id])) ? $mark_time[$forum_id] : $pun_user['user_lastmark'];

		foreach ($topic_ids as $topic_id)
		{
			$last_read[$topic_id] = $user_lastmark;
		}
	}

	return $last_read;
}

function forum_is_new($forum_id)
{	
	global $new_forums;
	
	return isset($new_forums[$forum_id]);
}

function topic_is_new($topic_id)
{
	global $new_topics;
	
	return isset($new_topics[$topic_id]);
}

function get_unread_topics($user_id = false, $return_query = true, $forum_ids = 0, $sql_extra = '', $sql_sort = '', $sql_limit = 666, $sql_limit_offset = 0)
{
	global $db, $pun_user;
	global $arr_modlang;

	$user_id = ($user_id === false) ? $pun_user['id'] : $user_id;
	
	$sql_where_forum_extra = '';
	
	if (!is_array($forum_ids))
	{
		if($forum_ids != 0)
		{
			$forum_ids = array($forum_ids);
			$sql_where_forum_extra = ' AND t.forum_id IN ('.implode(', ', $forum_ids).')';
		}
	}
	else
	{
		$sql_where_forum_extra = ' AND t.forum_id IN ('.implode(', ', $forum_ids).')';
	}

	// Data array we're going to return
	$unread_topics = array();
	
	if (empty($sql_sort))
	{
		$sql_sort = 'ORDER BY t.last_post DESC';
	}

	if(!$pun_user['is_guest'])
	{
		// Get list of the unread topics
		$last_mark = $pun_user['user_lastmark'];

		$sql = 'SELECT t.id, t.forum_id, t.last_post, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time';
		$sql .= ' FROM '.$db->prefix.'topics AS t';
		$sql .= ' INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')';
		$sql .= ' LEFT JOIN '.$db->prefix.'track_topics AS tt ON tt.user_id='.$user_id.' AND t.id=tt.topic_id';
		$sql .= ' LEFT JOIN '.$db->prefix.'track_forums AS ft ON ft.user_id='.$user_id.' AND t.forum_id=ft.forum_id';
		$sql .= ' WHERE t.last_post>'.$last_mark;
		$sql .= ' AND (fp.read_forum IS NULL OR fp.read_forum=1)';
		$sql .= ' AND t.moved_to IS NULL';
		$sql .= ' AND ((tt.mark_time IS NOT NULL AND t.last_post > tt.mark_time) OR (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.last_post > ft.mark_time) OR (tt.mark_time IS NULL AND ft.mark_time IS NULL))';
		$sql .= ' '.$sql_where_forum_extra;
		$sql .= ' '.$sql_extra;
		$sql .= ' '.$sql_sort;
		$sql .= ' LIMIT '.$sql_limit_offset.', '.$sql_limit;

		$result = $db->query($sql) or error($arr_modlang[9], __FILE__, __LINE__, $db->error());
		
		if($return_query)
		{
			return $result;
		}

		while ($row = $db->fetch_assoc($result))
		{
			$topic_id = (int) $row['id'];
			$unread_topics[$topic_id] = ($row['topic_mark_time']) ? (int) $row['topic_mark_time'] : (($row['forum_mark_time']) ? (int) $row['forum_mark_time'] : $last_mark);
		}
	}
	return $unread_topics;
}

function get_unread_forums($user_id = false, $return_query = true, $sql_extra = '', $sql_sort = '', $sql_limit = 666, $sql_limit_offset = 0)
{
	global $db, $pun_user;
	global $arr_modlang;

	$user_id = ($user_id === false) ? $pun_user['id'] : $user_id;

	// Data array we're going to return
	$unread_forums = array();

	if (empty($sql_sort))
	{
		$sql_sort = 'ORDER BY t.last_post DESC';
	}

	if(!$pun_user['is_guest'])
	{
		// Get list of the unread topics
		$last_mark = $pun_user['user_lastmark'];

		$sql = 'SELECT DISTINCT t.forum_id, t.id, t.last_post, tt.mark_time as topic_mark_time, ft.mark_time as forum_mark_time';
		$sql .= ' FROM '.$db->prefix.'topics AS t';
		$sql .= ' INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')';
		$sql .= ' LEFT JOIN '.$db->prefix.'track_topics AS tt ON tt.user_id='.$user_id.' AND t.id=tt.topic_id';
		$sql .= ' LEFT JOIN '.$db->prefix.'track_forums AS ft ON ft.user_id='.$user_id.' AND t.forum_id=ft.forum_id';
		$sql .= ' WHERE t.last_post>'.$last_mark;
		$sql .= ' AND (fp.read_forum IS NULL OR fp.read_forum=1)';
		$sql .= ' AND t.moved_to IS NULL';
		$sql .= ' AND ((tt.mark_time IS NOT NULL AND t.last_post > tt.mark_time) OR (tt.mark_time IS NULL AND ft.mark_time IS NOT NULL AND t.last_post > ft.mark_time) OR (tt.mark_time IS NULL AND ft.mark_time IS NULL))';
		$sql .= $sql_extra;
		$sql .= $sql_sort;
		$sql .= ' LIMIT '.$sql_limit_offset.', '.$sql_limit;

		$result = $db->query($sql) or error($arr_modlang[10], __FILE__, __LINE__, $db->error());
		
		if($return_query)
		{
			return $result;
		}

		while ($row = $db->fetch_assoc($result))
		{
			$forum_id = (int) $row['forum_id'];
			$unread_forums[$forum_id] = 1;
		}
		
	}
	return $unread_forums;
}

function update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time = false, $mark_time_forum = false)
{
	global $db, $tracking_topics, $pun_user;
	global $arr_modlang;

	// Determine the users last forum mark time if not given.
	if ($mark_time_forum === false)
	{
		if(!$pun_user['is_guest'])
		{
			$mark_time_forum = (!empty($f_mark_time)) ? $f_mark_time : $pun_user['user_lastmark'];
		}
	}

	// Check the forum for any left unread topics.
	// If there are none, we mark the forum as read.
	if(!$pun_user['is_guest'])
	{
		if ($mark_time_forum >= $forum_last_post_time)
		{
			// We do not need to mark read, this happened before. Therefore setting this to true
			$row = true;
		}
		else
		{
			$sql = 'SELECT t.forum_id FROM '.$db->prefix.'topics AS t
				LEFT JOIN '.$db->prefix.'track_topics AS tt ON (tt.topic_id=t.id AND tt.user_id='.$pun_user['id'].')
				WHERE t.forum_id = ' . $forum_id . '
					AND t.last_post > ' . $mark_time_forum . '
					AND t.moved_to IS NULL ' . '
					AND (tt.topic_id IS NULL OR tt.mark_time < t.last_post)
				GROUP BY t.forum_id
						LIMIT 1';
			$result = $db->query($sql) or error($arr_modlang[11], __FILE__, __LINE__, $db->error());
			$row = $db->fetch_assoc($result);
		}
	}
	else
	{
		$row = true;
	}

	if (!$row)
	{
		markread('topics', $forum_id);
		return true;
	}

	return false;
}

lang/French/common.php

chercher L127:
'Show new posts'		=>	'Afficher les nouveaux messages depuis la dernière visite',
remplacer:
'Show new posts'		=>	'Afficher les messages depuis la dernière visite',
'Show unread posts'		=>	'Afficher les messages non lus',
'Mark forum as read'		=>	'Marquer toutes les discussions de ce forum comme lues',

footer.php

chercher L54:
      echo "\t\t\t\t".'<dd><a href="search.php?action=show_unanswered">'.$lang_common['Show unanswered posts'].'</a></dd>'."\n";
ajouter après:
      echo "\t\t\t\t".'<dd><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></dd>'."\n";
      echo "\t\t\t\t".'<dd><a href="search.php?action=show_unread">'.$lang_common['Show unread posts'].'</a></dd>'."\n";

chercher L74:
// Display the "Jump to" drop list
ajouter avant:
  if($footer_style == 'viewforum')
  {
    echo "\n\t\t\t".'<dl id="searchlinks" class="conl">'."\n\t\t\t\t".'<dt><strong>'.$lang_common['Search links'].'</strong></dt>'."\n\t\t\t\t".'<dd><a href="misc.php?action=markforumread&id='.$id.'">'.$lang_common['Mark forum as read'].'</a></dd>'."\n\t\t\t".'</dl>'."\n";
    echo "\n\t\t\t".'<div class="clearer"></div>'."\n";
  }

header.php

chercher L189:
$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
remplacer:
$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_unread">'.$lang_common['Show unread posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';

index.php

chercher L41:
// Print the categories and forums
ajouter avant:
$new_forums = get_unread_forums($pun_user['id'], false);

chercher L82:
if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'])
remplacer:
if (!$pun_user['is_guest'] && forum_is_new($cur_forum['fid']))

misc.php

chercher L67:
$db->query('UPDATE '.$db->prefix.'users SET last_visit='.$pun_user['logged'].' WHERE id='.$pun_user['id']) or error('Unable to update user last visit data', __FILE__, __LINE__, $db->error());
remplacer:
markread('all');

chercher L73:
else if (isset($_GET['email']))
ajouter avant:
else if ($action == 'markforumread')
{
	$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
	if ($pun_user['is_guest'])
		message($lang_common['No permission']);
	if ($id < 1)
		message($lang_common['Bad request']);

	markread('topics', $id);
	
	redirect('viewforum.php?id='.$id, $lang_misc['Mark forum read redirect']);
}

moderate.php

chercher L310:
// Should we create redirect topics?
ajouter avant:
    // Track topics
		$db->query('UPDATE '.$db->prefix.'track_topics SET forum_id='.$move_to_forum.' WHERE topic_id IN('.implode(', ',$topics).')') or error('Unable to update topic tracking', __FILE__, __LINE__, $db->error());

chercher L444:
$db->query('DELETE FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error());
ajouter après:
    // Delete track
		$db->query('DELETE FROM '.$db->prefix.'track_topics WHERE topic_id IN('.$topics.')') or error('Unable to delete tracking topics', __FILE__, __LINE__, $db->error());

chercher L640:
if ($cur_topic['last_post'] > $pun_user['last_visit'] && !$ghost_topic)
remplacer:
    $new_topics = get_unread_topics($pun_user['id'], false, $fid);
		if (topic_is_new($cur_topic['id']) && !$ghost_topic)

register.php

chercher L198:
$db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$db->escape($email1).'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error());
remplacer:
$db->query('INSERT INTO '.$db->prefix.'users (username, group_id, password, email, email_setting, save_pass, timezone, language, style, registered, registration_ip, last_visit, user_lastmark) VALUES(\''.$db->escape($username).'\', '.$intial_group_id.', \''.$password_hash.'\', \''.$db->escape($email1).'\', '.$email_setting.', '.$save_pass.', '.$timezone.' , \''.$db->escape($language).'\', \''.$pun_config['o_default_style'].'\', '.$now.', \''.get_remote_address().'\', '.$now.', '.$now.')') or error('Unable to create user', __FILE__, __LINE__, $db->error());

search.php

chercher L95:
if ($action != 'show_new' && $action != 'show_24h' && $action != 'show_unanswered' && $action != 'show_subscriptions')
remplacer:
if ($action != 'show_new' && $action != 'show_unread' && $action != 'show_24h' && $action != 'show_unanswered' && $action != 'show_subscriptions')

chercher L322:
else if ($action == 'show_new' || $action == 'show_24h' || $action == 'show_user' || $action == 'show_subscriptions' || $action == 'show_unanswered')
remplacer:
else if ($action == 'show_new' || $action == 'show_unread' || $action == 'show_24h' || $action == 'show_user' || $action == 'show_subscriptions' || $action == 'show_unanswered')

chercher L324:
      // If it's a search for new posts
			if ($action == 'show_new')
remplacer:
      if ($action == 'show_unread')
			{
				if ($pun_user['is_guest'])
					message($lang_common['No permission']);
				
				$num_hits = 0;
				$result = get_unread_topics($pun_user['id'], true);
				$num_hits = $db->num_rows($result);
				
				if (!$num_hits)
					message($lang_search['No unread posts']);
			}
			// If it's a search for new posts
			else if ($action == 'show_new')

chercher L419:
if ($action != 'show_new' && $action != 'show_24h')
remplacer:
if ($action != 'show_new' && $action != 'show_unread' && $action != 'show_24h')

chercher L530:
// Finally, lets loop through the results and output them
ajouter avant:
$new_topics = get_unread_topics($pun_user['id'], false);

chercher L549:
if (!$pun_user['is_guest'] && $search_set[$i]['last_post'] > $pun_user['last_visit'])
remplacer:
if (!$pun_user['is_guest'] && topic_is_new($search_set[$i]['tid']))

chercher L614:
if (!$pun_user['is_guest'] && $search_set[$i]['last_post'] > $pun_user['last_visit'])
remplacer:
if (!$pun_user['is_guest'] && topic_is_new($search_set[$i]['tid']))

viewforum.php

chercher L62:
// Can we or can we not post new topics?
ajouter avant:
$new_topics = get_unread_topics($pun_user['id'], false, $id);

chercher L166:
if (!$pun_user['is_guest'] && $cur_topic['last_post'] > $pun_user['last_visit'] && $cur_topic['moved_to'] == null)
remplacer:
if (!$pun_user['is_guest'] && topic_is_new($cur_topic['id']) && $cur_topic['moved_to'] == null)

viewtopic.php

chercher L71:
$result = $db->query('SELECT MIN(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND posted>'.$pun_user['last_visit']) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
remplacer:
  $last_read = get_unread_topics(false, false, 0, ' AND t.id='.$id);
	$last_read = $last_read[$id];
	$result = $db->query('SELECT MIN(id) FROM '.$db->prefix.'posts WHERE topic_id='.$id.' AND posted>'.$last_read) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

chercher L97:
if (!$pun_user['is_guest'])
	$result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
remplacer:
if (!$pun_user['is_guest'])
{
	$sql = 'SELECT t.subject, t.closed, t.num_replies, t.sticky, t.last_post, t.posted, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed, tt.mark_time, ft.mark_time as forum_mark_time';
	$sql .= ' FROM '.$db->prefix.'topics AS t';
	$sql .= ' INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id';
	$sql .= ' LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].')';
	$sql .= ' LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].')';
	$sql .= ' LEFT JOIN '.$db->prefix.'track_topics AS tt ON tt.user_id='.$pun_user['id'].' AND t.id=tt.topic_id';
	$sql .= ' LEFT JOIN '.$db->prefix.'track_forums AS ft ON ft.user_id='.$pun_user['id'].' AND t.forum_id=ft.forum_id';
	$sql .= ' WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL';
	
	$result = $db->query($sql) or error('Impossible de retrouver les informations de la discussion', __FILE__, __LINE__, $db->error());
}

chercher L187:
while ($cur_post = $db->fetch_assoc($result))
ajouter avant:
$max_post_time = 0;

chercher L312:
?>
<div id="p<?php echo $cur_post['id'] ?>" class="blockpost<?php echo $vtbg ?><?php if (($post_count + $start_from) == 1) echo ' firstpost'; ?>">
ajouter avant:
  if($cur_post['posted'] > $max_post_time)
	{
		$max_post_time = $cur_post['posted'];
	}

chercher L345:
?>
<div class="postlinksb">
ajouter avant:
if (!$pun_user['is_guest'])
{
	$tmp_topic_data = array($id => $cur_topic);
	$topic_tracking_info = get_topic_tracking($cur_topic['forum_id'], $id, $tmp_topic_data, array($cur_topic['forum_id'] => $cur_topic['forum_mark_time']));
	unset($tmp_topic_data);
	
	if (isset($topic_tracking_info[$id]) && $cur_topic['last_post'] > $topic_tracking_info[$id] && $max_post_time > $topic_tracking_info[$id])
	{
		markread('topic', $cur_topic['forum_id'], $id, $max_post_time);
	
		// Update forum info
		update_forum_tracking_info($cur_topic['forum_id'], $cur_topic['last_post'], (isset($cur_topic['forum_mark_time'])) ? $cur_topic['forum_mark_time'] : false, false);
	}
}

ps: J'ai fait le choix personnel de laisser le lien "show_new" inchangé (affiche les nouveaux messages depuis la dernière visite) et d'ajouter un "show_unread" (affiche les messages non lues) dans les liens de search.php. Les modifications ci-dessus reflètent ce choix. Libre à chacun de faire un choix différent smile , il faudra alors adapter le code à plusieurs endroits.

Hors ligne

Pied de page des forums