I'm using Solspace favorites module and am looking to automatically add new entries+comments to the DB in a separate Favorites Collection to mark entries as either read or unread (fav or not fav).
Basic thinking: A “new entry” gets added by user (channel form) and after it’s all submitted, write to the Favorties table in the DB :
- Get all members active in the last X weeks (don’t want all or guests)
- Grab the submitted entry_id
- Grab the Favorites collection_id (read_unread)
- Recursively write to the favourites table in the DB (member_id, collection_y, entry_id, time_z)
Now on the front (using Favorites tag) when returning a list of entries – I can check for the existence of the entry_id and member_id - if there is a match I can visually mark that entry for that user as UNREAD (fav) or READ (not fav).
Continuing on, someone adds a comment to an entry. Need to mark it as UNREAD (new) so delete all instances and replace:
- Delete all DB entries where the collection = Y and the entry_id = X
- Get all members active in the last X weeks (don’t want all or guests)
- Grab the submitted entry_id
- Grab the Favorites collection_id (read_unread)
- Recursively write to the favourites table in the DB (member_id, collection_y, entry_id, time_z)
A member is deleted:
- Delete all favourites where member_id = member being deleted and collection = Y.
Members visit an entry:
- Grab the entry_id
- If entry_id, member_id + collection_y exists then delete it effectively marking it as READ.
This is all invisible to the user, I don’t need anything returned simply fired after add/deleting/viewing – hence I’m informed I need to build a module/Extension combo.
Am I correct in my assumptions below that these are the primary Hooks needed to get this functioning?
ADD COMMENT:
comment_form_end($res)
DELETE COMMENT:
delete_comment_additional($comment_ids)
ADD ENTRY:
channel_form_submit_entry_end()
DELETE MEMBER:
member_delete($member_ids)
VIEW ENTRY:
template_post_parse($final_template, $is_partial, $site_id)