Changeset 1302 for trunk


Ignore:
Timestamp:
03/26/15 19:59:04 (9 years ago)
Author:
nanardon
Message:

add related attribute to nethost: allow to indicate related host in bidiractionnal way

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web.pm

    r1291 r1302  
    299299            label => 'Commentaire', 
    300300        }, 
     301        related => { 
     302            label => 'Voir aussi:', 
     303        }, 
    301304    }, 
    302305); 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r1291 r1302  
    119119            description 
    120120            comment 
     121            related 
    121122            serialNumber 
    122123            encryptKey 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r1297 r1302  
    6161                multiple => 1, uniq => 1, 
    6262                input => sub { lc($_[0]) }  
     63            }, 
     64            related   => { 
     65                multiple => 1, uniq => 1, 
     66                reference => 'nethost', 
    6367            }, 
    6468            owner   => { 
     
    183187    } 
    184188 
    185     $self->SUPER::set_fields(%data) 
     189    my $res = $self->SUPER::set_fields(%data); 
     190 
     191    if (exists $data{related}) { 
     192        my %exists; 
     193        if ($data{related}) { 
     194            my @related = ref $data{related} ? @{$data{related}} : $data{related}; 
     195            foreach (@related) { 
     196                my $obj = $self->base->get_object('nethost', $_) or next; 
     197                $exists{$obj->id} = 1;  
     198                my @current = grep { $_ } $obj->get_attributes('related'); 
     199                grep { $_ eq $self->id } @current and next; 
     200                $obj->set_c_fields('related' => [ $self->id, @current ]); 
     201 
     202            } 
     203        } 
     204        foreach ($self->base->search_objects('nethost', 'related=' . $self->id)) { 
     205            my $obj = $self->base->get_object('nethost', $_) or next; 
     206            $exists{$_} and next; 
     207            my @current = grep { $_ eq $self->id } $obj->get_attributes('related'); 
     208            $obj->set_c_fields('related' => [ @current ]); 
     209        } 
     210    } 
     211 
     212    $res 
    186213} 
    187214 
  • trunk/LATMOS-Accounts/sqldata/attributes.csv

    r1282 r1302  
    111111"nethost","comment","Comment" 
    112112"aliases","comment","Comment" 
     113"nethost","related","Machine en relation" 
Note: See TracChangeset for help on using the changeset viewer.