HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Forcing notifications for staff to staff-group forums

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#108484 (In Topic #21140)
Avatar

Just a quick question.

Would it be possible, even with custom coding, to force all of my staff members to receive instant email notifications to activity in the reported posts forum and main staff forum? I'd like my staff to at all times be notified of things that have been reported that need reviewed as well as staff posts.
Back to the top
 
Posted
Rating:
#108493
Avatar

Community saint

The easiest solution would be to masquerade as your staff member's accounts and click the Monitor button in the Reported Posts forum and the Staff forum to enable the forum post notifications for the staff members. Then send an email to the staff members to tell them they must leave the notifications enabled for those forums or they risk losing their position as a staff member.

Instead of masquerading and manually setting the notifications, that could probably be done programmatically and turned into a cron hook that ocPortal would execute every so often to ensure all staff members, admins, and super moderators are monitoring those forums. The cron hook could enable those notifications if it finds them disabled and also email the main admin a list of staff members that are trying to disable them. I could probably take a look at making this in the near future…maybe in a week or two.
Back to the top
 
Posted
Rating:
#108495
Avatar

This is how I'd approach it Jason:
0001972: Usergroup enter hooks - ocPortal feature tracker

CRON hooks probably would annoy people, because it would keep resetting it.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#108496
Avatar

Actually it's worth mentioning you could do the same without having to code in the new hook support, via upon_query hooks. You'd scan for queries changing the f_members or f_group_members table, find the member ID via some regexp, and see what groups they're now in. You can set up a method in the hook to run *after* the query has happened, so the code runs knowing the new groups state.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#108498
Avatar

Community saint

Thanks for the info Chris. I'll take a look at both options.
Back to the top
 
Posted
Rating:
#108698
Avatar

Community saint

Chris, I got some work done on this over the past weekend. I started with the usergroup enter/exit hook and have that part mostly tested and working. I'm working off of the Composr codebase and will backport it to ocPortal. But before I continue, I have a few thoughts and questions:

I coded up an override for three functions (cns_member_leave_group, cns_add_member_to_group, and cns_member_validate_into_group) in sources/cns_gorups_actions2.php. The override needs some redundant code from the original function to work. Because of that, it would probably be less likely to break and easier to maintain if the override code was integrated into the original code. Would you like me to add the code directly in github to the sources/cns_groups_actions2.php (for Composr) and sources/ocf_groups_actions2.php (for ocPortal v9 branch)?

I created a hook directory as hooks/systems/upon_usergroup_enter_exit and opted to use entered_usergroup($member_id, $group_id, $as_primary) and exited_usergroup($member_id, $group_id, $as_primary). Do those names (hook directory and class methods) make sense?

The $as_primary, I'm assuming, will be a boolean to specify whether the $group_id is set as a Primary Usergroup for $member_id? Tracking the primary status is not part of the original usergroup add/exit functions, so I would have to add that to the override code I already have.

As for the actual hook itself, I can foresee some possible issues with enabling forum notifications programmatically. What if an admin removes and re-adds staff-related forums, or renames the Staff forum grouping or any of the forums contained in that grouping? One example, what if I delete my Staff forum from the Staff forum grouping, create a new Staff forum in a different forum grouping (i.e. Staff for a different zone), and then re-add a Staff forum to the Staff grouping once I realise I shouldn't have removed it. The forum_id_from_name() function could possibly return the ID for the wrong Staff forum. An idea I had was to make the hook so it can parse out the forum grouping name and the forum name from the hook class name (using get_class()) and extending the forum_id_from_name() function to include an optional $forum_grouping_name parameter. But then there is the same issue if forum grouping names are identical, it would return the first result found and not necessarily the correct result (and it would still be prone to breakage if forum names or groupings were renamed). Could we make the 'Add forum grouping' function only accept new unique names to prevent duplicates and possibly make the 'Add forum' function only accept new unique names to prevent duplicates within a forum grouping (but allow duplicates as long as they are in different groupings)? Any other thoughts on how to always get the correct forum id from the forum name without making it a config option or is a config option going to be the best way to go?


Last edit: by Jason Verhagen
Back to the top
 
Posted
Rating:
#108702
Avatar

Sounds great Jason, please do.

Tracking the primary status is not part of the original usergroup add/exit functions, so I would have to add that to the override code I already have

I think those functions are implicitly for secondary group membership, as there's only one primary group you can't "add" someone to one as such – I think the change is done directly in ocf_edit_member (now cns_edit_member), but you'll need to grep the code for other cases we may be writing to it.

Might be good to have an $is_new_member parameter too, so we can call it for new users.

Could we make the 'Add forum grouping' function only accept new unique names to prevent duplicates

Sounds sensible. It should have already honestly.

the 'Add forum' function only accept new unique names to prevent duplicates within a forum grouping (but allow duplicates as long as they are in different groupings)

Sounds good.

Any other thoughts on how to always get the correct forum id from the forum name without making it a config option or is a config option going to be the best way to go?

TBH I wouldn't over-do it. While I agree about the above strictness improvements, for the actual hook I'd personally just hardcode in IDs. The problem with the "long tail" of feature requests like this is that you can never solve it in an elegant way, because at this level of bespokeness the breadth of variation in requirement between users is more than you could make configurable within any UI or code structure. So I think assuming some level of code editing is always reasonable at this level. If I were doing it I'd make the hook you implement a Development categorised addon, and just hard-code in some variables with comments. Then people can modify the code easily enough.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#108798
Avatar

Community saint

Chris, thanks for the input. If I understand what you're saying about the $as_primary, we want to call the hook when the primary group is changed and use that variable as a way to notify the hook that it's the primary group that was changed and not a secondary group that was added?

In addition to the three previously mentioned functions in cns_groups_action2.php, a preliminary search turned up these additional files and functions that would probably need some hook calling code added (working from Composr codebase):

-sources/hooks/systems/ecommerce/usergroup.php
—handle_usergroup_subscription()

-sources/cns_members_action.php
—cns_make_member()

-sources/cns_posts_actions2.php
—cns_member_handle_promotion()

-sources/group_member_timeouts.php
—set_member_group_timeout()

I'll do some more coding and testing.


Back to the top
 
Posted
Rating:
#108805
Avatar

Chris, thanks for the input. If I understand what you're saying about the $as_primary, we want to call the hook when the primary group is changed and use that variable as a way to notify the hook that it's the primary group that was changed and not a secondary group that was added?

Yeah :).

You don't need it in your case, but I think it would be useful to people. Quite a handy hook type this :).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: