Diff
Modified: trunk/app/controllers/application.rb (2586 => 2587)
--- trunk/app/controllers/application.rb 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/app/controllers/application.rb 2011-04-14 15:39:11 UTC (rev 2587)
@@ -455,8 +455,8 @@
{
:title => 'category',
:query_option => 'CATEGORY',
- :id_column => 'contributions.contributable_type',
- :label_column => 'contributions.contributable_type',
+ :id_column => :auth_type,
+ :label_column => :auth_type,
:visible_name => true
},
@@ -693,27 +693,27 @@
def create_search_results_table(search_query, models)
- solr_results = User.multi_solr_search(search_query,
+ solr_results = models.first.multi_solr_search(search_query,
:models => models,
:results_format => :ids,
:limit => Conf.max_search_size)
conn = ActiveRecord::Base.connection
- conn.execute("CREATE TEMPORARY TABLE search_results (result_type VARCHAR(255), result_id INT)")
+ conn.execute("CREATE TEMPORARY TABLE search_results (id INT AUTO_INCREMENT UNIQUE KEY, result_type VARCHAR(255), result_id INT)")
# This next part converts the search results to SQL values
#
# from: { "id" => "Workflow:4" }, { "id" => "Pack:6" }, ...
- # to: "('Workflow', '4'), ('Pack', '6'), ..."
+ # to: "(NULL, 'Workflow', '4'), (NULL, 'Pack', '6'), ..."
if solr_results.results.length > 0
insert_part = solr_results.results.map do |result|
- "(" + result["id"].split(":").map do |bit|
+ "(NULL, " + result["id"].split(":").map do |bit|
"'#{bit}'"
end.join(", ") + ")"
end.join(", ")
-
+
conn.execute("INSERT INTO search_results VALUES #{insert_part}")
end
end
@@ -739,6 +739,18 @@
"HAVING " + having_bits.join(" OR ")
end
+ def column(column, opts)
+ if column == :auth_type
+ if opts[:auth_type]
+ opts[:auth_type]
+ else
+ "contributions.contributable_type"
+ end
+ else
+ column
+ end
+ end
+
def calculate_filter(params, filter, user, opts = {})
# apply all the joins and conditions except for the current filter
@@ -749,97 +761,113 @@
pivot_options[:filters].each do |other_filter|
if filter_list = find_filter(opts[:filters], other_filter[:query_option])
unless opts[:inhibit_other_conditions]
- conditions << comparison(other_filter[:id_column], filter_list[:expr][:terms]) unless other_filter == filter
+ conditions << comparison(column(other_filter[:id_column], opts), filter_list[:expr][:terms]) unless other_filter == filter
end
joins += other_filter[:joins] if other_filter[:joins]
end
end
+ filter_id_column = column(filter[:id_column], opts)
+ filter_label_column = column(filter[:label_column], opts)
+
joins += filter[:joins] if filter[:joins]
- conditions << "#{filter[:id_column]} IS NOT NULL" if filter[:not_null]
+ conditions << "#{filter_id_column} IS NOT NULL" if filter[:not_null]
unless opts[:inhibit_filter_query]
if params[:filter_query]
- conditions << "(#{filter[:label_column]} LIKE '%#{escape_sql(params[:filter_query])}%')"
+ conditions << "(#{filter_label_column} LIKE '%#{escape_sql(params[:filter_query])}%')"
end
end
- joins.push(:search) if params[:query]
+ joins.push(:search) if params[:query] && !opts[:arbitrary_models]
current = find_filter(opts[:filters], filter[:query_option]) ? find_filter(opts[:filters], filter[:query_option])[:expr][:terms] : []
if opts[:ids].nil?
limit = 10
else
- conditions << "(#{filter[:id_column]} IN ('#{opts[:ids].map do |id| escape_sql(id) end.join("','")}'))"
+ conditions << "(#{filter_id_column} IN ('#{opts[:ids].map do |id| escape_sql(id) end.join("','")}'))"
limit = nil
end
conditions = conditions.length.zero? ? nil : conditions.join(" AND ")
- objects = Authorization.authorised_index(Contribution,
+ if opts[:auth_type] && opts[:auth_id]
+ count_expr = "COUNT(DISTINCT #{opts[:auth_type]}, #{opts[:auth_id]})"
+ else
+ count_expr = "COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id)"
+ end
+
+ objects = Authorization.authorised_index(params[:query] && opts[:arbitrary_models] ? SearchResult : Contribution,
:all,
:include_permissions => true,
- :select => "#{filter[:id_column]} AS filter_id, #{filter[:label_column]} AS filter_label, COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) AS filter_count",
+ :select => "#{filter_id_column} AS filter_id, #{filter_label_column} AS filter_label, #{count_expr} AS filter_count",
+ :arbitrary_models => opts[:arbitrary_models],
+ :auth_type => opts[:auth_type],
+ :auth_id => opts[:auth_id],
:joins => joins.length.zero? ? nil : joins.uniq.map do |j| pivot_options[:joins][j] end.join(" "),
:conditions => conditions,
- :group => "#{filter[:id_column]} #{calculate_having_clause(filter, opts)}",
+ :group => "#{filter_id_column} #{calculate_having_clause(filter, opts)}",
:limit => limit,
- :order => "COUNT(DISTINCT contributions.contributable_type, contributions.contributable_id) DESC, #{filter[:label_column]}",
- :authorised_user => user).map do |object|
+ :order => "#{count_expr} DESC, #{filter_label_column}",
+ :authorised_user => user)
+
+ objects = objects.select do |x| !x[:filter_id].nil? end
- value = object.filter_id.to_s
- selected = current.include?(value)
+ objects = objects.map do |object|
- label_expr = deep_clone(opts[:filters])
- label_expr -= [find_filter(label_expr, filter[:query_option])] if find_filter(label_expr, filter[:query_option])
+ value = object.filter_id.to_s
+ selected = current.include?(value)
- unless selected && current.length == 1
- label_expr << { :name => filter[:query_option], :expr => { :terms => [value] } }
- end
+ label_expr = deep_clone(opts[:filters])
+ label_expr -= [find_filter(label_expr, filter[:query_option])] if find_filter(label_expr, filter[:query_option])
- checkbox_expr = deep_clone(opts[:filters])
+ unless selected && current.length == 1
+ label_expr << { :name => filter[:query_option], :expr => { :terms => [value] } }
+ end
- if expr_filter = find_filter(checkbox_expr, filter[:query_option])
+ checkbox_expr = deep_clone(opts[:filters])
- if selected
- expr_filter[:expr][:terms] -= [value]
- else
- expr_filter[:expr][:terms] += [value]
- end
+ if expr_filter = find_filter(checkbox_expr, filter[:query_option])
- checkbox_expr -= [expr_filter] if expr_filter[:expr][:terms].empty?
+ if selected
+ expr_filter[:expr][:terms] -= [value]
+ else
+ expr_filter[:expr][:terms] += [value]
+ end
- else
- checkbox_expr << { :name => filter[:query_option], :expr => { :terms => [value] } }
- end
+ checkbox_expr -= [expr_filter] if expr_filter[:expr][:terms].empty?
- label_uri = build_url(params, opts, label_expr, [:filter, :order], "page" => nil)
+ else
+ checkbox_expr << { :name => filter[:query_option], :expr => { :terms => [value] } }
+ end
- checkbox_uri = build_url(params, opts, checkbox_expr, [:filter, :order], "page" => nil)
+ label_uri = build_url(params, opts, label_expr, [:filter, :order], "page" => nil)
- label = object.filter_label.clone
- label = visible_name(label) if filter[:visible_name]
- label = label.capitalize if filter[:capitalize]
+ checkbox_uri = build_url(params, opts, checkbox_expr, [:filter, :order], "page" => nil)
- plain_label = object.filter_label
+ label = object.filter_label.clone
+ label = visible_name(label) if filter[:visible_name]
+ label = label.capitalize if filter[:capitalize]
- if params[:filter_query]
- label.sub!(Regexp.new("(#{params[:filter_query]})", Regexp::IGNORECASE), '<b>\1</b>')
- end
+ plain_label = object.filter_label
- {
- :object => object,
- :value => value,
- :label => label,
- :plain_label => plain_label,
- :count => object.filter_count,
- :checkbox_uri => checkbox_uri,
- :label_uri => label_uri,
- :selected => selected
- }
- end
+ if params[:filter_query]
+ label.sub!(Regexp.new("(#{params[:filter_query]})", Regexp::IGNORECASE), '<b>\1</b>')
+ end
+ {
+ :object => object,
+ :value => value,
+ :label => label,
+ :plain_label => plain_label,
+ :count => object.filter_count,
+ :checkbox_uri => checkbox_uri,
+ :label_uri => label_uri,
+ :selected => selected
+ }
+ end
+
[current, objects]
end
@@ -890,6 +918,9 @@
end
end
+ joins = []
+ conditions = []
+
# parse the filter _expression_ if provided. convert filter _expression_ to
# the old format. this will need to be replaced eventually
@@ -911,14 +942,31 @@
end
end
+ # perform search if requested
+
+ group_by = "contributions.contributable_type, contributions.contributable_id"
+
+ if params["query"]
+ drop_search_results_table
+ create_search_results_table(params["query"], [Workflow, Blob, Pack, User, Network])
+ joins.push(:search) unless opts[:arbitrary_models]
+ end
+
+ if opts[:arbitrary_models] && params[:query]
+ klass = SearchResult
+ contribution_records = false
+ auth_type = "search_results.result_type"
+ auth_id = "search_results.result_id"
+ group_by = "search_results.result_type, search_results.result_id"
+ else
+ contribution_records = true
+ end
+
# determine joins, conditions and order for the main results
- joins = []
- conditions = []
-
pivot_options[:filters].each do |filter|
if filter_list = find_filter(opts[:filters], filter[:query_option])
- conditions << comparison(filter[:id_column], filter_list[:expr][:terms])
+ conditions << comparison(column(filter[:id_column], opts.merge( { :auth_type => auth_type, :auth_id => auth_id } )), filter_list[:expr][:terms])
joins += filter[:joins] if filter[:joins]
end
end
@@ -931,14 +979,6 @@
joins += order_options[:joins] if order_options[:joins]
- # perform search if requested
-
- if params["query"]
- drop_search_results_table
- create_search_results_table(params["query"], [Workflow, Blob, Pack])
- joins.push(:search)
- end
-
having_bits = []
# pivot_options[:filters].each do |filter|
@@ -959,11 +999,14 @@
:all,
:authorised_user => user,
:include_permissions => true,
- :contribution_records => true,
+ :contribution_records => contribution_records,
+ :arbitrary_models => opts[:arbitrary_models],
+ :auth_type => auth_type,
+ :auth_id => auth_id,
:page => { :size => params["num"] ? params["num"].to_i : nil, :current => params["page"] },
:joins => joins.length.zero? ? nil : joins.uniq.map do |j| pivot_options[:joins][j] end.join(" "),
:conditions => conditions.length.zero? ? nil : conditions.join(" AND "),
- :group => "contributions.contributable_type, contributions.contributable_id #{having_clause}",
+ :group => "#{group_by} #{having_clause}",
:order => order_options[:order])
# produce a query hash to match the current filters
@@ -979,13 +1022,16 @@
# produce the filter list
- filters, cancel_filter_query_url = calculate_filters(params, opts, user)
+ opts_for_filter_query = opts.merge( { :auth_type => auth_type,
+ :auth_id => auth_id, :group_by => group_by } )
+ filters, cancel_filter_query_url = calculate_filters(params, opts_for_filter_query, user)
+
# produce the summary. If a filter query is specified, then we need to
# recalculate the filters without the query to get all of them.
if params[:filter_query]
- filters2 = calculate_filters(params, opts.merge( { :inhibit_filter_query => true } ), user)[0]
+ filters2 = calculate_filters(params, opts_for_filter_query.merge( { :inhibit_filter_query => true } ), user)[0]
else
filters2 = filters
end
Modified: trunk/app/controllers/content_controller.rb (2586 => 2587)
--- trunk/app/controllers/content_controller.rb 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/app/controllers/content_controller.rb 2011-04-14 15:39:11 UTC (rev 2587)
@@ -21,7 +21,7 @@
end
@pivot = contributions_list(Contribution, params, current_user,
- :filters => expr)
+ :filters => expr, :arbitrary_models => true)
# index.rhtml
end
Modified: trunk/app/controllers/search_controller.rb (2586 => 2587)
--- trunk/app/controllers/search_controller.rb 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/app/controllers/search_controller.rb 2011-04-14 15:39:11 UTC (rev 2587)
@@ -4,6 +4,9 @@
# See license.txt for details.
class SearchController < ApplicationController
+
+ include ApplicationHelper
+
def show
if params[:query].nil? or params[:query] == ''
@@ -14,6 +17,8 @@
@type = params[:type].to_s.downcase
+ @type = "all" if @type.nil? or @type == ""
+
if !Conf.search_categories.include?(@type)
error(@type)
return false
@@ -168,63 +173,22 @@
end
def search_all
- @query = params[:query] || ''
- @query.strip!
- @results = []
+ @query = params[:query]
- if Conf.solr_enable && address@hidden
+ @pivot_options = pivot_options
- categories = (Conf.search_categories - ['all']).map do |category|
- if Conf.model_aliases.key?(category.camelize.singularize)
- category = Conf.model_aliases[category.camelize.singularize].pluralize.underscore
- end
-
- category
- end
-
- models = categories.map do |category| eval(category.singularize.camelize) end
-
- @total_count = 0
-
- @infos = []
-
- models.each do |model|
-
- begin
- model_results = model.find_by_solr(@query.downcase, :limit => 10)
-
- results = model_results.results
- count = model_results.total
- rescue
- flash.now[:error] = "There was a problem with your search query."
-
- results = []
- count = 0
- end
-
- search_type = model.name.downcase.pluralize
-
- Conf.model_aliases.each do |k,v|
- search_type = k.downcase.pluralize if model.name == v
- end
-
- if (results.length > 0)
- @infos.push({
- :search_type => search_type,
- :model => model,
- :results => results,
- :total_count => count
- })
- end
-
- @total_count += count
- end
+ begin
+ expr = parse_filter_expression(params["filter"]) if params["filter"]
+ rescue Exception => ex
+ puts "ex = #{ex.inspect}"
+ flash.now[:error] = "Problem with query _expression_: #{ex}"
+ expr = nil
end
- respond_to do |format|
- format.html # search.rhtml
- end
+ @pivot = contributions_list(Contribution, params, current_user,
+ :filters => expr, :arbitrary_models => true)
+
end
def search_model
Added: trunk/app/models/search_result.rb (0 => 2587)
--- trunk/app/models/search_result.rb (rev 0)
+++ trunk/app/models/search_result.rb 2011-04-14 15:39:11 UTC (rev 2587)
@@ -0,0 +1,9 @@
+# myExperiment: app/models/search_result.rb
+#
+# Copyright (c) 2011 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+class SearchResult < ActiveRecord::Base
+ belongs_to(:result, :polymorphic => true)
+end
+
Modified: trunk/app/views/content/_index.rhtml (2586 => 2587)
--- trunk/app/views/content/_index.rhtml 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/app/views/content/_index.rhtml 2011-04-14 15:39:11 UTC (rev 2587)
@@ -98,7 +98,10 @@
</div>
<% else %>
<div class="results">
- <%= render :partial => "contributions/list", :locals => { :collection => @pivot[:results], :table => true } %>
+ <% @pivot[:results].each do |ob| %>
+ <% thing = ob.class == SearchResult ? ob.result : ob.contributable -%>
+ <%= render :partial => "#{thing.class.name.pluralize.downcase}/table", :locals => { :collection => [thing] } -%>
+ <% end %>
</div>
<% end %>
<div>
Modified: trunk/app/views/search/show.rhtml (2586 => 2587)
--- trunk/app/views/search/show.rhtml 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/app/views/search/show.rhtml 2011-04-14 15:39:11 UTC (rev 2587)
@@ -1,41 +1,16 @@
<% t "Results" -%>
-<%= render :partial => 'extra_search_help' %>
-
<h1>Search results for "<%= h @query -%>"</h1>
<% if @total_count == 0 %>
<p class="none_text">No search results.</p>
+ <%= render :partial => 'extra_search_help' %>
+
<% else %>
- <%= view_privileges_notice %>
- <br/>
+ <%= render :partial => "content/index" -%>
- <div id="tabsContainer" class="tabsContainer"></div>
-
- <% @infos.each do |info| %>
-
- <% name = visible_name(info[:model]).pluralize
- count = info[:results].length
- total = info[:total_count] -%>
-
- <div class="tabContainer">
- <div class="tabTitle"><%= name %> (<%= count -%><% if count < total %> of <%= total -%><% end %>)</div>
- <div class="tabContent">
-
- <% if count < total %>
- <p class="box_standout" style="font-size: 108%; margin-bottom: 1em; margin-top: 0.6em;"><b>
- There are more results than shown here. <a href="" search_path + "?type=#{info[:search_type]}&query=" + params[:query] -%>">See all <%= name %> results</a> for this query.
- </b></p>
- <% end %>
-
- <%= render :partial => "#{info[:model].to_s.underscore.pluralize}/table", :locals => { :collection => info[:results], :query => @query } %>
- </div>
- </div>
- <% end %>
-
<% end %>
-<br />
Added: trunk/app/views/users/_listing.rhtml (0 => 2587)
--- trunk/app/views/users/_listing.rhtml (rev 0)
+++ trunk/app/views/users/_listing.rhtml 2011-04-14 15:39:11 UTC (rev 2587)
@@ -0,0 +1,86 @@
+<% cache(:controller => 'users_cache', :action ="" 'listing', :id => user.id) do -%>
+ <td style="width: 100px"><div style="text-align: center; font-weight: bold">Member</div><br /><br /><center><%= contributor(user.id, 'User', true, 60) %></center></td>
+ <td class="mid" style="text-align: left;">
+
+ <p style="margin-top:0; padding-top:0; font-weight:bold; font-size: 108%;">
+ <%= icon "user", nil, nil, nil, '' %>
+ <%= name user %>
+ <%= friend_badge(user) %>
+ <%= admin_badge(user) %>
+ </p>
+
+ <% unless user.created_at.blank? %>
+ <p style="font-size: 85%;">
+ <b>Joined:</b>
+ <%= datetime user.created_at %>
+ </p>
+ <% end %>
+
+ <div class="desc" style="font-size: 85%;">
+ <% unless user.profile.body.blank? %>
+ <% desc = truncate(strip_html(user.profile.body), 180) %>
+ <%= query ? highlight_all(desc, query) : desc %>
+ <% else -%>
+ <span class="none_text">No description</span>
+ <% end %>
+ </div>
+
+ <% unless user.last_seen_at.blank? %>
+ <p style="font-size: 85%;">
+ <b>Last active:</b>
+ <%= datetime user.last_seen_at %>
+ </p>
+ <% end %>
+
+ <% if user.profile %>
+
+ <p style="font-size: 85%;">
+ <% unless user.profile.website.blank? %>
+ <b>Website:</b>
+ <%= link_to h(user.profile.website), h(user.profile.website), :popup => true %>
+ |
+ <% end %>
+
+ <% unless user.profile.email.blank? %>
+ <b>Email (public):</b>
+ <%= mail_to user.profile.email, nil, { :encode => "hex", :replace_at => " [at] " } %>
+ <% end %>
+ </p>
+
+ <p style="font-size: 85%;">
+ <% unless user.profile.field_or_industry.blank? %>
+ <b>Field/Industry:</b>
+ <%= h user.profile.field_or_industry %>
+ |
+ <% end %>
+
+ <% unless user.profile.occupation_or_roles.blank? %>
+ <b>Occupation/Role(s):</b>
+ <%= h user.profile.occupation_or_roles %>
+ <% end %>
+ </p>
+
+ <% end %>
+ </td>
+<% end %>
+
+<td class="actions" style="width: 90px;">
+ <%= icon "show", user_path(user.id), nil, nil, "View" %>
+ <% if mine? user %>
+ <%= icon "edit", edit_user_path(user), nil, nil, "Edit" %>
+ <% else %>
+ <!-- check if the profile that we are viewing now is a friend of current user -> stored for better performance -->
+ <% this_user_is_friend_of_current_user = (current_user != 0) && current_user.friend?(user.id) %>
+ <% unless !logged_in? || this_user_is_friend_of_current_user || current_user.friendship_pending?(user.id) %>
+ <%= icon "friendship", new_user_friendship_url(:user_id => user.id), nil, nil, "Request Friendship" %>
+ <% end %>
+
+ <%= icon "message", new_message_path(:user_id => user.id), nil, nil, "Message" %>
+
+ <% if logged_in? && this_user_is_friend_of_current_user %>
+ <% master_id, friendship_obj = current_user.friendship_from_self_id_and_friends_id(user.id) %>
+ <%= icon "friend_delete", user_friendship_path(master_id, friendship_obj) + "?return_to=" + currentusers_things_url('friends'), nil, {:confirm => "Are you sure you want to remove this user from your friend list?", :method => :delete}, "Cancel Friendship" %>
+ <% end %>
+ </td>
+<% end %>
+
Modified: trunk/app/views/users/_table.rhtml (2586 => 2587)
--- trunk/app/views/users/_table.rhtml 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/app/views/users/_table.rhtml 2011-04-14 15:39:11 UTC (rev 2587)
@@ -1,96 +1,15 @@
<% query ||= false -%>
<% unless collection.empty? %>
-
- <table class="alt_table">
- <% odd_row = false -%>
- <% for user in collection %>
- <% if user.activated? %>
- <tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
- <% cache(:controller => 'users_cache', :action ="" 'listing', :id => user.id) do -%>
- <td width="100px"><%= avatar user, 60 %></td>
- <td class="mid" style="text-align: left;">
- <p style="margin-top:0; padding-top:0; font-weight:bold; font-size: 108%;">
- <%= if user.profile then flag_icon(user.profile.location_country, user.profile.location) end %>
- <%= name user %>
- <%= friend_badge(user) %>
- <%= admin_badge(user) %>
- </p>
-
- <% unless user.created_at.blank? %>
- <p style="font-size: 85%;">
- <b>Joined:</b>
- <%= datetime user.created_at %>
- </p>
- <% end %>
-
- <div class="desc" style="font-size: 85%;">
- <% unless user.profile.body.blank? %>
- <% desc = truncate(strip_html(user.profile.body), 180) %>
- <%= query ? highlight_all(desc, query) : desc %>
- <% else -%>
- <span class="none_text">No description</span>
- <% end %>
- </div>
-
- <% unless user.last_seen_at.blank? %>
- <p style="font-size: 85%;">
- <b>Last active:</b>
- <%= datetime user.last_seen_at %>
- </p>
- <% end %>
-
- <% if user.profile %>
-
- <p style="font-size: 85%;">
- <% unless user.profile.website.blank? %>
- <b>Website:</b>
- <%= link_to h(user.profile.website), h(user.profile.website), :popup => true %>
- |
- <% end %>
-
- <% unless user.profile.email.blank? %>
- <b>Email (public):</b>
- <%= mail_to user.profile.email, nil, { :encode => "hex", :replace_at => " [at] " } %>
- <% end %>
- </p>
-
- <p style="font-size: 85%;">
- <% unless user.profile.field_or_industry.blank? %>
- <b>Field/Industry:</b>
- <%= h user.profile.field_or_industry %>
- |
- <% end %>
-
- <% unless user.profile.occupation_or_roles.blank? %>
- <b>Occupation/Role(s):</b>
- <%= h user.profile.occupation_or_roles %>
- <% end %>
- </p>
-
- <% end %>
- </td>
- <% end %>
- <td class="actions" style="width: 130px;">
- <%= icon "show", user_path(user.id), nil, nil, "View Profile" %>
- <% if mine? user %>
- <%= icon "edit", edit_user_path(user), nil, nil, "Edit" %>
- <% else %>
- <!-- check if the profile that we are viewing now is a friend of current user -> stored for better performance -->
- <% this_user_is_friend_of_current_user = (current_user != 0) && current_user.friend?(user.id) %>
- <% unless !logged_in? || this_user_is_friend_of_current_user || current_user.friendship_pending?(user.id) %>
- <%= icon "friendship", new_user_friendship_url(:user_id => user.id), nil, nil, "Request Friendship" %>
- <% end %>
- <%= icon "message", new_message_path(:user_id => user.id), nil, nil, "Send Message" %>
- <% if logged_in? && this_user_is_friend_of_current_user %>
- <% master_id, friendship_obj = current_user.friendship_from_self_id_and_friends_id(user.id) %>
- <%= icon "friend_delete", user_friendship_path(master_id, friendship_obj) + "?return_to=" + currentusers_things_url('friends'), nil, {:confirm => "Are you sure you want to remove this user from your friend list?", :method => :delete}, "Cancel Friendship" %>
- <% end %>
- <% end %>
- </td>
- </tr>
- <% end %>
- <% end %>
- </table>
-
+ <table class="alt_table">
+ <% odd_row = false -%>
+ <% for user in collection %>
+ <% if user.activated? %>
+ <tr class="<%= (odd_row = !odd_row) ? "odd_row" : "even_row" %>">
+ <%= render :partial => "users/listing", :locals => { :user => user, :query => query } %>
+ </tr>
+ <% end %>
+ <% end %>
+ </table>
<% end %>
+
Modified: trunk/config/default_settings.yml (2586 => 2587)
--- trunk/config/default_settings.yml 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/config/default_settings.yml 2011-04-14 15:39:11 UTC (rev 2587)
@@ -240,7 +240,7 @@
# max_search_size - The maximum number of items shown in each search result
# page.
-max_search_size: 100
+max_search_size: 5000
# email - These are the email addresses used for sending notifications and the
# email address to send feedback entered from the web site.
Modified: trunk/lib/authorization.rb (2586 => 2587)
--- trunk/lib/authorization.rb 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/lib/authorization.rb 2011-04-14 15:39:11 UTC (rev 2587)
@@ -781,7 +781,7 @@
def self.view_conditions(user_id = nil, friends = nil, networks = nil)
- return "(share_mode = 0 OR share_mode = 1 OR share_mode = 2)" if user_id.nil?
+ return "((contributions.id IS NULL) OR (share_mode = 0 OR share_mode = 1 OR share_mode = 2))" if user_id.nil?
policy_part =
"((contributions.contributor_type = 'User' AND contributions.contributor_id = #{user_id}) OR
@@ -789,12 +789,12 @@
((share_mode = 1 OR share_mode = 3 OR share_mode = 4 OR update_mode = 1 OR (update_mode = 0 AND (share_mode = 1 OR share_mode = 3))) AND
(contributions.contributor_type = 'User' AND contributions.contributor_id IN #{friends})))"
- "(#{policy_part} OR #{permission_part(['view', 'download', 'edit'], user_id, networks)})"
+ "((contributions.id IS NULL) OR (#{policy_part} OR #{permission_part(['view', 'download', 'edit'], user_id, networks)}))"
end
def self.download_conditions(user_id = nil, friends = nil, networks = nil)
- return "(share_mode = 0)" if user_id.nil?
+ return "((contributions.id IS NULL) OR (share_mode = 0))" if user_id.nil?
policy_part =
"((contributions.contributor_type = 'User' AND contributions.contributor_id = #{user_id}) OR
@@ -802,12 +802,12 @@
((share_mode = 1 OR share_mode = 3 OR update_mode = 1 OR (update_mode = 0 AND (share_mode = 1 OR share_mode = 3))) AND
(contributions.contributor_type = 'User' AND contributions.contributor_id IN #{friends})))"
- "(#{policy_part} OR #{permission_part(['download', 'edit'], user_id, networks)})"
+ "((contributions.id IS NULL) OR (#{policy_part} OR #{permission_part(['download', 'edit'], user_id, networks)}))"
end
def self.edit_conditions(user_id = nil, friends = nil, networks = nil)
- return "(share_mode = 0 AND update_mode = 0)" if user_id.nil?
+ return "((contributions.id IS NULL) OR (share_mode = 0 AND update_mode = 0))" if user_id.nil?
policy_part =
"((contributions.contributor_type = 'User' AND contributions.contributor_id = #{user_id}) OR
@@ -815,7 +815,7 @@
((update_mode = 1 OR (update_mode = 0 AND (share_mode = 1 OR share_mode = 3))) AND
(contributions.contributor_type = 'User' AND contributions.contributor_id IN #{friends})))"
- "(#{policy_part} OR #{permission_part(['edit'], user_id, networks)})"
+ "((contributions.id IS NULL) OR (#{policy_part} OR #{permission_part(['edit'], user_id, networks)}))"
end
def self.permission_part(permissions, user_id, networks)
@@ -855,7 +855,7 @@
auth_type = opts.delete(:auth_type) || "'#{model.name}'"
conditions.push(view_conditions(user_id, friends, networks))
- conditions.push("contributions.contributable_type = #{auth_type}") if model != Contribution
+ conditions.push("contributions.contributable_type = #{auth_type}") if !opts.delete(:arbitrary_models) && model != Contribution
# result model
Modified: trunk/public/stylesheets/styles.css (2586 => 2587)
--- trunk/public/stylesheets/styles.css 2011-04-13 16:31:26 UTC (rev 2586)
+++ trunk/public/stylesheets/styles.css 2011-04-14 15:39:11 UTC (rev 2587)
@@ -855,7 +855,8 @@
}
table.alt_table .mid {
- text-align: left :
+ text-align: left;
+ width: 390px;
}
table.alt_table tr td.actions { /*width: 135px;*/