Photoluminescence of nanodiamonds influenced by charge transfer from silicon and metal substrates