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

(-)a/virtualshelves/shelves.pl (-21 / +21 lines)
Lines 56-66 if ( $op eq 'add_form' ) { Link Here
56
        my $patron = GetMember( 'borrowernumber' => $shelf->owner );
56
        my $patron = GetMember( 'borrowernumber' => $shelf->owner );
57
        $template->param( owner => $patron, );
57
        $template->param( owner => $patron, );
58
        unless ( $shelf->can_be_managed( $loggedinuser ) ) {
58
        unless ( $shelf->can_be_managed( $loggedinuser ) ) {
59
            push @messages, { type => 'error', code => 'unauthorized_on_update' };
59
            push @messages, { type => 'alert', code => 'unauthorized_on_update' };
60
            $op = 'list';
60
            $op = 'list';
61
        }
61
        }
62
    } else {
62
    } else {
63
        push @messages, { type => 'error', code => 'does_not_exist' };
63
        push @messages, { type => 'alert', code => 'does_not_exist' };
64
    }
64
    }
65
} elsif ( $op eq 'add' ) {
65
} elsif ( $op eq 'add' ) {
66
    eval {
66
    eval {
Lines 78-86 if ( $op eq 'add_form' ) { Link Here
78
        $shelfnumber = $shelf->shelfnumber;
78
        $shelfnumber = $shelf->shelfnumber;
79
    };
79
    };
80
    if ($@) {
80
    if ($@) {
81
        push @messages, { type => 'error', code => ref($@), msg => $@ };
81
        push @messages, { type => 'alert', code => ref($@), msg => $@ };
82
    } elsif ( not $shelf ) {
82
    } elsif ( not $shelf ) {
83
        push @messages, { type => 'error', code => 'error_on_insert' };
83
        push @messages, { type => 'alert', code => 'error_on_insert' };
84
84
    } else {
85
    } else {
85
        push @messages, { type => 'message', code => 'success_on_insert' };
86
        push @messages, { type => 'message', code => 'success_on_insert' };
86
        $op = 'view';
87
        $op = 'view';
Lines 101-116 if ( $op eq 'add_form' ) { Link Here
101
            eval { $shelf->store };
102
            eval { $shelf->store };
102
103
103
            if ($@) {
104
            if ($@) {
104
                push @messages, { type => 'error', code => 'error_on_update' };
105
                push @messages, { type => 'alert', code => 'error_on_update' };
105
                $op = 'edit_form';
106
                $op = 'edit_form';
106
            } else {
107
            } else {
107
                push @messages, { type => 'message', code => 'success_on_update' };
108
                push @messages, { type => 'message', code => 'success_on_update' };
108
            }
109
            }
109
        } else {
110
        } else {
110
            push @messages, { type => 'error', code => 'unauthorized_on_update' };
111
            push @messages, { type => 'alert', code => 'unauthorized_on_update' };
111
        }
112
        }
112
    } else {
113
    } else {
113
        push @messages, { type => 'error', code => 'does_not_exist' };
114
        push @messages, { type => 'alert', code => 'does_not_exist' };
114
    }
115
    }
115
} elsif ( $op eq 'delete' ) {
116
} elsif ( $op eq 'delete' ) {
116
    $shelfnumber = $query->param('shelfnumber');
117
    $shelfnumber = $query->param('shelfnumber');
Lines 119-133 if ( $op eq 'add_form' ) { Link Here
119
        if ( $shelf->can_be_deleted( $loggedinuser ) ) {
120
        if ( $shelf->can_be_deleted( $loggedinuser ) ) {
120
            eval { $shelf->delete; };
121
            eval { $shelf->delete; };
121
            if ($@) {
122
            if ($@) {
122
                push @messages, { type => 'error', code => ref($@), msg => $@ };
123
                push @messages, { type => 'alert', code => ref($@), msg => $@ };
123
            } else {
124
            } else {
124
                push @messages, { type => 'message', code => 'success_on_delete' };
125
                push @messages, { type => 'message', code => 'success_on_delete' };
125
            }
126
            }
126
        } else {
127
        } else {
127
            push @messages, { type => 'error', code => 'unauthorized_on_delete' };
128
            push @messages, { type => 'alert', code => 'unauthorized_on_delete' };
128
        }
129
        }
129
    } else {
130
    } else {
130
        push @messages, { type => 'error', code => 'does_not_exist' };
131
        push @messages, { type => 'alert', code => 'does_not_exist' };
131
    }
132
    }
132
    $op = 'list';
133
    $op = 'list';
133
} elsif ( $op eq 'add_biblio' ) {
134
} elsif ( $op eq 'add_biblio' ) {
Lines 141-161 if ( $op eq 'add_form' ) { Link Here
141
                if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
142
                if ( $shelf->can_biblios_be_added( $loggedinuser ) ) {
142
                    my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
143
                    my $added = eval { $shelf->add_biblio( $biblio->{biblionumber}, $loggedinuser ); };
143
                    if ($@) {
144
                    if ($@) {
144
                        push @messages, { type => 'error', code => ref($@), msg => $@ };
145
                        push @messages, { type => 'alert', code => ref($@), msg => $@ };
145
                    } elsif ( $added ) {
146
                    } elsif ( $added ) {
146
                        push @messages, { type => 'message', code => 'success_on_add_biblio' };
147
                        push @messages, { type => 'message', code => 'success_on_add_biblio' };
147
                    } else {
148
                    } else {
148
                        push @messages, { type => 'message', code => 'error_on_add_biblio' };
149
                        push @messages, { type => 'message', code => 'error_on_add_biblio' };
149
                    }
150
                    }
150
                } else {
151
                } else {
151
                    push @messages, { type => 'error', code => 'unauthorized_on_add_biblio' };
152
                    push @messages, { type => 'alert', code => 'unauthorized_on_add_biblio' };
152
                }
153
                }
153
            } else {
154
            } else {
154
                push @messages, { type => 'error', code => 'item_does_not_exist' };
155
                push @messages, { type => 'alert', code => 'item_does_not_exist' };
155
            }
156
            }
156
        }
157
        }
157
    } else {
158
    } else {
158
        push @messages, { type => 'error', code => 'does_not_exist' };
159
        push @messages, { type => 'alert', code => 'does_not_exist' };
159
    }
160
    }
160
    $op = $referer;
161
    $op = $referer;
161
} elsif ( $op eq 'remove_biblios' ) {
162
} elsif ( $op eq 'remove_biblios' ) {
Lines 173-189 if ( $op eq 'add_form' ) { Link Here
173
                );
174
                );
174
            };
175
            };
175
            if ($@) {
176
            if ($@) {
176
                push @messages, { type => 'error', code => ref($@), msg => $@ };
177
                push @messages, { type => 'alert', code => ref($@), msg => $@ };
177
            } elsif ( $number_of_biblios_removed ) {
178
            } elsif ( $number_of_biblios_removed ) {
178
                push @messages, { type => 'message', code => 'success_on_remove_biblios' };
179
                push @messages, { type => 'message', code => 'success_on_remove_biblios' };
179
            } else {
180
            } else {
180
                push @messages, { type => 'error', code => 'no_biblio_removed' };
181
                push @messages, { type => 'alert', code => 'no_biblio_removed' };
181
            }
182
            }
182
        } else {
183
        } else {
183
            push @messages, { type => 'error', code => 'unauthorized_on_remove_biblios' };
184
            push @messages, { type => 'alert', code => 'unauthorized_on_remove_biblios' };
184
        }
185
        }
185
    } else {
186
    } else {
186
        push @messages, { type => 'error', code => 'does_not_exist' };
187
        push @messages, { type => 'alert', code => 'does_not_exist' };
187
    }
188
    }
188
    $op = $referer;
189
    $op = $referer;
189
}
190
}
Lines 288-297 if ( $op eq 'view' ) { Link Here
288
                );
289
                );
289
            }
290
            }
290
        } else {
291
        } else {
291
            push @messages, { type => 'error', code => 'unauthorized_on_view' };
292
            push @messages, { type => 'alert', code => 'unauthorized_on_view' };
292
        }
293
        }
293
    } else {
294
    } else {
294
        push @messages, { type => 'error', code => 'does_not_exist' };
295
        push @messages, { type => 'alert', code => 'does_not_exist' };
295
    }
296
    }
296
}
297
}
297
298
298
- 

Return to bug 15584