Class: People::InvitationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- People::InvitationsController
- Defined in:
- app/controllers/people/invitations_controller.rb
Instance Method Summary (collapse)
- - (Object) create
- - (Object) edit
- - (Object) index
- - (Object) mine
- - (Object) new
- - (Object) show
- - (Object) update
Instance Method Details
- (Object) create
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 |
# File 'app/controllers/people/invitations_controller.rb', line 70 def create = {:user => @currentuser, :email => params[:invitation][:email], :message => params[:invitation][:message]} if(!params[:invitecommunities].nil?) [:additionaldata] = {:invitecommunities => params[:invitecommunities]} end @invitation = Invitation.new() # check for existing user with same email if(@showuser = User.find_by_email(params[:invitation][:email])) flash.now[:warning] = "#{link_to_user(@showuser)} already has an eXtensionID" return render(:action => "new") end # check for existing invitation if(@existinginvitation = Invitation.find_by_email(params[:invitation][:email])) if(@existinginvitation.user == @currentuser) warningmsg = "You have already invited #{@existinginvitation.email} to get an eXtensionID." warningmsg += " <a href='#{edit_people_invitation_url(@existinginvitation)}'>Resend invitation?</a>" else warningmsg = "#{@existinginvitation.email} has already been invited to get an eXtensionID by #{link_to_user(@existinginvitation.user)}." end flash.now[:warning] = warningmsg return render(:action => "new") end if(!@invitation.save) return render(:action => "new") end end |
- (Object) edit
108 109 110 111 112 113 114 |
# File 'app/controllers/people/invitations_controller.rb', line 108 def edit @invitation = Invitation.find_by_id(params[:id]) if(@invitation.status == Invitation::ACCEPTED) flash[:warning] = 'This invitation has already been accepted.' return(redirect_to(people_invitation_url(@invitation))) end end |
- (Object) index
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/people/invitations_controller.rb', line 15 def index show = params[:show].nil? ? 'pending' : params[:show] case show when 'all' @invitelist = Invitation.paginate(:all, :include => [:user,:colleague], :order => 'created_at desc',:page => params[:page]) @page_title = "All Invitations" when 'accepted' @invitelist = Invitation.accepted.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Accepted Invitations" when 'completed' @invitelist = Invitation.completed.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Completed Invitations" when 'invalidemail' @invitelist = Invitation.invalidemail.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Invalid Invitations" when 'pending' @invitelist = Invitation.pending.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Pending Invitations" else @invitelist = Invitation.pending.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Pending Invitations" end end |
- (Object) mine
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/people/invitations_controller.rb', line 39 def mine show = params[:show].nil? ? 'pending' : params[:show] case show when 'all' @invitelist = Invitation.byuser(@currentuser).paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "All Invitations" when 'accepted' @invitelist = Invitation.byuser(@currentuser).accepted.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Accepted Invitations" when 'completed' @invitelist = Invitation.byuser(@currentuser).completed.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Completed Invitations" when 'invalidemail' @invitelist = Invitation.byuser(@currentuser).invalidemail.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Invalid Invitations" when 'pending' @invitelist = Invitation.byuser(@currentuser).pending.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Pending Invitations" else @invitelist = Invitation.byuser(@currentuser).pending.paginate(:all, :order => 'created_at desc',:page => params[:page]) @page_title = "Pending Invitations" end end |
- (Object) new
63 64 65 66 67 68 |
# File 'app/controllers/people/invitations_controller.rb', line 63 def new @invitation = Invitation.new respond_to do |format| format.html # new.html.erb end end |
- (Object) show
100 101 102 103 104 105 106 |
# File 'app/controllers/people/invitations_controller.rb', line 100 def show @invitation = Invitation.find_by_id(params[:id]) if(@invitation.nil?) flash[:error] = 'That invitation does not exist' return(redirect_to(:action => 'index')) end end |
- (Object) update
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'app/controllers/people/invitations_controller.rb', line 116 def update @invitation = Invitation.find_by_id(params[:id]) if(@invitation.nil?) flash[:error] = 'That invitation does not exist' return(redirect_to(:action => 'index')) end = {} # only allow updates of what we only allow if(@invitation.status == Invitation::INVALID_EMAIL) # expecting email change if(params[:invitation][:email].blank? or (params[:invitation][:email] == @invitation.email)) flash.now[:warning] = 'This email address was marked as invalid, please change the invitation email.' return(render(:action => 'edit')) else [:email] = params[:invitation][:email] [:status] = Invitation::PENDING end end if(@invitation.user != @currentuser) # only accept a resendmessage if(!params[:invitation][:resendmessage].blank?) [:resendmessage] = params[:invitation][:resendmessage] end else if(!params[:invitation][:message].blank?) [:message] = params[:invitation][:message] else [:message] = '' end if(!params[:invitecommunities].nil?) if(@invitation.additionaldata.blank?) [:additionaldata] = {:invitecommunities => params[:invitecommunities]} else [:additionaldata] = @invitation.additionaldata.merge(:invitecommunities => params[:invitecommunities]) end end end if(!@invitation.update_attributes()) return render(:action => "edit") else @invitation.resend(@currentuser) end end |