View | Details | Raw Unified | Return to bug 28031
Collapse All | Expand All

(-)a/Koha/Patron/Attribute.pm (-10 / +7 lines)
Lines 46-61 sub store { Link Here
46
46
47
    my $self = shift;
47
    my $self = shift;
48
48
49
    my $type = $self->type;
50
51
    Koha::Exceptions::Patron::Attribute::InvalidType->throw( type => $self->code )
49
    Koha::Exceptions::Patron::Attribute::InvalidType->throw( type => $self->code )
52
        unless $type;
50
        unless $self->type;
53
51
54
    Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self )
52
    Koha::Exceptions::Patron::Attribute::NonRepeatable->throw( attribute => $self )
55
        unless $self->repeatable_ok($type);
53
        unless $self->repeatable_ok();
56
54
57
    Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( attribute => $self )
55
    Koha::Exceptions::Patron::Attribute::UniqueIDConstraint->throw( attribute => $self )
58
        unless $self->unique_ok($type);
56
        unless $self->unique_ok();
59
57
60
    return $self->SUPER::store();
58
    return $self->SUPER::store();
61
}
59
}
Lines 145-154 whether storing the current object state would break the repeatable constraint. Link Here
145
143
146
sub repeatable_ok {
144
sub repeatable_ok {
147
145
148
    my ( $self, $type ) = @_;
146
    my ( $self ) = @_;
149
147
150
    my $ok = 1;
148
    my $ok = 1;
151
    if ( !$type->repeatable ) {
149
    if ( ! $self->type->repeatable ) {
152
        my $params = {
150
        my $params = {
153
            borrowernumber => $self->borrowernumber,
151
            borrowernumber => $self->borrowernumber,
154
            code           => $self->code
152
            code           => $self->code
Lines 172-181 whether storing the current object state would break the unique constraint. Link Here
172
170
173
sub unique_ok {
171
sub unique_ok {
174
172
175
    my ( $self, $type ) = @_;
173
    my ( $self ) = @_;
176
174
177
    my $ok = 1;
175
    my $ok = 1;
178
    if ( $type->unique_id ) {
176
    if ( $self->type->unique_id ) {
179
        my $params = { code => $self->code, attribute => $self->attribute };
177
        my $params = { code => $self->code, attribute => $self->attribute };
180
178
181
        $params->{borrowernumber} = { '!=' => $self->borrowernumber } if $self->borrowernumber;
179
        $params->{borrowernumber} = { '!=' => $self->borrowernumber } if $self->borrowernumber;
182
- 

Return to bug 28031