app/models/enrollment.rb
# Return a hash describing privileges of the specified user
# on this enrollment
Return a hash describing privileges of the specified user
on this enrollment
Return a hash describing privileges of the specified user on this enrollment
def privileges(user)
		p = TinyPrivileges.new
		return p if user.nil?
		return p.grant_all if user.admin?
		return p.grant_all if user == contract.facilitator
		user_role = contract.role_of(user)
		if user_role.nil?
			p[:browse] = 
			p[:view] = 
			p[:create_note] = 
			p[:view_students] = 
			p[:view_note] = (user.privilege == User::PRIVILEGE_STAFF)
			return p
		end
		p[:edit] = (user_role >= Enrollment::ROLE_INSTRUCTOR)
		p[:view] = 
		p[:create_note] = 
		p[:view_note] =
		p[:browse] = ((user_role >= Enrollment::ROLE_INSTRUCTOR) or
									(user.id == participant.id))
		p[:view_students] =   
		p[:edit_note] = user_role >= Enrollment::ROLE_INSTRUCTOR
		return p
	end
def privileges ( user ) p = TinyPrivileges . new return p if user . nil? return p . grant_all if user . admin? return p . grant_all if user == contract . facilitator user_role = contract . role_of ( user ) if user_role . nil? p [ :browse ] = p [ :view ] = p [ :create_note ] = p [ :view_students ] = p [ :view_note ] = ( user . privilege == User :: PRIVILEGE_STAFF ) return p end p [ :edit ] = ( user_role >= Enrollment :: ROLE_INSTRUCTOR ) p [ :view ] = p [ :create_note ] = p [ :view_note ] = p [ :browse ] = ( ( user_role >= Enrollment :: ROLE_INSTRUCTOR ) or ( user . id == participant . id ) ) p [ :view_students ] = p [ :edit_note ] = user_role >= Enrollment :: ROLE_INSTRUCTOR return p end
Return a hash describing privileges of the specified user
on this enrollment
Return a hash describing privileges of the specified user on this enrollment
# create a new privileges object with no rights # user must be specified # an admin has full privileges ########################################## # see if the user has an enrollment role on the contract here ########################################## # USER IS NOT ENROLLED # if no role, then check for staff privileges # staff members can view and do notes # non-staff, non-enrolled user has no privileges ########################################## # USER IS ENROLLED # FOR EDIT PRIVILEGES, # user must be instructor # FOR VIEW, NOTE PRIVILEGES, # user must be an instructor or a supervisor or the enrolled student # an instructor or supervisor can edit a note # bogus since an enrollment only deals with one student
user
<not_specific>