[FREE] Topic ID

Started by kasperzi, August 09, 2018, 09:48:16 AM

Previous topic - Next topic

kasperzi

Hello,

First of all sorry for my bad English language.

I need this:

How to check if user read topic by ID,

Like admin post topic about update, and if user see(open) it he got alert message, or show element only for that group of people who see that post ?

Is that possible ?

Kindred

possible... but complicated

What exactly are you trying to do?

Make sure everyone reads some sort of announcement topic?
If so, there is a mod for that.

Or, maybe, from your second statement - you are trying to display some feature only to people who read that message...
that gets more complicated


However, just because the user OPENED the page of that topic does not mean that they actually read it.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

There's also the "mark all as read" function which may remove some tracking of which individual topics have been read...

kasperzi

Look, only who "open/read" that topic (ID of topic for example ID: 561627.0) can see another HTML/PHP object

If I didnt open that topic I don't see that block in theme. Only who open/read that topic can see that block.

Kindred

#4
in that case...  especially, given what Arantor reminded me of -- no, it's not actually possible.

If I wanted to view it - I can just "mark all as read" - and then I can see whatever you have hidden.

Heck, even just hiding it behind something like that is moderately complicated
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

You misunderstand my point. Read the topic, block shows - mark everything as read and magically the block is now gone again because of how SMF works. (And may not be visible again ever to that user.)

In any case all you're going to guarantee at any point is that someone opened the page, not that they read anything in it.

There is no scenario for this that I've ever seen where this is actually the right tool for the job.

Pipke

this will do the job, let me know if this works for you ;)

in file Sources/Display.php
Code (find) Select

function Display()
{
global $scripturl, $txt, $modSettings, $context, $settings;
global $options, $sourcedir, $user_info, $board_info, $topic, $board;
global $attachments, $messages_request, $topicinfo, $language, $smcFunc;


add this code right after it->save file->reupload (make backup first of file)
Code (add after) Select

//CODE FOR WICH TOPIC!
$topic = 561627; // this is the topic id you want them to read, change as desired!
$has_seen = !empty($modSettings['user_ids_has_read']) ? unserialize($modSettings['user_ids_has_read']) : array();

if ($context['current_topic'] === $topic) {
$has_seen = array_merge($has_seen, array($context['user']['id']));
updateSettings(array('user_ids_has_read' => serialize(array_unique($has_seen))));
}


Then use code as i posted below (where i dont know atm where you want it at SMF) it will do as you said -> Look, only who "open/read" that topic (ID of topic for example ID: 561627.0) can see another HTML/PHP object


        //CODE FOR 'OTHER PAGE/HTML' USERS WHO CAN SEE IF HAS SEEN/CLICKED TOPIC
global $modSettings, $context;

$has_seen = !empty($modSettings['user_ids_has_read']) ? unserialize($modSettings['user_ids_has_read']) : array();

if (in_array($context['user']['id'], $has_seen)) {
// This they will see if clicked/seen topic
echo 'Got ya, you have seen/clicked topic 561627';
}




"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Arantor

Hope there's not too many people reading the topic, $modSettings isn't infinitely large.

Also, wait for the edits that will want to track read status of a second topic.

Pipke

Quote from: Arantor on August 09, 2018, 05:54:50 PM
Hope there's not too many people reading the topic, $modSettings isn't infinitely large.

true but i reached to 6019 users ids till i got Fatal error: Maximum execution time of 30 seconds exceeded
a:6019:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:...etc etc

This can be done with a user group instead, but he lets wait for the OP.

Quote from: Arantor on August 09, 2018, 05:54:50 PM
Also, wait for the edits that will want to track read status of a second topic.

The OP didnt ask for a second topic sofar...i can't read minds, yeah we all can reply with what if.....
"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Arantor

This is why I don't write code for such things, because I've been bitten too many times with the opposite end of the what-ifs.

Kindred

Pipke,

Even I could have written that code. There is a reason why we didn't do it to start with We try to prevent admins from doing code that a) doesn't actually do what they want and b) has potential to impact the site badly...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

kasperzi

Quote from: Pipke on August 09, 2018, 05:44:41 PM
this will do the job, let me know if this works for you ;)

in file Sources/Display.php
Code (find) Select

function Display()
{
global $scripturl, $txt, $modSettings, $context, $settings;
global $options, $sourcedir, $user_info, $board_info, $topic, $board;
global $attachments, $messages_request, $topicinfo, $language, $smcFunc;


add this code right after it->save file->reupload (make backup first of file)
Code (add after) Select

//CODE FOR WICH TOPIC!
$topic = 561627; // this is the topic id you want them to read, change as desired!
$has_seen = !empty($modSettings['user_ids_has_read']) ? unserialize($modSettings['user_ids_has_read']) : array();

if ($context['current_topic'] === $topic) {
$has_seen = array_merge($has_seen, array($context['user']['id']));
updateSettings(array('user_ids_has_read' => serialize(array_unique($has_seen))));
}


Then use code as i posted below (where i dont know atm where you want it at SMF) it will do as you said -> Look, only who "open/read" that topic (ID of topic for example ID: 561627.0) can see another HTML/PHP object


        //CODE FOR 'OTHER PAGE/HTML' USERS WHO CAN SEE IF HAS SEEN/CLICKED TOPIC
global $modSettings, $context;

$has_seen = !empty($modSettings['user_ids_has_read']) ? unserialize($modSettings['user_ids_has_read']) : array();

if (in_array($context['user']['id'], $has_seen)) {
// This they will see if clicked/seen topic
echo 'Got ya, you have seen/clicked topic 561627';
}

Thats it thank you so much

Advertisement: