Mention Users with @ Download 1.9.1

This component/theme doesn't work with the latest OSSN version.
5.0
us bryce alvord 5 years ago

OSSN MENTION USERS COMPONENT

This component enables a user to mention other users in posts and comments by using the syntax @Full Name or conditionally @username and that will send the mentioned user a notification telling them that they were mentioned in a post or comment with a link to that item.

This can be used in conjunction with the Display Username component as of v1.2 if you want to display usernames and mention @username instead of display Full Name and mention @Full Name. It will dynamically switch based whether or not the Display Username component is installed and turned on. You can find more info on it here: https://www.opensource-socialnetwork.org/component/view/3065/display-username

  • When mentioning usernames using the Display Username component the exact casing must be used to match the user.

  • When mentioning user full names the casing DOES matter as that can help find uniqueness.

  • Mentions are not limited to the friends of the user, the entire user base can be mentioned

  • Multiple mentions can be done in a post or comment.

CHANGE LOG
-------------------1.9.1------------------

  • Added ability to parse off trailing '(apostrophe) and 's for use in plurals and ownership

  • Added recommended method and hooks from Z-Man

-------------------1.9--------------------

  • Added 'ossn:notifications:mention:post:created' to en locale

  • Added 'ossn:notifications:mention:comment:created' to en locale

  • Renamed init method from basic name to prevent potential collision with other components

POSSIBLE ENHANCEMENTS

  • No UI based on prototype having significant cons

  • ?

Comments
German Michael Zülsdorff Replied 5 years ago

To start when a post gets deleted ... have a look into OssnWall->deletePost()

You find a callback being triggered like

ossn_trigger_callback('post', 'delete', $post);

Register that callback in your component like

ossn_register_callback('post', 'delete', 'removeMentionNotification');

removeMentionNotification(....) {
// remove accompanying notification record of type 'mention:post:created'
}

The other parts are basically similar, find the triggers in OssnUsers->deleteUser() and OssnComments->deleteComment()

us Bryce alvord Replied 5 years ago

Z,

Can you help me understand point A better. Are you saying I need to implement a new hook on a delete comment or delete post that will delete the notification? Im just trying to understand. This one is new to me. Obviously from a programming and flow perspective I get the importance, just need to understand the OSSN implementation better because Im not sure if this would be like this

add a hook to the delete action >> check to see if notification is pending on deleted item >> delete notification if item is deleted >> else display the notification

or this

upon clicking the notification icon >> check to see if notification is pending on deleted item >> delete notification if item is deleted >> else display the notification

or

something else

Thanks!

us Bryce alvord Replied 5 years ago

Hey no worries Z-Man,

I appreciate all the help I can get. I will be happy to implement your change idea. I will delete v1.1 so no one grabs it in the mean time but I will try to get v1.2 with that change uploaded tonight. Thanks again man, I really appreciate the helpfulness.

Bryce

German Michael Zülsdorff Replied 5 years ago

Great idea and a good start, Bryce!
But I'm still not really happy with version 1.1

A) Whenever you create new database records in general - asure they will be deleted if necessary. In this case:
1. if the posting / comment has been deleted by the originator
2. if the originator has been deleted / has left the community

Otherwise you'll end up with orphan records and notifications pointing into the blue here.

B) com_notificationHandler() is a fair solution for communities with a handful of users, yes, but fetching a complete userbase with thousends of members will make your function a real monster, eating up memory and maybe even result in timeouts. Thus, instead of fetching the complete list and do a comparison whether the mentioned user may be part of it I'd recommend to make use of OssnUsers->searchUsers() instead. This way you need only one query and either you get something back or not.

us Bryce alvord Replied 5 years ago

V1.1 has been uploaded with Arsalans suggestions addressed

us Bryce alvord Replied 5 years ago

Excellent, thank you, I will add that for v1.1 tonight

Indonesian Arsalan Shah Replied 5 years ago

You should be able to add icon in com_mention_notifier_view_notification or once you updated the type, the notification item should get a html class , you can view source code of browser and see which class is assigned to li, then using css you can use fontawesome (this is second approach)

us Bryce alvord Replied 5 years ago

Yep thats the one. I was wondering if it is easy to wire up a new icon type like for my mention:component:post type for example

Indonesian Arsalan Shah Replied 5 years ago

You mean the icon display in notification view box?

us Bryce alvord Replied 5 years ago

Good point Arsalan, I guess I didnt consider that could have ramifications. Im at work now and will adjust it after I get home so Im going to delete the upload so no one else grabs it until v1.1 is done. BTW, any advice on how I can get a little font awesome icon to show for my type similar to how

post:created

does in the notification template?

Thanks for the input!

Component

Developer: bryce
License GPL v2
Type: Communication
Requires Ossn Version : 5.x
Latest Version: 1.9.1
Last Updated 5 years ago
Repository Url View Repository

Versions