Use drupal_is_cli() to determine enviorement.
Merge pull request #5810 from openscholar/5780-1

Use drupal_is_cli() to determine environment