61 lines
1.8 KiB
Ruby
61 lines
1.8 KiB
Ruby
# encoding: utf-8
|
|
#
|
|
# Redmine - project management software
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
|
#
|
|
# This program is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU General Public License
|
|
# as published by the Free Software Foundation; either version 2
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
module WelcomeHelper
|
|
include ProjectsHelper
|
|
|
|
def newbieTopiclist
|
|
find_all_topic_by_board_id
|
|
end
|
|
|
|
def newbieTopicStickyList
|
|
find_all_topic_by_board_id 1
|
|
end
|
|
|
|
def find_project_by_topic topic
|
|
board = find_board_by_topic(topic)
|
|
find_project_by_board board
|
|
end
|
|
|
|
def find_all_hot_project
|
|
sort_project_by_hot
|
|
end
|
|
|
|
private
|
|
|
|
def search_project
|
|
Project.find_by_identifier "newbie_faq"
|
|
end
|
|
|
|
def find_all_topic_by_board_id sticky = 0, limit = 30
|
|
project = search_project
|
|
return [] if(project.nil? or project.boards.nil?)
|
|
board_id = project.boards.first.id
|
|
logger.debug "[WelcomeHelper] ===> find_all_topic_by_board_id=> project.id:#{project.id}, board_id:#{board_id}, sticky:#{sticky}"
|
|
Message.where("board_id = :board_id and sticky=:sticky", :board_id => board_id, :sticky => sticky ).limit(limit)
|
|
end
|
|
|
|
def find_board_by_topic topic
|
|
Board.find_by_id(topic.board_id)
|
|
end
|
|
def find_project_by_board board
|
|
Project.find_by_id(board.project_id)
|
|
end
|
|
end
|