1

(105 replies, posted in General discussion)

Someone helped me to solve the problem. Here is the code from what I had to change:

//////////////////// REPLACE : ///////////////

            if (!empty($sfdb))
            {
                foreach ($sfdb as $sub_forums)
                {

                    if ($cur_forum['fid'] == $sub_forums[0] && !$pun_user['is_guest'] && forum_is_new($cur_forum['fid'], $cur_forum['last_post']))
                    {
                        $item_status = 'inew';
                        $icon_text = $lang_common['New icon'];
                        $icon_type = 'icon inew';
                    }
                }
            }

//////////////////// WITH: ///////////////

    if (!empty($sfdb)) {
        foreach ($sfdb as $sub_forums) {
            if (!$pun_user['is_guest']) {
                if ($cur_forum['fid'] == $sub_forums[0]) {
                    if (forum_is_new($cur_forum['fid'], $cur_forum['last_post']) || forum_is_new($sub_forums[6], $sub_forums[5])) {
                        $item_status = 'inew';
                        $icon_text = $lang_common['New icon'];
                        $icon_type = 'icon inew';
                    }
                }
            }
        }
    }

If anyone is interested in can send my index.php file.

2

(105 replies, posted in General discussion)

bingiman wrote:

I guess no one is willing to devote some time to it at present. So sad because we reached so far with it. sad

Perhaps most people don't know where to start to help us. The only thing that has to be done is to install punbb, the subforums and mark forums as read mod. The problem is that someone needs to help us with creating a query that reads out if there are new posts in the subforums so it can be displayed on the index.php page.

3

(105 replies, posted in General discussion)

Nobody can suggest a solution?

4

(105 replies, posted in General discussion)

MattF wrote:
bingiman wrote:

Well I am hoping so as well, but it doesn't' look good. As far as I can see no one is willing to lend a hand.

It has nothing to do with willingness. There are things one has to do outside of the forums, you know. big_smile big_smile

Surkow, those numbers are array locators. Check above that code you posted, and you'll see where the $sfdb array is created.

I'll have another look at this when I have the chance, but I am a tad pulled out at the moment with other things.

I looked up that part of the code and I now understand what it tries to do.

$sfdb[$sfcount][0] = $current['parent_forum_id'];
$sfdb[$sfcount][5] = $current['last_post'];

And the relevant part of the code:

if ($cur_forum['fid'] == $sub_forums[0] && !$pun_user['is_guest'] && $sub_forums[5] > $pun_user['last_visit'])

So if the current forum id is the same as the parent forum id (forum categories can have parent forums if they are subforums), the user isn't a guest and the last post of the subforums is greater than the post from the last post of the category itself it will display a new post icon.

Edit:

If I change it to:

if ($cur_forum['fid'] == $sub_forums[0] && !$pun_user['is_guest'] && forum_is_new($cur_forum['fid'], $cur_forum['last_post']))

It tries to find out if you've already read the last posts in the parent forum. This way the only thing that needs to be added is a check for the subforums (so it's partly working now).

So now the question...how do I get the info from the subforums to see if the posts are read? I know there is a while with "$cur_subforum = $db->fetch_assoc($subforum_result)" in it. The query for $subforum_result is:

$subforum_result = $db->query('SELECT f.forum_desc, f.forum_name, f.id, f.last_post, f.last_post_id, f.last_poster, f.moderators, f.num_posts, f.num_topics, f.redirect_url, p.poster_id AS last_poster_id FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'posts AS p ON (p.id=f.last_post_id) WHERE parent_forum_id='.$id.' ORDER BY disp_position') or error('Unable to fetch sub forum info',__FILE__,__LINE__,$db->error());

Edit2:

Also a thing to remember is that the forum categories that are subforums are just normal categories that are hidden and are linked to a parent forum. It would be nice if someone could help to create a query that checks if the subforums from a parent forum have posts that are read.

5

(105 replies, posted in General discussion)

Perhaps MattF or Smartys could suggest what to do to solve this last part of the problem?

6

(105 replies, posted in General discussion)

I was able to find the part of the code in the index.php file that causes the bug:

foreach ($sfdb as $sub_forums)

                {

                    if ($cur_forum['fid'] == $sub_forums[0] && !$pun_user['is_guest'] && $sub_forums[5] > $pun_user['last_visit'])

                    {

                        $item_status = 'inew';

                        $icon_text = $lang_common['New icon'];

                        $icon_type = 'icon inew';

I don't know yet what the 0 and the 5 mean in this part of the code.

Edit:

This is the function that checks if all posts are read:

function forum_is_new($forum_id, $last_post_time) { // this function scares me but I believe all the logic is good.  Have fun :)
    
    global $pun_user, $new_topics;
    
    // first we try to do this the easy way.  
    if ($pun_user['last_visit'] >= $last_post_time) { // were there no posts since the user's last visit?
        return false;
    } else if (!empty($pun_user['read_topics']['f'][$forum_id]) &&    // has the user marked all topics in 
        $pun_user['read_topics']['f'][$forum_id] >= $last_post_time) { // the forum read since the last post?
        return false;
    } else if (empty($pun_user['read_topics']['t']) && empty($pun_user['read_topics']['f'])) { // is it even possible that any of the new posts could be read?
        return true;
    } else {
        // now we must loop through all the "unread" topics in the forum and see if the user has read them.
        foreach($new_topics[$forum_id] as $topic_id => $last_post) {
            if ( // i'll be nice and explain this one for you. if:
                (empty($pun_user['read_topics']['f'][$forum_id]) || // the user hasn't marked the forum read, or
                $pun_user['read_topics']['f'][$forum_id] < $last_post) && // they have but the topic has been posted in since, AND
                (empty($pun_user['read_topics']['t'][$topic_id]) || // the user hasn't marked the topic read, or
                $pun_user['read_topics']['t'][$topic_id] < $last_post) // they have but the topic has been posted in since, then
            )
                return true; // the topic must be new
        }
        return false; // well, since every topic was marked read, then the forum must not have any new posts.
    }
}

Somehow this has to be linked to the index.php page.

7

(105 replies, posted in General discussion)

nvm, we shouldn't let this become a slowchat topic. tongue

8

(105 replies, posted in General discussion)

I can reproduce that the second part works for the viewforum file.

9

(105 replies, posted in General discussion)

bingiman wrote:

The second part for the viewforum in that post does work, so now it is only the index to sort out.

Good news. Perhaps we can send a mail to the guy who created the french subforum mod to see if he only changed the names and not the internal working of the mod.

Edit: sous_forums means sub_forums (sous means something alike "under").

10

(105 replies, posted in General discussion)

bingiman wrote:

Anything so far guys?

Nothing atm. You also didn't seem to appear on my msn list yet.

11

(105 replies, posted in General discussion)

bingiman wrote:

I am constantly trying different bits of code but nothing works so far. I was actually focusing on the index first but nada, zip, zilch so far. big_smile

My MSN is shedrock@sympatico.ca if anyone needs to contact me.

Added you to my msn list. I didn't really have time yet to work on the mod itself.

12

(105 replies, posted in General discussion)

bingiman wrote:

on, well, I'll have to keep checking this post then. I'll wait because I reached so far with the mod and to turn back now would be a drag. not to mention I'd have to go back and reinstall the the mods since then on my old backup. sad

Besides that the communities I run ask for subforums the things you mention are also a reason for me to be stubborn about this modification. If there's any testing needed you can send me a mail to get my msn or something alike.

@MattF - I'm glad someone with knowledge like you is trying to find a solution.

13

(105 replies, posted in General discussion)

bingiman wrote:

Any progress on this Matt?

I've send him a mail with the same question. tongue

Atm I can only try to understand how the modification works. Perhaps it's best to read the other topic I linked with info about the french subforum modification.

14

(105 replies, posted in General discussion)

bingiman wrote:

Actually Matt, It is very easy to install. I was a bit hesitant at first but when I saw Surkow had this mod I just had to install it because it only makes sense to have this on your forums. It should be in the core of punBB.

Bingiman

Agreed, This mod isn't difficult to install at all. There are just a few modifications for the index.php and viewforum.php files. I guess my knowledge about the queries needed is a bit limited.

Edit: it seems people were trying to solve this problem a while ago in the mark posts as read topic for a french version of the subforum mod. See this link for more info. It doesn't seem to be the exact same mod...but perhaps we could learn something from it.

15

(105 replies, posted in General discussion)

MattF wrote:

Have you got the link for that mod? Seem to remember I once looked at it, but there's cartloads of changes to make to the files, isn't there? I might have a peek at it again. big_smile Without the faintest idea how the thing works overall, it's a bit hard to work around it. big_smile

This is the topic where you can download it: http://www.punres.org/viewtopic.php?id=321

16

(105 replies, posted in General discussion)

When I get home I will test the suggestions. I remember I got the correct results on viewforum.php before. But (like bingiman said) it doesn't work for the index.

17

(105 replies, posted in General discussion)

Smartys wrote:

That code for the mod is looking at the topics in a forum, not at subforums. Take a look at the code for index.php, that's where you want to take code from./

The index.php file contains the following:

    // Are there new posts?
    // MOD: MARK TOPICS AS READ - 1 LINE MODIFIED CODE FOLLOWS
    if (!$pun_user['is_guest'] && forum_is_new($cur_forum['fid'], $cur_forum['last_post']))
    {
        $item_status = 'inew';
        $icon_text = $lang_common['New icon'];
        $icon_type = 'icon inew';
    }

If I use "if (!$pun_user['is_guest'] && forum_is_new($cur_subforum['fid'], $cur_subforum['last_post']))" instead of what I posted in my last post the main index.php still shows a new post.

18

(105 replies, posted in General discussion)

Perhaps a related problem with the subforums modification. Currently I installed the "mark topics as read" mod which marks post read as soon as you read them (instead of looking which posts are read since your last visit).

The original code install instructions for the mark topics as read mod:

#
#---------[ 40. OPEN ]--------------------------------------------------------
#

viewforum.php


#
#---------[ 41. FIND (line: 166) ]--------------------------------------------
#
        if (!$pun_user['is_guest'] && $cur_topic['last_post'] > $pun_user['last_visit'] && $cur_topic['moved_to'] == null)


#
#---------[ 42. REPLACE WITH ]------------------------------------------------
#

        // MOD: MARK TOPICS AS READ - 1 LINE MODIFIED CODE FOLLOWS
        if (!$pun_user['is_guest'] && topic_is_new($cur_topic['id'], $id,  $cur_topic['last_post']) && $cur_topic['moved_to'] == null)

After looking at the instructions from the subforum mod I found the following:

    // Are there new posts?

    if (!$pun_user['is_guest'] && $cur_subforum['last_post'] > $pun_user['last_visit'])

    {

        $item_status = 'inew';

        $icon_text = $lang_common['New icon'];

        $icon_type = 'icon inew';

    }

So after comparing those instructions I thought the line after // Are there new posts?" had to be changed to "if (!$pun_user['is_guest'] && topic_is_new($cur_subforum['id'], $id,  $cur_subforum['last_post']))". Sadly enough this didn't have the expected result (nothing changed). Can anyone tell me how to mark posts read in the subforums in the viewforum.php page? Currently the viewtopic.php page works like it should.

I already changed the database and table to "utf8_general_ci". I can't seem to think why it doesn't work yet. I used the following command:

sed -e 's/latin1/utf8/g' < sqlfile.sql > newsqlfile.sql

I also checked the table that contains the messages of the chatbox and the new messages are not displayed correctly because they are now stored without special characters. I'm now looking at the script of the chatbox mod but I can't seem to find any problems with it.

$db->query("SET NAMES 'UTF8'")

This seemed to do the trick. The weird thing is that only old messages are now displayed. New typed messages in the chatbox only show up without the special characters (no longer a question mark but still incomplete). I changed the database to utf-8 and the collation as well. What are the other things I need to do? It seems the queries that are send are no longer stored correctly in the database.

Thanks, it seems promising. I'll post my progress.

After I created a .htaccess file with that contents and cleared the forum cache directory nothing happened. I was thinking...if it's stored correctly in the database and the forum has no problem with showing those characters is it possible that the database doesn't send the strings in the correct character encoding?

I had a couple of issues with the character encoding of different language packs. I solved them by saving the language files as UTF-8 and changing <pun_char_encoding> to utf-8. Currently there is a problem I cannot solve and it seems it only occurs on my local server (LAMP) both with modified and clean installs of punbb. Certain mods like the "PBB ChatBox" mod have trouble showing the correct characters. For example, characters with accents are not displayed (instead question marks are shown). After checking the database it seems that all the different input characters are stored correctly in the tables of the database. I know it's not a problem of the script because I worked on different servers where it did seem to work without problems. Is there anything I can try? I already tried converting all tables to utf-8 but it didn't make any difference. Also it does not matter what kind of character encoding is used when viewing the page.

Edit: the following characters are not shown correctly even when the database shows them correctly and the page is in UTF-8:

ä å é ç è

Besides problems with these characters there also seems to be a problem with using "&".

25

(1 replies, posted in PunBB 1.2 troubleshooting)

Look in the styles directory for yourstyle_cs.css and search for "td".