Modified: branches/event_logging/app/helpers/application_helper.rb (1877 => 1878)
--- branches/event_logging/app/helpers/application_helper.rb 2008-10-21 11:20:14 UTC (rev 1877)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-10-21 17:19:17 UTC (rev 1878)
@@ -1501,6 +1501,34 @@
end
end
+ when "PackContributableEntry", "PackRemoteEntry"
+ case action
+ when "create"
+ begin
+ # check if the pack is still there
+ pack = Pack.find(log_entry.referenced_id)
+ pack_link = link_to(contributable_name_from_instance(pack), pack_path(pack.id))
+
+ if loggable_type.to_s == "PackContributableEntry"
+ # ..and check if local entry (and the item it points to) can still be found
+ contributable_entry = PackContributableEntry.find(log_entry.activity_loggable_id)
+ object, object_path = evaluate_object_instance_and_path(contributable_entry.contributable_type, contributable_entry.contributable_id)
+ object_path += "?version=#{contributable_entry.contributable_version}" unless contributable_entry.contributable_version.nil?
+ object_visible_name = contributable_name_from_instance(object)
+
+ rtn << [timestamp, "#{culprit_link} added #{link_to object_visible_name, object_path} #{model_visible_name(object.class.to_s)} to #{pack_link} Pack."]
+ else
+ # ..and check if external link can still be found
+ # (title can't be blank for external items)
+ remote_entry = PackRemoteEntry.find(log_entry.activity_loggable_id)
+
+ rtn << [timestamp, "#{culprit_link} added external link to #{pack_link} Pack: #{link_to remote_entry.title, remote_entry.uri, :title => tooltip_title_attrib(h(remote_entry.uri))}."]
+ end
+ rescue ActiveRecord::RecordNotFound
+ # do nothing, but don't display the news entry for missing pack / item entry
+ end
+ end
+
when "Membership"
begin
# this membership record contains ID of the user who has performed the "accept" action;
@@ -1513,17 +1541,18 @@
network_id = log_entry.culprit_id
end
- # check that both user & network still exist
+ # check that both user & network (with it's admin) still exist
# (get the name and the title if they do; exit otherwise)
user = User.find(user_id)
network = Network.find(network_id)
+ network_admin = network.owner
# if no exception at this point, can generate the news item:
# (name() and title() will accept instance instead of ID of the object - to save an extra DB access)
case action
when "invite"
- rtn << [timestamp, "#{name(user)} was invited to join the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(network_admin)} invited #{name(user)} to join the #{title(network)} Group."]
when "request"
rtn << [timestamp, "#{name(user)} requested to join the #{title(network)} Group."]
when "accept"
@@ -1532,13 +1561,13 @@
if log_entry.culprit_type == "User"
rtn << [timestamp, "#{name(user)} rejected invitation to join the #{title(network)} Group."]
else
- rtn << [timestamp, "#{name(user)}'s request to join the #{title(network)} Group was rejected."]
+ rtn << [timestamp, "#{name(network_admin)} rejected #{name(user)}'s request to join the #{title(network)} Group."]
end
when "destroy"
if log_entry.culprit_type == "User"
rtn << [timestamp, "#{name(user)} has left the #{title(network)} Group."]
else
- rtn << [timestamp, "#{name(user)} was removed from the list of members of the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(network_admin)} removed #{name(user)} from the list of members of the #{title(network)} Group."]
end
end
rescue ActiveRecord::RecordNotFound
@@ -1608,15 +1637,17 @@
end
if write_news_entry
- shared_with, shared_with_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
- case shared_with.class.to_s
+ shared_with_entity, shared_with_entity_path = evaluate_object_instance_and_path(log_entry.referenced_type, log_entry.referenced_id)
+ case shared_with_entity.class.to_s
when "User"
- shared_with_name_or_title = shared_with.name
+ shared_with_name_or_title = shared_with_entity.name
when "Network"
- shared_with_name_or_title = shared_with.title
+ shared_with_name_or_title = shared_with_entity.title
else
- shared_with_name_or_title = shared_with.to_s
+ shared_with_name_or_title = shared_with_entity.to_s
end
+ shared_with = link_to(shared_with_name_or_title, shared_with_entity_path)
+ shared_with += (" " + model_visible_name(shared_with_entity.class.to_s)) unless (shared_with_entity.class.to_s == "User")
shared_what_links_arr = []
items_shared_with_this_permission = Contribution.find_by_sql("SELECT contributable_type, contributable_id FROM Contributions WHERE policy_id = #{permission.policy_id}.")
@@ -1626,10 +1657,10 @@
items_shared_with_this_permission.each do |item|
object, path = evaluate_object_instance_and_path(item.contributable_type, item.contributable_id)
object_visible_name = contributable_name_from_instance(object)
- shared_what_links_arr << link_to(object_visible_name, path)
+ shared_what_links_arr << (link_to(object_visible_name, path) + " " + model_visible_name(object.class.to_s))
end
- rtn << [timestamp, "#{culprit_link} shared #{access_rights} #{shared_what_links_arr.join(", ")} with #{link_to shared_with_name_or_title, shared_with_path} #{model_visible_name(shared_with.class.to_s)}."]
+ rtn << [timestamp, "#{culprit_link} shared #{access_rights} #{shared_what_links_arr.join(", ")} with #{shared_with}."]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing permission / network or user to which it refers to
@@ -1765,6 +1796,23 @@
end
end
+ when "Citation"
+ if action == "create"
+ begin
+ # check to see if the citation and the cited item are still present
+ citation = Citation.find(log_entry.activity_loggable_id)
+
+ # HACK: only workflow can be cited & code is not generic
+ object = Workflow.find(log_entry.referenced_id)
+ object_path = workflow_path(log_entry.referenced_id)
+ object_visible_name = contributable_name_from_instance(object)
+
+ rtn << [timestamp, "#{culprit_link} added #{link_to "citation", workflow_citation_path(object.id, citation.id)} for #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s)}."]
+ rescue ActiveRecord::RecordNotFound
+ # do nothing, but don't display the news entry for missing citation / cited item
+ end
+ end
+
when "PictureSelection"
# TODO: how to check that picture selection is still valid?
rtn << [timestamp, "#{culprit_link} selected a new profile picture #{link_to image_tag(avatar_url(log_entry.referenced_id, 50)), user_path(log_entry.culprit_id)}."]