app/controllers/wall_comments_controller.rb
# Require the users to be connected.
Require the users to be connected.
Require the users to be connected .
def connection_required
      if wall?
        unless connected_to?(user)
          respond_to do |format|
            format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
            format.html { redirect_to index_url }
          end
          return
        end
      elsif group_wall?
        unless @group.can_participate?(logged_in_user)
          respond_to do |format|
            format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
            format.html { redirect_to index_url }
          end
          return
        end
      elsif event?
        if @event.eventable_type == "Group"
          unless @event.eventable.can_participate?(logged_in_user) && @event.attendees.include?(logged_in_user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        else
          unless @event.attendees.include?(logged_in_user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        end
      elsif photo?
        if @photo.owner_type == "User"
          unless connected_to?(user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        elsif @photo.owner_type == "Group"
          unless user.can_participate?(logged_in_user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        end
      elsif blog?
        if @blog.owner_type == "User"
          unless connected_to?(user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        elsif @blog.owner_type == "Group"
          unless user.can_participate?(logged_in_user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        end
      elsif news_item?
        if @news_item.newsable_type == "Group"
          unless user.can_participate?(logged_in_user)
            respond_to do |format|
              format.js { render(:update){|page| page.alert "你無法執行這個動作"} }
              format.html { redirect_to index_url }
            end
            return
          end
        end
      end
    end
def connection_required if wall? unless connected_to? ( user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end elsif group_wall? unless @group . can_participate? ( logged_in_user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end elsif event? if @event . eventable_type == "Group" unless @event . eventable . can_participate? ( logged_in_user ) && @event . attendees . include? ( logged_in_user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end else unless @event . attendees . include? ( logged_in_user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end end elsif photo? if @photo . owner_type == "User" unless connected_to? ( user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end elsif @photo . owner_type == "Group" unless user . can_participate? ( logged_in_user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end end elsif blog? if @blog . owner_type == "User" unless connected_to? ( user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end elsif @blog . owner_type == "Group" unless user . can_participate? ( logged_in_user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end end elsif news_item? if @news_item . newsable_type == "Group" unless user . can_participate? ( logged_in_user ) respond_to do | format | format . js { render ( :update ) { | page | page . alert "你無法執行這個動作"} } format . html { redirect_to index_url } end return end end end end
Require the users to be connected.
Require the users to be connected .