MDL-12945 fixed sql purity to make pg happy, fixed bug in user list of active chats; merged from MOODLE_19_STABLE
MDL-12945 fixed sql purity to make pg happy, fixed bug in user list of active chats; merged from MOODLE_19_STABLE

dilawar/moodle