Advertisement:

Author Topic: @mention members  (Read 193726 times)

Offline jsx

  • Full Member
  • ***
  • Posts: 448
  • Gender: Male
Re: @mention members
« Reply #600 on: April 05, 2019, 04:04:24 AM »
@Dragooon

The selection does not appear in this checkbox:

Enable mentions e-mail for current members

Whereas, the selection appears correctly in this checkbox:

Enable mentions e-mail by default
The Great Winged Hussars

https://www.youtube.com/watch?v=eWkrQQly6xU

We remember
In september
When The Winged Hussars arrived!

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 905
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: @mention members
« Reply #601 on: April 09, 2019, 02:00:16 AM »
For anyone wanting to explain to their forum members how this mod is used feel free to copy
http://gsx1400owners.org/forum/index.php?topic=477.0
to your hearts content.  Cheers
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.

Offline grzeg8102

  • Newbie
  • *
  • Posts: 5
Re: @mention members
« Reply #602 on: September 24, 2019, 05:11:43 AM »
Great mod! Very useful. Since I started being a user of a Discourse forum I dreamt of something similar in my my own SMF forum I'm running.

@Dragoon - I'm only missing the mod to run also on the recents page ("/index.php?action=recent"). Can you please add it? Hopefully it's nothing complex and only requires the function mentions_post_scripts(); to be called in one more place.

BTW. I'd like to share my CSS for it - it tries to mimic Discourse mention style. Attached

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,462
  • Gender: Male
    • i30 Owners Club
Re: @mention members
« Reply #603 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));

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,341
Re: @mention members
« Reply #604 on: December 04, 2019, 02:42:39 PM »
(bool) returns true or false, which would need to be explicitly cast to numbers to make that work - false, by default, implicit casts to empty string, not 0, unless explicit-casting to int.

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,462
  • Gender: Male
    • i30 Owners Club
Re: @mention members
« Reply #605 on: December 04, 2019, 02:48:18 PM »
Yep - that's what was happening. Must have been different under 5.6 as that seemed to return 0?

With the change above it I now get 0 or 1 (obviously) instead of null or 1.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,341
Re: @mention members
« Reply #606 on: December 04, 2019, 02:52:48 PM »
Nope, those semantics have never changed. I’m assuming it’s just always been left ticked - unlike false, true will convert to 1 as far as the DB library cares.

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,462
  • Gender: Male
    • i30 Owners Club
Re: @mention members
« Reply #607 on: December 04, 2019, 03:22:54 PM »
I wonder how many people have tried to untick it? Not me, that's for sure.

I only spotted it when doing my routine checks on the error logs.


Quote
... unlike false, true will convert to 1 ...

That implies the original code has always been imperfect, as far as setting a 0 or 1 into the int-only DB space.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,341
Re: @mention members
« Reply #608 on: December 04, 2019, 03:32:18 PM »
Yup, it very likely has.

Offline Xpresskonami

  • Jr. Member
  • **
  • Posts: 279
  • Gender: Male
Re: @mention members
« Reply #609 on: December 14, 2019, 05:54:51 AM »
@Dragooon

The selection does not appear in this checkbox:

Enable mentions e-mail for current members

Whereas, the selection appears correctly in this checkbox:

Enable mentions e-mail by default

I Want to Enable mentions e-mail for current members. I select the box, and the box is not selecting... any solutions please

Offline jsx

  • Full Member
  • ***
  • Posts: 448
  • Gender: Male
Re: @mention members
« Reply #610 on: December 24, 2019, 01:18:02 PM »
@Dragooon

The selection does not appear in this checkbox:

Enable mentions e-mail for current members

Whereas, the selection appears correctly in this checkbox:

Enable mentions e-mail by default

I Want to Enable mentions e-mail for current members. I select the box, and the box is not selecting... any solutions please

Yes, but when you save this setting, this setting will work.
The Great Winged Hussars

https://www.youtube.com/watch?v=eWkrQQly6xU

We remember
In september
When The Winged Hussars arrived!

Offline jsx

  • Full Member
  • ***
  • Posts: 448
  • Gender: Male
Re: @mention members
« Reply #611 on: February 15, 2020, 11:11:10 AM »
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));

Such a mistake appears in the logs:





Is this the same mistake you mentioned?
The Great Winged Hussars

https://www.youtube.com/watch?v=eWkrQQly6xU

We remember
In september
When The Winged Hussars arrived!

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,462
  • Gender: Male
    • i30 Owners Club
Re: @mention members
« Reply #612 on: February 15, 2020, 12:40:04 PM »
Quote
Is this the same mistake you mentioned?

Since it's a completely different error message from an entirely different region of Subs.php handling something not even close to a DB query, the answer has to be no.

Offline jsx

  • Full Member
  • ***
  • Posts: 448
  • Gender: Male
Re: @mention members
« Reply #613 on: February 16, 2020, 03:47:28 AM »
Can anyone help me solve this error?
The Great Winged Hussars

https://www.youtube.com/watch?v=eWkrQQly6xU

We remember
In september
When The Winged Hussars arrived!

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 485
  • Gender: Female
Life doesn't have to be perfect to be wonderful ...

Offline jsx

  • Full Member
  • ***
  • Posts: 448
  • Gender: Male
The Great Winged Hussars

https://www.youtube.com/watch?v=eWkrQQly6xU

We remember
In september
When The Winged Hussars arrived!

Offline rarecorp

  • Newbie
  • *
  • Posts: 4
Re: @mention members
« Reply #616 on: April 16, 2020, 08:21:11 AM »
Hello,

I was wondering if this mod or any other mods out there can tag a whole membergroup? Not a user-specific tag, but the whole user group that will be notified when tagged.

Thank you in advance.

Edit: I saw a mod hxxp:www.smfpacks.com/mentionsmod/ [nonactive] -- but it seems to be paid, anything free mod similar to this one?

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,462
  • Gender: Male
    • i30 Owners Club
Re: @mention members
« Reply #617 on: April 16, 2020, 08:58:00 AM »
Is $9.99 over your budget?

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 485
  • Gender: Female
Re: @mention members
« Reply #618 on: April 30, 2020, 03:28:26 AM »
I've been using this mod since just after it was released (I use it on multiple forums) and I've made two enhancements to suit my needs.




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:
Code: [Select]
sendmail($mention['email_address'], $subject, $body)Replace With:
Code: [Select]
// 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:
Code: [Select]
function mentions_process_store(array $mentions, $id_post, $subject, $approved = true)
{
global $smcFunc, $txt, $user_info, $scripturl;
Replace With:
Code: [Select]
function mentions_process_store(array $mentions, $id_post, $subject, $approved = true, $pa_id = 0, $pa_name = null)
{
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:
Code: [Select]
array($id_post, $user_info['id'], $mention['id'], time()),Replace With:
Code: [Select]
// Use $mention_member_id instead of $user_info['id'].
array($id_post, $mention_member_id, $mention['id'], time()),

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



In ./Sources/Post.php
Find:
Code: [Select]
if (!empty($topic_info['locked']) && !allowedTo('moderate_board'))Add Before:
Code: [Select]
// 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:
Code: [Select]
$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:
Code: [Select]
// 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:
Code: [Select]

mentions_process_post($msgOptions, $topicOptions, $posterOptions);
if (!empty($msgOptions['mentions']))
mentions_process_store($msgOptions['mentions'], $msgOptions['id'], $msgOptions['subject'], $msgOptions['approved']);
Replace With:
Code: [Select]
// 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']);

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

Offline landyvlad

  • Sr. Member
  • ****
  • Posts: 905
  • Gender: Male
    • Michael Reed on Facebook
    • GSX1400 Owners ORG
Re: @mention members
« Reply #619 on: April 30, 2020, 10:36:56 PM »
Great idea.
Please do not PM, IM or Email me with questions on astrophysics or theology.  You will get better and faster responses by asking homeless people in the street. Thank you.

To paraphrase Kindred: "There are no technical solutions to social problems."

No hack nor blackhats, just persistent asshats.