1 (edited by xnit 2012-07-28 09:17)

Topic: [Release] Not sum

Not Sum - We switch off calculation of messages
The plugin serves for deenergizing of calculation of messages of users in certain sections.
In addition the plugin synchronizes quantity of messages at users.

Not Sum for FluxBB by Visman
Adapted to punBB 1.2 by me. :3

Download:
hotfile.com/dl/164736601/8cbb898/NOT_SUM_EN.zip.html

I. delete.php
    
    1.
        Find:
            delete_topic($cur_post['tid']);
        Replace with:
            delete_topic($cur_post['tid'], $cur_post['no_sum_mess']); // not sun - Visman
    
    2.
        Find:
            redirect('viewtopic.php?id='.$cur_post['tid'], $lang_delete['Post del redirect']);
        Add BEFORE:
            // not sum - Visman
            if ($cur_post['no_sum_mess'] == 0)
                $db->query('UPDATE '.$db->prefix.'users SET num_posts=num_posts-1 WHERE id='.$cur_post['poster_id']) or error('Unable to update user', __FILE__, __LINE__, $db->error());
    
    3.    
        Find:
            $result = $db->query('SELECT f.id AS fid, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.id AS tid, t.subject, t.posted, t.closed, p.poster, p.poster_id, p.message, p.hide_smilies FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND p.id='.$id) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
        Add:
        f.no_sum_mess,
        After:
        f.moderators, f.redirect_url, 

        
II. include\common_admin.php

    1.
        Find:
            if ($topic_ids != '')
            {
        Add AFTER:
            // not sum - Visman
            $result = $db->query('SELECT no_sum_mess FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forums', __FILE__, __LINE__, $db->error());
            if (!$db->num_rows($result))
                $flag_f = 1;
            else
                $flag_f = $db->result($result);
                
            if ($flag_f == 0)
            {
                $result = $db->query('SELECT COUNT(id), poster_id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topic_ids.') GROUP BY poster_id', true) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
                while ($row = $db->fetch_row($result))
                {
                $db->query('UPDATE '.$db->prefix.'users SET num_posts = num_posts-'.$row[0].' WHERE id='.$row[1]) or error('Unable to update posters messages count', __FILE__, __LINE__, $db->error());
                }
            }
III. moderate.php

    1.
        Find:
            $result = $db->query('SELECT moderators FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
        Replace with:
            $result = $db->query('SELECT moderators, no_sum_mess FROM '.$db->prefix.'forums WHERE id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error()); // not sum - Visman
    
    2.
        Find:
            // Delete the posts
        Add BEFORE:
            // ?????????? ?????? ? ?????? ? not sum - Visman
            if ($flag_f == 0)
            {
                $result = $db->query('SELECT COUNT(id), poster_id FROM '.$db->prefix.'posts WHERE id IN('.$posts.') GROUP BY poster_id', true) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
                while ($row = $db->fetch_row($result))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET num_posts=num_posts-'.$row[0].' WHERE id='.$row[1]) or error('Unable to update posters messages count', __FILE__, __LINE__, $db->error());
                }
            }
    
    3.
        Find:
            // Create a list of the post ID's in this topic and then strip the search index
        Add BEFORE:
            // not sum - Visman
            if ($flag_f == 0)
            {
                $result = $db->query('SELECT COUNT(id), poster_id FROM '.$db->prefix.'posts WHERE topic_id IN('.$topics.') GROUP BY poster_id', true) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
                while ($row = $db->fetch_row($result))
                {
                    $db->query('UPDATE '.$db->prefix.'users SET num_posts=num_posts-'.$row[0].' WHERE id='.$row[1]) or error('Unable to update posters messages count', __FILE__, __LINE__, $db->error());
                }
            }
    
    
IV. post.php
    
    1.
        Find:
            if ($tid)
                $result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics, t.subject, t.closed FROM '.$db->prefix.'topics AS t 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
            else
                $result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, fp.post_replies, fp.post_topics FROM '.$db->prefix.'forums AS f 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 f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
        Replace with:
            if ($tid)
                $result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, f.no_sum_mess, fp.post_replies, fp.post_topics, t.subject, t.closed FROM '.$db->prefix.'topics AS t 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'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$tid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
            else
                $result = $db->query('SELECT f.id, f.forum_name, f.moderators, f.redirect_url, f.no_sum_mess, fp.post_replies, fp.post_topics FROM '.$db->prefix.'forums AS f 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 f.id='.$fid) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
                
V. include\functions.php
    1.
        Find:
            function delete_topic($topic_id)
            {
                global $db;

                // Delete the topic and any redirect topics
                $db->query('DELETE FROM '.$db->prefix.'topics WHERE id='.$topic_id.' OR moved_to='.$topic_id) or error('Unable to delete topic', __FILE__, __LINE__, $db->error());

                // Create a list of the post ID's in this topic
                $post_ids = '';
                $result = $db->query('SELECT id FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
                while ($row = $db->fetch_row($result))
                    $post_ids .= ($post_ids != '') ? ','.$row[0] : $row[0];
                    
        Replace with:
            function delete_topic($topic_id, $flag_f = 1) // not sum - Visman
            {
            global $db;

                // Delete the topic and any redirect topics
                $db->query('DELETE FROM '.$db->prefix.'topics WHERE id='.$topic_id.' OR moved_to='.$topic_id) or error('Unable to delete topic', __FILE__, __LINE__, $db->error());

                if ($flag_f == 0) // ?????????? ?????? ? ?????? ? not sum - Visman
                {
                    $result = $db->query('SELECT COUNT(id), poster_id FROM '.$db->prefix.'posts WHERE topic_id='.$topic_id.' GROUP BY poster_id') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error());
                    while ($row = $db->fetch_row($result))
                    {
                        $db->query('UPDATE '.$db->prefix.'users SET num_posts = num_posts-'.$row[0].' WHERE id='.$row[1]) or error('Unable to update posters messages count', __FILE__, __LINE__, $db->error());
                    }
                }
                
                
                
VI. Copy files:

    lang\English\admin_plugin_not_sum.php 
    lang\English\admin_forums.php
    plugins\AP_Not_Sum.php

VII. Open "forums" table in your database and add this line:
`no_sum_mess` tinyint(1) NOT NULL default '0',

* License: GPL version 2 or higher