diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 0fc8be0..1b12131 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -4,7 +4,7 @@ class CategoriesController < ApplicationController def show if [Category::DOMAIN_ARTICLES, Category::DOMAIN_NEWS].include? @category.domain @articles = Article.with_comments.ordered.limited.nodrafts.category params[:id] - Category.find(params[:id]).read_by! cuser if cuser + Category.find(params[:id]).mark_as_read! for: cuser if cuser render partial: 'articles/article', collection: @articles.to_a end end diff --git a/app/controllers/custom_urls_controller.rb b/app/controllers/custom_urls_controller.rb index 1611999..277172e 100644 --- a/app/controllers/custom_urls_controller.rb +++ b/app/controllers/custom_urls_controller.rb @@ -25,7 +25,7 @@ class CustomUrlsController < ApplicationController raise ActiveRecord::RecordNotFound unless custom_url @article = custom_url.article raise AccessError unless @article.can_show? cuser - @article.read_by! cuser if cuser + @article.mark_as_read! for: cuser if cuser render 'articles/show' end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 0c2e6d9..6b232fe 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -17,7 +17,7 @@ class ForumsController < ApplicationController .order('state DESC, (SELECT created_at FROM posts p2 WHERE p2.topic_id = topics.id ORDER BY created_at DESC LIMIT 1) DESC') .paginate(page: params[:page], per_page: 30) - @forum.read_by! cuser if cuser + @forum.mark_as_read! for: cuser if cuser @nobody = true end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 4668f52..7efdb04 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -23,7 +23,7 @@ class IssuesController < ApplicationController def show raise AccessError unless @issue.can_show? cuser - @issue.read_by! cuser + @issue.mark_as_read! for: cuser end def new diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 7c248e5..9036de5 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -7,7 +7,7 @@ class MessagesController < ApplicationController def show raise AccessError unless @message.can_show? cuser - @message.read_by! cuser + @message.mark_as_read! for: cuser @messages = @message.thread end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index bfdf191..f154243 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -22,7 +22,7 @@ class MoviesController < ApplicationController end def show - @movie.read_by! cuser if cuser + @movie.mark_as_read! for: cuser if cuser @movie.record_view_count(request.remote_ip, cuser.nil?) redirect_to @movie.file.related if @movie.file and @movie.file.related end diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 33493e4..f4e5ee1 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -13,8 +13,8 @@ class TopicsController < ApplicationController return_here @topic.record_view_count(request.remote_ip, cuser.nil?) - @topic.read_by! cuser if cuser - @topic.forum.read_by! cuser if cuser + @topic.mark_as_read! for: cuser if cuser + @topic.forum.mark_as_read! for: cuser if cuser @newpost = Post.new @newpost.topic = @topic @newpost.user = cuser diff --git a/app/models/article.rb b/app/models/article.rb index 52ab126..314793f 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -69,7 +69,7 @@ class Article < ActiveRecord::Base after_destroy :remove_readings has_view_count - acts_as_readable + acts_as_reader acts_as_versioned non_versioned_columns << 'category_id' diff --git a/app/models/category.rb b/app/models/category.rb index ab8fbb1..2bc42d3 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -48,7 +48,7 @@ class Category < ActiveRecord::Base has_many :gathers has_many :servers - acts_as_readable + acts_as_reader def to_s name diff --git a/app/models/forum.rb b/app/models/forum.rb index 785dec8..72fd341 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -34,7 +34,7 @@ class Forum < ActiveRecord::Base after_create :update_position - acts_as_readable + acts_as_reader def to_s self.title @@ -65,17 +65,17 @@ class Forum < ActiveRecord::Base end def self.available_to cuser, level - user_has_access = - Forum .joins("JOIN forumers ON forumers.forum_id = forums.id - AND forumers.access = #{level}") - .joins("JOIN groups ON forumers.group_id = groups.id") - .joins("JOIN groupers ON groupers.group_id = groups.id - AND groupers.user_id = #{cuser.id}") + user_has_access = + Forum .joins("JOIN forumers ON forumers.forum_id = forums.id + AND forumers.access = #{level}") + .joins("JOIN groups ON forumers.group_id = groups.id") + .joins("JOIN groupers ON groupers.group_id = groups.id + AND groupers.user_id = #{cuser.id}") - is_admin = Grouper.where(user_id: cuser, group_id: Group::ADMINS) - Forum.where("EXISTS (#{is_admin.to_sql}) OR - id IN (SELECT q.id from (#{user_has_access.to_sql}) q ) OR - id IN (SELECT q.id from (#{Forum.public_forums.to_sql}) q )") + is_admin = Grouper.where(user_id: cuser, group_id: Group::ADMINS) + Forum.where("EXISTS (#{is_admin.to_sql}) OR + id IN (SELECT q.id from (#{user_has_access.to_sql}) q ) OR + id IN (SELECT q.id from (#{Forum.public_forums.to_sql}) q )") end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 891216b..a279781 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -49,7 +49,7 @@ class Issue < ActiveRecord::Base before_save :parse_text after_save :remove_readings - acts_as_readable + acts_as_reader def to_s title diff --git a/app/models/message.rb b/app/models/message.rb index 395f990..c288b10 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -37,7 +37,7 @@ class Message < ActiveRecord::Base before_save :parse_text after_create :send_notifications - acts_as_readable + acts_as_reader def to_s title diff --git a/app/models/movie.rb b/app/models/movie.rb index d834d0e..bce92e4 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -62,7 +62,7 @@ class Movie < ActiveRecord::Base mount_uploader :picture, MovieUploader has_view_count - acts_as_readable + acts_as_reader def to_s file.to_s diff --git a/app/models/topic.rb b/app/models/topic.rb index 84dc60a..ac2e1df 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -39,7 +39,7 @@ class Topic < ActiveRecord::Base after_create :make_post - acts_as_readable + acts_as_reader def self.recent_topics find_by_sql %q{