Project

General

Profile

« Previous | Next » 

Revision 58ef684f

Added by Marc Dequènes about 13 years ago

  • ID 58ef684fdd3c63aeed9975aa7b7bb6a300d9aa58

[evol] attributes parameters rework §2 (display code) (refs #142)

View differences:

lib/ldap_shadows/display_helper.rb
def self.display_fields(shadow, attr_data, options = {})
str_lines = []
attr_data.each_pair do |key, val|
next if val[:expert] and not options[:expert]
next if val[:admin] and not options[:admin]
next if ['write_only', 'forbidden'].include? val[:access]
case val[:visibility]
when 'never'
next
when 'admin'
next unless options[:admin]
when 'expert'
next unless options[:admin] or options[:expert]
end
field_name = Translator.translate_field_name(key)
......
nb_files = val[:multiple] ? val[:value].size : 1
str += " -> #{nb_files} file(s) available"
else
str += ": " + (val[:multiple] ?
val[:value].sort.collect{|v| LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], v).to_s }.join(", ") :
LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], val[:value]).to_s)
str += ":"
if val[:multiple]
list = val[:value].sort.collect{|v| LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], v).to_s }
case val[:presentation_multiple]
when 'list'
str += "\n" + list.collect{|v| " * " + v }.join("\n")
when 'shortlist'
str += " " + list.join(", ")
else
str += " [list of #{list.size} values]"
end
else
str += " " + LdapShadows::Manipulation.interpret_field_value(shadow, val[:syntax], val[:value]).to_s
end
end
str_lines << str

Also available in: Unified diff