View Only Boards

Started by Rudolf, January 31, 2007, 10:45:10 AM

Previous topic - Next topic

Hj Ahmad Rasyid Hj Ismail

#480
Quote from: scenerip2k on June 28, 2010, 01:51:04 AM
3. Edit your ManageBoards.template.php
I have fixed that so you don't need to edit. Modified file is attached.

EDITED: Attachement removed. Please use this one: http://www.simplemachines.org/community/index.php?topic=146964.msg2734095#msg2734095

sharks

There is a bug with the 2.0 RC3 version. If the option to list all recent posts is enabled, it will list all the latest posts, even if some of the posts are in boards which have been set to invisible and/or inaccessible to guests.

Hj Ahmad Rasyid Hj Ismail

#482
Quote from: sharks on August 06, 2010, 12:02:08 PM
There is a bug with the 2.0 RC3 version. If the option to list all recent posts is enabled, it will list all the latest posts, even if some of the posts are in boards which have been set to invisible and/or inaccessible to guests.
I agree with you sharks. I have made some effort to check and (I think I had) fixed it. Please try and see how it goes. It is working on my site.

EDITED: Attached mod refixed due the error reported by sharks.

sharks

In the boards set to visible only, but not accessible, normally, on the board index, you should see this:
Last post by Protected
in Protected

but instead, i still see the actual last post and the last topic, which should both not be visible.

Hj Ahmad Rasyid Hj Ismail

Quote from: sharks on August 07, 2010, 10:58:37 AM
In the boards set to visible only, but not accessible, normally, on the board index, you should see this:
Last post by Protected
in Protected

but instead, i still see the actual last post and the last topic, which should both not be visible.
What you are saying does not make sense to me. If the board is visible, the topic is also visible but not accessible. If the board is not accessible and not visible then it would not show, at all.

waqarhassan

i have also installed it this is very useful thing its works fine in my forum

sharks

#486
Quote from: ahrasis on August 07, 2010, 11:17:21 AM
Quote from: sharks on August 07, 2010, 10:58:37 AM
In the boards set to visible only, but not accessible, normally, on the board index, you should see this:
Last post by Protected
in Protected

but instead, i still see the actual last post and the last topic, which should both not be visible.
What you are saying does not make sense to me. If the board is visible, the topic is also visible but not accessible. If the  board is not accessible and not visible then it would not show, at all.

But that's the way it works when installed in SMF 1.1.11
I would expect it to behave the same way in SMF 2.0 RC3.
And v2 still does not fix the problem with posts appearing in the recent posts list on the index forum page, when some board has been set to visible only, but not accessible. Try it out on SMF 1.1.11 and you will see the differences of what i mean.

Here is what i see in Features and Options on SMF 1.1.11

Allow guests to browse the forum     (checked)
Show the message index for "view only" boards (unchecked)

Both options also exist in SMF 2.0 RC3 but the second option does not work 100%. If unchecked, that second option should "protect" the last topic title and last post in the visible-only board. That's the way it works on SMF 1.1.11

Hj Ahmad Rasyid Hj Ismail

Yes. It doesn't work similarly to 1.1.x. The name is clearly view only board which means the board can be made viewable or otherwise the default accessible (of course viewable) or not.

It does not protect the post access but it protects board access. So it is possible to list all this board topics and posts, recent or otherwise, without users being able to access when it is set to view only.

sharks

#488
Bad News:

My 2.0 RC3 forum's error log is flooding like crazy right now, after installing v2. I get these 2 errors repeatedly.

8: Undefined variable: post
Only show the errors from this file
File: /home/user/sharks/Sources/Subs-Recent.php
Line: 84

8: Undefined index: ID_BOARD
Only show the errors from this file
File: /home/user/sharks/Sources/Subs-Recent.php
Line: 76

Hj Ahmad Rasyid Hj Ismail

Quote from: sharks on August 07, 2010, 11:46:59 AM
Bad News:

My 2.0 RC3 forum's error log is flooding like crazy right now, after installing v2. I get these 2 errors repeatedly.

8: Undefined variable: post
Only show the errors from this file
File: /home/user/sharks/Sources/Subs-Recent.php
Line: 84

8: Undefined index: ID_BOARD
Only show the errors from this file
File: /home/user/sharks/Sources/Subs-Recent.php
Line: 76
Can your post from 10 lines before line 76 and 10 lines after line 84 in your Subs-Recent.php so I can check it?

sharks

It happens to all members when logged in and when guests are also browsing the boards. Help!

Hj Ahmad Rasyid Hj Ismail

#491
Quote from: sharks on August 07, 2010, 11:52:20 AM
It happens to all members when logged in and when guests are also browsing the boards. Help!
Can your post from 10 lines before line 76 and 10 lines after line 84 in your Subs-Recent.php so I can check it?

Btw, looking from ID_BOARD, you might have old code (not fully have clean uninstall from previous mod) before installing the one above. There is no ID_BOARD in the code.

sharks

#492
I just uploaded my Subs-Recent.php. Find it attached to this post.

Quote from: ahrasis on August 07, 2010, 11:54:14 AM
Btw, looking from ID_BOARD, you might have old code (not fully have clean uninstall from previous mod) before installing the one above. There is no ID_BOARD in the code.
What should i edit then? I have tried to execute a clean uninstall, but the previous mod was a forced installation to begin with, so it messed up my code.

sharks

#493
Here is the code part you requested:


// Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
// !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
$request = $smcFunc['db_query']('substring', '
SELECT
m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg,
IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE m.id_msg >= {int:likely_max_msg}' .
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
AND b.id_board != {int:recycle_board}' : '') . '
AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY m.id_msg DESC
LIMIT ' . $latestPostOptions['number_posts'],
array(
'likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']),
'recycle_board' => $modSettings['recycle_board'],
'is_approved' => 1,
)
);
$posts = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
// Censor the subject and post for the preview ;).
censorText($row['subject']);
censorText($row['body']);

$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';


//- View Only Boards MOD- START
// Do not show protected topics
if (empty($modSettings['vob_allowMessageIndexView']) && in_array($row['ID_BOARD'],$user_info['view_only_boards']))
continue;
//- View Only Boards MOD- END

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'protected' => in_array($post['board'], $user_info['view_only_boards']), //- View Only Boards MOD-
'name' => $row['board_name'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 24),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'raw_timestamp' => $row['poster_time'],
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>'
);
}
$smcFunc['db_free_result']($request);

return $posts;
}

// Callback-function for the cache for getLastPosts().


There is too much error flooding and it is causing some spikes in server load.
I will have to remove your mod until it is stable. Too bad, it looked useful.
I advise everyone to stick to the old code, until this one is properly fixed, otherwise you'll break your forum.

Hj Ahmad Rasyid Hj Ismail

Quote from: sharks on August 07, 2010, 12:07:41 PM

if (empty($modSettings['vob_allowMessageIndexView']) && in_array($row['ID_BOARD'],$user_info['view_only_boards']))

This should be not be in capital ID_BOARD but lower id_board.
if (empty($modSettings['vob_allowMessageIndexView']) && in_array($row['id_board'],$user_info['view_only_boards']))
Sorry, I didn't see this. Do uninstall the mod. I'll try to fix the mod right away.

Hj Ahmad Rasyid Hj Ismail

I've fixed the ID_BOARD to id_board in the mod and already updated the attached mod in that post http://www.simplemachines.org/community/index.php?topic=146964.msg2734095#msg2734095

sharks

I have installed your v2 fixed mod, but still getting this error repeatedly.

8: Undefined variable: post
Only show the errors from this file
File: /home/user/sharks/Sources/Subs-Recent.php
Line: 84

Hj Ahmad Rasyid Hj Ismail

Quote from: sharks on August 07, 2010, 12:27:44 PM
I have installed your v2 fixed mod, but still getting this error repeatedly.

8: Undefined variable: post
Only show the errors from this file
File: /home/user/sharks/Sources/Subs-Recent.php
Line: 84
I am actually trying to see what is causing that. I have tested the mod without having the same problem. I am looking at it now.

Hj Ahmad Rasyid Hj Ismail

Alright. Got it. I updated the refixed copy on that post. Sorry, for the trouble. Just merely trying to help.

sharks

I tested the v2 re-fixed version and there are no errors. And no need for apologies, your efforts are very much appreciated. :)

Great job!

Advertisement: