	public static Set findApplicable(HttpServletRequest request, boolean instructorPrefOnly, boolean examPref) throws Exception {
    	User user = Web.getUser(request.getSession());
    	Session session = Session.getCurrentAcadSession(user);
    	TimetableManager mgr = TimetableManager.getManager(user);
    	if (user.isAdmin()) return findAll(instructorPrefOnly, examPref);
    	TreeSet ret = new TreeSet();
    	for (Iterator i=findAll(instructorPrefOnly,examPref).iterator();i.hasNext();) {
    		DistributionType dt = (DistributionType)i.next();
    		Set depts = dt.getDepartments(session.getUniqueId());
    		if (depts.isEmpty()) {
    			ret.add(dt);
    		} else {
    			boolean contains = false;
    			for (Iterator j=mgr.getDepartments().iterator();!contains && j.hasNext();) {
    				Department d = (Department)j.next();
    				if (depts.contains(d)) contains = true; 
    			}
    			if (contains)
    				ret.add(dt);
    		}
    	}
    	return ret;
    }

	public static Set findApplicable(HttpServletRequest request, boolean instructorPrefOnly, boolean examPref) throws Exception {
    	User user = Web.getUser(request.getSession());
    	Session session = Session.getCurrentAcadSession(user);
    	TimetableManager mgr = TimetableManager.getManager(user);
    	if (user.isAdmin()) return findAll(instructorPrefOnly, examPref);
    	TreeSet ret = new TreeSet();
    	for (Iterator i=findAll(instructorPrefOnly,examPref).iterator();i.hasNext();) {
    		DistributionType dt = (DistributionType)i.next();
    		Set depts = dt.getDepartments(session==null?null:session.getUniqueId());
    		if (depts.isEmpty()) {
    			ret.add(dt);
    		} else {
    			boolean contains = false;
    			for (Iterator j=mgr.getDepartments().iterator();!contains && j.hasNext();) {
    				Department d = (Department)j.next();
    				if (depts.contains(d)) contains = true; 
    			}
    			if (contains)
    				ret.add(dt);
    		}
    	}
    	return ret;
    }
