News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Hide Post

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

Previous topic - Next topic

RoarinRow

Quote from: Leaf on December 06, 2005, 09:33:44 AM
When I say backup files, I mean bbs source files, not the db in MySQL.

It is a good practice to backup all your source files in your bbs directory before you install any mod. Usually, a mod will change files in Sources and/or Themes directory. At lease backup files in these two directories.

Or, if you configure a bbs on your local machine for test purpose, you can install and test a mod on bbs in your local machine to make sure everything working fine before you apply it to your actual forum.

My web hosts takes snap shots of all files and keeps originals of all modified files.  I could take a recover from the individual files themselves.  Not sure which one impacts the dictionary that it's looking for or what path it is looking in Subs-Post.php.

I thinking it would be good to have a test environment of some kind. 

SMF 2.0
TP 1.0 RC1.1
Wordpress 3.1.3

spaceman

Hello,

Well everytime I try to load install.php manually it gives me this error:

QuoteFatal error: Call to undefined function: db_query() in /[snipped]/forum/Packages/install.php on line 7

This happens to any other mod I tried to install manually. Is there anything I need to take notice when loading install.php which insert additional queries into Mysql database? Or did I execute the install.php file from the wrong directory?

For inserting manually through phpMyAdmin I do not know how to manage these in install.php:

Quote// Build group list
$result = db_query("SELECT ID_GROUP FROM {$db_prefix}membergroups WHERE minPosts < 0", __FILE__, __LINE__);
if (!$result) die("Cannot load group id");
$len = mysql_num_rows($result);
$groups = array(0); // Don't include guest
for ($i = 0; $i < $len; $i++) {
  $row = mysql_fetch_row($result);
  if ($row[0] == 1) continue; // Skip admins
  $groups[] = $row[0];
}
mysql_free_result($result);

// Build special board list
$result = db_query("SELECT DISTINCT ID_BOARD FROM {$db_prefix}board_permissions WHERE ID_BOARD > 0", __FILE__, __LINE__);
if (!$result) die("Cannot load board permission");
$len = mysql_num_rows($result);
$boards = array(0);  // Include global permission
for ($i = 0; $i < $len; $i++) {
  $row = mysql_fetch_row($result);
  $boards[] = $row[0];
}
mysql_free_result($result);

// Build & execute add permission query
$permission = "INSERT IGNORE INTO {$db_prefix}board_permissions (ID_GROUP, ID_BOARD, permission, addDeny) VALUES
";
foreach ($groups as $g)
  foreach ($boards as $b) {
    $permission .= "($g,$b,'hide_post_own',1),($g,$b,'hide_post_any',1),($g,$b,'view_hidden_msg',1),";
  }
.
.
.

Please help me. Thank you very much!

spaceman

Oh well, upon trial and error I manage to insert the queries into my database :)

Question:
I have setup the forum to preview message on mouseover on topic titles (Topic Listing) using Alt="" method. Upon installation of this mod I notice guests or unqualified viewers are still manage to preview the last hidden post. I think it's enabled on purpose?

Leaf

#63
QuoteWell everytime I try to load install.php manually it gives me this error:

The install.php needs to be run on forum. db_query() is a wapper function in smf. If you want to install db manually, you can package install.php in a simple mod and run it. This simple mod is a zip file of three files: package-info.xml, install.php & uninstall.php. The content of the package-info.xml will be similiar to this:

<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">
<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
<name>HidePost - Update Database Only</name>
<id>XiaoqingZhou:HidePostDb</id>
<type>modification</type>
<version>1.0</version>
<install>
<code type="file">install.php</code>
</install>
<uninstall>
<code type="file">uninstall.php</code>
</uninstall>
</package-info>


If you only want to install and don't need uninstall, you can remove the uninstall part from the package-info.xml and just zip install.php with package-info.xml.

Quote from: spaceman on December 07, 2005, 09:37:29 AM
I have setup the forum to preview message on mouseover on topic titles (Topic Listing) using Alt="" method. Upon installation of this mod I notice guests or unqualified viewers are still manage to preview the last hidden post. I think it's enabled on purpose?
Search & the lastest post are not checked by default. If you want, you can add by yourself. ;D

spaceman

Thanks!! Got it working like a charm now!!

I'll try to check "Search & the lastest post" (I assume it's in admin)?

Anyway this is a brilliant mod!! :D

Leaf

Quote from: spaceman on December 07, 2005, 11:51:55 PM
I'll try to check "Search & the lastest post" (I assume it's in admin)?
They are not supported in the current version. No options in admin.

guppy

I'm using a custom theme. May I ask if there are any changes made to the template files for upgrade from 1.0.2 to 1.0.3?

Leaf

No changes in template files from 1.0.2 to 1.0.3.

sendoh23

#68
very useful mod....gd job there yo :D
more functions can be added...example integrete with points system ..jus a suggestion

NTA

This Mod not compatible with PHP 5  :) please fix this.

I have this error :

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in c:\AppServ\www\smf\Sources\Display.php on line 731

Leaf

Release version 1.0.4:
- Remove call by reference to be compatible with PHP 5
- Support SMF 1.1 beta 3 public

Upgradable from 1.0.3 to 1.0.4. Data in database will remain the same during upgrade.

Aly

Is there a way that we can also be able to rename 'karma' to whatever we've renamed out system to? My memebers are a bit confused because we call the karma 'tokens' but when they use the hide post mod... it says 'karma'.

I tried to attempt to alter it myself... cause i found where to do it... but i ended up screwing up my forum and had to reinstall xD

Leaf

#72
You can change the following strings in HidePost.english.php:
$txt['hide_karma'] = 'karma';
$txt['hide_karma_msg'] = '[Hidden post: You need %s karma to see it. You currently have %s.]';

Just rename 'karma' to the word you use like this:
$txt['hide_karma'] = 'token';
$txt['hide_karma_msg'] = '[Hidden post: You need %s tokens to see it. You currently have %s.]';

Aly

^hmm that's where i thought i needed to edit... it didnt work out the last time i tried... but maybe i took something out that i shouldn't have >_<

Anyway, it worked this time around though... thank you again leaf ^^

JackRyan

Hey Leaf, I'm curious, is it possible to set this hack up so that Admins and G-Mods can't view the hidden post?

I was hoping to use the hack for trivia games and acronym games etc, but it won't work if the staff can view the posts without replying first.

Leaf

There is a way to disable G-Mods and moderators if you change some logic in the code. Replace two functions in HidePost.php with the following:


// Check whether the user has replied to the current topic.
function checkUserRepliedToTopic($topic)
{
  global $user_info, $board_info, $context, $db_prefix, $ID_MEMBER;
 
// Find if there a post from you in this thread!!!
if (!$user_info['is_guest'])
{
// Skip check if no topic, and allow global moderators.
if (empty($topic)) {
      $context['user_post_avaible'] = 1;
      return $context['user_post_avaible'];
}
   
$request = db_query("
SELECT ID_MSG, ID_MEMBER
FROM {$db_prefix}messages
WHERE ID_TOPIC = $topic AND ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);

if (mysql_num_rows($request)) $context['user_post_avaible'] = 1;
else $context['user_post_avaible'] = 0;
mysql_free_result($request);
}
else $context['user_post_avaible'] = 0; //Anyway no way you should see it!

return $context['user_post_avaible'];
}

// Check for hidden posts. Show hidden message if needed.
function getHiddenMessage($disable_hidden_msg_color = 0)
{
global $modSettings, $context, $user_info, $ID_MEMBER, $txt;

$message = $context['current_message'];

// Did this user post this message?
$user_own = isset($message['ID_MEMBER']) && $ID_MEMBER == $message['ID_MEMBER'] && !$user_info['is_guest'];

// Some contexts for hiding posts ... ;)
$context['can_view_post'] = $user_own || allowedTo('view_hidden_post', array($message['ID_BOARD']));
$message['hiddenOption'] = (int) $message['hiddenOption'];
$message['hiddenValue'] = (int) $message['hiddenValue'];

// Hiding posts ? ..... Haha....Check here.....
if (!empty($modSettings['allow_hiddenPost']) && !empty($message['hiddenOption']) && isset($message['hiddenValue']))
{
$hidden_message = '';
// Check each hiding criteria..... ;)
if ($message['hiddenOption'] == 1)
{
// Hide by login ....;;;;
$hidden_message = $txt['hide_login_msg'];
$context['can_view_post'] |= !$user_info['is_guest'];
}
elseif ($message['hiddenOption'] == 2)
{
// Hide by reply ....... ;
$hidden_message = $txt['hide_reply_msg'];
$context['can_view_post'] |= checkUserRepliedToTopic($message['ID_TOPIC']);
}
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();
$context['can_view_post'] |= ($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);
$context['can_view_post'] |= ($posts >= $message['hiddenValue']);
}
else
{
// Normal posts. Anyone can see it. ;)
$context['can_view_post'] = 1;
}

if ($hidden_message != '') {
// Get final hiding message here.... ;;;;
$show_hidden_msg = !empty($modSettings['show_hiddenMessage']) || allowedTo('view_hidden_msg');
$show_hidden_msg_in_color = empty($disable_hidden_msg_color) && !empty($modSettings['show_hiddenColor']);
$hidden_message = $show_hidden_msg_in_color ? ('[color=' . $modSettings['show_hiddenColor'] . ']' . $hidden_message . '[/color]') : $hidden_message;
$message['body'] = !empty($context['can_view_post']) ? (empty($show_hidden_msg) ? $message['body'] : $hidden_message . '<br /><br />' . $message['body']) : $hidden_message;
}
else {
// Normal posts!!!.Anyone can see it. ;)
$context['can_view_post'] = 1;
}
}
else
{
// Normal posts!!! Of course, anyone can see it.
$context['can_view_post'] = 1;
}

return $message['body'];
}


The above changes still use the hidden post permission ('view_hidden_post'). You need set the correct permission for each group. By default, Admins have full permissions on smf forum. So, Admins still can view hidden posts.

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

In addition to the above changes, you can force Admins to reply to hidden post by ignore the view hidden post permission. Search for this line in above code:

   $context['can_view_post'] = $user_own || allowedTo('view_hidden_post', array($message['ID_BOARD']));

Replace with:

   $context['can_view_post'] = $user_own;

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

NOTE: These changes are customized for your needs and will not be supported in future version.

joeblow1102

i hid one of my posts by login and it works great.  i tried viewing it as a guest and it didn't work.  said i had to login.  but then i logged in under my name and it said i had to login, but it showed the message as well.  is this a known problem, or just one with my board?

kicon

iam new. please help me out for installation. when i do the install the script. it said:

Fatal error: Call to undefined function: db_query() in /home/gamedep/public_html/test/install.php on line 7

how could i solve this problem? do i need the previous version for it?

Leaf

Quote from: joeblow1102 on December 19, 2005, 11:04:47 PM
i hid one of my posts by login and it works great.  i tried viewing it as a guest and it didn't work.  said i had to login.  but then i logged in under my name and it said i had to login, but it showed the message as well.  is this a known problem, or just one with my board?
It is designed this way to let users know that it is a hidden post. You can turn off the message by unchecking the option "Enable viewing hidden messages if user can see the posts" and also turn off the permssion "View hidden messages in posts".

Leaf

#79
Quote from: kicon on December 20, 2005, 07:14:21 PM
iam new. please help me out for installation. when i do the install the script. it said:

Fatal error: Call to undefined function: db_query() in /home/gamedep/public_html/test/install.php on line 7

how could i solve this problem? do i need the previous version for it?

You don't need a previous version. db_query() is a function supported by smf forum and you need to run the install from package manager in smf. If you do want to manually install this mod, you can check one of the messages I posted before which describes how to install the db only. The message is:

http://www.simplemachines.org/community/index.php?topic=58833.msg414109#msg414109

Advertisement: