[TRICK] displaying the "unknown action" in the who's online list

Started by Kindred, January 30, 2012, 10:20:00 PM

Previous topic - Next topic

Kindred

so, you have a bunch of mods installed and 90% of them - while they add functionality to your forum - don't add themselves into the list of valid actions in the Who's Online list.

This little trick won't fix ALL of the problems (it's a quick trick, it doesn't drill down into special actions or sub-actions) but it will, at least, display where the user actually IS in your system.

Code (find in Sources/Who.php) Select

function determineActions($urls, $preferred_prefix = false)
{
  global $txt, $user_info, $modSettings, $smcFunc, $context;


Code (add after) Select

global $scripturl;


Code (find in Sources/who.php) Select

// Unlisted or unknown action.
else
$data[$k] = $txt['who_unknown'];


Code (replace) Select

// Unlisted or unknown action.
else
$data[$k] = $txt['who_thisaction'] . '<a href="' . $scripturl . '?action=' . $actions['action'] . '">' . $actions['action'] . '</a>';


then add the following text string to modifications.YOURLANGUAGE.txt

$txt['who_thisaction'] = 'Viewing the ';
Сл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."

Kindred

note: I have been playing with the following, but it doesn't quite work....


// Unlisted or unknown action.
else {
if (isset($actions['sa'])) {
$extraaction['sa']['text'] = ' - ' . $actions['sa'];
$extraaction['sa']['url'] = ';sa=' . $actions['sa'];
} else {
$extraaction['sa']['text'] = '';
$extraaction['sa']['url'] = '';
}
if (isset($actions['area'])) {
$extraaction['area']['text'] = ' - ' . $actions['area'];
$extraaction['area']['url'] = ';area=' . $actions['area'];
} else {
$extraaction['area']['text'] = '';
$extraaction['area']['url'] = '';
}
if (isset($actions['u'])) {
$extraaction['u']['text'] = ' for User ID' . $actions['u'];
$extraaction['u']['url'] = ';u=' . $actions['u'];
} else {
$extraaction['u']['text'] = '';
$extraaction['u']['url'] = '';
}
if (isset($actions['cat'])) {
$extraaction['cat']['text'] = ' in Category' . $actions['cat'];
$extraaction['cat']['url'] = ';cat=' . $actions['cat'];
} else {
$extraaction['cat']['text'] = '';
$extraaction['cat']['url'] = '';
}

$data[$k] =  'Viewing the <a href="' . $scripturl . '?action=' . $actions['action'] . $extraaction['sa']['url'] . $extraaction['area']['url'] . $extraaction['u']['url'] . $extraaction['cat']['url'] .'">' . $actions['action'] . $extraaction['sa']['text'] . $extraaction['area']['text'] . $extraaction['u']['text'] . $extraaction['cat']['text'] . '</a>';
}

Сл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."

Matthew K.

Very neat, Kindred...it'd be cool if eventually SMF had this implemented into the core so modifications didn't HAVE to.

nza2k

Thank you Kindred,

Is there any way, without killing the sever, to display real time stats instead of a list of names.

For instance :
- 5 members and 1 moderator are watching post 1
- 7 members are watching post 2
- 3 members are connecting
- 1 member is posting a new message
...

?
Avis sur les voyagistes dans le forum de Voyage-Net, propulsé par SMF depuis des années :)

Kindred

that would require a whole bunch more recoding...   my trick is just to replace the frustrating "unknown action"
Сл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."

nza2k

Avis sur les voyagistes dans le forum de Voyage-Net, propulsé par SMF depuis des années :)

Kindred

note:  I just discovered that you also should add $scripturl to the global variables at the start of the function.
Сл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."

geek_andy

Quote from: Labradoodle-360 on January 30, 2012, 11:34:55 PM
Very neat, Kindred...it'd be cool if eventually SMF had this implemented into the core so modifications didn't HAVE to.

I completely agree.

Works great Kindred! Thanks!

Chalky




NanoSector

My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

TattooLeashed

Only the word 'Portal' is seen now by the members. Guests show the proper things. Strange...

Kindred

which code snippet did you use?   And did you make exactly the edit that I showed?
Сл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."

NanoSector

My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Kindred

ah yes...   I didn't even think to $txt the english string (naughty me!)

Sorry, my dutch is non existent, so I can't comment directly. lol....
Сл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."

NanoSector

Quote from: Kindred on April 05, 2012, 04:08:43 PM
ah yes...   I didn't even think to $txt the english string (naughty me!)

Sorry, my dutch is non existent, so I can't comment directly. lol....
First code's what needs to be added in Modifications.{language}.php, second and third code is Find > Replace.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Antechinus

Nifty. I like it. Should be default IMO.

What I would also like is a change in that silly "Nothing, or nothing you can see" message. It would make more sense to say "Ant is messing around in admin" or something like that, if it is the case, rather than getting all spooky about it.

TattooLeashed

I did all that Yoshi but it still doesn't work :(


This is how it looks like in who.php:


// Unlisted or unknown action.
else {
if (isset($actions['sa'])) {
$extraaction['sa']['text'] = ' - ' . $actions['sa'];
$extraaction['sa']['url'] = ';sa=' . $actions['sa'];
} else {
$extraaction['sa']['text'] = '';
$extraaction['sa']['url'] = '';
}
if (isset($actions['area'])) {
$extraaction['area']['text'] = ' - ' . $actions['area'];
$extraaction['area']['url'] = ';area=' . $actions['area'];
} else {
$extraaction['area']['text'] = '';
$extraaction['area']['url'] = '';
}
if (isset($actions['u'])) {
$extraaction['u']['text'] = ' for User ID' . $actions['u'];
$extraaction['u']['url'] = ';u=' . $actions['u'];
} else {
$extraaction['u']['text'] = '';
$extraaction['u']['url'] = '';
}
if (isset($actions['cat'])) {
$extraaction['cat']['text'] = ' in Category' . $actions['cat'];
$extraaction['cat']['url'] = ';cat=' . $actions['cat'];
} else {
$extraaction['cat']['text'] = '';
$extraaction['cat']['url'] = '';
}

$data[$k] = $txt['unknown_action_viewing'] . ' <a href="' . $scripturl . '?action=' . $actions['action'] . '">' . $actions['action'] . '</a>';
}[s][/s] 


And I put the txt line in my modifications.dutch.php file. What am i doing wrong? Starts to bug me ;)

NanoSector

That's the code that doesn't work ;)

Just use the code I provided, it's in the first post of this topic.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Advertisement: