public static function count_unread_popup_notifications($useridto = 0) {
        global $USER, $DB;

        if (empty($useridto)) {
            $useridto = $USER->id;
        }

        return $DB->count_records_sql(
            "SELECT count(id)
               FROM {notifications}
              WHERE id IN (SELECT notificationid FROM {message_popup_notifications})
                AND useridto = ?
                AND timeread is NULL",
            [$useridto]
        );
    }
public static function count_unread_popup_notifications($useridto = 0) {
        global $USER, $DB;

        if (empty($useridto)) {
            $useridto = $USER->id;
        }

        return $DB->count_records_sql(
            "SELECT count(id)
               FROM {notifications}
              WHERE id IN (SELECT notificationid FROM {message_popup_notifications})
                AND useridto = ?
                AND timeread is NULL",
            [$useridto]
        );
    }
public static function count_unread_popup_notifications ( $ useridto = 0 ) { global $ USER , $ DB ; if ( empty ( $ useridto ) ) { $ useridto = $ USER -> id ; } return $ DB -> count_records_sql ( "SELECT count(id)
               FROM {notifications}
              WHERE id IN (SELECT notificationid FROM {message_popup_notifications})
                AND useridto = ?
                AND timeread is NULL" , [ $ useridto ] ) ; }
Count the unread notifications for a user.

@param int $useridto the user id who received the notification
@return int count of the unread notifications
@since 3.2
Count the unread notifications for a user .