public static function get_unread_popup_notification_count($useridto) {
        global $USER;

        $params = self::validate_parameters(
            self::get_unread_popup_notification_count_parameters(),
            array('useridto' => $useridto)
        );

        $context = context_system::instance();
        self::validate_context($context);

        $useridto = $params['useridto'];

        if (!empty($useridto)) {
            if (core_user::is_real_user($useridto)) {
                $userto = core_user::get_user($useridto, '*', MUST_EXIST);
            } else {
                throw new moodle_exception('invaliduser');
            }
        }

        // Check if the current user is the sender/receiver or just a privileged user.
        if ($useridto != $USER->id and !has_capability('moodle/site:readallmessages', $context)) {
            throw new moodle_exception('accessdenied', 'admin');
        }

        return \message_popup\api::count_unread_popup_notifications($useridto);
    }
public static function get_unread_popup_notification_count($useridto) {
        global $USER;

        $params = self::validate_parameters(
            self::get_unread_popup_notification_count_parameters(),
            array('useridto' => $useridto)
        );

        $context = context_system::instance();
        self::validate_context($context);

        $useridto = $params['useridto'];

        if (!empty($useridto)) {
            if (core_user::is_real_user($useridto)) {
                $userto = core_user::get_user($useridto, '*', MUST_EXIST);
            } else {
                throw new moodle_exception('invaliduser');
            }
        }

        // Check if the current user is the sender/receiver or just a privileged user.
        if ($useridto != $USER->id and !has_capability('moodle/site:readallmessages', $context)) {
            throw new moodle_exception('accessdenied', 'admin');
        }

        return \message_popup\api::count_unread_popup_notifications($useridto);
    }
public static function get_unread_popup_notification_count ( $ useridto ) { global $ USER ; $ params = self :: validate_parameters ( self :: get_unread_popup_notification_count_parameters ( ) , array ( 'useridto' => $ useridto ) ) ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; $ useridto = $ params [ 'useridto' ] ; if ( ! empty ( $ useridto ) ) { if ( core_user :: is_real_user ( $ useridto ) ) { $ userto = core_user :: get_user ( $ useridto , '*' , MUST_EXIST ) ; } else { throw new moodle_exception ( 'invaliduser' ) ; } } // Check if the current user is the sender/receiver or just a privileged user. if ( $ useridto != $ USER -> id and ! has_capability ( 'moodle/site:readallmessages' , $ context ) ) { throw new moodle_exception ( 'accessdenied' , 'admin' ) ; } return \ message_popup \ api :: count_unread_popup_notifications ( $ useridto ) ; }
Get unread notification count function.

@since  3.2
@throws invalid_parameter_exception
@throws moodle_exception
@param  int      $useridto       the user id who received the message
@return external_description
Get unread notification count function .