Revision 1297:0a574315af3e app/controllers
| app/controllers/boards_controller.rb | ||
|---|---|---|
| 39 | 39 |
sort_init 'updated_on', 'desc' |
| 40 | 40 |
sort_update 'created_on' => "#{Message.table_name}.created_on",
|
| 41 | 41 |
'replies' => "#{Message.table_name}.replies_count",
|
| 42 |
'updated_on' => "#{Message.table_name}.updated_on"
|
|
| 42 |
'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)"
|
|
| 43 | 43 |
|
| 44 | 44 |
@topic_count = @board.topics.count |
| 45 | 45 |
@topic_pages = Paginator.new self, @topic_count, per_page_option, params['page'] |
| 46 |
@topics = @board.topics.reorder("#{Message.table_name}.sticky DESC").order(sort_clause).all(
|
|
| 47 |
:include => [:author, {:last_reply => :author}],
|
|
| 48 |
:limit => @topic_pages.items_per_page, |
|
| 49 |
:offset => @topic_pages.current.offset) |
|
| 46 |
@topics = @board.topics. |
|
| 47 |
reorder("#{Message.table_name}.sticky DESC").
|
|
| 48 |
includes(:last_reply). |
|
| 49 |
limit(@topic_pages.items_per_page). |
|
| 50 |
offset(@topic_pages.current.offset). |
|
| 51 |
order(sort_clause). |
|
| 52 |
preload(:author, {:last_reply => :author}).
|
|
| 53 |
all |
|
| 50 | 54 |
@message = Message.new(:board => @board) |
| 51 | 55 |
render :action => 'show', :layout => !request.xhr? |
| 52 | 56 |
} |
| app/controllers/messages_controller.rb | ||
|---|---|---|
| 123 | 123 |
|
| 124 | 124 |
private |
| 125 | 125 |
def find_message |
| 126 |
find_board |
|
| 126 |
return unless find_board
|
|
| 127 | 127 |
@message = @board.messages.find(params[:id], :include => :parent) |
| 128 | 128 |
@topic = @message.root |
| 129 | 129 |
rescue ActiveRecord::RecordNotFound |
| ... | ... | |
| 135 | 135 |
@project = @board.project |
| 136 | 136 |
rescue ActiveRecord::RecordNotFound |
| 137 | 137 |
render_404 |
| 138 |
nil |
|
| 138 | 139 |
end |
| 139 | 140 |
end |
| app/controllers/my_controller.rb | ||
|---|---|---|
| 182 | 182 |
# params[:block] : id of the block to add |
| 183 | 183 |
def add_block |
| 184 | 184 |
block = params[:block].to_s.underscore |
| 185 |
(render :nothing => true; return) unless block && (BLOCKS.keys.include? block) |
|
| 186 |
@user = User.current |
|
| 187 |
layout = @user.pref[:my_page_layout] || {}
|
|
| 188 |
# remove if already present in a group |
|
| 189 |
%w(top left right).each {|f| (layout[f] ||= []).delete block }
|
|
| 190 |
# add it on top |
|
| 191 |
layout['top'].unshift block |
|
| 192 |
@user.pref[:my_page_layout] = layout |
|
| 193 |
@user.pref.save |
|
| 185 |
if block.present? && BLOCKS.key?(block) |
|
| 186 |
@user = User.current |
|
| 187 |
layout = @user.pref[:my_page_layout] || {}
|
|
| 188 |
# remove if already present in a group |
|
| 189 |
%w(top left right).each {|f| (layout[f] ||= []).delete block }
|
|
| 190 |
# add it on top |
|
| 191 |
layout['top'].unshift block |
|
| 192 |
@user.pref[:my_page_layout] = layout |
|
| 193 |
@user.pref.save |
|
| 194 |
end |
|
| 194 | 195 |
redirect_to :action => 'page_layout' |
| 195 | 196 |
end |
| 196 | 197 |
|
Also available in: Unified diff