  Recent experiments with ultracold atoms in an optical lattice have realized
cavity-mediated long-range interaction and observed the emergence of a
supersolid phase and a density wave phase in addition to Mott insulator and
superfluid phases. Here we consider theoretically the effect of uncorrelated
disorder on the phase diagram of this system and study the two-dimensional
Bose-Hubbard model with cavity-mediated long-range interactions and
uncorrelated diagonal disorder. We also study the phase diagram of the extended
Bose-Hubbard model with nearest-neighbor interactions in the presence of
uncorrelated diagonal disorder. The extended Bose-Hubbard model with
nearest-neighbor interactions has been realized in the experiment using dipolar
interaction recently. With the help of quantum Monte Carlo simulations using
the worm algorithm, we determine the phase diagram of those two models. We
compare the phase diagrams of cavity-mediated long-range interactions with
nearest-neighbor interactions. We show that two kinds of Bose glass phases
exist: one with and one without density wave order. We also find that weak
disorder enhances the supersolid phase.
