2013-03-07 04:17:07 +08:00
|
|
|
# Helps us determine whether a topic should be displayed as pinned or not,
|
|
|
|
# taking into account anonymous users and users who have dismissed it
|
|
|
|
class PinnedCheck
|
|
|
|
|
2014-04-10 08:56:56 +08:00
|
|
|
def self.unpinned?(topic,topic_user=nil)
|
|
|
|
topic.pinned_at &&
|
|
|
|
topic_user &&
|
|
|
|
topic_user.cleared_pinned_at &&
|
|
|
|
topic_user.cleared_pinned_at > topic.pinned_at
|
2013-03-07 04:17:07 +08:00
|
|
|
end
|
|
|
|
|
2014-04-10 08:56:56 +08:00
|
|
|
def self.pinned?(topic, topic_user=nil)
|
|
|
|
!!topic.pinned_at &&
|
|
|
|
!unpinned?(topic,topic_user)
|
2013-03-07 04:17:07 +08:00
|
|
|
end
|
|
|
|
|
2014-04-10 08:56:56 +08:00
|
|
|
end
|