Archives FluxBB.fr

Les archives de FluxBB.fr

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

#1 14-12-2007 14:53:18

freecom
Membre

Avatar à coter du dernier post

Bonjour à tous,

voilà je viens vers vous pour une petite chose, je souhaiterais mettre sur l'accueil de mes forums a coter du derniers user qui à poster son avatar.

Pour être plus explicite voici un montage

2_sans_titre-71.jpg

Quel est le fichier à modifier ?
Et quel est la variable à ajouter ?, si je contrains les proportions de l'image... ex: 35x35 px...

Cdt

Hors ligne

#3 14-12-2007 16:10:02

sharrinddlar
Membre

Re : Avatar à coter du dernier post

Me revoilà,

Voici une petite correction.
Je ne sais pas si c'est terrible, mais cela fonctionne et c'est assez simple à mettre en place:

trouve dans index.php:

   

// If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';

Et remplace le par:

    //Petite modif pour une apparition des avatars...
    // Retrieve the id for the avatar (and their respective poster/online status)
    $resulta = $db->query('SELECT id FROM '.$db->prefix.'users WHERE username="'.$cur_forum['last_poster'].'"', true) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
    while ($cur_avartar = $db->fetch_assoc($resulta))
        {
            if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
            {
                if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_avartar['id'].'.gif'))
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_avartar['id'].'.gif" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_avartar['id'].'.jpg'))
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_avartar['id'].'.jpg" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_avartar['id'].'.png'))
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_avartar['id'].'.png" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                         
            }
            else
                $user_avatar = '';
            //
        }

    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = $user_avatar.'<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';

Donne m'en des nouvelles...
++ wink

EDIT: si cela convient et que personne ne trouve d'alternative plus courte, je la rajouterais dans les mods... smile

Dernière modification par sharrinddlar (14-12-2007 16:40:13)

Hors ligne

#4 14-12-2007 17:11:50

freecom
Membre

Re : Avatar à coter du dernier post

Merci pour ta rapidité, mais moi voici mon code

// If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = '<a href="'.makeurl("p", $cur_forum['last_post_id'], format_time($cur_forum['last_post'])).'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
    else
        $last_post = ' ';

    if ($cur_forum['moderators'] != '')
    {
        $mods_array = unserialize($cur_forum['moderators']);
        $moderators = array();

        while (list($mod_username, $mod_id) = @each($mods_array))
            $moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';

        $moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
    }

J'ai du rewrite d'installer, et j'ai peur de me planter...
Désolé de ne pas avoir du code générique....

Hors ligne

#5 14-12-2007 17:39:04

sharrinddlar
Membre

Re : Avatar à coter du dernier post

Nouvelle modif,

Le précédant pouvait faire bugger:

trouve dans index.php:

    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';

Remplace le par:

//-------------------------
    //Modification personnel pour affichage avatar
    //-------------------------
    // Retrieve the id for the avatar (and their respective poster/online status)
        if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.gif'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.gif" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.jpg'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.jpg" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.png'))
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.png" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
            else
                $user_avatar = '';
                             
        }
        else
            $user_avatar = '';
        //
    //-------------------------
    //la mod va jusqu'à $user_avatar.
    //-------------------------
    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = $user_avatar.'<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';

puis toujours dans index.php:

trouve:

// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_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 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

Remplace le par:

// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, u.id AS uid FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'users AS u ON f.last_poster=u.username WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

Normalement plus de pb.

tu peux voir le résultat sur mon forum: http://www.chaodisiaque.com/forum/index.php

++ smile

Hors ligne

#7 14-12-2007 17:45:44

Blatoon
Membre

Re : Avatar à coter du dernier post

Tout beau! Merci. Y a moyen de faire la même chose avec la userlist?

Hors ligne

#9 14-12-2007 18:12:01

sharrinddlar
Membre

Re : Avatar à coter du dernier post

Et Hop,

Pour le userlist!!

trouvez dans userlist.php:

$user_title_field = get_title($user_data);
?>
                <tr>
                    <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td>

remplacez par:

$user_title_field = get_title($user_data);
        
        //-------------------------
        //Modification personnel pour affichage avatar
        //-------------------------
        // Retrieve the id for the avatar (and their respective poster/online status)
            if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
            {
                if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_data['id'].'.gif'))
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$user_data['id'].'.gif" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_data['id'].'.jpg'))
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$user_data['id'].'.jpg" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$user_data['id'].'.png'))
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$user_data['id'].'.png" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                else
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/avatar_defaut.gif" style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                                 
            }
            else
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/avatar_defaut.gif" style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
            //

?>
                <tr>
                    <td class="tcl"><?php echo $user_avatar.'<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td>

Par contre il faudra que vous mettiez une image avatar par défaut au format GIF dans votre dossier img/avatars/ et avec le nom avatar_defaut.gif

Au pire enregistrez celle qu'il y a sur mon forum.

Voici le résultat: http://www.chaodisiaque.com/forum/userlist.php

++ wink

Dernière modification par sharrinddlar (14-12-2007 18:12:25)

Hors ligne

#10 14-12-2007 18:29:36

Blatoon
Membre

Re : Avatar à coter du dernier post

TU es vraiment un chef! Merci beaucoup.

Hors ligne

#11 15-12-2007 11:42:15

Bashatio
Membre

Re : Avatar à coter du dernier post

sharrinddlar ce serait génial si tu pouvais l'adapter aussi pour viewforum.php.

     Merci à toi

Dernière modification par Bashatio (15-12-2007 11:42:32)

Hors ligne

#13 15-12-2007 12:55:03

sharrinddlar
Membre

Re : Avatar à coter du dernier post

Re,

Bon la mod pour le viewforum est faite.
Un peu plus complexe à faire, car il faut modifier une grosse partie.

Trouvez dans viewforum.php:

// Fetch list of topics to display on this page
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
    // Without "the dot"
    $sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
    // With "the dot"
    switch ($db_type)
    {
        case 'mysql':
        case 'mysqli':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

        case 'sqlite':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
            break;

        default:
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

    }
}

et remplacez par:

// Fetch list of topics to display on this page
//---------------------
// Dans toutes les requetes --> u.id AS uid <-- a été rajouté 
// ainsi que --> LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username <--
//---------------------
if ($pun_user['is_guest'] || $pun_config['o_show_dot'] == '0')
{
    // Without "the dot"
    $sql = 'SELECT u.id AS uid, t.id, t.poster, t.subject, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
    // With "the dot"
    switch ($db_type)
    {
        case 'mysql':
        case 'mysqli':
            $sql = 'SELECT u.id AS uid, p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

        case 'sqlite':
            $sql = 'SELECT u.id AS uid, p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
            break;

        default:
            $sql = 'SELECT u.id AS uid, p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' LEFT JOIN '.$db->prefix.'users AS u ON t.last_poster=u.username WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

    }
}

Puis toujours dans viewforum.php:

Trouvez:

if ($cur_topic['moved_to'] == null)
            $last_post = '<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>';

Remplacez par:

//-------------------------
            //Modification personnel pour affichage avatar
            //-------------------------
            // Retrieve the id for the avatar (and their respective poster/online status)
                if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
                {
                    if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_topic['uid'].'.gif'))
                        $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_topic['uid'].'.gif" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                    else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_topic['uid'].'.jpg'))
                        $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_topic['uid'].'.jpg" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                    else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_topic['uid'].'.png'))
                        $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_topic['uid'].'.png" '.$img_size[3].' style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                    else
                        $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/avatar_defaut.gif" style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                                     
                }
                else
                    $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/avatar_defaut.gif" style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                //-------------------
                //La mod va jusqu'à --> $user_avatar.
                //-------------------

        if ($cur_topic['moved_to'] == null)
            $last_post = $user_avatar.'<a href="viewtopic.php?pid='.$cur_topic['last_post_id'].'#p'.$cur_topic['last_post_id'].'">'.format_time($cur_topic['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['last_poster']).'</span>';

Vous pouvez voir le résultat sur mon forum punbb: http://www.chaodisiaque.com/forum/viewforum.php?id=3

J'ai fait une petite modif qui affiche l'avatar par défaut, donc il faut que vous fassiez comme le userlist.php si c'est pas déjà fait, mettre une image par défaut nommée avatar_defaut.gif dans le dossier avatars

Par contre j'ai fait les modif pour toutes les bases SQLite, MySQL et défault, et je n'ai testé que MySQL... Donc merci de rapporter d'éventuels bugs wink

++

Hors ligne

#14 15-12-2007 12:58:39

sharrinddlar
Membre

Re : Avatar à coter du dernier post

Puis pour avoir l'avatar par défaut aussi sur l'index.

trouvez dans index.php après avoir mis la mod:

else
                $user_avatar = '';
                             
        }
        else
            $user_avatar = '';

Puis remplacer par:

else
                $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/avatar_defaut.gif" style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';
                             
        }
        else
            $user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/avatar_defaut.gif" style = "width:35px; height:35px; float:left; margin-right:5px;" alt="" />';

++ wink

Hors ligne

#15 15-12-2007 21:04:51

Bashatio
Membre

Re : Avatar à coter du dernier post

Merci et bravo pour ton travail.

Hors ligne

#17 15-12-2007 21:09:51

Bashatio
Membre

Re : Avatar à coter du dernier post

Merci. Je viens justement de le voir après aboir posté mon message. smile

Hors ligne

#18 17-12-2007 08:40:41

freecom
Membre

Re : Avatar à coter du dernier post

Salut sharrinddlar !

Je rentre de weekend et je viens de tester ça ! Ça marche impec !
Encore merci wink

Sinon bien l'idée d'une mod pour les différentes personnalisations de userlist, & viewtopic !!

Hors ligne

Pied de page des forums