Changeset 2505
- Timestamp:
- 01/08/22 09:16:59 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Objects.pm
r2398 r2505 464 464 my ($self, %cdata) = @_; 465 465 my %data; 466 my $sub; 466 467 my $res = 0; 467 468 foreach my $cfield (keys %cdata) { 469 470 if (my ($sotype, $key, $scfield) = $cfield =~ /^(\w+)(?:\[(\w+)\])?\.(.*)/) { 471 $key ||= '_'; 472 $sub->{$sotype}{$key}{$scfield} = $cdata{$cfield}; 473 next; 474 } 475 468 476 my $attribute = $self->attribute($cfield) or do { 469 477 $self->base->log(LA_ERR, … … 514 522 } 515 523 524 my $subupdate = 0; 525 if ($sub) { 526 527 # Security: if caller is create_c_object calling it to check permission ? 528 # See below 529 # my ($caller) = caller(); 530 # my $subcreate = $caller eq 'create_c_object' ? 'create_c_object' : __SUB__; 531 532 # Trying to create subobject 533 foreach my $sotype (keys %$sub) { 534 my $SubKeyRef = $self->base->GetSubObjectKey($self->otype, $sotype) or do { 535 $self->base->log(LA_ERR, "Cannot create object type $sotype, subtype of " . $self->otype . " not defined"); 536 return; 537 }; 538 foreach my $skey (keys %{ $sub->{$sotype} || {} }) { 539 # TODO Check if object exists ! 540 # Building id 541 my $info = $sub->{$sotype}{$skey} || {}; 542 # For id: if key is given using it, otherwise using random 543 my $sid = 544 $info->{$SubKeyRef} || 545 $self->id . '-' . join('', map { ('a' .. 'z')[rand(26)] } (0 .. 6)); 546 $info->{$SubKeyRef} = $self->id; 547 548 # Here we don't check permission to create sub object: 549 $self->base->_create_c_object($sotype, $sid, %{ $info || {} }) or return; 550 $subupdate++; 551 } 552 } 553 } 554 555 516 556 if (keys %updated) { 517 557 $self->PostSetAttribute() or do { … … 530 570 } 531 571 } 532 return scalar(keys %updated);572 return(scalar(keys %updated) + $subupdate); 533 573 } 534 574
Note: See TracChangeset
for help on using the changeset viewer.