see: http://moodle.org/mod/forum/discuss.php?d=59286
1/ add new standard function isguestuser() - use it where we deal with real guest user ( replaces $user->username == 'guest')
2/ review the use of 'moodle/legacy:guest' - replace some with isguestuser(), add needed capabilities or keep as is
3/ remove isguest() - use isguestuser(), add missing capabilities OR in some places use has_capability('moodle/legacy:guest', $context, NULL, false)