Hello,
I have a new resource that adds a moderator permission and needs to send a notification to these moderators when a specific action happens. Item 1.1 of Marketplace Submission Guidelines says:
It was already said to me in old ticket system that "there are things that can't be done in other way/there's only one way to do" or something like that, like methods from models, etc. So my question is basically in this part, for example, that can be found in \IPS\Content::report():
/* Send notification to mods */
$moderators = array( 'm' => array(), 'g' => array() );
foreach ( \IPS\Db::i()->select( '*', 'core_moderators' ) as $mod )
{
$canView = FALSE;
if ( $mod['perms'] == '*' )
{
$canView = TRUE;
}
if ( $canView === FALSE )
{
$perms = json_decode( $mod['perms'], TRUE );
if ( isset( $perms['can_view_reports'] ) AND $perms['can_view_reports'] === TRUE )
{
$canView = TRUE;
}
}
if ( $canView === TRUE )
{
$moderators[ $mod['type'] ][] = $mod['id'];
}
}
$notification = new \IPS\Notification( \IPS\Application::load('core'), 'report_center', $index, array( $index, $reportInsert, $this ) );
foreach ( \IPS\Db::i()->select( '*', 'core_members', ( \count( $moderators['m'] ) ? \IPS\Db::i()->in( 'member_id', $moderators['m'] ) . ' OR ' : '' ) . \IPS\Db::i()->in( 'member_group_id', $moderators['g'] ) . ' OR ' . \IPS\Db::i()->findInSet( 'mgroup_others', $moderators['g'] ) ) as $member )
{
$notification->recipients->attach( \IPS\Member::constructFromData( $member ) );
}
$notification->send();
That's exactly what I need: search for all moderators (unrestricted or that has a specific permission) but it would change basically the moderator permission name and the notification line.
So the doubt is pretty straightforward: is it allowed/safe to use it? If no, how to check moderator permissions in "another way"?
Thank you.