=cut
sub get_available {
- my ( $class, $borrowernumber ) = @_;
+ my ( $class, $patron_id ) = @_;
my $params = {
order_by => 'name',
- columns => [ 'id', 'borrowernumber', 'name', 'is_shared' ],
+ columns => [ 'id', 'patron_id', 'name', 'is_shared' ],
};
return {
owned => Koha::Item::Templates->search(
{
- borrowernumber => $borrowernumber
+ patron_id => $patron_id
},
$params
),
shared => Koha::Item::Templates->search(
{
- borrowernumber => { "!=" => $borrowernumber },
- is_shared => 1
+ patron_id => { "!=" => $patron_id },
+ is_shared => 1
},
$params
),
my $template_id = $input->param('template_id') || $input->cookie('ItemEditorSessionTemplateId');
if ( $delete_template_submit ) {
my $t = Koha::Item::Templates->find($template_id);
- $t->delete if $t && ( $t->borrowernumber eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) );
+ $t->delete if $t && ( $t->patron_id eq $loggedinuser || haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } ) );
$template_id = undef;
$use_template_for_session = undef;
}
contents => $item->unblessed,
}
) if $template && (
- $template->borrowernumber eq $loggedinuser
+ $template->patron_id eq $loggedinuser
||
haspermission( $uid, { 'editcatalogue' => 'manage_item_editor_templates' } )
);
else {
my $template = Koha::Item::Template->new(
{
- name => $template_name,
- borrowernumber => $loggedinuser,
- is_shared => $template_is_shared ? 1 : 0,
- contents => $item->unblessed,
+ name => $template_name,
+ patron_id => $loggedinuser,
+ is_shared => $template_is_shared ? 1 : 0,
+ contents => $item->unblessed,
}
)->store();
}
$dbh->do(q{
CREATE TABLE `item_editor_templates` (
`id` INT(11) NOT NULL auto_increment COMMENT "id for the template",
- `borrowernumber` int(11) DEFAULT NULL COMMENT "creator of this template",
+ `patron_id` int(11) DEFAULT NULL COMMENT "creator of this template",
`name` MEDIUMTEXT NOT NULL COMMENT "template name",
`is_shared` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "controls if template is shared",
`contents` LONGTEXT NOT NULL COMMENT "json encoded template data",
PRIMARY KEY (`id`),
- CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
+ CONSTRAINT `bn` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
});
DROP TABLE IF EXISTS `item_editor_templates`;
CREATE TABLE `item_editor_templates` (
`id` INT(11) NOT NULL auto_increment COMMENT "id for the template",
- `borrowernumber` int(11) DEFAULT NULL COMMENT "creator of this template",
+ `patron_id` int(11) DEFAULT NULL COMMENT "creator of this template",
`name` MEDIUMTEXT NOT NULL COMMENT "template name",
`is_shared` TINYINT(1) NOT NULL DEFAULT 0 COMMENT "controls if template is shared",
`contents` LONGTEXT NOT NULL COMMENT "json encoded template data",
PRIMARY KEY (`id`),
- CONSTRAINT `bn` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
+ CONSTRAINT `bn` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
my $owner_template = Koha::Item::Template->new(
{
- borrowernumber => $patron_1->id,
- name => 'My template',
- contents => { location => 'test' },
- is_shared => 0,
+ patron_id => $patron_1->id,
+ name => 'My template',
+ contents => { location => 'test' },
+ is_shared => 0,
}
)->store();
my $shared_template = Koha::Item::Template->new(
{
- borrowernumber => $patron_2->id,
- name => 'My template',
- contents => { location => 'test' },
- is_shared => 1,
+ patron_id => $patron_2->id,
+ name => 'My template',
+ contents => { location => 'test' },
+ is_shared => 1,
}
)->store();
my $unshared_template = Koha::Item::Template->new(
{
- borrowernumber => $patron_2->id,
- name => 'My template',
- contents => { location => 'test' },
- is_shared => 0,
+ patron_id => $patron_2->id,
+ name => 'My template',
+ contents => { location => 'test' },
+ is_shared => 0,
}
)->store();