implemented last-forum-read-at
This commit is contained in:
@@ -2,6 +2,7 @@ class ForumTopicsController < ApplicationController
|
||||
respond_to :html, :xml, :json
|
||||
before_filter :member_only, :except => [:index, :show]
|
||||
before_filter :normalize_search, :only => :index
|
||||
before_filter :update_last_forum_read_at, :only => [:index, :show]
|
||||
rescue_from User::PrivilegeError, :with => "static/access_denied"
|
||||
|
||||
def new
|
||||
@@ -56,6 +57,12 @@ private
|
||||
forum_topic.is_sticky = params[:forum_topic][:is_sticky]
|
||||
end
|
||||
|
||||
def update_last_forum_read_at
|
||||
return if CurrentUser.last_forum_read_at.present? && CurrentUser.last_forum_read_at > 1.day.ago
|
||||
|
||||
CurrentUser.update_column(:last_forum_read_at, Time.now)
|
||||
end
|
||||
|
||||
def normalize_search
|
||||
if params[:title_matches]
|
||||
params[:search] ||= {}
|
||||
|
||||
@@ -6,6 +6,7 @@ class SessionsController < ApplicationController
|
||||
def create
|
||||
if User.authenticate(params[:name], params[:password])
|
||||
@user = User.find_by_name(params[:name])
|
||||
@user.update_column(:last_logged_in_at, Time.now)
|
||||
session[:user_id] = @user.id
|
||||
redirect_to(params[:url] || session[:previous_uri] || posts_path, :notice => "You are now logged in.")
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user