Bug fix. Previously, all categories were visible from all webs. Now category lists are restricted to the current web.
This commit is contained in:
parent
f208d50032
commit
b65a5b8e30
2 changed files with 7 additions and 3 deletions
|
@ -356,7 +356,7 @@ class WikiController < ApplicationController
|
|||
end
|
||||
|
||||
def parse_category
|
||||
@categories = WikiReference.list_categories.sort
|
||||
@categories = WikiReference.list_categories(@web).sort
|
||||
@category = @params['category']
|
||||
if @category
|
||||
@set_name = "category '#{@category}'"
|
||||
|
|
|
@ -46,8 +46,12 @@ class WikiReference < ActiveRecord::Base
|
|||
names = connection.select_all(sanitize_sql([query, category])).map { |row| row['name'] }
|
||||
end
|
||||
|
||||
def self.list_categories
|
||||
query = "SELECT DISTINCT referenced_name FROM wiki_references WHERE link_type = '#{CATEGORY}'"
|
||||
def self.list_categories(web)
|
||||
query = "SELECT DISTINCT wiki_references.referenced_name " +
|
||||
"FROM wiki_references LEFT OUTER JOIN pages " +
|
||||
"ON wiki_references.page_id = pages.id " +
|
||||
"WHERE wiki_references.link_type = '#{CATEGORY}' " +
|
||||
"AND pages.web_id = #{web.id}"
|
||||
connection.select_all(query).map { |row| row['referenced_name'] }
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue