22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/cpee-worklist/user.rb', line 22
def self::ok?(opts,task,user)
fname = File.join(opts[:top],'orgmodels',Riddl::Protocols::Utils::escape(task['orgmodel']))
orgmodel = XML::Smart.open_unprotected(fname)
orgmodel.register_namespace 'o', 'http://cpee.org/ns/organisation/1.0'
subjects = orgmodel.find('/o:organisation/o:subjects/o:subject')
unit = task['unit']
role = task['role']
if (unit=='*')
if (role=='*')
subjects.each{|s| return true if s.attributes['uid']==user}
else
orgmodel.find("/o:organisation/o:subjects/o:subject[o:relation/@role='#{role}']").each do |s|
return true if user==s.attributes['uid']
end
end
else
if (role=='*')
orgmodel.find("/o:organisation/o:subjects/o:subject[o:relation/@unit='#{unit}']").each do |s|
return true if user==s.attributes['uid']
end
else
orgmodel.find("/o:organisation/o:subjects/o:subject[o:relation/@unit='#{unit}' and o:relation/@role='#{role}']").each do |s|
return true if user==s.attributes['uid']
end
end
end
false
end
|