• Welcome to Simple Machines Community Forum. Please login or sign up.
October 18, 2021, 01:30:05 AM

News:

Want to get involved in developing SMF, then why not lend a hand on our github!


@mention members

Started by Dragooon, May 02, 2014, 01:07:58 PM

Previous topic - Next topic

moyack

Hi:

I just found this small bug. In Mentions.english.php it's needed to add $scripturl global variable to avoid log errors.

Code (find) Select
global $txt, $context;

Code (replace) Select
global $txt, $context, $scripturl;

Sectomy

hi,

i also have the Advanced Editor, in one thread theres a code you need to add to the mention mod, but i dont now where or which file, maybe anyone could help:

$('textarea[name=message]').add($('body.rich_editor', $('iframe#html_message').contents())).add($('body.advanced_editor', $('iframe#iframe_smfpacks_advanced_editor').contents())).add('#smfpacks_advanced_editor').atwho(mentions_config);

North East Man

I realise this is no longer supported but does anyone know how to make the pop up suggestion list have more items on it.  It shows me 10 possible members but I have 5000 members and with popular names like John or Gill, it isn't showing all the possible matches.

RockLee

You should reduce the number of matches as you apply more characters and I am not sure if it impacts negative this however it should change in file ../Themes/default/scripts/mentions.js line 17 just in case do not use very large values.


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

North East Man

Hi Rock Lee,

Thanks for that pointer.  I have now changed that number to 25 so now have up to 25 suggestions on the list - not enough to cover the most popular name, but covers most members.  Just had to clear the browser cache After making the change.


RockLee

I was testing with a local website of mine and it could support up to 50 references, but without traffic and it is a small database, so depending on the type of host have up to 30 should work without problems. Sorry I forgot to mention the cache is something normal that many times does not allow you to see the modifications made.


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

ambre222

Hello,
I got this error Illegal mix of collations for operation 'in'
Fichier: /home/attrapes/public_html/forum/Sources/Mentions.php
Ligne: 193
when trying to mention for instance someone with weird accents Mügan.
Is there a way to fix that without changing the encoding of the database ?

Dephyrius

I realize that im liking missing something here, and am not sure what happened or what the last admin on our forums did after updating to 2.0.17 or what's happening. the @members mention mod shows its there, I click list files, they all seem to be there, but the mod doesn't work anymore. When I try and uninstall this is the screen I get and I'm not wanting to mess anything up in uninstalling and reinstalling it (which I suspect needs to be done).

jsx

What could be the reason why new mentions do not appear in the list of mentions in user profile?

RockLee

Quote from: Dephyrius on December 26, 2020, 12:03:21 PM
I realize that im liking missing something here, and am not sure what happened or what the last admin on our forums did after updating to 2.0.17 or what's happening. the @members mention mod shows its there, I click list files, they all seem to be there, but the mod doesn't work anymore. When I try and uninstall this is the screen I get and I'm not wanting to mess anything up in uninstalling and reinstalling it (which I suspect needs to be done).

Surely I replaced all the files with the new ones and did not leave the modification, you can try to see the parse of the mod to install manually.


Regards!°
¡Regresando como cual Fenix! ~ Bomber Code © 2020
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

shadav

Quote from: moyack on May 03, 2020, 10:08:08 AM
Hi:

I just found this small bug. In Mentions.english.php it's needed to add $scripturl global variable to avoid log errors.

Code (find) Select
global $txt, $context;

Code (replace) Select
global $txt, $context, $scripturl;

well I tried this but I am still getting tons of these errors
https://4rearth.info/index.php?
8: Undefined index: title
File: /Sources/Mentions.php
Line: 45

jsx

@GL700Wing

Changing the codes in the Mentions.php file that you provided in this post causes that new mentions to the user profile are not displayed.

Can you fix it?

I mean these codes for:

QuoteThe second is to enable forum admins to fix incorrectly formatted mentions in existing posts (eg, '@ name' instead of '@name') and to have the corrected mention attributed to the post author (by default the corrected mention is attributed to the member editing the post).

jsx

@GL700Wing

Changing this code causes that the mention is not displayed in the mentions table in the user's profile.

Find:

array($id_post, $user_info['id'], $mention['id'], time()),

Replace With:

// Use $mention_member_id instead of $user_info['id'].
array($id_post, $mention_member_id, $mention['id'], time()),

GL700Wing

Quote from: jsx on February 08, 2021, 01:47:02 PM
@GL700Wing

Changing this code causes that the mention is not displayed in the mentions table in the user's profile.
@JSX - Please do not bump messages within 24-48 hours and please do not PM me for support unless I ask you to (this is the second time you have done this!).
Life doesn't have to be perfect to be wonderful ...

jsx

1. First of all, I do not intentionally bump the post, after some time it is not possible to edit the post here in the forum. And after some time I did the test by replacing the codes one by one and came to the conclusion that this code prevents displaying a new mention in the table of mentions. So I added a post telling you which code is blocking the new mention. Did I do something wrong? No. So stop being rude.

2. This forum does not have a mentions system so @username does not work - so that's why I sent you a normal message to take a look at this bug! That it was a kindly private message. Just because users still reporting this problem to me, that there is no new mention in the mentions table. Did I do something wrong? No.

3. Before you add a generally available tutorial, check if everything works properly after changing the codes. And if someone detects a bug and reports it, just be friendly! Being nice isn't complicated. Unless you have a problem with that so okay.

4. If you want to be nasty then you should write it to me privately, not in the modification thread.

5. On October 25, 2020, I sent you a private message asking: "These changes may be implement to "@mention members" package? I mean to install this mod with these changes already".

And I mentioned to you:

"I understand, that's why I ask in a private message if there is such a possibility to not clutter the help topic. If it is possible, then I will ask for help on this topic".

It's a normal question and you answered my questions and you had no problem.

I know that the forum is used to help and I just sent a private message kindly, that's all.

GL700Wing

Quote from: jsx on February 09, 2021, 12:31:51 AM
1. First of all, I do not intentionally bump the post, after some time it is not possible to edit the post here in the forum. And after some time I did the test by replacing the codes one by one and came to the conclusion that this code prevents displaying a new mention in the table of mentions. So I added a post telling you which code is blocking the new mention. Did I do something wrong? No. So stop being rude.
Fair enough re not being able to edit your previous post.  I wasn't rude - I was polite ...

Quote2. This forum does not have a mentions system so @username does not work - so that's why I sent you a normal message to take a look at this bug! That it was a kindly private message. Just because users still reporting this problem to me, that there is no new mention in the mentions table. Did I do something wrong? No.
Did you do something wrong - in my opinion, and given that you sent the PM less than five minutes after you posted your second message here, Yes!

Quote3. Before you add a generally available tutorial, check if everything works properly after changing the codes. And if someone detects a bug and reports it, just be friendly! Being nice isn't complicated. Unless you have a problem with that so okay.
Apologies for not testing this fully and thank you for reporting the issue. My suggestion is that you remove the code change I suggested until I have time to investigate it. 

Quote4. If you want to be nasty then you should write it to me privately, not in the modification thread.
I wasn't nasty - I was polite ...
Life doesn't have to be perfect to be wonderful ...

GL700Wing

Quote from: jsx on January 01, 2021, 05:24:15 AM
What could be the reason why new mentions do not appear in the list of mentions in user profile?
Yes - if you implemented the second enhancement suggestion I made I accidentally omitted another change that is required in ./Sources/Subs-Post.php and the reason I hadn't noticed it on the forums I use this enhancement on was because I had actually made that required change - apologies for any inconvenience this has caused.

The additional change required in ./Sources/Subs-Post.php is as follows:
Find:
// Alright, done now... we can abort now, I guess... at least this much is done.
ignore_user_abort($previous_ignore_user_abort);

if (!empty($msgOptions['mentions']))
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], $msgOptions['approved']);

Replace With:
// Alright, done now... we can abort now, I guess... at least this much is done.
ignore_user_abort($previous_ignore_user_abort);

if (!empty($msgOptions['mentions']))
// Fix for bug - see https://www.simplemachines.org/community/index.php?topic=522005.msg3695332#msg3695332
// Added $posterOptions['id'] and $posterOptions['name'] as these options are now required for mentions_process_store.
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], isset($msgOptions['approved']) ? $msgOptions['approved'] : 1, $posterOptions['id'], $posterOptions['name']);






The two enhancement suggestions (which includes the change shown above) are now as follows:

The first is, if the option 'Enable mentions e-mail by default' is enabled, to also notify a member by PM that they have been mentioned and then to only send an email message if the member does not receive email notifications of PMs.

In ./Sources/Mentions.php
Find:
sendmail($mention['email_address'], $subject, $body)
Replace With:
// Send the mention notification by PM.
sendpm(array('to' => array($mention['id']), 'bcc' => array()), $subject, $body);

// If the member being mentioned does not receive email notifications of PMs send a separate email message.
$result = $smcFunc['db_query']('', '
SELECT id_member, pm_email_notify
FROM {db_prefix}members
WHERE id_member = {int:mention_id}',
array(
'mention_id' => (int) array($mention['id']),
)
);
$row = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);
$pmMailNotify = ($row['pm_email_notify']);
if ($pmMailNotify == 0)
sendmail($mention['email_address'], $subject, $body);






The second is to enable forum admins to fix incorrectly formatted mentions in existing posts (eg, '@ name' instead of '@name') and to have the corrected mention attributed to the post author (by default the corrected mention is attributed to the member editing the post).

In ./Sources/Mentions.php
Find:
function mentions_process_store(array $mentions, $id_post, $subject, $approved = true)
{
global $smcFunc, $txt, $user_info, $scripturl;

Replace With:
function mentions_process_store(array $mentions, $id_post, $subject, $approved = true, $pa_id, $pa_name)
{
global $smcFunc, $txt, $user_info, $scripturl;

// Check if the user editing post is the same as the post author.
$mention_member_id = $user_info['id'];
$mention_member_name = $user_info['name'];
if ($pa_id != $user_info['id'])
{
$mention_member_id = $pa_id;
$mention_member_name = $pa_name;
}


Find:
array($id_post, $user_info['id'], $mention['id'], time()),
Replace With:
// Use $mention_member_id instead of $user_info['id'].
array($id_post, $mention_member_id, $mention['id'], time()),


Find:
'MEMBERNAME' => $user_info['name'],
Replace With:
// Use $mention_member_name instead of $user_info['name'].
'MEMBERNAME' => $mention_member_name,





In ./Sources/Post.php
Find:
if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))
Add Before:
// Added pa_id to user_info to enable Admins to correct mentions in existing posts and have the mention attributed to the post author.
$user_info['pa_id'] = $row['id_member'];



Find:
$posterOptions = array(
'id' => $user_info['id'],
'name' => $_POST['guestname'],
'email' => $_POST['email'],
'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']) && $board_info['posts_count'],

Add After:
// Added pa_id and pa_name to enable Admins to correct mentions in existing posts and have the mention attributed to the post author.
'pa_id' => isset($_REQUEST['msg']) && !empty($topic) ? $user_info['pa_id'] : $user_info['id'],
'pa_name' => $_POST['guestname'],





In ./Sources/Subs-Post.php
Find:


mentions_process_post($msgOptions, $topicOptions, $posterOptions);
if (!empty($msgOptions['mentions']))
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], $msgOptions['approved']);

Replace With:
// If an Admin is modifying another member's post to correct mentions have the mention attributed to the post author.
if ($user_info['is_admin'] && isset($posterOptions['pa_id']) && ($posterOptions['id'] !== $posterOptions['pa_id']))
{
$pa_posterOptions = $posterOptions;
$pa_posterOptions['id'] = $posterOptions['pa_id'];
$pa_posterOptions['name'] = $posterOptions['pa_name'];
mentions_process_post($msgOptions, $topicOptions, $pa_posterOptions);
}
else
mentions_process_post($msgOptions, $topicOptions, $posterOptions);

if (!empty($msgOptions['mentions']))
// Fix for bug - see https://www.simplemachines.org/community/index.php?topic=522005.msg3695332#msg3695332
// Added $posterOptions['pa_id'] and $posterOptions['pa_name'] to enable Admins to correct mentions in existing posts and have the mention attributed to the post author.
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], isset($msgOptions['approved']) ? $msgOptions['approved'] : 1, $posterOptions['pa_id'], $posterOptions['pa_name']);



Find:
// Alright, done now... we can abort now, I guess... at least this much is done.
ignore_user_abort($previous_ignore_user_abort);

if (!empty($msgOptions['mentions']))
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], isset($msgOptions['approved']));

Replace With:
// Alright, done now... we can abort now, I guess... at least this much is done.
ignore_user_abort($previous_ignore_user_abort);

if (!empty($msgOptions['mentions']))
// Fix for bug - see https://www.simplemachines.org/community/index.php?topic=522005.msg3695332#msg3695332
// Added $posterOptions['id'] and $posterOptions['name'] as these options are now required for mentions_process_store.
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], isset($msgOptions['approved']) ? $msgOptions['approved'] : 1, $posterOptions['id'], $posterOptions['name']);

Life doesn't have to be perfect to be wonderful ...

FragaCampos

I want to thank you for this, Shambles. I just installed this mod and I was having this error.
Your solution works perfectly (although I had to read all messages, because the error is not in text format, but in an image, which is not searchable).



Quote from: Shambles on December 04, 2019, 02:34:33 PM
Under PHP 7.1, when unchecking Profile > Profile Info > Mentions > E-mail mention notifications:





The (bool) cast within Mentions.php is no longer returning 0 when false; it's returning null, causing the above error.

Solution:

Sources/Mentions.php

Code (Find) Select

if (!empty($_POST['save']) && $user_info['id'] == $memID)
updateMemberData($memID, array('email_mentions' => (bool) !empty($_POST['email_mentions'])));


Code (Replace) Select

if (!empty($_POST['save']) && $user_info['id'] == $memID)
updateMemberData($memID, array('email_mentions' => empty($_POST['email_mentions']) ? 0 : 1));


FragaCampos

I'm also getting this error sometimes.
Could it be due to special chars like spaces and é,à,ç, etc.?


Quote from: ambre222 on November 13, 2020, 08:56:21 AM
Hello,
I got this error Illegal mix of collations for operation 'in'
Fichier: /home/attrapes/public_html/forum/Sources/Mentions.php
Ligne: 193
when trying to mention for instance someone with weird accents Mügan.
Is there a way to fix that without changing the encoding of the database ?

FragaCampos

Ok, I managed to fix this with these modification and now it seems to accept special characters and spaces.
https://www.simplemachines.org/community/index.php?topic=522005.msg3877028#msg3877028




Quote from: ambre222 on November 13, 2020, 08:56:21 AM
Hello,
I got this error Illegal mix of collations for operation 'in'
Fichier: /home/attrapes/public_html/forum/Sources/Mentions.php
Ligne: 193
when trying to mention for instance someone with weird accents Mügan.
Is there a way to fix that without changing the encoding of the database ?

Advertisement: