Modified: branches/event_logging/app/helpers/application_helper.rb (1907 => 1908)
--- branches/event_logging/app/helpers/application_helper.rb 2008-10-30 15:18:15 UTC (rev 1907)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-10-30 15:55:30 UTC (rev 1908)
@@ -1460,6 +1460,9 @@
# not needed, because all events for user's networks will be added - both
# where they are member and admin of
# -----------------------------------------------------------------------
+ # NB! this db query is not the same as the one done when ALL network news are
+ # generated - therefore, was not possible to make recursive call on each
+ # of the networks in turn
contributor.networks_owned.each do |network|
network_events = ActivityLog.find(:all, :conditions => ["created_at > ? AND created_at < ? AND (culprit_type = ? AND culprit_id = ?)", after, before, network.class.to_s, network.id])
events_as_admin.concat(network_events)
@@ -1491,6 +1494,17 @@
end
return events if return_raw_events
+
+ # NB! only if this is the "home" page, not the profile page
+ unless contributor_news_only
+ # all recursive calls are finished by this point - now can add site announcements to the event list;
+ # (this user with no friends who are site admins AND who is not a member of any groups, where site admins are
+ # members too, will still get news entries about site announcements - which is very important
+ site_announcements = ActivityLog.find(:all, :conditions => ["created_at > ? AND created_at < ? AND activity_loggable_type = ?", after, before, "Announcement"])
+ events.concat(site_announcements)
+ end
+
+
# remove any duplicates (which may arise when getting same event log entry from friends' related events),
# then sort by date descending
events = events.uniq.sort { |a, b|
@@ -1530,14 +1544,17 @@
# (further checks for other related objects are carried out in the respective sections for every ActivityLoggable type)
unless ["Membership", "User"].include? loggable_type
# for all "activity_loggables" apart from those above, the culprit is the "user";
- # if culprit is not found by ActiveRecord - exception will be thrown
- # -> news item not to be shown then
+ # if culprit is not found by ActiveRecord - exception will not be thrown with current search syntax
+ # -> news item not to be shown then; return NIL
begin
culprit = User.find(:first, :select => "id, name", :conditions => ["id = ?", log_entry.culprit_id])
+ return nil if culprit.nil?
+
culprit_link = name(culprit)
my_event = (log_entry.culprit_id == current_viewer.id)
rescue ActiveRecord::RecordNotFound
# culprit wasn't found - skip this news entry
+ # (left as additional security measure, but most likely will never be called)
return nil
end
end