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

(-)a/C4/Creators/Batch.pm (-4 / +6 lines)
Lines 152-161 sub retrieve { Link Here
152
        push (@{$self->{'items'}}, {$number_type => $record->{$number_type}, label_id => $record->{'label_id'}});
152
        push (@{$self->{'items'}}, {$number_type => $record->{$number_type}, label_id => $record->{'label_id'}});
153
        $record_flag = 1;       # true if one or more rows were retrieved
153
        $record_flag = 1;       # true if one or more rows were retrieved
154
    }
154
    }
155
    return -2 if $record_flag == 0;     # a hackish sort of way of indicating no such record exists
155
    if ($record_flag == 0) {
156
        return; # no such record exists return undef
157
    }
156
    if ($sth->err) {
158
    if ($sth->err) {
157
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
159
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
158
        return -1;
160
        return;
159
    }
161
    }
160
    $self->{'batch_stat'} = 1;
162
    $self->{'batch_stat'} = 1;
161
    bless ($self, $type);
163
    bless ($self, $type);
Lines 263-274 This module provides methods for creating, and otherwise manipulating batch obje Link Here
263
265
264
=head2 C4::Labels::Batch->retrieve(batch_id => $batch_id)
266
=head2 C4::Labels::Batch->retrieve(batch_id => $batch_id)
265
267
266
    Invoking the I<retrieve> method constructs a new batch object containing the current values for batch_id. The method returns a new object upon success and 1 upon failure.
268
    Invoking the I<retrieve> method constructs a new batch object containing the current values for batch_id. The method returns a new object upon success and undefined upon failure.
267
    Errors are logged to the Apache log.
269
    Errors are logged to the Apache log.
268
270
269
    examples:
271
    examples:
270
272
271
        my $batch = C4::Labels::Batch->retrieve(batch_id => 1); # Retrieves batch 1 and returns an object containing the record
273
        my $batch = C4::Labels::Batch->(batch_id => 1); # Retrieves batch 1 and returns an object containing the record
272
274
273
=head2 delete()
275
=head2 delete()
274
276
(-)a/C4/Creators/Layout.pm (-10 / +8 lines)
Lines 63-69 sub new { Link Here
63
    my $invocant = shift;
63
    my $invocant = shift;
64
    my $self = '';
64
    my $self = '';
65
    if (_check_params(@_) eq 1) {
65
    if (_check_params(@_) eq 1) {
66
        return -1;
66
        return;
67
    }
67
    }
68
    my $type = ref($invocant) || $invocant;
68
    my $type = ref($invocant) || $invocant;
69
    if (grep {$_ eq 'Labels'} @_) {
69
    if (grep {$_ eq 'Labels'} @_) {
Lines 101-107 sub retrieve { Link Here
101
    $sth->execute($opts{'layout_id'}, $opts{'creator'});
101
    $sth->execute($opts{'layout_id'}, $opts{'creator'});
102
    if ($sth->err) {
102
    if ($sth->err) {
103
        warn sprintf('Database returned the following error: %s', $sth->errstr);
103
        warn sprintf('Database returned the following error: %s', $sth->errstr);
104
        return -1;
104
        return;
105
    }
105
    }
106
    my $self = $sth->fetchrow_hashref;
106
    my $self = $sth->fetchrow_hashref;
107
    bless ($self, $type);
107
    bless ($self, $type);
Lines 136-141 sub delete { Link Here
136
        warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
136
        warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
137
        return -1;
137
        return -1;
138
    }
138
    }
139
    return; # return no error code on success
139
}
140
}
140
141
141
sub save {
142
sub save {
Lines 156-162 sub save { Link Here
156
        $sth->execute(@params);
157
        $sth->execute(@params);
157
        if ($sth->err) {
158
        if ($sth->err) {
158
            warn sprintf('Database returned the following error: %s', $sth->errstr);
159
            warn sprintf('Database returned the following error: %s', $sth->errstr);
159
            return -1;
160
            return;
160
        }
161
        }
161
        return $self->{'layout_id'};
162
        return $self->{'layout_id'};
162
    }
163
    }
Lines 178-184 sub save { Link Here
178
        $sth->execute(@params);
179
        $sth->execute(@params);
179
        if ($sth->err) {
180
        if ($sth->err) {
180
            warn sprintf('Database returned the following error: %s', $sth->errstr);
181
            warn sprintf('Database returned the following error: %s', $sth->errstr);
181
            return -1;
182
            return;
182
        }
183
        }
183
        my $sth1 = C4::Context->dbh->prepare("SELECT MAX(layout_id) FROM creator_layouts;");
184
        my $sth1 = C4::Context->dbh->prepare("SELECT MAX(layout_id) FROM creator_layouts;");
184
        $sth1->execute();
185
        $sth1->execute();
Lines 191-212 sub save { Link Here
191
sub get_attr {
192
sub get_attr {
192
    my $self = shift;
193
    my $self = shift;
193
    if (_check_params(@_) eq 1) {
194
    if (_check_params(@_) eq 1) {
194
        return -1;
195
        return;
195
    }
196
    }
196
    my ($attr) = @_;
197
    my ($attr) = @_;
197
    if (exists($self->{$attr})) {
198
    if (exists($self->{$attr})) {
198
        return $self->{$attr};
199
        return $self->{$attr};
199
    }
200
    }
200
    else {
201
        return -1;
202
    }
203
    return;
201
    return;
204
}
202
}
205
203
206
sub set_attr {
204
sub set_attr {
207
    my $self = shift;
205
    my $self = shift;
208
    if (_check_params(@_) eq 1) {
206
    if (_check_params(@_) eq 1) {
209
        return -1;
207
        return;
210
    }
208
    }
211
    my %attrs = @_;
209
    my %attrs = @_;
212
    foreach my $attrib (keys(%attrs)) {
210
    foreach my $attrib (keys(%attrs)) {
Lines 389-395 R = Right Link Here
389
387
390
=head2 get_attr($attribute)
388
=head2 get_attr($attribute)
391
389
392
    Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
390
    Invoking the I<get_attr> method will return the value of the requested attribute or undef on error.
393
391
394
    example:
392
    example:
395
        C<my $value = $layout->get_attr($attribute);>
393
        C<my $value = $layout->get_attr($attribute);>
(-)a/C4/Creators/Lib.pm (-12 / +15 lines)
Lines 135-141 my $output_formats = [ Link Here
135
135
136
=head2 C4::Creators::Lib::get_all_templates()
136
=head2 C4::Creators::Lib::get_all_templates()
137
137
138
    This function returns a reference to a hash containing all templates upon success and 1 upon failure. Errors are logged to the Apache log.
138
    This function returns a reference to a hash containing all templates upon success and undefined upon failure. Errors are logged to the Apache log.
139
139
140
    examples:
140
    examples:
141
141
Lines 152-158 sub get_all_templates { Link Here
152
    $sth->execute();
152
    $sth->execute();
153
    if ($sth->err) {
153
    if ($sth->err) {
154
        warn sprintf('Database returned the following error: %s', $sth->errstr);
154
        warn sprintf('Database returned the following error: %s', $sth->errstr);
155
        return -1;
155
        return;
156
    }
156
    }
157
    ADD_TEMPLATES:
157
    ADD_TEMPLATES:
158
    while (my $template = $sth->fetchrow_hashref) {
158
    while (my $template = $sth->fetchrow_hashref) {
Lines 163-169 sub get_all_templates { Link Here
163
163
164
=head2 C4::Creators::Lib::get_all_layouts()
164
=head2 C4::Creators::Lib::get_all_layouts()
165
165
166
    This function returns a reference to a hash containing all layouts upon success and 1 upon failure. Errors are logged to the Apache log.
166
    This function returns a reference to a hash containing all layouts upon success and undefined upon failure. Errors are logged to the Apache log.
167
167
168
    examples:
168
    examples:
169
169
Lines 180-186 sub get_all_layouts { Link Here
180
    $sth->execute();
180
    $sth->execute();
181
    if ($sth->err) {
181
    if ($sth->err) {
182
        warn sprintf('Database returned the following error: %s', $sth->errstr);
182
        warn sprintf('Database returned the following error: %s', $sth->errstr);
183
        return -1;
183
        return;
184
    }
184
    }
185
    ADD_LAYOUTS:
185
    ADD_LAYOUTS:
186
    while (my $layout = $sth->fetchrow_hashref) {
186
    while (my $layout = $sth->fetchrow_hashref) {
Lines 191-197 sub get_all_layouts { Link Here
191
191
192
=head2 C4::Creators::Lib::get_all_profiles()
192
=head2 C4::Creators::Lib::get_all_profiles()
193
193
194
    This function returns an arrayref whose elements are hashes containing all profiles upon success and 1 upon failure. Errors are logged
194
    This function returns an arrayref whose elements are hashes containing all profiles upon success and undefined upon failure. Errors are logged
195
    to the Apache log. Two parameters are accepted. The first limits the field(s) returned. This parameter should be string of comma separted
195
    to the Apache log. Two parameters are accepted. The first limits the field(s) returned. This parameter should be string of comma separted
196
    fields. ie. "field_1, field_2, ...field_n" The second limits the records returned based on a string containing a valud SQL 'WHERE' filter.
196
    fields. ie. "field_1, field_2, ...field_n" The second limits the records returned based on a string containing a valud SQL 'WHERE' filter.
197
197
Lines 214-220 sub get_all_profiles { Link Here
214
    $sth->execute();
214
    $sth->execute();
215
    if ($sth->err) {
215
    if ($sth->err) {
216
        warn sprintf('Database returned the following error: %s', $sth->errstr);
216
        warn sprintf('Database returned the following error: %s', $sth->errstr);
217
        return -1;
217
        return;
218
    }
218
    }
219
    ADD_PROFILES:
219
    ADD_PROFILES:
220
    while (my $profile = $sth->fetchrow_hashref) {
220
    while (my $profile = $sth->fetchrow_hashref) {
Lines 235-241 sub get_all_image_names { Link Here
235
    $sth->execute();
235
    $sth->execute();
236
    if ($sth->err) {
236
    if ($sth->err) {
237
        warn sprintf('Database returned the following error: %s', $sth->errstr);
237
        warn sprintf('Database returned the following error: %s', $sth->errstr);
238
        return -1;
238
        return;
239
    }
239
    }
240
    grep {push @$image_names, {type => $$_[0], name => $$_[0], selected => 0}} @{$sth->fetchall_arrayref([0])};
240
    grep {push @$image_names, {type => $$_[0], name => $$_[0], selected => 0}} @{$sth->fetchall_arrayref([0])};
241
    return $image_names;
241
    return $image_names;
Lines 266-272 sub get_batch_summary { Link Here
266
    $sth->execute($params{'creator'});
266
    $sth->execute($params{'creator'});
267
    if ($sth->err) {
267
    if ($sth->err) {
268
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
268
        warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
269
        return -1;
269
        return;
270
    }
270
    }
271
    ADD_BATCHES:
271
    ADD_BATCHES:
272
    while (my $batch = $sth->fetchrow_hashref) {
272
    while (my $batch = $sth->fetchrow_hashref) {
Lines 275-281 sub get_batch_summary { Link Here
275
        $sth1->execute($batch->{'batch_id'}, $params{'creator'});
275
        $sth1->execute($batch->{'batch_id'}, $params{'creator'});
276
        if ($sth1->err) {
276
        if ($sth1->err) {
277
            warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
277
            warn sprintf('Database returned the following error on attempted SELECT count: %s', $sth1->errstr);
278
            return -1;
278
            return;
279
        }
279
        }
280
        my $count = $sth1->fetchrow_arrayref;
280
        my $count = $sth1->fetchrow_arrayref;
281
        $batch->{'_item_count'} = @$count[0];
281
        $batch->{'_item_count'} = @$count[0];
Lines 315-321 sub get_label_summary { Link Here
315
        $sth->execute($item->{'item_number'}, $params{'batch_id'});
315
        $sth->execute($item->{'item_number'}, $params{'batch_id'});
316
        if ($sth->err) {
316
        if ($sth->err) {
317
            warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
317
            warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
318
            return -1;
318
            return;
319
        }
319
        }
320
        my $record = $sth->fetchrow_hashref;
320
        my $record = $sth->fetchrow_hashref;
321
        my $label_summary;
321
        my $label_summary;
Lines 361-367 sub get_card_summary { Link Here
361
        $sth->execute($item->{'borrower_number'});
361
        $sth->execute($item->{'borrower_number'});
362
        if ($sth->err) {
362
        if ($sth->err) {
363
            warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
363
            warn sprintf('Database returned the following error on attempted SELECT: %s', $sth->errstr);
364
            return -1;
364
            return;
365
        }
365
        }
366
        my $record = $sth->fetchrow_hashref;
366
        my $record = $sth->fetchrow_hashref;
367
        my $card_summary->{'_card_number'} = $card_number;
367
        my $card_summary->{'_card_number'} = $card_number;
Lines 535-541 sub get_table_names { Link Here
535
sub html_table {
535
sub html_table {
536
    my $headers = shift;
536
    my $headers = shift;
537
    my $data = shift;
537
    my $data = shift;
538
    return undef if scalar(@$data) == 0;      # no need to generate a table if there is not data to display
538
    # no need to generate a table if there is not data to display
539
    unless ( @{$data} ) {
540
        return;
541
    }
539
    my $table = [];
542
    my $table = [];
540
    my $fields = [];
543
    my $fields = [];
541
    my @table_columns = ();
544
    my @table_columns = ();
(-)a/C4/Creators/PDF.pm (-4 / +4 lines)
Lines 152-159 sub Jpeg { Link Here
152
sub prAltJpeg
152
sub prAltJpeg
153
{  my ($iData, $iWidth, $iHeight, $iFormat,$aiData, $aiWidth, $aiHeight, $aiFormat) = @_;
153
{  my ($iData, $iWidth, $iHeight, $iFormat,$aiData, $aiWidth, $aiHeight, $aiFormat) = @_;
154
   my ($namnet, $utrad);
154
   my ($namnet, $utrad);
155
   if (! $PDF::Reuse::pos)                    # If no output is active, it is no use to continue
155
   if (! $PDF::Reuse::pos) {                  # If no output is active, it is no use to continue
156
   {   return undef;
156
      return;
157
   }
157
   }
158
   prJpegBlob($aiData, $aiWidth, $aiHeight, $aiFormat);
158
   prJpegBlob($aiData, $aiWidth, $aiHeight, $aiFormat);
159
   my $altObjNr = $PDF::Reuse::objNr;
159
   my $altObjNr = $PDF::Reuse::objNr;
Lines 182-189 sub prAltJpeg Link Here
182
sub prJpegBlob
182
sub prJpegBlob
183
{  my ($iData, $iWidth, $iHeight, $iFormat, $altArrayObjNr) = @_;
183
{  my ($iData, $iWidth, $iHeight, $iFormat, $altArrayObjNr) = @_;
184
   my ($iLangd, $namnet, $utrad);
184
   my ($iLangd, $namnet, $utrad);
185
   if (! $PDF::Reuse::pos)                    # If no output is active, it is no use to continue
185
   if (! $PDF::Reuse::pos) {                  # If no output is active, it is no use to continue
186
   {   return undef;
186
       return;
187
   }
187
   }
188
   my $checkidOld = $PDF::Reuse::checkId;
188
   my $checkidOld = $PDF::Reuse::checkId;
189
   if (!$iFormat)
189
   if (!$iFormat)
(-)a/C4/Creators/Profile.pm (-9 / +10 lines)
Lines 57-64 sub _conv_points { Link Here
57
57
58
sub new {
58
sub new {
59
    my $invocant = shift;
59
    my $invocant = shift;
60
    if (_check_params(@_) eq 1) {
60
    if (_check_params(@_) == 1) {
61
        return -1;
61
        return;
62
    }
62
    }
63
    my $type = ref($invocant) || $invocant;
63
    my $type = ref($invocant) || $invocant;
64
    my $self = {
64
    my $self = {
Lines 85-91 sub retrieve { Link Here
85
    $sth->execute($opts{'profile_id'}, $opts{'creator'});
85
    $sth->execute($opts{'profile_id'}, $opts{'creator'});
86
    if ($sth->err) {
86
    if ($sth->err) {
87
        warn sprintf('Database returned the following error: %s', $sth->errstr);
87
        warn sprintf('Database returned the following error: %s', $sth->errstr);
88
        return -1;
88
        return;
89
    }
89
    }
90
    my $self = $sth->fetchrow_hashref;
90
    my $self = $sth->fetchrow_hashref;
91
    $self = _conv_points($self) if ($opts{convert} && $opts{convert} == 1);
91
    $self = _conv_points($self) if ($opts{convert} && $opts{convert} == 1);
Lines 122-127 sub delete { Link Here
122
        warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
122
        warn sprintf('Database returned the following error on attempted DELETE: %s', $sth->errstr);
123
        return -1;
123
        return -1;
124
    }
124
    }
125
    return;
125
}
126
}
126
127
127
sub save {
128
sub save {
Lines 142-148 sub save { Link Here
142
        $sth->execute(@params);
143
        $sth->execute(@params);
143
        if ($sth->err) {
144
        if ($sth->err) {
144
            warn sprintf('Database returned the following error on attempted UPDATE: %s', $sth->errstr);
145
            warn sprintf('Database returned the following error on attempted UPDATE: %s', $sth->errstr);
145
            return -1;
146
            return;
146
        }
147
        }
147
        return $self->{'profile_id'};
148
        return $self->{'profile_id'};
148
    }
149
    }
Lines 164-170 sub save { Link Here
164
        $sth->execute(@params);
165
        $sth->execute(@params);
165
        if ($sth->err) {
166
        if ($sth->err) {
166
            warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
167
            warn sprintf('Database returned the following error on attempted INSERT: %s', $sth->errstr);
167
            return -1;
168
            return;
168
        }
169
        }
169
        my $sth1 = C4::Context->dbh->prepare("SELECT MAX(profile_id) FROM printers_profile;");
170
        my $sth1 = C4::Context->dbh->prepare("SELECT MAX(profile_id) FROM printers_profile;");
170
        $sth1->execute();
171
        $sth1->execute();
Lines 176-182 sub save { Link Here
176
sub get_attr {
177
sub get_attr {
177
    my $self = shift;
178
    my $self = shift;
178
    if (_check_params(@_) eq 1) {
179
    if (_check_params(@_) eq 1) {
179
        return -1;
180
        return;
180
    }
181
    }
181
    my ($attr) = @_;
182
    my ($attr) = @_;
182
    if (exists($self->{$attr})) {
183
    if (exists($self->{$attr})) {
Lines 184-190 sub get_attr { Link Here
184
    }
185
    }
185
    else {
186
    else {
186
        warn sprintf('%s is currently undefined.', $attr);
187
        warn sprintf('%s is currently undefined.', $attr);
187
        return -1;
188
        return;
188
    }
189
    }
189
}
190
}
190
191
Lines 278-291 CM = SI Centimeters (28.3464567 points per) Link Here
278
=head2 save()
279
=head2 save()
279
280
280
    Invoking the I<save> method attempts to insert the profile into the database if the profile is new and update the existing profile record if the profile exists. The method returns
281
    Invoking the I<save> method attempts to insert the profile into the database if the profile is new and update the existing profile record if the profile exists. The method returns
281
    the new record profile_id upon success and -1 upon failure (This avoids conflicting with a record profile_id of 1). Errors are logged to the Apache log.
282
    the new record profile_id upon success and undef upon failure (This avoids conflicting with a record profile_id of 1). Errors are logged to the Apache log.
282
283
283
    example:
284
    example:
284
        C<my $exitstat = $profile->save(); # to save the record behind the $profile object>
285
        C<my $exitstat = $profile->save(); # to save the record behind the $profile object>
285
286
286
=head2 get_attr($attribute)
287
=head2 get_attr($attribute)
287
288
288
    Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
289
    Invoking the I<get_attr> method will return the value of the requested attribute or undef on errors.
289
290
290
    example:
291
    example:
291
        C<my $value = $profile->get_attr($attribute);>
292
        C<my $value = $profile->get_attr($attribute);>
(-)a/C4/Creators/Template.pm (-13 / +10 lines)
Lines 89-95 sub new { Link Here
89
    my $invocant = shift;
89
    my $invocant = shift;
90
    my $type = ref($invocant) || $invocant;
90
    my $type = ref($invocant) || $invocant;
91
    if (_check_params(@_) eq 1) {
91
    if (_check_params(@_) eq 1) {
92
        return -1;
92
        return;
93
    }
93
    }
94
    my $self = {
94
    my $self = {
95
        profile_id      =>      0,
95
        profile_id      =>      0,
Lines 124-130 sub retrieve { Link Here
124
    $sth->execute($opts{'template_id'}, $opts{'creator'});
124
    $sth->execute($opts{'template_id'}, $opts{'creator'});
125
    if ($sth->err) {
125
    if ($sth->err) {
126
        warn sprintf('Database returned the following error: %s', $sth->errstr);
126
        warn sprintf('Database returned the following error: %s', $sth->errstr);
127
        return -1;
127
        return;
128
    }
128
    }
129
    my $self = $sth->fetchrow_hashref;
129
    my $self = $sth->fetchrow_hashref;
130
    $self = _conv_points($self) if (($opts{convert} && $opts{convert} == 1) || $opts{profile_id});
130
    $self = _conv_points($self) if (($opts{convert} && $opts{convert} == 1) || $opts{profile_id});
Lines 152-158 sub delete { Link Here
152
    if (scalar(@query_params) < 2) {   # If there is no template id or creator type then we cannot delete it
152
    if (scalar(@query_params) < 2) {   # If there is no template id or creator type then we cannot delete it
153
        warn sprintf('%s : Cannot delete template as the template id is invalid or non-existant.', $call_type) if !$query_params[0];
153
        warn sprintf('%s : Cannot delete template as the template id is invalid or non-existant.', $call_type) if !$query_params[0];
154
        warn sprintf('%s : Cannot delete template as the creator type is invalid or non-existant.', $call_type) if !$query_params[1];
154
        warn sprintf('%s : Cannot delete template as the creator type is invalid or non-existant.', $call_type) if !$query_params[1];
155
        return -1;
155
        return;
156
    }
156
    }
157
    my $query = "DELETE FROM " . $opts{'table_name'} . " WHERE template_id = ? AND creator = ?";
157
    my $query = "DELETE FROM " . $opts{'table_name'} . " WHERE template_id = ? AND creator = ?";
158
    my $sth = C4::Context->dbh->prepare($query);
158
    my $sth = C4::Context->dbh->prepare($query);
Lines 178-184 sub save { Link Here
178
        $sth->execute(@params);
178
        $sth->execute(@params);
179
        if ($sth->err) {
179
        if ($sth->err) {
180
            warn sprintf('Database returned the following error: %s', $sth->errstr);
180
            warn sprintf('Database returned the following error: %s', $sth->errstr);
181
            return -1;
181
            return;
182
        }
182
        }
183
        $self->{'template_stat'} = 1;
183
        $self->{'template_stat'} = 1;
184
        return $self->{'template_id'};
184
        return $self->{'template_id'};
Lines 202-208 sub save { Link Here
202
        $sth->execute(@params);
202
        $sth->execute(@params);
203
        if ($sth->err) {
203
        if ($sth->err) {
204
            warn sprintf('Database returned the following error: %s', $sth->errstr);
204
            warn sprintf('Database returned the following error: %s', $sth->errstr);
205
            return -1;
205
            return;
206
        }
206
        }
207
        my $sth1 = C4::Context->dbh->prepare("SELECT MAX(template_id) FROM " . $opts{'table_name'} . ";");
207
        my $sth1 = C4::Context->dbh->prepare("SELECT MAX(template_id) FROM " . $opts{'table_name'} . ";");
208
        $sth1->execute();
208
        $sth1->execute();
Lines 216-236 sub save { Link Here
216
sub get_attr {
216
sub get_attr {
217
    my $self = shift;
217
    my $self = shift;
218
    if (_check_params(@_) eq 1) {
218
    if (_check_params(@_) eq 1) {
219
        return -1;
219
        return;
220
    }
220
    }
221
    my ($attr) = @_;
221
    my ($attr) = @_;
222
    if (exists($self->{$attr})) {
222
    if (exists($self->{$attr})) {
223
        return $self->{$attr};
223
        return $self->{$attr};
224
    }
224
    }
225
    else {
225
    return;
226
        return -1;
227
    }
228
}
226
}
229
227
230
sub set_attr {
228
sub set_attr {
231
    my $self = shift;
229
    my $self = shift;
232
    if (_check_params(@_) eq 1) {
230
    if (_check_params(@_) eq 1) {
233
        return -1;
231
        return;
234
    }
232
    }
235
    my %attrs = @_;
233
    my %attrs = @_;
236
    foreach my $attrib (keys(%attrs)) {
234
    foreach my $attrib (keys(%attrs)) {
Lines 374-380 CM = SI Centimeters (28.3464567 points per) Link Here
374
=head2 save()
372
=head2 save()
375
373
376
    Invoking the I<save> method attempts to insert the template into the database if the template is new and update the existing template record if
374
    Invoking the I<save> method attempts to insert the template into the database if the template is new and update the existing template record if
377
    the template exists. The method returns the new record template_id upon success and -1 upon failure (This avoids template_ids conflicting with a
375
    the template exists. The method returns the new record template_id upon success and undef upon failure (This avoids template_ids conflicting with a
378
    record template_id of 1). Errors are logged to the Apache log.
376
    record template_id of 1). Errors are logged to the Apache log.
379
377
380
    example:
378
    example:
Lines 382-388 CM = SI Centimeters (28.3464567 points per) Link Here
382
380
383
=head2 get_attr($attribute)
381
=head2 get_attr($attribute)
384
382
385
    Invoking the I<get_attr> method will return the value of the requested attribute or -1 on errors.
383
    Invoking the I<get_attr> method will return the value of the requested attribute or undef on errors.
386
384
387
    example:
385
    example:
388
        C<my $value = $template->get_attr($attribute);>
386
        C<my $value = $template->get_attr($attribute);>
389
- 

Return to bug 4450