myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3503] branches/wf4ever/lib/authorization.rb: add


From: noreply
Subject: [myexperiment-hackers] [3503] branches/wf4ever/lib/authorization.rb: added function to work out which contributors can perform a given action on a given object
Date: Thu, 11 Apr 2013 23:28:06 +0000 (UTC)

Revision
3503
Author
dgc
Date
2013-04-11 23:28:06 +0000 (Thu, 11 Apr 2013)

Log Message

added function to work out which contributors can perform a given action on a given object

Modified Paths

Diff

Modified: branches/wf4ever/lib/authorization.rb (3502 => 3503)


--- branches/wf4ever/lib/authorization.rb	2013-04-11 16:07:25 UTC (rev 3502)
+++ branches/wf4ever/lib/authorization.rb	2013-04-11 23:28:06 UTC (rev 3503)
@@ -480,5 +480,17 @@
 
     scope
   end
+
+  # This function calculates which agents are authorized to perform a given
+  # action on a given object.  E.g. "Who can edit this workflow"?
+
+  def self.authorized_for_object(action, object)
+    case action
+    when :view, :download, :edit
+      [object.contributor] + Permission.all(:conditions => { action ="" true, :policy_id => object.contribution.policy_id } ).map { |p| p.contributor }
+    else
+      raise "Unknown action: #{action}"
+    end
+  end
 end
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]