Archives FluxBB.fr

Les archives de FluxBB.fr

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

#1 31-01-2008 19:41:23

foxmask
Lugo

User Online Today Colored

j'ai codé une extension wink
un pour faire un "qui est en ligne"
un truc basique ...

1) ouvrir footer.php
2) ligne 92
remplacer

    if ($pun_config['o_users_online'] == '1'  )

par

    ($hook = get_hook('ft_get_users_online_colored')) ? eval($hook) : null;

    if ($pun_config['o_users_online'] == '1' and $hook == '' )

voilà  vous avez ajouté un HOOk ^^

reste à  l'exploiter avec une extension
dans le repertoire extensions
créez le repertoire online_today_colored
et voici le manifest.xml :

<?xml version="1.0" encoding="utf-8"?>

<extension engine="1.0">
  <id>online_today_colored</id>
  <title>Users Online Today (Colored)</title>
  <version>1.0</version>
  <description>Display the users online list with the color of their group</description>
  <author>FoxMaSk</author>
  <minversion>1.3 Beta</minversion>
  <maxtestedon>1.3 Beta</maxtestedon>

  <note type="install">This will display the Online list of users in place of the default PunBB 1.3.</note>

  <install><![CDATA[

  ]]></install>

  <uninstall><![CDATA[


  ]]></uninstall>

  <hooks>
    <hook id="ft_get_users_online_colored"><![CDATA[
        $date = getdate(time());
        $todaystamp = mktime(0,0,0, $date['mon'], $date['mday'], $date['year']);
            
        // fetch the users that came today.
        $query = array(
            'SELECT'    => 'username, id, group_id, last_visit',
            'FROM'        => 'users',
               'WHERE'        => "last_visit >='".$todaystamp."'",
            'ORDER BY'    => 'last_visit DESC'
        );
        
        $result = $db->query_build($query, true) or error(__FILE__, __LINE__);
        $users_today = array();
        while ($pun_user_online_today = $db->fetch_assoc($result)) 
        {
            if ($pun_user_online_today['group_id'] == '1')
                $users_today[] .=  "\n\t\t\t\t".'<a href="'.pun_link($pun_url['user'],$pun_user_online_today['id']).'" title="Last visit of '.htmlspecialchars($pun_user_online_today['username']).' : '.format_time($pun_user_online_today['last_visit']).'"><span style="color: green;font-weight:bold;">'.$pun_user_online_today['username'].'</span></a>';
            else
                $users_today[] .=  "\n\t\t\t\t".'<a href="'.pun_link($pun_url['user'],$pun_user_online_today['id']).'" title="Last visit of '.htmlspecialchars($pun_user_online_today['username']).' : '.format_time($pun_user_online_today['last_visit']).'">'.$pun_user_online_today['username'].'</a>';
        }
       
    
        // Fetch users online info and generate strings for output
        $query = array(
            'SELECT'    => 'o.user_id, o.ident, u.group_id',
            'FROM'        => 'online AS o',
            'JOINS'     => array(
                    array(
                        'LEFT JOIN' => 'users AS u',
                        'ON'    => 'o.user_id=u.id'
                        ),
                    ),
               'WHERE'        => 'o.idle=0',
            'ORDER BY'    => 'o.ident'
        );

        $result = $db->query_build($query, true) or error(__FILE__, __LINE__);
        $num_guests = 0;
        $users = array();

        while ($pun_user_online = $db->fetch_assoc($result))
        {
            if ($pun_user_online['user_id'] > 1) {
                if ( $pun_user_online['group_id'] == '1' ) 
                    $users[] = '<a href="'.pun_link($pun_url['user'], $pun_user_online['user_id']).'"><span style="color:red; font-weight:bold;">'.htmlspecialchars($pun_user_online['ident']).'</span></a>';
                else 
                    $users[] = '<a href="'.pun_link($pun_url['user'], $pun_user_online['user_id']).'">'.htmlspecialchars($pun_user_online['ident']).'</a>';
                
            }
            else
                ++$num_guests;
        }
    
        echo "\t".'<div id="onlinelist">'."\n".
            "\t\t".'<h3>'. printf($lang_index['Online'], $num_guests, count($users)) .'</h3>'."\n";

        // If there are registered users logged in, list them
        if (count($users) > 0)
            echo "\t\t\t".'<p>'.implode(', ', $users).'</p>'."\n";

        echo "\t".'</div>'."\n";

        echo "\t".'<div id="onlinetoday">'."\n".
            "\t\t".'<h3> Online Today : ( '. count($users_today)  .') </h3>'."\n";
        if (count($users_today) > 0)
            echo "\t\t\t".'<p>'.implode(',', $users_today).'</p>'."\n";
        else
            echo '<p><em>None</em></p>'."\n";
            
        echo "\t".'</div>'."\n";

        
    ]]></hook>
  </hooks>
</extension>

et voila le travail ^^
reste à l'installer et voir smile

c'est très succint mais c'est pour aider wink


http://www.foxmask.info
HaveFnuBB! le seul forum produit avec le framework PHP5 Jelix
(dé)pot de miel
Membre de la CoreTeam Jelix

Hors ligne

#2 31-01-2008 19:48:08

foxmask
Lugo

Re : User Online Today Colored

on déplacera le poste quand une categorie punbb 1.3 et un forum "extensions" aura vu le jour wink


http://www.foxmask.info
HaveFnuBB! le seul forum produit avec le framework PHP5 Jelix
(dé)pot de miel
Membre de la CoreTeam Jelix

Hors ligne

#3 07-03-2008 06:17:57

Pandark
Guide

Re : User Online Today Colored

Je crois que c'est le cas maintenant smile
Okey, c'est n'importe quoi tongue, j'ai déplacé dans le forum entraide au lieu d'en créer un "extensions" mais vu comme c'est peu rempli, j'ai la folie de croire qu'on le perdra moins facilement ici ^^


=>  Plugins | Modifications | Liens utiles   <=
                .._ -Pandark- _..
                Serial Dreamer

Hors ligne

#4 07-03-2008 06:36:00

Mpok
Néo Admin

Re : User Online Today Colored

Pandark a écrit :

Je crois que c'est le cas maintenant smile

Ben non, mais il faudra que quelqu'un s'en occupe un jour wink
(l'équivalent de "Modifications" pour "Extensions")

Hors ligne

Pied de page des forums