public function getUsergroups( $type ) { $config = Komento::getConfig(); $gids = ''; switch( $type ) { case 'confirm': break; case 'pending': case 'moderate': $gids = $config->get( 'notification_to_usergroup_pending' ); break; case 'report': $gids = $config->get( 'notification_to_usergroup_reported' ); break; case 'reply': $gids = $config->get( 'notification_to_usergroup_reply' ); break; case 'comment': case 'new': default: $gids = $config->get( 'notification_to_usergroup_comment' ); break; } if( !empty( $gids ) ) { if( !is_array( $gids ) ) { $gids = explode( ',', $gids ); } $users = array(); $ids = array(); foreach( $gids as $gid ) { $ids = $ids + Komento::getUsersByGroup( $gid ); } foreach( $ids as $id ) { $tmp = JFactory::getUser( $id ); $user = array( 'id' => $tmp->id, 'fullname' => $tmp->name, 'email' => $tmp->email ); $users[$tmp->email] = (object) $user; } return $users; } return array(); }
public function getNotificationTarget( $target, $action, $comment ) { $ids = array(); switch( $target ) { case 'usergroup': $gids = $this->config->get( 'notification_es_to_usergroup_' . $action ); if( !empty( $gids ) ) { if( !is_array( $gids ) ) { $gids = explode( ',', $gids ); } foreach( $gids as $gid ) { $ids += Komento::getUsersByGroup( $gid ); } } break; case 'author': if( $this->config->get( 'notification_es_to_author' ) ) { $application = Komento::loadApplication( $comment->component )->load( $comment->cid ); $author = $application->getAuthorId(); if( !empty( $author ) ) { $ids = array( $author ); } } break; case 'parent': if( !empty( $comment->parent_id ) ) { $parent = Komento::getTable( 'comments' ); $state = $parent->load( $comment->parent_id ); if( $state && !empty( $parent->created_by ) ) { $ids = array( $parent->created_by ); } } break; case 'owner': if( !empty( $comment->created_by ) ) { $ids = array( $comment->created_by ); } break; case 'participant': if( $this->config->get( 'notification_es_to_participant' ) ) { $options = array( 'component' => $comment->component, 'cid' => $comment->cid, 'noguest' => true, 'state' => 1 ); $model = Komento::getModel( 'comments' ); $ids = $model->getUsers( $options ); } break; } return $ids; }