76

Re: Sub Forum Mod and index

No rush then. big_smile big_smile

Not done anything as of yet. Just trying to figure if there's an easier way to do the whole thing. From the quick look I had at the code for this mod, it seems to work in an excessively convoluted manner. That doesn't mean there is an easier way though. big_smile big_smile

Re: Sub Forum Mod and index

Well, from what Smartys said, it seems like the whole thing has to be rewritten. I am no coder but I don't see what that would have to be done. The problem is with the index and the viewforum. I would imagine that and "if else" would do the trick in both files. I mean one is reading the parent forums and the other the subs. Then again, what do I know. I honestly wish I knew PHP and MySQL.

Bingiman

78

Re: Sub Forum Mod and index

With regards to specifics, I honestly couldn't say at the moment. However, the way it works seems weird. It could be more adaptable than it is. (As I mentioned however, that is just a fleeting glance impression). I am going to have a bash at it. I'm just waiting until the penny drops regarding what may be the simplest and most useful way to do it. It'll pop into my head at some point. big_smile big_smile

Re: Sub Forum Mod and index

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

80

Re: Sub Forum Mod and index

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.

81

Re: Sub Forum Mod and index

Surkow wrote:

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

Whomever accused me of knowing 'owt lied. big_smile big_smile

Re: Sub Forum Mod and index

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.

83

Re: Sub Forum Mod and index

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.

Re: Sub Forum Mod and index

ok, no problem. I will keep a lookout here.

Re: Sub Forum Mod and index

Anything so far guys?

86

Re: Sub Forum Mod and index

bingiman wrote:

Anything so far guys?

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

87 (edited by MattF 2007-10-31 19:33)

Re: Sub Forum Mod and index

Not had chance to do anything yet. My hands are a tad full this week, upto just. I'll mention if/when I make any headway. smile

Btw, on an unrelated note, have you had a play with that other code I sent you yet? smile

Re: Sub Forum Mod and index

Not yet...believe it or not all I've been doing is trying to get this to work. I am obsessed with it. I will probably have to pay someone to get it working for me. Anyway, I will try your mod out this week for sure. smile

89

Re: Sub Forum Mod and index

bingiman wrote:

Not yet...believe it or not all I've been doing is trying to get this to work. I am obsessed with it.

A modding obsession does tend to be one of PunBB's side effects, doesn't it. big_smile big_smile

Re: Sub Forum Mod and index

I was looking at this post. The code is in French so it doesn't rally help me maybe one of you guys can decipher it.

http://www.punres.org/viewtopic.php?pid=6925#p6925

Re: Sub Forum Mod and index

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

92 (edited by Surkow 2007-11-02 07:24)

Re: Sub Forum Mod and index

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").

93

Re: Sub Forum Mod and index

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

94 (edited by bingiman 2007-11-02 19:32)

Re: Sub Forum Mod and index

Yeah, I sorta figured it all out when I compared it. However, it still doesn't' work for the index. sad

95 (edited by Surkow 2007-11-02 19:09)

Re: Sub Forum Mod and index

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

96 (edited by Surkow 2007-11-02 22:45)

Re: Sub Forum Mod and index

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.

97

Re: Sub Forum Mod and index

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

Re: Sub Forum Mod and index

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.

99

Re: Sub Forum Mod and index

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.

100 (edited by Surkow 2007-11-03 22:50)

Re: Sub Forum Mod and index

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.