• Welcome to Simple Machines Community Forum. Please login or sign up.
January 26, 2022, 06:55:00 AM

News:

SMF 2.1 RC4 has been released! Try it out and help us test! :) Read more.


Hide Post

Started by Leaf, November 30, 2005, 10:49:38 PM

Previous topic - Next topic

Leaf

December 04, 2005, 03:11:08 AM #20 Last Edit: December 04, 2005, 03:19:43 AM by Leaf
Release versoin 1.0.2 for SMF 1.1:

Changes:
- Rearrange files and database fields
- Add option to configure hidden message color
- Add permissions to view hidden posts
- Add hiding function in post preview and quotes
- Fix some bugs
- Support Simplified Chinese (UTF-8) for SMF 1.1

guppy

Hi! I'm having problems showing the hidden post option for SMF 1.0.5.

Seems like some codes couldn't be found:


<operation>
<search position="replace"><![CDATA[
<div align="right" class="smalltext"><a href="#top" onclick="return insertQuoteFast(', $post['id'], ');">', $txt[260], '</a></div>
<div class="post">', $post['message'], '</div>
</td>
</tr>';
]]></search>
<add><![CDATA[
';
if ($post['can_view_post'])
echo '
<div align="right" class="smalltext"><a href="#top" onclick="return insertQuoteFast(', $post['id'], ');">', $txt[260], '</a></div>';
echo '
<div class="post">', $post['message'], '</div>
</td>
</tr>';
}
]]></add>
</operation>


what i have in default is:


<div align="right" class="smalltext"><a href="#top" onclick="reqWin(\'', $scripturl, '?action=quotefast;quote=', $post['id'], ';sesc=', $context['session_id'], '\', 240, 90);">', $txt[260], '</a></div>
<div style="overflow: auto; width: 100%;">', $post['message'], '</div>



I get blank when i replaced this part manually...

Leaf

December 04, 2005, 11:21:22 AM #22 Last Edit: December 04, 2005, 12:40:50 PM by Leaf
Release v1.0.2 for smf 1.0.5: HidePost1.0.2_smf_1-0-5.zip

There is no way to combine the same feature into one mod because of the changes between smf 1.0.5 and smf 1.1 rc1.

spaceman

This is actually a great mod.

Is there a demo of this for us to test out prior to installation? (As I need to install mods manually on my third-party theme).

Besides, do members have button options (just like Bold, Italic, Underline etc buttons) while doing this hiding trick? Or do they have to apply the codes themselves?

Anyway thank you for such an innovative mod! :)

Leaf

December 04, 2005, 04:47:46 PM #24 Last Edit: December 04, 2005, 05:56:39 PM by Leaf
Relase version 1.0.2. It adds post permissions to view hidden posts.

If a user belongs to a certain allowed group, they may be able to view all hidden posts regardless whether they meet the hiding criteria or not.

Admin can configure the hidden message color from global settings.
Hiding option is available if user clicks on "Additional Options" when posting.

Version 1.0.2 sets all default hiding post permssions during installation:
- Regular user and above can hiding his own or any posts if he can modify/create a post.
- Regular user and above can always see the hidden message if he can see the post.
- Admins and moderators can view hidden posts.

Demo picture: http://www.anetcity.com/bbs/index.php?topic=6378.0

Please uninstall any previous version if you want to install this versoin.

-------------------------------------

刚刚发布版本1.0.2, 增加了用户权限限制。加密方法有四种:登录、回复、积分、发贴数。
1.0.2中可以根据用户组来设定是否可以观看加密的贴子。
因为改了数据库内容,需要先反安装旧版本才能安装新版本。
演示: http://www.anetcity.com/bbs/index.php?topic=6378.0

Leaf

December 04, 2005, 04:54:05 PM #25 Last Edit: December 04, 2005, 05:54:08 PM by Leaf
Quote from: spaceman on December 04, 2005, 01:01:07 PM
This is actually a great mod.
Thanks! It takes me more time than I thought to finish it. Hope it help others.

Special thanks to Sheepy for his Mod Creator!!! Without it, I won't be able to create this mod.  ;D

Quote from: spaceman on December 04, 2005, 01:01:07 PM
Is there a demo of this for us to test out prior to installation? (As I need to install mods manually on my third-party theme).
See: http://www.anetcity.com/bbs/index.php?topic=6378.0
I posted a demo picture there.

Quote from: spaceman on December 04, 2005, 01:01:07 PM
Besides, do members have button options (just like Bold, Italic, Underline etc buttons) while doing this hiding trick? Or do they have to apply the codes themselves?
There is no such button in current version. It acts like posting attachments.
You will see the hiding option if you are allowed to hide your posts in the  "Additional Options" of the posting page.

RoarinRow

Awesome mod Leaf, thank you very much for making available on 1.0.5!   :)

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

Synn

Excellent Mod!  :D

Is there any way I can include how many posts the user actually has?
For example:

[Hidden post: You need 10 posts to see it. You currently have 5]

Leaf

December 04, 2005, 07:02:40 PM #28 Last Edit: December 04, 2005, 07:07:44 PM by Leaf
Quote from: Synn on December 04, 2005, 06:17:32 PM
Excellent Mod!  :D

Is there any way I can include how many posts the user actually has?
For example:

[Hidden post: You need 10 posts to see it. You currently have 5]
Updated the mod to show the current posts/karma in hidden message.

You can install the updated version, or just replace some code:

In HidePost.php, search for:
elseif ($message['hiddenOption'] == 3)
{
// Hide by Karma ..... ;;;
$hidden_message = sprintf($txt['hide_karma_msg'], $message['hiddenValue']);
checkUserIsInSpecialGroup();
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || (isset($user_info['karma']) && ($user_info['karma']['good'] - $user_info['karma']['bad']) >= $message['hiddenValue']);
}
elseif ($message['hiddenOption'] == 4)
{
// Hide by post number .....;;
$hidden_message = sprintf($txt['hide_posts_msg'], $message['hiddenValue']);
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || (isset($user_info['posts']) && $user_info['posts'] >= $message['hiddenValue']);
}

Replace with:
elseif ($message['hiddenOption'] == 3)
{
// Hide by Karma ..... ;;;
$karma = isset($user_info['karma']) ? ($user_info['karma']['good'] - $user_info['karma']['bad']) : 0;
$hidden_message = sprintf($txt['hide_karma_msg'], $message['hiddenValue'], $karma);
checkUserIsInSpecialGroup();
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || ($karma >= $message['hiddenValue']);
}
elseif ($message['hiddenOption'] == 4)
{
// Hide by post number .....;;
$posts = isset($user_info['posts']) ? $user_info['posts'] : 0;
$hidden_message = sprintf($txt['hide_posts_msg'], $message['hiddenValue'], $posts);
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || ($posts >= $message['hiddenValue']);
}


In HidePost.english.php, search for:
$txt['hide_karma_msg'] = '[Hidden post: You need %s karma to see it.]';
$txt['hide_posts_msg'] = '[Hidden post: You need %s posts to see it.]';


Replace with:
$txt['hide_karma_msg'] = '[Hidden post: You need %s karma to see it. You currently have %s.]';
$txt['hide_posts_msg'] = '[Hidden post: You need %s posts to see it. You currently have %s.]';

guppy

Hi, thanks for the update  ;D Working great!

Cld you explain the following permissions? Quite confused  ::)

View hidden posts
View hidden messages in posts

Leaf

View hidden posts: If a user has this permission, he will be able to see all hidden posts.
View hidden messages in posts: If a user has this permission and the global option to show hidden messages is turned off, he will be able to see the hidden messages if he can see the hidden posts.

RoarinRow

Quote from: Leaf on December 04, 2005, 07:02:40 PM
Quote from: Synn on December 04, 2005, 06:17:32 PM
Excellent Mod!  :D

Is there any way I can include how many posts the user actually has?
For example:

[Hidden post: You need 10 posts to see it. You currently have 5]
Updated the mod to show the current posts/karma in hidden message.

You can install the updated version, or just replace some code:

In HidePost.php, search for:
elseif ($message['hiddenOption'] == 3)
{
// Hide by Karma ..... ;;;
$hidden_message = sprintf($txt['hide_karma_msg'], $message['hiddenValue']);
checkUserIsInSpecialGroup();
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || (isset($user_info['karma']) && ($user_info['karma']['good'] - $user_info['karma']['bad']) >= $message['hiddenValue']);
}
elseif ($message['hiddenOption'] == 4)
{
// Hide by post number .....;;
$hidden_message = sprintf($txt['hide_posts_msg'], $message['hiddenValue']);
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || (isset($user_info['posts']) && $user_info['posts'] >= $message['hiddenValue']);
}

Replace with:
elseif ($message['hiddenOption'] == 3)
{
// Hide by Karma ..... ;;;
$karma = isset($user_info['karma']) ? ($user_info['karma']['good'] - $user_info['karma']['bad']) : 0;
$hidden_message = sprintf($txt['hide_karma_msg'], $message['hiddenValue'], $karma);
checkUserIsInSpecialGroup();
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || ($karma >= $message['hiddenValue']);
}
elseif ($message['hiddenOption'] == 4)
{
// Hide by post number .....;;
$posts = isset($user_info['posts']) ? $user_info['posts'] : 0;
$hidden_message = sprintf($txt['hide_posts_msg'], $message['hiddenValue'], $posts);
$message['can_view_post'] |= (checkUserIsInSpecialGroup()) || ($posts >= $message['hiddenValue']);
}


In HidePost.english.php, search for:
$txt['hide_karma_msg'] = '[Hidden post: You need %s karma to see it.]';
$txt['hide_posts_msg'] = '[Hidden post: You need %s posts to see it.]';


Replace with:
$txt['hide_karma_msg'] = '[Hidden post: You need %s karma to see it. You currently have %s.]';
$txt['hide_posts_msg'] = '[Hidden post: You need %s posts to see it. You currently have %s.]';


Excellent, thank you! 

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

guppy

Quote from: Leaf on December 04, 2005, 07:26:06 PM
View hidden posts: If a user has this permission, he will be able to see all hidden posts.
View hidden messages in posts: If a user has this permission and the global option to show hidden messages is turned off, he will be able to see the hidden messages if he can see the hidden posts.

got it! thanks  ;)

RoarinRow

Would you know how to resolve this error:

8: Undefined index: hidden_value
File: /forum/Themes/default/languages/Post.english.php (eval?)
Line: 433

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

Leaf

Do you install the mod manually?

This error means it can not find $context['hidden_value'] in Post.template.php.

Here are the place it is defined:

In Post.php, after line:
      // Check the boxes that should be checked.

There should be:
      $context['hidden_option'] = $row['hiddenOption'];
      $context['hidden_value'] = $row['hiddenValue'];

In Post.php, after line:
      // By default....
      $context['use_smileys'] = true;
      $context['icon'] = 'xx';

There should be:
      $context['hidden_option'] = 0;
      $context['hidden_value'] = 0;

If you still get such error, before this line  in Post.php:

   // Check if it's locked.  It isn't locked if no topic is specified.

Add:
      $context['hidden_option'] = 0;
      $context['hidden_value'] = 0;

RoarinRow

Quote from: Leaf on December 05, 2005, 12:15:29 AM
Do you install the mod manually?

This error means it can not find $context['hidden_value'] in Post.template.php.

Here are the place it is defined:

In Post.php, after line:
      // Check the boxes that should be checked.

There should be:
      $context['hidden_option'] = $row['hiddenOption'];
      $context['hidden_value'] = $row['hiddenValue'];

In Post.php, after line:
      // By default....
      $context['use_smileys'] = true;
      $context['icon'] = 'xx';

There should be:
      $context['hidden_option'] = 0;
      $context['hidden_value'] = 0;

If you still get such error, before this line  in Post.php:

   // Check if it's locked.  It isn't locked if no topic is specified.

Add:
      $context['hidden_option'] = 0;
      $context['hidden_value'] = 0;


Thank you.  I have all the lines above except these, so I added:

$context['hidden_option'] = 0;
$context['hidden_value'] = 0;

Before this line:

// Check if it's locked.  It isn't locked if no topic is specified.   

I installed via Package Manager.

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

RoarinRow

Found one bug.  I did a test where a user was not supposed to see the post until they had 1999 posts, but when the user Replied to the post he was able to see the message.

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

RoarinRow

Sorry found one other bug.  When a certain Karma number is indicated it will say for example, you need 6 Karma to view message and you have zero.  But in reality, the user reading message had 22 Karma, not zero.

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

guppy

And also a search will still show the hidden posts in the results.

(But I'm just hiding links so I don't need a solution  :P)

Leaf

December 05, 2005, 11:15:33 AM #39 Last Edit: December 05, 2005, 01:43:20 PM by Leaf
Quote from: RoarinRow on December 05, 2005, 02:46:11 AM
Sorry found one other bug.  When a certain Karma number is indicated it will say for example, you need 6 Karma to view message and you have zero.  But in reality, the user reading message had 22 Karma, not zero.
Sorry, copy/paste error. I fixed it and uploaded new zip files.

To fix it, in Load.php search for:

      'karma' => array(
         'good' => isset($user_settings['karmaGood']) ? $user_settings['karmaGood'] : 0,
         'bad' => isset($user_settings['karmaGood']) ? $user_settings['karmaGood'] : 0,
      ),

Replace with:
      'karma' => array(
         'good' => isset($user_settings['karmaGood']) ? $user_settings['karmaGood'] : 0,
         'bad' => isset($user_settings['karmaBad']) ? $user_settings['karmaBad'] : 0,
      ),

Quote from: RoarinRow on December 05, 2005, 01:15:51 AM
Found one bug.  I did a test where a user was not supposed to see the post until they had 1999 posts, but when the user Replied to the post he was able to see the message.
I tested and posts worked fine for me.

There is a hiding threshold in global settings with a default value of 500. If you want to use a value more than that, you need to change this global setting first. When saving a post, if the hidden value is greater than this threshold, it is set to the threshold.

Another thing, Admins, Global Moderators can always see hidden posts anywhere. Moderators can see posts in his board. User can see his own posts. Please check to that user's groups, too.

Quote from: iwyen on December 05, 2005, 10:55:44 AM
And also a search will still show the hidden posts in the results.

(But I'm just hiding links so I don't need a solution  :P)
Anyway, search only shows partial results. Originally, I added hidden post in search, but removed it for performance issue.

Advertisement: