Code : Tout sélectionner
Mod At A glance: Permet d'afficher sur la page d'index du forum, les dernières actualité et les derniers sujet de discussion.
Le lien envoie directement sur le 1° sujet non lu.
Code : Tout sélectionner
<?php
/***************************************************************************
* glance.php
* -------------------
* begin : Monday, Apr 07, 2001
* copyright : blulegend, Jack Kan
* contact : www.phpbb.com, member: blulegend
* version : 2.2.1
*
***************************************************************************/
/* Edit your PREFERENCES in glance_config.php, NOT HERE. */
/************************* DO NOT EDIT BELOW THIS LINE *********************/
if ( !defined('IN_PHPBB') )
{
die("Hacking attempt");
}
define('IN_GLANCE', true);
include($phpbb_root_path . 'glance_config.'.$phpEx);
//
// GET USER LAST VISIT
//
$glance_last_visit = $userdata['user_lastvisit'];
//
// MESSAGE TRACKING
//
//if ( !isset($tracking_topics) && $glance_track ) $tracking_topics = ( isset($HTTP_COOKIE_VARS[$config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$config['cookie_name'] . '_t']) : '';
$tracking_topics = array();
// CHECK FOR BAD WORDS
//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
//
// GET THE LATEST NEWS TOPIC
//
if ( $glance_num_news )
{
$news_data = $db->sql_fetchrow($result);
$sql_select = ", p.post_time";
$sql_from = ", " . POSTS_TABLE . " p";
$sql_where = " AND p.post_id = t.topic_last_post_id";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_time, t.forum_id" . $sql_select . "
FROM " . TOPICS_TABLE . " t" . $sql_from . "
WHERE t.forum_id = " . $glance_news_forum_id . $sql_where . "
AND t.topic_moved_id = 0
ORDER BY t.topic_first_post_id DESC
LIMIT " . $glance_num_news;
$latest_news = array();
$result = $db->sql_query($sql);
while ( $topic_row = $db->sql_fetchrow($result) )
{
$topic_row['topic_title'] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_row['topic_title']) : $topic_row['topic_title'];
$latest_news[] = $topic_row;
$tracking_topics += get_complete_topic_tracking($topic_row["forum_id"], $topic_row["topic_id"], $global_announce_list = false);
}
$db->sql_freeresult($result);
}
//
// GET THE LAST 5 TOPICS
//
if ( $glance_num_recent )
{
$unauthed_forums = array();
$sql = "SELECT forum_id, auth_view FROM " . FORUMS_TABLE . " WHERE forum_id <> " . $glance_news_forum_id;
$glance_auth_level = ( $glance_auth_read ) ? AUTH_VIEW : AUTH_ALL;
//$is_auth_ary = auth($glance_auth_level, AUTH_LIST_ALL, $userdata);
$forumsignore = '';
$notAllowedForums = array();
$notAllowedForums = array_keys($auth->acl_getf('!f_read', true));
if (sizeof($notAllowedForums)> 0) {
$forumsignore = implode(', ', $notAllowedForums);
} else {
$forumsignore= "-1";
}
if ( $num_forums = count($is_auth_ary) )
{
while ( list($forum_id, $auth_mod) = each($is_auth_ary) )
{
$unauthed = false;
if ( !$auth_mod['auth_view'] && $auth_mod['forum_id'] != $glance_news_forum_id )
{
$unauthed = true;
}
if ( !$glance_auth_read && !$auth_mod['auth_read'] && $auth_mod['forum_id'] != $glance_news_forum_id )
{
$unauthed = true;
}
if ( $unauthed )
{
$forumsignore .= $forum_id . ', ';
}
}
}
$sql = "SELECT t.topic_title, t.topic_id, p2.post_time, t.forum_id
FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p2
WHERE t.forum_id NOT IN (" . $forumsignore . "," . $glance_news_forum_id . ")
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND t.topic_moved_id = 0
ORDER BY p2.post_time DESC
LIMIT " . $glance_num_recent;
$latest_topics = array();
$result = $db->sql_query($sql);
while ( $topic_row = $db->sql_fetchrow($result) )
{
$topic_row['topic_title'] = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_row['topic_title']) : $topic_row['topic_title'];
$latest_topics[] = $topic_row;
$tracking_topics += get_complete_topic_tracking($topic_row["forum_id"], $topic_row["topic_id"], $global_announce_list = false);
}
$db->sql_freeresult($result);
}
if ( $glance_num_news )
{
if ( !empty($latest_news) )
{
$bullet_pre = 'glance_news_bullet';
for ( $i = 0; $i < count($latest_news); $i++ )
{
if ($user->data['is_registered'])
{
$unread_topics = false;
$topic_id = $latest_news[$i]['topic_id'];
if ( $latest_news[$i]['post_time'] > $glance_last_visit )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) && $glance_track )
{
if( $tracking_topics[$topic_id] >= $latest_news[$i]['post_time'] )
{
$unread_topics = false;
}
}
}
$shownew = $unread_topics;
}
else
{
$unread_topics = false;
$shownew = true;
}
$bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? '_new' : '_old' );
$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '';
$topic_link = $glance_forum_dir . 'viewtopic.php?t=' . $latest_news[$i]['topic_id'] . $newest_code;
$template->assign_block_vars('news', array(
'BULLET' => $$bullet_full,
'TOPIC_TITLE' => $latest_news[$i]['topic_title'],
'TOPIC_LINK' => $topic_link,
'TOPIC_TIME' => $user->format_date($latest_news[$i]['topic_time']))
);
}
}
else
{
$template->assign_block_vars('news', array(
'BULLET' => $glance_recent_bullet_old,
'TOPIC_TITLE' => 'None')
);
}
}
if ( $glance_num_recent )
{
$glance_info = 'counted recent';
$bullet_pre = 'glance_recent_bullet';
if ( !empty($latest_topics) )
{
for ( $i = 0; $i < count($latest_topics); $i++ )
{
if ($user->data['is_registered'])
{
$unread_topics = false;
$topic_id = $latest_topics[$i]['topic_id'];
if ( $latest_topics[$i]['post_time'] > $glance_last_visit )
{
$unread_topics = true;
if( !empty($tracking_topics[$topic_id]) && $glance_track )
{
if( $tracking_topics[$topic_id] >= $latest_topics[$i]['post_time'] )
{
$unread_topics = false;
}
}
}
$shownew = $unread_topics;
}
else
{
$unread_topics = false;
$shownew = true;
$topic_id = $latest_topics[$i]['topic_id'];
}
$bullet_full = $bullet_pre . ( ( $shownew && $glance_show_new_bullets ) ? '_new' : '_old' );
//avant nico:
//$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '';
//Modif nico:
$newest_code = ( $unread_topics && $glance_show_new_bullets ) ? '&view=newest' : '&view=latest';
//Post à pointer
$post = 0;
if ( $unread_topics && $glance_show_new_bullets ) {
//Récupérer le premier post non lu
$sql = "Select post_id
FROM `" . POSTS_TABLE . "`
where post_time >= ".$tracking_topics[$topic_id]."
AND topic_id = ".$topic_id."
ORDER by post_time ASC
limit 1";
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$post = $row["post_id"];
}
} else {
$sql = "Select max(post_id)
FROM `" . POSTS_TABLE . "`
where topic_id = ".$topic_id;
$result = $db->sql_query($sql);
while ( $row = $db->sql_fetchrow($result) ) {
$post = $row["max(post_id)"];
}
}
$topic_link = $glance_forum_dir . 'viewtopic.php?p=' . $post . "#p".$post;
$template->assign_block_vars('recent', array(
'BULLET' => $$bullet_full,
'TOPIC_LINK' => $topic_link,
'TOPIC_TITLE' => $latest_topics[$i]['topic_title'])
);
}
}
else
{
$template->assign_block_vars('recent', array(
'BULLET' => $glance_recent_bullet_old,
'TOPIC_TITLE' => 'None')
);
}
}
//Photos
$myUser = new user_site($user->data['user_id']);
$myUser->setSession_id($user->data['session_id']);
$myUser->setVariablePhpBB($user->data);
$myUser->setObjetPhpBB($user);
//var_dump($glance_num_recent);die;
$tab = photo_commentaire::getLastCommentaireForUser($myUser, $glance_num_recent / 2 - 1, true);
foreach ($tab as $resultat) {
$photo = new photo($resultat['photo_id']);
$contexte = $photo->contexte();
if (!empty($contexte)) {
$quoi = 'une photo';
} else {
$quoi = 'la photo';
$contexte = $photo->url();
}
$topic_link = 'http://www.team-azerty.com/images/view-' . $photo->photo_id() . '.html';
$topic_title = 'Commentaire sur ' . $quoi . ' ' . $contexte . ' ';
$template->assign_block_vars('recent', array(
'BULLET' => $$bullet_full,
'TOPIC_LINK' => $topic_link,
'TOPIC_TITLE' => $topic_title)
);
}
if ( $glance_num_news )
{
$template->assign_block_vars('switch_glance_news', array());
}
if ( $glance_num_recent )
{
$template->assign_block_vars('switch_glance_recent', array());
}
$template->assign_vars(array(
'RECENT_HEADING' => $glance_recent_heading,
'NEWS_HEADING' => $glance_news_heading)
);
$template->assign_var('GLANCE_OUTPUT_YES', 'YES');
// THE END
?>
Code : Tout sélectionner
<?php
/***************************************************************************
* glance_config.php
* -------------------
* begin : Monday, Apr 07, 2001
* copyright : blulegend, Jack Kan
* contact : www.phpbb.com, member: blulegend
*
***************************************************************************/
if ( !defined('IN_GLANCE') )
{
die("Hacking attempt");
}
/***************************************************************************
*
* *************** SET UP VARIABLES HERE ***********************/
// FORUM DIRECTORY
$glance_forum_dir = '';
// NEWS FORUM ID
$glance_news_forum_id = 0; // SET TO ZERO IF YOU DO NOT HAVE A NEWS FORUM
// NUMBER OF NEWS ARTICLES YOU WISH TO DISPLAY
$glance_num_news = 0; // SET TO ZERO IF YOU DO NOT WANT THIS TO BE DISPLAYED or DO NOT HAVE A NEWS FORUM
// NUMBER OF RECENT ARTICLES YOU WISH TO DISPLAY
$glance_num_recent = 10; // SET TO ZERO IF YOU DO NOT WANT THIS TO BE DISPLAYED
// NEWS HEADING
$glance_news_heading = 'Dernières brèves';
// RECENT TOPIC HEADING
$glance_recent_heading = 'Dernières discussions';
// NEWS BULLET OLD
$glance_news_bullet_old = '<span class="genmed"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// RECENT TOPIC BULLET OLD
$glance_recent_bullet_old = '<span class="genmed"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// NEWS BULLET NEW
$glance_news_bullet_new = '<span class="genmed" style="color:#FFA34F"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// RECENT TOPIC BULLET NEW
$glance_recent_bullet_new = '<span class="genmed" style="color:#FFA34F"><b>›</b> </span>'; // CAN ALSO BE AN IMAGE
// TABLE WIDTH
$glance_table_width = 250;
// CHANGE THE BULLET IF A TOPIC IS NEW? (true / false)
$glance_show_new_bullets = true;
// MESSAGE TRACKING WILL TRACK TO SEE IF A USER HAS READ THE TOPIC DURING THEIR SESSION (true / false)
$glance_track = true;
// SHOW TOPICS THE USER CAN VIEW, BUT NOT READ? (true / false)
$glance_auth_read = true;
/************************* DO NOT EDIT BELOW THIS LINE *********************/
?>
Avant
Code : Tout sélectionner
// Output page
page_header($user->lang['INDEX']);
$template->set_filenames(array(
'body' => 'index_body.html')
);
Code : Tout sélectionner
if ($user->data['is_registered']) include($phpbb_root_path . 'glance.'.$phpEx);
Modifier le fichier /styles/prosilver/template/overall_header.html
Avant
Code : Tout sélectionner
<!-- IF S_DISPLAY_SEARCH and not S_IN_SEARCH -->
<div id="search-box">
<form action="{U_SEARCH}" method="post" id="search">
<fieldset>
<input name="keywords" id="keywords" type="text" maxlength="128" title="{L_SEARCH_KEYWORDS}" class="inputbox search" value="<!-- IF SEARCH_WORDS-->{SEARCH_WORDS}<!-- ELSE -->{L_SEARCH_MINI}<!-- ENDIF -->" onclick="if(this.value=='{LA_SEARCH_MINI}')this.value='';" onblur="if(this.value=='')this.value='{LA_SEARCH_MINI}';" />
<input class="button2" value="{L_SEARCH}" type="submit" /><br />
<a href="{U_SEARCH}" title="{L_SEARCH_ADV_EXPLAIN}">{L_SEARCH_ADV}</a> {S_SEARCH_HIDDEN_FIELDS}
</fieldset>
</form>
</div>
<!-- ENDIF -->
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
<!-- ENDIF -->
Code : Tout sélectionner
<table width="300" cellpadding="2" cellspacing="1" class="tablebg" id="atGlanceBox">
<!-- BEGIN switch_glance_news -->
<tr>
<th>{NEWS_HEADING}</th>
</tr>
<tr>
<td >
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_news -->
<!-- BEGIN news -->
<tr>
<td nowrap valign="top">{news.BULLET}<a href="{news.TOPIC_LINK}">{news.TOPIC_TITLE}</a><br>{news.TOPIC_TIME}</td>
</tr>
<!-- END news -->
<!-- BEGIN switch_glance_news -->
</table>
</td>
</tr>
<!-- END switch_glance_news -->
<!-- BEGIN switch_glance_recent -->
<tr>
<th>{RECENT_HEADING}</th>
</tr>
<tr>
<tr>
<td>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_recent -->
<!-- BEGIN recent -->
<tr>
<td nowrap valign="top" >{recent.BULLET}<a href="{recent.TOPIC_LINK}">{recent.TOPIC_TITLE}</a></td>
</tr>
<!-- END recent -->
<!-- BEGIN switch_glance_recent -->
</table>
</td>
</tr>
<!-- END switch_glance_recent -->
</table>
Code : Tout sélectionner
#atGlanceBox {
color: #FFFFFF;
margin-top: 0px;
margin-right: 250px;
display: block;
float: right;
position: absolute;
right: 0px;
white-space: nowrap; /* For Opera */
}
#atGlanceBox a {
color: #ffffff;
}
#atGlanceBox a:hover {
color: #b8cdef;
}
Modifier le fichier /styles/subsilver2/template/overall_header.html
Après
Code : Tout sélectionner
<td width="100%" align="center"><h1>{SITENAME}</h1><span class="gen">{SITE_DESCRIPTION}</span></td>
Code : Tout sélectionner
<!-- IF GLANCE_OUTPUT_YES -->
<td>
<!-- INCLUDE glance_body.html -->
{GLANCE_OUTPUT}
</td>
<!-- ENDIF -->
Code : Tout sélectionner
<table width="300" cellpadding="2" cellspacing="1" class="tablebg" id="atGlanceBox">
<!-- BEGIN switch_glance_news -->
<tr>
<th>{NEWS_HEADING}</th>
</tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_news -->
<!-- BEGIN news -->
<tr>
<td nowrap valign="top">
{news.BULLET}
<a href="{news.TOPIC_LINK}" class="forumlink">
{news.TOPIC_TITLE}
</a>
<br>
{news.TOPIC_TIME}
</td>
</tr>
<!-- END news -->
<!-- BEGIN switch_glance_news -->
</table>
</td>
</tr>
<!-- END switch_glance_news -->
<!-- BEGIN switch_glance_recent -->
<tr>
<th>{RECENT_HEADING}</th>
</tr>
<tr>
<tr>
<td class="row1">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- END switch_glance_recent -->
<!-- BEGIN recent -->
<tr>
<td nowrap valign="top" >
{recent.BULLET}
<a href="{recent.TOPIC_LINK}" class="genmed">
{recent.TOPIC_TITLE}
</a>
</td>
</tr>
<!-- END recent -->
<!-- BEGIN switch_glance_recent -->
</table>
</td>
</tr>
<!-- END switch_glance_recent -->
</table>