Hide all subjects/topics (who_topic) in Who's Online from board ID 5

Started by Ahadawan, January 23, 2012, 12:28:07 PM

Previous topic - Next topic

Ahadawan

Hi,

I've a semi-hidden board (it's not visible in the board index, but everyone could and should be able to access it), and I've been trying to hide it (and the topics in it) from the Who's Online-list. I found this topic about the subject:

http://www.simplemachines.org/community/index.php?topic=246458.0

I found it quite helpful, since it lets me know how to hide both certain topics (through topic_id) and a certain board (the message index itself). I'm now trying to figure out how to hide not a specific topic, but ALL topics in a certain board. Let's say the board ID is 5.

I can use this to hide topic (id:1) from who's online:
if($row['ID_TOPIC'] != 1)
$data[$k] = sprintf($session_text, $row['ID_TOPIC'], censorText($row['subject']));

And this, to hide a certain board (message index) (id: 5):
if($row['ID_BOARD'] != 5)
$data[$k] = sprintf($session_text, $row['ID_BOARD'], $row['name']);

Both codes supplied by [SiNaN] in the topic mentioned above.

However, as i mentioned, i cannot hide ALL topics in board id 5 by using the codes above, so i wonder if anyone could help me with this, I've been trying to use "if($row['ID_BOARD'] != 5)" in the code for topic_id's, and unfortunately i can't seem to get it right.

Remember, i still need everyone to be able to access the board, so i can't change that permission.

Thank you,
Ahadawan

(I'm using SMF 1.1.16)


Edit:
I assume this is where i need to make changes, so I'm putting this in as well, so you guys don't have to go search through Who.php-files unnecessarily.
// Load topic names.
if (!empty($topic_ids))
{
$result = db_query("
SELECT t.ID_TOPIC, m.subject
FROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)
WHERE $user_info[query_see_board]
AND t.ID_TOPIC IN (" . implode(', ', array_keys($topic_ids)) . ")
AND t.ID_BOARD = b.ID_BOARD
AND m.ID_MSG = t.ID_FIRST_MSG

AND b.anonymousBoard = 0
LIMIT " . count($topic_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
// Show the topic's subject for each of the actions.
foreach ($topic_ids[$row['ID_TOPIC']] as $k => $session_text)
$data[$k] = sprintf($session_text, $row['ID_TOPIC'], censorText($row['subject']));
}
mysql_free_result($result);
}

Ahadawan

Still trying to solve this :) So if anyone has any thought, please let me know.

emanuele

Hi Ahadawan and welcome to sm.org!

I would try with something like the following.

This is the original code:
$result = db_query("
SELECT t.ID_TOPIC, m.subject
FROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)
WHERE $user_info[query_see_board]
AND t.ID_TOPIC IN (" . implode(', ', array_keys($topic_ids)) . ")
AND t.ID_BOARD = b.ID_BOARD
AND m.ID_MSG = t.ID_FIRST_MSG
LIMIT " . count($topic_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
// Show the topic's subject for each of the actions.
foreach ($topic_ids[$row['ID_TOPIC']] as $k => $session_text)
$data[$k] = sprintf($session_text, $row['ID_TOPIC'], censorText($row['subject']));
}


change it to:
$result = db_query("
SELECT t.ID_TOPIC, m.subject, t.ID_BOARD
FROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)
WHERE $user_info[query_see_board]
AND t.ID_TOPIC IN (" . implode(', ', array_keys($topic_ids)) . ")
AND t.ID_BOARD = b.ID_BOARD
AND m.ID_MSG = t.ID_FIRST_MSG
LIMIT " . count($topic_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
// Show the topic's subject for each of the actions.
foreach ($topic_ids[$row['ID_TOPIC']] as $k => $session_text)
if($row['ID_BOARD'] != 1)
$data[$k] = sprintf($session_text, $row['ID_TOPIC'], censorText($row['subject']));
}


And replace the 1 in if($row['ID_BOARD'] != 1) to the id of your board.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Ahadawan

Thank you! :D That seems to work. :)
I knew it was something in the SELECT-part i needed to load somehow.

Now I'm wondering if there's a possibility to change the who's online-message to something else. It seems to be loading $txt['who_hidden']. Could i make it load a custom $txt['who_hidden2'] or something instead, just for that board?

I found this part, which i think would be relevant:
// It's a topic!  Must be!
if (isset($actions['topic']))
{
// Assume they can't view it, and queue it up for later.
$data[$k] = $txt['who_hidden'];
$topic_ids[(int) $actions['topic']][$k] = $txt['who_topic'];
}


If i could somehow change it just for topics in the board mentioned above that would be great. I assume I have to add something to the code you showed me, since i have to pick only topics from a certain board.
Perhaps if i could duplicate $data[$k] = $txt['who_hidden']; and change it around, but not sure how to do it.

I'll of course mess around with it a bit myself, but if you (or anyone else) has any thoughts please let me know. :)

emanuele

$result = db_query("
SELECT t.ID_TOPIC, m.subject, t.ID_BOARD
FROM ({$db_prefix}boards AS b, {$db_prefix}topics AS t, {$db_prefix}messages AS m)
WHERE $user_info[query_see_board]
AND t.ID_TOPIC IN (" . implode(', ', array_keys($topic_ids)) . ")
AND t.ID_BOARD = b.ID_BOARD
AND m.ID_MSG = t.ID_FIRST_MSG
LIMIT " . count($topic_ids), __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
// Show the topic's subject for each of the actions.
foreach ($topic_ids[$row['ID_TOPIC']] as $k => $session_text)
if($row['ID_BOARD'] != 1)
$data[$k] = sprintf($session_text, $row['ID_TOPIC'], censorText($row['subject']));
else
$data[$k] = $txt['who_hidden2'];
}


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.


Advertisement: