Changeset 2105 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 09/25/17 18:47:33 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r2090 r2105 215 215 label => l('Deletion protection'), 216 216 hide => 1, 217 }, 218 setReftoMe => { 219 multiple => 1, 220 managed => 1, 221 delayed => 1, 222 set => sub { 223 my ($self, $data) = @_; 224 my $count = 0; 225 foreach (ref $data ? @{$data} : $data) { 226 my ($otype, $oname, $attribute) = $_ =~ m/^([^\.]+)\.(.+)\.([^\.]+)$/ or next; 227 my $object = $base->get_object($otype, $oname) or next; 228 my $attr = $base->attribute($otype, $attribute) or next; 229 if ($attr->reference ne $self->object->type) { 230 $base->log(LA_ERR, "Cannot set $_ pointing to " . $self->object->id . ": attribute does not reference " . $self->object->type); 231 return; 232 } 233 if ($attr->multiple) { 234 my @values = $object->get_attributes($attribute); 235 $count += $object->set_c_fields($attribute => [ @values, $self->object->id ]); 236 } else { 237 $count += $object->set_c_fields($attribute => $self->object->id); 238 } 239 } 240 return $count; 241 }, 242 label => l('Set me as reference'), 217 243 }, 218 244 );
Note: See TracChangeset
for help on using the changeset viewer.