Contatore post nuovi non letti ed i propri

Snippet & addons per il nostro phpbb 3
Rispondi
Avatar utente
Dr.House
Amministratore
Amministratore
Messaggi: 2173
Iscritto il: 08/01/2012, 8:24
Link del Forum: www.phpbb-italia.it
Località: Reggio Calabria
Contatta:

Contatore post nuovi non letti ed i propri

Messaggio da Dr.House »

Piccola snippet che consente di leggere nell'index i nuovi post, quelli non letti ed i propri

Autore:All4phone

Apri: includes/function.php

Cerca:

Codice: Seleziona tutto

    // The following assigns all _common_ variables that may be used at any point in a template.
Aggiungi prima:

Codice: Seleziona tutto

        //
        // + new posts since last visit & you post number
        //
        if ($user->data['is_registered'])
        {
            $ex_fid_ary = array_unique(array_merge(array_keys($auth->acl_getf('!f_read', true)), array_keys($auth->acl_getf('!f_search', true))));
           
            if ($auth->acl_get('m_approve'))
            {
             $m_approve_fid_ary = array(-1);
             $m_approve_fid_sql = '';
            }
            else if ($auth->acl_getf_global('m_approve'))
            {
             $m_approve_fid_ary = array_diff(array_keys($auth->acl_getf('!m_approve', true)), $ex_fid_ary);
             $m_approve_fid_sql = ' AND (p.post_approved = 1' . ((sizeof($m_approve_fid_ary)) ? ' OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) : '') . ')';
            }
            else
            {
             $m_approve_fid_ary = array();
             $m_approve_fid_sql = ' AND p.post_approved = 1';
            }

            $sql = 'SELECT COUNT(distinct t.topic_id) as total
                 FROM ' . TOPICS_TABLE . ' t
                 WHERE t.topic_last_post_time > ' . $user->data['user_lastvisit'] . '
                   AND t.topic_moved_id = 0
                   ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
                   ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
            $result = $db->sql_query($sql);
            $new_posts_count = (int) $db->sql_fetchfield('total');

            // your post number
            $sql = "SELECT user_posts
             FROM " . USERS_TABLE . "
             WHERE user_id = " . $user->data['user_id'];
            $result = $db->sql_query($sql);
            $you_posts_count = (int) $db->sql_fetchfield('user_posts');
           
            // unread posts
            $sql_where = 'AND t.topic_moved_id = 0
                   ' . str_replace(array('p.', 'post_'), array('t.', 'topic_'), $m_approve_fid_sql) . '
                   ' . ((sizeof($ex_fid_ary)) ? 'AND ' . $db->sql_in_set('t.forum_id', $ex_fid_ary, true) : '');
            $unread_list = array();
            $unread_list = get_unread_topics($user->data['user_id'], $sql_where, 'ORDER BY t.topic_id DESC');
           
            if (!empty($unread_list))
            {
             $sql = 'SELECT COUNT(distinct t.topic_id) as total
               FROM ' . TOPICS_TABLE . ' t
               WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list));
             $result = $db->sql_query($sql);
             $unread_posts_count = (int) $db->sql_fetchfield('total');
            }
            else
            {
             $unread_posts_count = 0;
            }

           $template->assign_vars(array(
                'L_NEW_POSTS'        => $user->lang['SEARCH_NEW'] . ' (' . $new_posts_count . ')',
                'L_UNREAD_POSTS'=>   $user->lang['SEARCH_UNREAD'] . ' (' . $unread_posts_count . ')',
                'L_SELF_POSTS'    =>   $user->lang['SEARCH_SELF'] . ' (' . $you_posts_count . ')',
                ));

        }
        //
        // - new posts since last visit & you post number
        //       
Apri: styles/prosilver/template/index_body.html

cerca:

Codice: Seleziona tutto

    <li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a><!-- IF S_USER_LOGGED_IN --> &bull; <a href="{U_SEARCH_UNREAD}">{L_SEARCH_UNREAD}</a> &bull; <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><!-- ENDIF --> &bull; <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></li>
sostituisci con:

Codice: Seleziona tutto

    <li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a><!-- IF S_USER_LOGGED_IN --> &bull; <a href="{U_SEARCH_UNREAD}">{L_UNREAD_POSTS}</a> &bull; <a href="{U_SEARCH_NEW}">{L_NEW_POSTS}</a><!-- ENDIF --> &bull; <a href="{U_SEARCH_ACTIVE_TOPICS}">{L_SEARCH_ACTIVE_TOPICS}</a></li>
Apri: styles/prosilver/template/overall_header.html

cerca:

Codice: Seleziona tutto

   <a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a>
sostituisci con:

Codice: Seleziona tutto

        <a href="{U_SEARCH_SELF}">{L_SELF_POSTS}</a>
testato su phpbbb3 3.0.10
screen.png
Non hai i permessi necessari per visualizzare i file allegati in questo messaggio.
Rispondi