Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: All Colours Sam on February 07, 2013, 03:42:35 PM

Title: Private Topics
Post by: All Colours Sam on February 07, 2013, 03:42:35 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3626)

Private topics mod
by: Suki (http://missallsunday.com)

License


/*
* Version: MPL 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
* If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
*/


Description

Allows users with permissions to mark topics as private and invite people to it, the mod also has a permission to see all topics marked as private without the need to be invited.

This mod only covers a vanilla SMF installation, if you have mods that adds their own queries to fetch topics then you need to manually apply the appropiate check to that code.

for SMF 2.0.x only

Laguage
-English


ChangeLog
Title: Re: Private Topics
Post by: All Colours Sam on February 07, 2013, 03:48:15 PM
ugh! I sent this before I realized the mess with grandchild boards.

If you are planing on using this, keep in mind that it doesn't play well with child and grandchild boards (and I have no idea how to properly add support for it) and it does add a performance hit, it is not recommended to use this on a busy site.
Title: Re: Private Topics
Post by: littlenicki on February 08, 2013, 09:10:03 AM
Oh! That's a great idea! Would you mind doing a SMF 1.1 Version of this mod please Mr. Suki? Thank you!
Title: Re: Private Topics
Post by: All Colours Sam on February 08, 2013, 10:41:35 AM
I'm sorry, I do not write mods for outdated versions and I ain't a Mr ;)  but since the mod is open source, anyone can write a version for 1.1.x
Title: Re: Private Topics
Post by: Thels on February 12, 2013, 12:30:27 PM
Hi,

It seems like an interesting mod, but I'm a little confused about how to get it to work.

Would it be possible to automatically mark all threads on a specific board as private, so for that board, people can only see and reply to the thread they made themselves, except for global moderators who are able to view and reply to all threads?

Kind regards,
Thels.
Title: Re: Private Topics
Post by: All Colours Sam on February 12, 2013, 01:21:09 PM
Welcome, first of all, the annoying captcha goes away at 10 posts.

Well, I specifically added a check so the users can chose for themselves whether or not mark any of their topics as private, the mark as private option will only be available on the boards you specified in the mod's settings admin page.

You can change this on your theme's Post.template.php

<input type="checkbox" id="ptenable" name="ptenable"', !empty($context['ptenable']) ? ' checked="checked"' : '', ' class="input_check" />


with this:

<input type="checkbox" id="ptenable" name="ptenable"', !empty($context['ptenable']) || !empty($ptBoard) ? ' checked="checked"' : '', ' class="input_check" />


And it will make the check as marked by default.
Title: Re: Private Topics
Post by: pastorvictor on February 12, 2013, 05:32:29 PM
Thank you, Suki, this sounds like a great mod! So if I don't have any subforums, I shouldn't have any issues with it?
Title: Re: Private Topics
Post by: All Colours Sam on February 12, 2013, 05:42:38 PM
Only the server load been increased, if you have a pretty busy forum then I don't recommend adding this.
Title: Re: Private Topics
Post by: pastorvictor on February 12, 2013, 05:53:02 PM
It actually hasn't opened yet, so I'm not sure how busy it will be yet. I do know that I want to have a board where my staff can offer private counseling to the users but not through PM, so this sounds like the way to go. Would this use even more resources than, say, AJAX Chat?
Title: Re: Private Topics
Post by: All Colours Sam on February 12, 2013, 06:04:18 PM
No, any chat will add far more load to the server than this mod. This mod will only become an issue when you have literally thousands of users requesting topics.
Title: Re: Private Topics
Post by: pastorvictor on February 12, 2013, 06:10:57 PM
Oh okay, thanks again Suki. This sounds like the way to go, at least for now. I'm *hoping* to have thousands of members, of course, but it will still take some time for that to happen :)
Title: Re: Private Topics
Post by: pastorvictor on February 13, 2013, 06:33:21 PM
Suki, where it says "type a user ID," is that for the user to allow non-moderators to view it? If so, can this be disabled?
Title: Re: Private Topics
Post by: All Colours Sam on February 13, 2013, 07:02:54 PM
Your users can leave that field as empty and then only the topic author and whoever has the permission to see any topic will be able to see it.
Title: Re: Private Topics
Post by: Skaty on March 04, 2013, 04:45:51 PM
Very usefull mod and i need it but it is really work in "vanilla smf".  cant make it work in custom theme.  does anyone can use it in custom theme ?


ps:  now i tried with fresh smf and it is gave me the same error, i think there is something else to make it work.

The error is, when i create a private topic it given me ''The database value you're trying to insert does not exist: topic_id'' and can't reach some of my mods it is given me another error.

is there any solution for this ? if this is a bug i can send a demo acc for test :)
Title: Re: Private Topics
Post by: All Colours Sam on March 04, 2013, 07:34:37 PM
Thing is, I cannot reproduce this on my local installation, I already tried several times with no luck...

Can you please tell me step by steps all the changes you did, including the boards where you are enabling this, whos member is having the issues, do you set the permissions correctly? are your boards childboards or grand childboards?  all details you can provide would help.
Title: Re: Private Topics
Post by: Skaty on March 04, 2013, 07:55:41 PM
I can't explane all of these with my english :) i thing it would be better to sent you a demo acc (did it).
Title: Re: Private Topics
Post by: All Colours Sam on March 04, 2013, 07:59:18 PM
a demo acc at this point isn't going to help since I just don't know the steps you did for the error to appear, that is why I want to know which steps you did.

doesn't matter if you can't explain it in English, post it on your native language, google will do the rest, the point here is to know all the steps you did.
Title: Re: Private Topics
Post by: Skaty on March 04, 2013, 09:14:21 PM
Okay then, i will tell the steps and you can try them with demo acc.

The mod is active in board number 1. So first try to open new thread in here. chech the box and don't write any member id.
it will give this error ''The database value you're trying to insert does not exist: topic_id''

but the post will open. and appear for everyone.

the board error doesn't appear now. i will give more information later.
Title: Re: Private Topics
Post by: All Colours Sam on March 05, 2013, 08:39:46 PM
OK, thanks, that gives me an idea on where I need to look, hopefully this "undefined topic" error will finally stop hunting me!

Will take a look when I have some time.
Title: Re: Private Topics
Post by: Skaty on March 13, 2013, 06:14:11 PM
Quote from: Suki on March 05, 2013, 08:39:46 PM
OK, thanks, that gives me an idea on where I need to look, hopefully this "undefined topic" error will finally stop hunting me!

Will take a look when I have some time.

Okay  :laugh:
Title: Re: Private Topics
Post by: Skaty on April 02, 2013, 08:34:11 AM
Suki,  i'm still trying to work this mod. Sometimes it is working sometimes it is not. i wonder maybe i'm doing something wrong with entegrate it my theme. can you help me with just this part ?

how should has to be ?

find

if (!empty($board['last_post']['id']))
echo '
<p><span>', $board['last_post']['member']['link'] , ' ', $txt['in'], ' ', $board['last_post']['link'], '</span><br />
', $board['last_post']['time'],'
</p>';


change

if (!empty($board['last_post']['id']))
if (!empty($modSettings['PrivateTopics_enable']))
{
global $user_info;
$ptTrue = false;
$pt = new PrivateTopics($board['last_post']['id']);
$ptCache = $pt->doGet();

if (!empty($ptCache) && is_array($ptCache) && !allowedTo('can_always_see_private_topics'))
{
if (!in_array($user_info['id'], $ptCache))
echo '
<p>', !empty($modSettings['PrivateTopics_boardindex_message']) ? $modSettings['PrivateTopics_boardindex_message'] : PrivateTopics::doTools()->getText('boardindex_message_default') ,'</p>';

else
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';
}

else
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';
}

else
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';


Title: Re: Private Topics
Post by: All Colours Sam on April 02, 2013, 08:47:39 AM
Exactly like you posted it?  just find/replace.

To say "not working" doesn't really help, at all.
Title: Re: Private Topics
Post by: Skaty on April 02, 2013, 08:54:30 AM
i couldn't express myself.


in defaul theme it has these codes.
if (!empty($board['last_post']['id']))
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';


but in mine theme it has these, how has to be the modified.


if (!empty($board['last_post']['id']))
echo '
<p><span>', $board['last_post']['member']['link'] , ' ', $txt['in'], ' ', $board['last_post']['link'], '</span><br />
', $board['last_post']['time'],'
</p>';
Title: Re: Private Topics
Post by: All Colours Sam on April 02, 2013, 08:59:14 AM
The only thing that changes is this:


echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'] , '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>'


Just replace that echo part with what you have:


echo '
<p><span>', $board['last_post']['member']['link'] , ' ', $txt['in'], ' ', $board['last_post']['link'], '</span><br />
', $board['last_post']['time'],'
</p>';



If you see closely on the code you need to add, there are multiple instance of that echo statement, replace all of them with what you have.
Title: Re: Private Topics
Post by: Skaty on April 02, 2013, 09:26:24 AM
Okay i did it like this:


if (!empty($board['last_post']['id']))
if (!empty($modSettings['PrivateTopics_enable']))
{
global $user_info;
$ptTrue = false;
$pt = new PrivateTopics($board['last_post']['id']);
$ptCache = $pt->doGet();

if (!empty($ptCache) && is_array($ptCache) && !allowedTo('can_always_see_private_topics'))
{
if (!in_array($user_info['id'], $ptCache))
echo '
<p>', !empty($modSettings['PrivateTopics_boardindex_message']) ? $modSettings['PrivateTopics_boardindex_message'] : PrivateTopics::doTools()->getText('boardindex_message_default') ,'</p>';

else
echo '
<p><span>', $board['last_post']['member']['link'] , ' ', $txt['in'], ' ', $board['last_post']['link'], '</span><br />
', $board['last_post']['time'],'
</p>';
}

else
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';
}

else
echo '
<p><strong>', $txt['last_post'], '</strong>  ', $txt['by'], ' ', $board['last_post']['member']['link'], '<br />
', $txt['in'], ' ', $board['last_post']['link'], '<br />
', $txt['on'], ' ', $board['last_post']['time'],'
</p>';


when i make a topic private and put a id, other members can't see the all boards it gives a DB error. in default theme can see the topic but can't open it, it seems working in default.
Title: Re: Private Topics
Post by: All Colours Sam on April 02, 2013, 09:32:48 AM
Did you do all the other edits the mod needs?

This is just a template edit.  Anyway, you only replaced one echo statement, there are more two more.

Can really help you if you don't provide more details.... what DB error? what did you do? did you installed this manually?
Title: Re: Private Topics
Post by: Skaty on May 10, 2013, 12:08:42 PM
the mod is sending pm to invite users but it is do it just in the first time when post is created. if you add couple of more id after that it is not sending pms to the new ids.

is ''anyone'' have and idea how to fix this ?

thanks in advance.