refactored the emailer/write slightly

When I tried to access emailer/write for a class that has 3000
students, it took too long to load. I condensed four of the queries
into one, which seems to speed up the processing time a lot.
added survey validation and modifies events add/edit

I've included a validation for survey to check the availability
field. If it is left unselected, a validation error will now occur.

I've added two buttons to events add/edit to select or unselect
all the groups. This is to make it more convenient for instructors
that just want to select all the groups.
removed extra permission check for departments/faculties

I have also fixed the links to the courses in the departments/view.
It was missing a '/' which made the url invalid.
removed permissions for admins to access the departments controller

I couldn't just deny controllers/departments because the list of
accessible courses for admins depend on it. I had to deny access
for each function instead.