Sha256: 54d22bacea3724c153c44dbbc8b7fd1475a582380e01886e0e4cc81fcb4dbc45

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

class ActivitiesController < BaseController
  before_filter :login_required,  :except => :index
  before_filter :find_user,       :only => :network
  
  before_filter :require_current_user,            :except => [:index, :destroy]
  before_filter :require_ownership_or_moderator,  :only   => :destroy
  
  
  def network
    @activities = @user.network_activity(:per_page => 15, :page => params[:page])
  end
  
  def index
    @activities = User.recent_activity(:per_page => 30, :page => params[:page], :limit => 1000)
    @popular_tags = popular_tags(30)
  end
  
  def destroy
    @activity = Activity.find(params[:id])
    @activity.destroy
    
    respond_to do |format|
      format.html {redirect_to :back and return}
      format.js
    end
  end
  
  private
    def require_ownership_or_moderator
      @activity = Activity.find(params[:id])  
         
      unless @activity && @activity.can_be_deleted_by?(current_user)
        redirect_to :controller => 'sessions', :action => 'new' and return false
      end
      return @user
    end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
community_engine-2.3.2 app/controllers/activities_controller.rb
community_engine-2.3.1 app/controllers/activities_controller.rb
community_engine-2.3.0 app/controllers/activities_controller.rb
community_engine-2.1.0 app/controllers/activities_controller.rb
community_engine-2.0.0 app/controllers/activities_controller.rb
community_engine-2.0.0.beta3 app/controllers/activities_controller.rb
community_engine-2.0.0.beta2 app/controllers/activities_controller.rb
community_engine-2.0.0.beta1 app/controllers/activities_controller.rb