Revision 98217996
Added by Marc Dequènes over 14 years ago
- ID 9821799643b84c1515f3c342036686bd3a266f73
lib/ldap_shadows/elements/object.rb | ||
---|---|---|
end
|
||
|
||
def handle
|
||
name = self[dn_attribute] || self.attributes[dn_attribute] || self.dn
|
||
name = self[dn_attribute] || self.attributes[dn_attribute] || self.dn.to_s
|
||
name = name.first if name.is_a? Array
|
||
name.strip
|
||
end
|
||
... | ... | |
end
|
||
rel[:class_name] = foreign_klass.to_s
|
||
|
||
rel_attr_val = rel[:foreign_key]
|
||
case rel[:type]
|
||
when 'belongs_to'
|
||
belongs_to field_name, rel.reject {|key, val| not ActiveLdap::Associations::ClassMethods::VALID_BELONGS_TO_OPTIONS.include?(key) }
|
||
rel_attr_val = rel[:primary_key] if rel[:many] and rel[:primary_key]
|
||
when 'has_many'
|
||
has_many field_name, rel.reject {|key, val| not ActiveLdap::Associations::ClassMethods::VALID_HAS_MANY_OPTIONS.include?(key) }
|
||
else
|
||
... | ... | |
|
||
object_relations_info[field_name] = {
|
||
:foreign_klass => foreign_klass,
|
||
:single_value => ActiveLdap::Base.schema.attribute(rel[:foreign_key]).single_value?,
|
||
:single_value => ActiveLdap::Base.schema.attribute(rel_attr_val).single_value?,
|
||
:read_only => rel[:read_only] || false
|
||
}
|
||
end
|
||
... | ... | |
attr_list.unshift(name_attribute) unless name_attribute.nil?
|
||
attr_list.each do |attr|
|
||
if attr == 'dn'
|
||
return self.dn
|
||
return self.dn.to_s
|
||
elsif self.attribute_present?(attr)
|
||
val = self.send(attr, true)
|
||
return val[0].strip
|
||
... | ... | |
|
||
expert_attributes = self.class.parameters[:presentation][:expert_attributes]
|
||
admin_attributes = attr_list.select do |attr|
|
||
ActiveLdap::Base.schema.attribute(attr).operational?
|
||
ActiveLdap::Base.schema.attribute(attr).directory_operation?
|
||
end
|
||
|
||
rel_list = self.possible_relations
|
||
... | ... | |
parent_item = Manipulation.find_item_by_full_handle(self.class.shadow, parent_full_handle)
|
||
|
||
if self.new_entry?
|
||
self.base = parent_item.dn_obj - parent_item.class.base_obj
|
||
self.base = parent_item.dn - parent_item.class.base
|
||
else
|
||
raise PreProcessingError, _("Moving items is not yet implemented")
|
||
end
|
||
... | ... | |
|
||
begin
|
||
parent_item = Manipulation.find_item_by_full_handle(self.class.shadow, parent_full_handle)
|
||
self.base = parent_item.dn_obj - parent_item.class.base_obj
|
||
self.base = parent_item.dn - parent_item.class.base
|
||
rescue
|
||
raise PreProcessingError, _("Cannot create the item: bad default parent for this kind of object: %s") % $!
|
||
end
|
Also available in: Unified diff
[evol] switched to a higher activeldap library (closes #27)