News:

Wondering if this will always be free?  See why free is better.

Main Menu

View Any Topic permission

Started by Feldon, March 09, 2007, 10:04:07 PM

Previous topic - Next topic

RoarinRow


SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

egobuster

Hi guys, I am hope you can help.

Essentially my forum has to have a member profiles where each members can make individual posts with restrictions as to who can access, view and reply to these posts.

The concept similar to myspace, but so there is an open forum for members as well.

One solution is to create threads that would have an option to be only visible and accecceble by the selected members. it would be a bonus if I could put a each member in charge of their own thread and they choose as to who can see that thread and access it.

Alternativelly, which is a bit of a headache, I can set up threads through admin board, but then add permission for each of the member.

I do not want to create groups, just need each member to be able to moderate, view and have access to selected threads.


Any suggestions.

Thanks you.


[email protected]

PoLlama

Could you add a feature in to allow people to view topics they cannot see, if they have the exact URL?

Like a new permission
"Allow user to view topics as long as they have URL".

I want to add a pastebin to my forum, in terms of forums, a board where all topics except stickies are hidden, but can be accessed through the exact URL only. This is useful for stuff like temporary downloads, and private discussions. It seems no one knows about pastebins on SMF, but i've seen a few vBulletin forums with them.

Another idea...
"Allow user to view topics created by buddies".

If you do happen to implement one of these ideas thanks.

Feldon

Just fyi, my mod's mostly a one time thing.  I'll be maintaining it through SMF version changes, but I don't plan to add any new features.

Regarding the pastebin, how would you make your friends aware of its availability?  Would sending a PM to multiple people with the code or whatever in it not be the same thing?  You're already going to have to send them the link privately somehow.

Paracelsus

I think I've detected a bug:

After install, it gave me the error below... this happens when somenone tries to look at other members messages in the profile, as long as that member has more than 1000 messages:

Column 'ID_MSG' in where clause is ambiguous
Ficheiro: /home/forumscp/public_html/Sources/Profile.php
Linha: 1463

After some research we believe to have detected the problem in the following code:
// Guess the range of messages to be shown.
if ($msgCount > 1000)
{
$margin = floor(($max_msg_member - $min_msg_member) * (($start + $modSettings['defaultMaxMessages']) / $msgCount) + .1 * ($max_msg_member - $min_msg_member));
$range_limit = $reverse ? 'ID_MSG < ' . ($min_msg_member + $margin) : 'ID_MSG > ' . ($max_msg_member - $margin);
}

$context['page_title'] = $txt[458] . ' ' . $user_profile[$memID]['realName'];

// View Any Topic Permission
$request = db_query("
SELECT b.ID_BOARD
FROM {$db_prefix}boards AS b", __FILE__, __LINE__);
$normal_boards = array(-1);
while ($row = mysql_fetch_assoc($request)) {
if (allowedTo('view_any_topic', $row['ID_BOARD']))
$normal_boards[] = $row['ID_BOARD'];
}
mysql_free_result($request);

// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
$looped = false;
while (true)
{
$request = db_query("
SELECT
b.ID_BOARD, b.name AS bname, c.ID_CAT, c.name AS cname, m.ID_TOPIC, m.ID_MSG,
t.ID_MEMBER_STARTED, t.ID_FIRST_MSG, t.ID_LAST_MSG, m.body, m.smileysEnabled,
m.subject, m.posterTime
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT), {$db_prefix}messages AS mf
WHERE m.ID_MEMBER = $memID
AND m.ID_TOPIC = t.ID_TOPIC
AND t.ID_BOARD = b.ID_BOARD
AND mf.ID_MSG = t.ID_FIRST_MSG
AND ( b.ID_BOARD IN (" . implode(', ', $normal_boards) . ") OR t.isSticky = 1 OR mf.ID_MEMBER = $ID_MEMBER )" . (empty($range_limit) ? '' : "
AND $range_limit") . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG " . ($reverse ? 'ASC' : 'DESC') . "
LIMIT $start, $maxIndex", __FILE__, __LINE__);

// Make sure we quit this loop.
if (mysql_num_rows($request) === $maxIndex || $looped)
break;
$looped = true;
$range_limit = '';
}


So we've added m.ID_MSG to both ID_MSG expressions (near the beginning of the above code) and the problem got solved while maintaining the ability of regular users not being able to see no-permission messages in others profiles $range_limit = $reverse ? 'm.ID_MSG < ' . ($min_msg_member + $margin) : 'm.ID_MSG > ' . ($max_msg_member - $margin);

Feldon

Another good find!

I agree with your solution and have implemented it.

An updated package, version 1.7, is now available from the mod download page.

http://custom.simplemachines.org/mods/index.php?mod=687

ButtonBash

With v1.7, I'm getting many 'fails' when getting ready to install.

Using SMF 1.1.3, which this mod is stated to work with.

Seemed to be causing quite a stir with the installer. I'm looking forward to a solution, as this mod would be incredibly handy to use.

Feldon

Quote from: ButtonBash on September 23, 2007, 05:49:39 PM
With v1.7, I'm getting many 'fails' when getting ready to install.

Using SMF 1.1.3, which this mod is stated to work with.

Seemed to be causing quite a stir with the installer. I'm looking forward to a solution, as this mod would be incredibly handy to use.

I'm sorry to see that.  This mod should install just fine with a fresh install of SMF.  If you are running other mods, we may be affecting some of the same blocks of code.

I would try uninstalling the other mods, installing my mod, and then installing the other mods again.  If this doesn't work, you can try manually installing my mod (or one of the other overlapping mods).  With mine, you need to unzip the package and follow the instructions in the ViewAnyTopicPermission.xml file.  You will likely find that the code blocks you are instructed to 'replace' will have been altered by another mod, so be careful.  Keep a back-up of the original files so that you can upload them again if anything gets screwed up.

Feldon

#28
I made a small change to the mod so that the version number appears correctly on the Packages page.  I updated the mod download page.  There were no 'real' changes.

UPDATE: SMF 1.1.4 was released today.  The mod continues to appear to work correctly.

Paracelsus

Hi Feldon...

I've just noticed that the "Recent Posts" window actually shows the posts made in a board where this MOD is applied, ie., only Staff has "View Any Topic" permission and the board is without Post/Topic Count, Notifications and Announcements. It shows the message name and who wrote, although it's not possible for a guest to actually go into the topic and read it.

I would like to hide them in the list and from what I've read it should be possible... Since it happens to me both in default and custom themes, I've even checked the code changed in Stats.php and it matches perfectly the one in the original package... there's one more MOD on Subs file, the Enhancement Statistics MOD, but I don't know if it's some sort of lack of compatibility between them.

Can you address this question and see if something is wrong?

Feldon

Quote from: Paracelsus on September 26, 2007, 04:03:39 AM
Hi Feldon...

I've just noticed that the "Recent Posts" window actually shows the posts made in a board where this MOD is applied, ie., only Staff has "View Any Topic" permission and the board is without Post/Topic Count, Notifications and Announcements. It shows the message name and who wrote, although it's not possible for a guest to actually go into the topic and read it.

I would like to hide them in the list and from what I've read it should be possible... Since it happens to me both in default and custom themes, I've even checked the code changed in Stats.php and it matches perfectly the one in the original package... there's one more MOD on Subs file, the Enhancement Statistics MOD, but I don't know if it's some sort of lack of compatibility between them.

Can you address this question and see if something is wrong?

I'm sorry you are having trouble.

To begin, I'd like to make sure we are discussing the same screen.  If you go to the home page of your forum, most themes have a "Forum Stats" section at the bottom.  In that section is a link to "View the most recent posts on the forum."  That opens the Recent Posts screen.

In my case, I'm currently running SMF version 1.1.4 with TinyPortal 0.9.8 and no other mods.  The recent posts appear to be correctly hidden when I'm logged in as a regular member.

The fact that your Stats.php file appears to be unchanged from the original SMF file, suggests that the mod isn't properly installed.  The Stats.php file should be altered by the mod.  I would try uninstalling and then reinstalling my mod.  If this doesn't work, you can try manually installing my mod.  To manually install, simply unzip the package and follow the instructions in the ViewAnyTopicPermission.xml file.

If necessary, can you point me to the Enhancement Statisticis Mod?  There appear to be a couple mods with a similar name.


As an aside, I think the next time I release a new version, I am going to try to reduce the amount of code I reference in the installer.  This should make it less likely that another mod interferes.

Paracelsus

It is likely we are NOT discussing the same thing... ;D ... let's see:

In the Info Center, BEFORE the Forum Stats, you have this topic list, which is called "Recent Posts", a list to which you can define how many topics will appear there in the admin theme config (1, 2, 10 or 0 if you don't want any to appear). In that list I can see as a guest the subject and author messages posted in no-access boards well configured with the View Any Topic disabled.

I actually checked all files that are subject to change after I posted here and there's no doubt that the everything is as supposed - all the new code is inserted correctly. I supposed it would be something in Stats.php but it can be in Recent.php or somewhere else.

Paracelsus

I found the piece of code in BoardIndex.template.php... maybe this function isn't addressed in the MOD (although I actually think it should):

// Here's where the "Info Center" starts...
echo '<br />
<div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;"' : '', '>
<div class="catbg" style="padding: 6px; vertical-align: middle; text-align: center; ">
<a href="#" onclick="shrinkHeaderIC(!current_header_ic); return false;"><img id="upshrink_ic" src="', $settings['images_url'], '/', empty($options['collapse_header_ic']) ? 'collapse.gif' : 'expand.gif', '" alt="*" title="', $txt['upshrink_description'], '" style="margin-right: 2ex;" align="right" /></a>
', $txt[685], '
</div>
<div id="upshrinkHeaderIC"', empty($options['collapse_header_ic']) ? '' : ' style="display: none;"', '>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';

// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']))
{
echo '
<tr>
<td class="titlebg" colspan="2">', $txt[214], '</td>
</tr>
<tr>
<td class="windowbg" width="20" valign="middle" align="center">
<a href="', $scripturl, '?action=recent"><img src="', $settings['images_url'], '/post/xx.gif" alt="', $txt[214], '" /></a>
</td>
<td class="windowbg2">';

// Only show one post.
if ($settings['number_recent_posts'] == 1)
{
// latest_post has link, href, time, subject, short_subject (shortened with...), and topic. (its id.)
echo '
<b><a href="', $scripturl, '?action=recent">', $txt[214], '</a></b>
<div class="smalltext">
', $txt[234], ' &quot;', $context['latest_post']['link'], '&quot; ', $txt[235], ' (', $context['latest_post']['time'], ')<br />
</div>';
}
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%" border="0">';

/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td class="middletext" valign="top"><b>', $post['link'], '</b> ', $txt[525], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</td>
<td class="middletext" align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
</tr>';
echo '
</table>';
}
echo '
</td>
</tr>';
}

Feldon

Oh! Doh...  I will fix it.  Should have something by the end of the weekend for sure.

Another good find!

My forum had that set to 0 posts so I never saw it.

Feldon

Version 1.8 has been made available from the mod's download page: http://custom.simplemachines.org/mods/index.php?mod=687

The changes are:
- [BUGFIX] I previously missed the recent posts explicitly listed in the Info Center.  This has been corrected.
- [BUGFIX] The Top 10 Replies and Top 10 Views sections of the Stats page was simply hiding posts in the top 10 that were in a board with the permission disabled, meaning that the member might see fewer than 10 replies/views.  It now finds the top 10 replies/views not in the board with the permission disabled.
- Modified the ViewAnyTopicPermission.xml file to look for smaller chunks of code.  Hopefully this will lead to fewer incompatabilities with other mods.

If I've broken anything, or if you find anything else, please let me know!

Paracelsus

It's working fine now!  ;D
Thanks!!!

clap clap clap

Paracelsus

Actually, there's something missing  ;D ;D

When in Child-Board, it's possible for a member with limited access to it (view any permission enabled) to see the last message title, date and author for any message (even  others messages) from the "mother"-board.

Feldon

Version 1.9 is now available from the mod's download page: http://custom.simplemachines.org/mods/index.php?mod=687

The changes are:
- [BUGFIX] I previously missed the child board's last post information while viewing the parent board.  This has been corrected.

Thank you Paracelsus for finding this.

Again, if I've broken anything, or if you find any other problems, just let me know.

As an aside, there really is a remarkable amount of code duplication throughout SMF.  There seems to be an ever-increasing number of places it is looking for board/topic information.  From what I can tell, the reason is because depending on the function (recent posts, last posts, normal board viewing, notifications, etc) a slightly different database query is required.  This makes my job hard, because if I miss any little function (which I apparently have 4 times now), my mod will be incomplete.  I hope we have now caught everything, but I wouldn't bet on it.

Paracelsus


Paracelsus

Here I am again... LOL

When in profile, looking at the users messages gives me this error:

QuoteNot unique table/alias: 'mf'
Ficheiro: /home/forumscp/public_html/Sources/Profile.php
Linha: 1469

Nota: Parece que a sua base de dados precisa de ser actualizada. Os ficheiros estão na versão SMF 1.1.4, enquanto a sua base de dados está na versão1.1.2. Recomenda-se que seja executada a actualização para a última versão.

The last part is in portuguese and means that the SMF files are in version 1.1.4 while the database is in version 1.1.2.

The code in Profile which matches the line is the following (line 1469 is the last one in the bottom):
// View Any Topic Permission
$request = db_query("
SELECT b.ID_BOARD
FROM {$db_prefix}boards AS b", __FILE__, __LINE__);
$normal_boards = array(-1);
while ($row = mysql_fetch_assoc($request)) {
if (allowedTo('view_any_topic', $row['ID_BOARD']))
$normal_boards[] = $row['ID_BOARD'];
}
mysql_free_result($request);

// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
$looped = false;
while (true)
{
$request = db_query("
SELECT
b.ID_BOARD, b.name AS bname, c.ID_CAT, c.name AS cname, m.ID_TOPIC, m.ID_MSG,
t.ID_MEMBER_STARTED, t.ID_FIRST_MSG, t.ID_LAST_MSG, m.body, m.smileysEnabled,
m.subject, m.posterTime
FROM ({$db_prefix}messages AS m, {$db_prefix}messages AS mf, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT), {$db_prefix}messages AS mf
WHERE m.ID_MEMBER = $memID
AND m.ID_TOPIC = t.ID_TOPIC
AND t.ID_BOARD = b.ID_BOARD
AND mf.ID_MSG = t.ID_FIRST_MSG
AND ( b.ID_BOARD IN (" . implode(', ', $normal_boards) . ") OR t.isSticky = 1 OR mf.ID_MEMBER = $ID_MEMBER )
AND t.ID_BOARD = b.ID_BOARD" . (empty($range_limit) ? '' : "
AND $range_limit") . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG " . ($reverse ? 'ASC' : 'DESC') . "
LIMIT $start, $maxIndex", __FILE__, __LINE__);

Advertisement: