Module: BigbluebuttonRails::ControllerMethods
- Defined in:
- lib/bigbluebutton_rails/controller_methods.rb
Overview
Module that is automatically included into all controllers.
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/bigbluebutton_rails/controller_methods.rb', line 6 def self.included(base) base.class_eval do helper_method :bigbluebutton_user, :bigbluebutton_role # Method used to acquire the user for which the BigBlueButton actions are being # called (e.g. the user creating or joining the room). # Defaults to the user currently logged in, using the method current_user. # If your application has no method current_user or if you want # to change the behavior of this method, just redefine it in your # controller. You may want to do it in the ApplicationController to make it # available to all controllers. For example: # # def bigbluebutton_user # User.where(:bigbluebutton_admin => true).first # end # # Note that BigbluebuttonRails assumes that the returned object has # a method called 'name' that returns the user's full name. def current_user end # Returns the role that the current user has in the room 'room'. Return values: # :moderator # the user has attendee permissions # :attendee # the user has moderator permissions # :key # the user must enter a key that will define his role # nil # no role at all (the room is blocked to this user) # # Returning :moderator or :attendee means that the current user has access # to the room and has moderator or attendee privileges, respectively. # Returning :key indicates that the user must enter a key to define # his role in the room. # At last, returning nil means that the user cannot access access this room # at all. BigbluebuttonRails::RoomController will thrown an exception of the # class BigbluebuttonRails::RoomAccessDenied in this case. By default rails will # show an error page whenever an exception is thrown (and not catch). To show # a better-looking page, add in your ApplicationController a block to catch the # exception, such as: # # rescue_from BigbluebuttonRails::RoomAccessDenied do |exception| # flash[:error] = "You don't have permission to access this room!" # redirect_to root_url # end # # You may want to redefine this method in your application to define # real roles to the users. By default, if the room is not private and the user # is logged, he will have moderator permissions. Otherwise, he must enter # a key. Redefine it in your ApplicationController to make it available # to all controllers. For example: # # def bigbluebutton_role(@room) # # # the owner is the moderator # if @room.owner == bigbluebutton_user # :moderator # # # only friends are allowed to enter # elsif @room.owner.friends.include? bigbluebutton_user # if @room.private # :key # with key if the room is private # else # :attendee # end # # # not a friend? you're not allowed in # else # nil # end # # end # def (room) if room.private or .nil? :key # ask for a key else :moderator end end # Method used called right before a meeting is created to check # whether the current user ('bigbluebutton_user') is allowed to create # the meeting in the target room. # By default any moderator can create meetings. # The parameter 'room' is the BigbluebuttonRoom where the meeting is about # to be created. And 'role' is the role already defined for the user # (:moderator, :attendee, etc). # # You may want to override this in your ApplicationController to # implement your own logic, for example: # # def bigbluebutton_can_create?(room, role) # if role == :moderator && bigbluebutton_user.admin? # true # else # false # end # end # def (room, role) role == :moderator end end end |