We review a new theory of viscoelasticity of a glass-forming viscous liquid near and below the glass transition. In our model we assume that each point in the material has a specific viscosity, which varies randomly in space according to a fluctuating activation free energy. We include a Maxwellian elastic term and assume that the corresponding shear modulus fluctuates as well with the same distribution as that of the activation barriers. The model is solved in coherent-potential approximation (CPA), for which a derivation is given. The theory predicts an Arrhenius-type temperature dependence of the viscosity in the vanishing-frequency limit, independent of the distribution of the activation barriers. The theory implies that this activation energy is generally different from that of a diffusing particle with the same barrier-height distribution. If the distribution of activation barriers is assumed to have Gaussian form, the finite-frequency version of the theory describes well the typical low-temperature alpha relaxation peak of glasses. Beta relaxation can be included by adding another Gaussian with center at much lower energies than that responsible for the alpha relaxation. At high frequencies our theory reduces to the description of an elastic medium with spatially fluctuating elastic moduli (heterogeneous elasticity theory), which explains the occurrence of the boson-peak-related vibrational anomalies of glasses.